From b67e40197927dde293ccb80a3a6ad9a6e98b8a09 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Tue, 10 Mar 2020 23:27:09 +0000 Subject: [PATCH] Generated from 0a95e56a2693de3539ef29e10463a2f967eb8dfe Include changes that got missed from 2020-03-01 --- .../Generated/CassandraResourcesOperations.cs | 3097 ++++++++ .../CassandraResourcesOperationsExtensions.cs | 953 +++ .../src/Generated/CollectionOperations.cs | 806 +++ .../CollectionOperationsExtensions.cs | 207 + .../CollectionPartitionOperations.cs | 565 ++ ...CollectionPartitionOperationsExtensions.cs | 157 + .../CollectionPartitionRegionOperations.cs | 321 + ...tionPartitionRegionOperationsExtensions.cs | 99 + .../Generated/CollectionRegionOperations.cs | 321 + .../CollectionRegionOperationsExtensions.cs | 99 + .../src/Generated/CosmosDBManagementClient.cs | 473 ++ .../DatabaseAccountRegionOperations.cs | 303 + ...tabaseAccountRegionOperationsExtensions.cs | 87 + .../Generated/DatabaseAccountsOperations.cs | 4175 +++++++++++ .../DatabaseAccountsOperationsExtensions.cs | 1115 +++ .../src/Generated/DatabaseOperations.cs | 779 ++ .../Generated/DatabaseOperationsExtensions.cs | 189 + .../Generated/GremlinResourcesOperations.cs | 3095 ++++++++ .../GremlinResourcesOperationsExtensions.cs | 949 +++ .../ICassandraResourcesOperations.cs | 574 ++ .../src/Generated/ICollectionOperations.cs | 133 + .../ICollectionPartitionOperations.cs | 102 + .../ICollectionPartitionRegionOperations.cs | 69 + .../Generated/ICollectionRegionOperations.cs | 69 + .../Generated/ICosmosDBManagementClient.cs | 173 + .../IDatabaseAccountRegionOperations.cs | 63 + .../Generated/IDatabaseAccountsOperations.cs | 683 ++ .../src/Generated/IDatabaseOperations.cs | 123 + .../Generated/IGremlinResourcesOperations.cs | 574 ++ .../Generated/IMongoDBResourcesOperations.cs | 574 ++ .../src/Generated/IOperations.cs | 68 + .../IPartitionKeyRangeIdOperations.cs | 68 + .../IPartitionKeyRangeIdRegionOperations.cs | 72 + .../src/Generated/IPercentileOperations.cs | 60 + .../IPercentileSourceTargetOperations.cs | 68 + .../Generated/IPercentileTargetOperations.cs | 64 + .../IPrivateEndpointConnectionsOperations.cs | 190 + .../IPrivateLinkResourcesOperations.cs | 82 + .../src/Generated/ISqlResourcesOperations.cs | 1183 ++++ .../Generated/ITableResourcesOperations.cs | 287 + .../src/Generated/Models/ARMProxyResource.cs | 71 + .../Generated/Models/ARMResourceProperties.cs | 88 + .../Models/AutoUpgradePolicyResource.cs | 53 + .../Generated/Models/AzureEntityResource.cs | 59 + .../src/Generated/Models/Capability.cs | 55 + ...CassandraKeyspaceCreateUpdateParameters.cs | 98 + .../CassandraKeyspaceGetPropertiesResource.cs | 93 + .../Models/CassandraKeyspaceGetResults.cs | 76 + .../Models/CassandraKeyspaceResource.cs | 65 + .../Generated/Models/CassandraPartitionKey.cs | 52 + .../src/Generated/Models/CassandraSchema.cs | 69 + .../CassandraTableCreateUpdateParameters.cs | 98 + .../CassandraTableGetPropertiesResource.cs | 111 + .../Models/CassandraTableGetResults.cs | 74 + .../Models/CassandraTableResource.cs | 83 + .../src/Generated/Models/ClusterKey.cs | 62 + .../src/Generated/Models/Column.cs | 61 + .../src/Generated/Models/CompositePath.cs | 62 + .../Models/CompositePathSortOrder.cs | 22 + .../Models/ConflictResolutionMode.cs | 22 + .../Models/ConflictResolutionPolicy.cs | 73 + .../src/Generated/Models/ConnectorOffer.cs | 21 + .../src/Generated/Models/ConsistencyPolicy.cs | 115 + .../Generated/Models/ContainerPartitionKey.cs | 93 + .../Generated/Models/CreateUpdateOptions.cs | 67 + .../src/Generated/Models/DataType.cs | 26 + .../Models/DatabaseAccountConnectionString.cs | 63 + .../DatabaseAccountCreateUpdateParameters.cs | 238 + .../Models/DatabaseAccountGetResults.cs | 306 + .../Generated/Models/DatabaseAccountKind.cs | 23 + ...abaseAccountListConnectionStringsResult.cs | 57 + .../Models/DatabaseAccountListKeysResult.cs | 68 + .../DatabaseAccountListReadOnlyKeysResult.cs | 63 + .../Models/DatabaseAccountOfferType.cs | 54 + .../DatabaseAccountRegenerateKeyParameters.cs | 70 + .../Models/DatabaseAccountUpdateParameters.cs | 218 + .../Models/DefaultConsistencyLevel.cs | 78 + .../src/Generated/Models/ErrorResponse.cs | 60 + .../Models/ErrorResponseException.cs | 62 + .../src/Generated/Models/ExcludedPath.cs | 52 + .../Models/ExtendedResourceProperties.cs | 73 + .../src/Generated/Models/FailoverPolicies.cs | 78 + .../src/Generated/Models/FailoverPolicy.cs | 95 + .../GremlinDatabaseCreateUpdateParameters.cs | 98 + .../GremlinDatabaseGetPropertiesResource.cs | 93 + .../Models/GremlinDatabaseGetResults.cs | 74 + .../Models/GremlinDatabaseResource.cs | 65 + .../GremlinGraphCreateUpdateParameters.cs | 98 + .../GremlinGraphGetPropertiesResource.cs | 147 + .../Models/GremlinGraphGetResults.cs | 74 + .../Generated/Models/GremlinGraphResource.cs | 119 + .../src/Generated/Models/IncludedPath.cs | 65 + .../src/Generated/Models/IndexKind.cs | 23 + .../src/Generated/Models/Indexes.cs | 74 + .../src/Generated/Models/IndexingMode.cs | 23 + .../src/Generated/Models/IndexingPolicy.cs | 98 + .../src/Generated/Models/KeyKind.cs | 24 + .../src/Generated/Models/Location.cs | 120 + .../src/Generated/Models/Metric.cs | 101 + .../Generated/Models/MetricAvailability.cs | 61 + .../src/Generated/Models/MetricDefinition.cs | 93 + .../src/Generated/Models/MetricName.cs | 60 + .../src/Generated/Models/MetricValue.cs | 92 + ...MongoDBCollectionCreateUpdateParameters.cs | 98 + .../MongoDBCollectionGetPropertiesResource.cs | 113 + .../Models/MongoDBCollectionGetResults.cs | 76 + .../Models/MongoDBCollectionResource.cs | 85 + .../MongoDBDatabaseCreateUpdateParameters.cs | 98 + .../MongoDBDatabaseGetPropertiesResource.cs | 93 + .../Models/MongoDBDatabaseGetResults.cs | 74 + .../Models/MongoDBDatabaseResource.cs | 65 + .../src/Generated/Models/MongoIndex.cs | 60 + .../src/Generated/Models/MongoIndexKeys.cs | 55 + .../src/Generated/Models/MongoIndexOptions.cs | 59 + .../src/Generated/Models/Operation.cs | 61 + .../src/Generated/Models/OperationDisplay.cs | 79 + .../src/Generated/Models/Page.cs | 53 + .../src/Generated/Models/Page1.cs | 53 + .../src/Generated/Models/PartitionKind.cs | 22 + .../src/Generated/Models/PartitionMetric.cs | 77 + .../src/Generated/Models/PartitionUsage.cs | 70 + .../src/Generated/Models/PercentileMetric.cs | 102 + .../Generated/Models/PercentileMetricValue.cs | 107 + .../Models/PrimaryAggregationType.cs | 26 + .../Models/PrivateEndpointConnection.cs | 71 + .../Models/PrivateEndpointProperty.cs | 51 + .../Generated/Models/PrivateLinkResource.cs | 70 + ...ivateLinkServiceConnectionStateProperty.cs | 73 + .../ProvisionedThroughputSettingsResource.cs | 84 + .../src/Generated/Models/ProxyResource.cs | 50 + .../Models/RegionForOnlineOffline.cs | 67 + .../src/Generated/Models/Resource.cs | 72 + .../src/Generated/Models/SpatialSpec.cs | 62 + .../src/Generated/Models/SpatialType.cs | 24 + .../SqlContainerCreateUpdateParameters.cs | 98 + .../SqlContainerGetPropertiesResource.cs | 148 + .../Models/SqlContainerGetResults.cs | 74 + .../Generated/Models/SqlContainerResource.cs | 120 + .../SqlDatabaseCreateUpdateParameters.cs | 98 + .../SqlDatabaseGetPropertiesResource.cs | 113 + .../Generated/Models/SqlDatabaseGetResults.cs | 74 + .../Generated/Models/SqlDatabaseResource.cs | 65 + ...qlStoredProcedureCreateUpdateParameters.cs | 98 + ...SqlStoredProcedureGetPropertiesResource.cs | 101 + .../Models/SqlStoredProcedureGetResults.cs | 76 + .../Models/SqlStoredProcedureResource.cs | 73 + .../SqlTriggerCreateUpdateParameters.cs | 98 + .../Models/SqlTriggerGetPropertiesResource.cs | 122 + .../Generated/Models/SqlTriggerGetResults.cs | 74 + .../Generated/Models/SqlTriggerResource.cs | 94 + ...erDefinedFunctionCreateUpdateParameters.cs | 98 + ...serDefinedFunctionGetPropertiesResource.cs | 102 + .../SqlUserDefinedFunctionGetResults.cs | 76 + .../Models/SqlUserDefinedFunctionResource.cs | 76 + .../Models/TableCreateUpdateParameters.cs | 97 + .../Models/TableGetPropertiesResource.cs | 91 + .../src/Generated/Models/TableGetResults.cs | 74 + .../src/Generated/Models/TableResource.cs | 65 + .../Models/ThroughputPolicyResource.cs | 64 + ...ThroughputSettingsGetPropertiesResource.cs | 126 + .../Models/ThroughputSettingsGetResults.cs | 76 + .../Models/ThroughputSettingsResource.cs | 99 + .../ThroughputSettingsUpdateParameters.cs | 83 + .../src/Generated/Models/TrackedResource.cs | 83 + .../src/Generated/Models/TriggerOperation.cs | 25 + .../src/Generated/Models/TriggerType.cs | 22 + .../src/Generated/Models/UniqueKey.cs | 56 + .../src/Generated/Models/UniqueKeyPolicy.cs | 59 + .../src/Generated/Models/UnitType.cs | 27 + .../src/Generated/Models/Usage.cs | 88 + .../Generated/Models/VirtualNetworkRule.cs | 64 + .../Generated/MongoDBResourcesOperations.cs | 3097 ++++++++ .../MongoDBResourcesOperationsExtensions.cs | 953 +++ .../src/Generated/Operations.cs | 392 ++ .../src/Generated/OperationsExtensions.cs | 87 + .../PartitionKeyRangeIdOperations.cs | 321 + ...PartitionKeyRangeIdOperationsExtensions.cs | 99 + .../PartitionKeyRangeIdRegionOperations.cs | 330 + ...ionKeyRangeIdRegionOperationsExtensions.cs | 105 + .../src/Generated/PercentileOperations.cs | 294 + .../PercentileOperationsExtensions.cs | 81 + .../PercentileSourceTargetOperations.cs | 315 + ...centileSourceTargetOperationsExtensions.cs | 99 + .../Generated/PercentileTargetOperations.cs | 304 + .../PercentileTargetOperationsExtensions.cs | 89 + .../PrivateEndpointConnectionsOperations.cs | 1039 +++ ...EndpointConnectionsOperationsExtensions.cs | 299 + .../PrivateLinkResourcesOperations.cs | 513 ++ ...rivateLinkResourcesOperationsExtensions.cs | 117 + .../SdkInfo_CosmosDBManagementClient.cs | 46 + .../src/Generated/SqlResourcesOperations.cs | 6269 +++++++++++++++++ .../SqlResourcesOperationsExtensions.cs | 1999 ++++++ .../src/Generated/TableResourcesOperations.cs | 1541 ++++ .../TableResourcesOperationsExtensions.cs | 457 ++ 194 files changed, 52171 insertions(+) create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CosmosDBManagementClient.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICassandraResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICosmosDBManagementClient.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountsOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IGremlinResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IMongoDBResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileSourceTargetOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileTargetOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateEndpointConnectionsOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateLinkResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ISqlResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ITableResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMProxyResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMResourceProperties.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AutoUpgradePolicyResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AzureEntityResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Capability.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraPartitionKey.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraSchema.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ClusterKey.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Column.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePath.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePathSortOrder.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionMode.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionPolicy.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConnectorOffer.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConsistencyPolicy.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ContainerPartitionKey.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CreateUpdateOptions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DataType.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountConnectionString.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountKind.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListConnectionStringsResult.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListKeysResult.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListReadOnlyKeysResult.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountOfferType.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountRegenerateKeyParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DefaultConsistencyLevel.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponse.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponseException.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExcludedPath.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExtendedResourceProperties.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicies.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicy.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IncludedPath.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexKind.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Indexes.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingMode.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingPolicy.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/KeyKind.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Location.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Metric.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricAvailability.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricDefinition.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricName.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricValue.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndex.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexKeys.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexOptions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Operation.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/OperationDisplay.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page1.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionKind.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionMetric.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionUsage.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetric.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetricValue.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrimaryAggregationType.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointConnection.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointProperty.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProvisionedThroughputSettingsResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProxyResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/RegionForOnlineOffline.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Resource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialSpec.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialType.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableCreateUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputPolicyResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetPropertiesResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetResults.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsUpdateParameters.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TrackedResource.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerOperation.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerType.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKey.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKeyPolicy.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UnitType.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Usage.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/VirtualNetworkRule.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Operations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/OperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SdkInfo_CosmosDBManagementClient.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperationsExtensions.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperations.cs create mode 100644 sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperationsExtensions.cs diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperations.cs new file mode 100644 index 000000000000..676a735c0db3 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperations.cs @@ -0,0 +1,3097 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CassandraResourcesOperations operations. + /// + internal partial class CassandraResourcesOperations : IServiceOperations, ICassandraResourcesOperations + { + /// + /// Initializes a new instance of the CassandraResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal CassandraResourcesOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Lists the Cassandra keyspaces under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListCassandraKeyspacesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListCassandraKeyspaces", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the Cassandra keyspaces under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetCassandraKeyspace", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateCassandraKeyspaceWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteCassandraKeyspaceWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the Cassandra Keyspace under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetCassandraKeyspaceThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetCassandraKeyspaceThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// Keyspace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the Cassandra table under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListCassandraTablesWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListCassandraTables", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the Cassandra table under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetCassandraTable", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateCassandraTableWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteCassandraTableWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the Cassandra table under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetCassandraTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetCassandraTableThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateCassandraTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateCassandraTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + if (createUpdateCassandraKeyspaceParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateCassandraKeyspaceParameters"); + } + if (createUpdateCassandraKeyspaceParameters != null) + { + createUpdateCassandraKeyspaceParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateCassandraKeyspaceParameters", createUpdateCassandraKeyspaceParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateCassandraKeyspace", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateCassandraKeyspaceParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateCassandraKeyspaceParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteCassandraKeyspace", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// Keyspace. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateCassandraKeyspaceThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + if (createUpdateCassandraTableParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateCassandraTableParameters"); + } + if (createUpdateCassandraTableParameters != null) + { + createUpdateCassandraTableParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateCassandraTableParameters", createUpdateCassandraTableParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateCassandraTable", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateCassandraTableParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateCassandraTableParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteCassandraTable", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// table. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateCassandraTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyspaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyspaceName"); + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("keyspaceName", keyspaceName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateCassandraTableThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{keyspaceName}", System.Uri.EscapeDataString(keyspaceName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..7479230d255d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CassandraResourcesOperationsExtensions.cs @@ -0,0 +1,953 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CassandraResourcesOperations. + /// + public static partial class CassandraResourcesOperationsExtensions + { + /// + /// Lists the Cassandra keyspaces under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListCassandraKeyspaces(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName) + { + return operations.ListCassandraKeyspacesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the Cassandra keyspaces under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListCassandraKeyspacesAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListCassandraKeyspacesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the Cassandra keyspaces under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + public static CassandraKeyspaceGetResults GetCassandraKeyspace(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName) + { + return operations.GetCassandraKeyspaceAsync(resourceGroupName, accountName, keyspaceName).GetAwaiter().GetResult(); + } + + /// + /// Gets the Cassandra keyspaces under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The cancellation token. + /// + public static async Task GetCassandraKeyspaceAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetCassandraKeyspaceWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + public static CassandraKeyspaceGetResults CreateUpdateCassandraKeyspace(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters) + { + return operations.CreateUpdateCassandraKeyspaceAsync(resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateCassandraKeyspaceAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateCassandraKeyspaceWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + public static void DeleteCassandraKeyspace(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName) + { + operations.DeleteCassandraKeyspaceAsync(resourceGroupName, accountName, keyspaceName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteCassandraKeyspaceAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteCassandraKeyspaceWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the Cassandra Keyspace under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + public static ThroughputSettingsGetResults GetCassandraKeyspaceThroughput(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName) + { + return operations.GetCassandraKeyspaceThroughputAsync(resourceGroupName, accountName, keyspaceName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the Cassandra Keyspace under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The cancellation token. + /// + public static async Task GetCassandraKeyspaceThroughputAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetCassandraKeyspaceThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// Keyspace. + /// + public static ThroughputSettingsGetResults UpdateCassandraKeyspaceThroughput(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateCassandraKeyspaceThroughputAsync(resourceGroupName, accountName, keyspaceName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// Keyspace. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateCassandraKeyspaceThroughputAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the Cassandra table under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + public static IEnumerable ListCassandraTables(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName) + { + return operations.ListCassandraTablesAsync(resourceGroupName, accountName, keyspaceName).GetAwaiter().GetResult(); + } + + /// + /// Lists the Cassandra table under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListCassandraTablesAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListCassandraTablesWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the Cassandra table under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + public static CassandraTableGetResults GetCassandraTable(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName) + { + return operations.GetCassandraTableAsync(resourceGroupName, accountName, keyspaceName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Gets the Cassandra table under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task GetCassandraTableAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetCassandraTableWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + public static CassandraTableGetResults CreateUpdateCassandraTable(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters) + { + return operations.CreateUpdateCassandraTableAsync(resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateCassandraTableAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateCassandraTableWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + public static void DeleteCassandraTable(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName) + { + operations.DeleteCassandraTableAsync(resourceGroupName, accountName, keyspaceName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteCassandraTableAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteCassandraTableWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the Cassandra table under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + public static ThroughputSettingsGetResults GetCassandraTableThroughput(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName) + { + return operations.GetCassandraTableThroughputAsync(resourceGroupName, accountName, keyspaceName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the Cassandra table under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task GetCassandraTableThroughputAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetCassandraTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// table. + /// + public static ThroughputSettingsGetResults UpdateCassandraTableThroughput(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateCassandraTableThroughputAsync(resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// table. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateCassandraTableThroughputAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateCassandraTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + public static CassandraKeyspaceGetResults BeginCreateUpdateCassandraKeyspace(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters) + { + return operations.BeginCreateUpdateCassandraKeyspaceAsync(resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateCassandraKeyspaceAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateCassandraKeyspaceWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + public static void BeginDeleteCassandraKeyspace(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName) + { + operations.BeginDeleteCassandraKeyspaceAsync(resourceGroupName, accountName, keyspaceName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteCassandraKeyspaceAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteCassandraKeyspaceWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// Keyspace. + /// + public static ThroughputSettingsGetResults BeginUpdateCassandraKeyspaceThroughput(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateCassandraKeyspaceThroughputAsync(resourceGroupName, accountName, keyspaceName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// Keyspace. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateCassandraKeyspaceThroughputAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + public static CassandraTableGetResults BeginCreateUpdateCassandraTable(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters) + { + return operations.BeginCreateUpdateCassandraTableAsync(resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateCassandraTableAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateCassandraTableWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + public static void BeginDeleteCassandraTable(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName) + { + operations.BeginDeleteCassandraTableAsync(resourceGroupName, accountName, keyspaceName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteCassandraTableAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteCassandraTableWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// table. + /// + public static ThroughputSettingsGetResults BeginUpdateCassandraTableThroughput(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateCassandraTableThroughputAsync(resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current Cassandra + /// table. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateCassandraTableThroughputAsync(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateCassandraTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperations.cs new file mode 100644 index 000000000000..e41b837c9fc0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperations.cs @@ -0,0 +1,806 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionOperations operations. + /// + internal partial class CollectionOperations : IServiceOperations, ICollectionOperations + { + /// + /// Initializes a new instance of the CollectionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal CollectionOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves the usages (most recent storage data) for the given collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListUsages", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves metric definitions for the given collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricDefinitionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetricDefinitions", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperationsExtensions.cs new file mode 100644 index 000000000000..bfdbbbae2f86 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionOperationsExtensions.cs @@ -0,0 +1,207 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CollectionOperations. + /// + public static partial class CollectionOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this ICollectionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this ICollectionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the usages (most recent storage data) for the given collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + public static IEnumerable ListUsages(this ICollectionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string)) + { + return operations.ListUsagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the usages (most recent storage data) for the given collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + /// + /// The cancellation token. + /// + public static async Task> ListUsagesAsync(this ICollectionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListUsagesWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves metric definitions for the given collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + public static IEnumerable ListMetricDefinitions(this ICollectionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid) + { + return operations.ListMetricDefinitionsAsync(resourceGroupName, accountName, databaseRid, collectionRid).GetAwaiter().GetResult(); + } + + /// + /// Retrieves metric definitions for the given collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricDefinitionsAsync(this ICollectionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricDefinitionsWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperations.cs new file mode 100644 index 000000000000..80ec3d7900e2 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperations.cs @@ -0,0 +1,565 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartitionOperations operations. + /// + internal partial class CollectionPartitionOperations : IServiceOperations, ICollectionPartitionOperations + { + /// + /// Initializes a new instance of the CollectionPartitionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal CollectionPartitionOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection, split by partition. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves the usages (most recent storage data) for the given collection, + /// split by partition. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListUsages", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperationsExtensions.cs new file mode 100644 index 000000000000..9b459e9075c5 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionOperationsExtensions.cs @@ -0,0 +1,157 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CollectionPartitionOperations. + /// + public static partial class CollectionPartitionOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection, split by partition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this ICollectionPartitionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection, split by partition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this ICollectionPartitionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the usages (most recent storage data) for the given collection, + /// split by partition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + public static IEnumerable ListUsages(this ICollectionPartitionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string)) + { + return operations.ListUsagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the usages (most recent storage data) for the given collection, + /// split by partition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + /// + /// The cancellation token. + /// + public static async Task> ListUsagesAsync(this ICollectionPartitionOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListUsagesWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperations.cs new file mode 100644 index 000000000000..7d068afd2d51 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperations.cs @@ -0,0 +1,321 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartitionRegionOperations operations. + /// + internal partial class CollectionPartitionRegionOperations : IServiceOperations, ICollectionPartitionRegionOperations + { + /// + /// Initializes a new instance of the CollectionPartitionRegionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal CollectionPartitionRegionOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection and region, split by partition. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (region == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "region"); + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("region", region); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{region}", System.Uri.EscapeDataString(region)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperationsExtensions.cs new file mode 100644 index 000000000000..819e2a04e95d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionPartitionRegionOperationsExtensions.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CollectionPartitionRegionOperations. + /// + public static partial class CollectionPartitionRegionOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection and region, split by partition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this ICollectionPartitionRegionOperations operations, string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, region, databaseRid, collectionRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection and region, split by partition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this ICollectionPartitionRegionOperations operations, string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, region, databaseRid, collectionRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperations.cs new file mode 100644 index 000000000000..1ae6b8d8742a --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperations.cs @@ -0,0 +1,321 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionRegionOperations operations. + /// + internal partial class CollectionRegionOperations : IServiceOperations, ICollectionRegionOperations + { + /// + /// Initializes a new instance of the CollectionRegionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal CollectionRegionOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account, collection and region. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (region == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "region"); + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("region", region); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{region}", System.Uri.EscapeDataString(region)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperationsExtensions.cs new file mode 100644 index 000000000000..00f139c37848 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CollectionRegionOperationsExtensions.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CollectionRegionOperations. + /// + public static partial class CollectionRegionOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account, collection and region. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this ICollectionRegionOperations operations, string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, region, databaseRid, collectionRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account, collection and region. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this ICollectionRegionOperations operations, string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, region, databaseRid, collectionRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CosmosDBManagementClient.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CosmosDBManagementClient.cs new file mode 100644 index 000000000000..3c0fc422cbad --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/CosmosDBManagementClient.cs @@ -0,0 +1,473 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + + /// + /// Azure Cosmos DB Database Service Resource Provider REST API + /// + public partial class CosmosDBManagementClient : ServiceClient, ICosmosDBManagementClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// Azure subscription ID. + /// + public string SubscriptionId { get; set; } + + /// + /// The ID of the target subscription. + /// + public string SubscriptionId1 { get; set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IDatabaseAccountsOperations. + /// + public virtual IDatabaseAccountsOperations DatabaseAccounts { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IDatabaseOperations. + /// + public virtual IDatabaseOperations Database { get; private set; } + + /// + /// Gets the ICollectionOperations. + /// + public virtual ICollectionOperations Collection { get; private set; } + + /// + /// Gets the ICollectionRegionOperations. + /// + public virtual ICollectionRegionOperations CollectionRegion { get; private set; } + + /// + /// Gets the IDatabaseAccountRegionOperations. + /// + public virtual IDatabaseAccountRegionOperations DatabaseAccountRegion { get; private set; } + + /// + /// Gets the IPercentileSourceTargetOperations. + /// + public virtual IPercentileSourceTargetOperations PercentileSourceTarget { get; private set; } + + /// + /// Gets the IPercentileTargetOperations. + /// + public virtual IPercentileTargetOperations PercentileTarget { get; private set; } + + /// + /// Gets the IPercentileOperations. + /// + public virtual IPercentileOperations Percentile { get; private set; } + + /// + /// Gets the ICollectionPartitionRegionOperations. + /// + public virtual ICollectionPartitionRegionOperations CollectionPartitionRegion { get; private set; } + + /// + /// Gets the ICollectionPartitionOperations. + /// + public virtual ICollectionPartitionOperations CollectionPartition { get; private set; } + + /// + /// Gets the IPartitionKeyRangeIdOperations. + /// + public virtual IPartitionKeyRangeIdOperations PartitionKeyRangeId { get; private set; } + + /// + /// Gets the IPartitionKeyRangeIdRegionOperations. + /// + public virtual IPartitionKeyRangeIdRegionOperations PartitionKeyRangeIdRegion { get; private set; } + + /// + /// Gets the ISqlResourcesOperations. + /// + public virtual ISqlResourcesOperations SqlResources { get; private set; } + + /// + /// Gets the IMongoDBResourcesOperations. + /// + public virtual IMongoDBResourcesOperations MongoDBResources { get; private set; } + + /// + /// Gets the ITableResourcesOperations. + /// + public virtual ITableResourcesOperations TableResources { get; private set; } + + /// + /// Gets the ICassandraResourcesOperations. + /// + public virtual ICassandraResourcesOperations CassandraResources { get; private set; } + + /// + /// Gets the IGremlinResourcesOperations. + /// + public virtual IGremlinResourcesOperations GremlinResources { get; private set; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + public virtual IPrivateLinkResourcesOperations PrivateLinkResources { get; private set; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + public virtual IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; private set; } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling CosmosDBManagementClient.Dispose(). False: will not dispose provided httpClient + protected CosmosDBManagementClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected CosmosDBManagementClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected CosmosDBManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected CosmosDBManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected CosmosDBManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling CosmosDBManagementClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public CosmosDBManagementClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + DatabaseAccounts = new DatabaseAccountsOperations(this); + Operations = new Operations(this); + Database = new DatabaseOperations(this); + Collection = new CollectionOperations(this); + CollectionRegion = new CollectionRegionOperations(this); + DatabaseAccountRegion = new DatabaseAccountRegionOperations(this); + PercentileSourceTarget = new PercentileSourceTargetOperations(this); + PercentileTarget = new PercentileTargetOperations(this); + Percentile = new PercentileOperations(this); + CollectionPartitionRegion = new CollectionPartitionRegionOperations(this); + CollectionPartition = new CollectionPartitionOperations(this); + PartitionKeyRangeId = new PartitionKeyRangeIdOperations(this); + PartitionKeyRangeIdRegion = new PartitionKeyRangeIdRegionOperations(this); + SqlResources = new SqlResourcesOperations(this); + MongoDBResources = new MongoDBResourcesOperations(this); + TableResources = new TableResourcesOperations(this); + CassandraResources = new CassandraResourcesOperations(this); + GremlinResources = new GremlinResourcesOperations(this); + PrivateLinkResources = new PrivateLinkResourcesOperations(this); + PrivateEndpointConnections = new PrivateEndpointConnectionsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperations.cs new file mode 100644 index 000000000000..b5ab980af126 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperations.cs @@ -0,0 +1,303 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccountRegionOperations operations. + /// + internal partial class DatabaseAccountRegionOperations : IServiceOperations, IDatabaseAccountRegionOperations + { + /// + /// Initializes a new instance of the DatabaseAccountRegionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DatabaseAccountRegionOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and region. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (region == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "region"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("region", region); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{region}", System.Uri.EscapeDataString(region)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperationsExtensions.cs new file mode 100644 index 000000000000..f7462fbe72ab --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountRegionOperationsExtensions.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DatabaseAccountRegionOperations. + /// + public static partial class DatabaseAccountRegionOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and region. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IDatabaseAccountRegionOperations operations, string resourceGroupName, string accountName, string region, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, region, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and region. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IDatabaseAccountRegionOperations operations, string resourceGroupName, string accountName, string region, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, region, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperations.cs new file mode 100644 index 000000000000..9c04577336a9 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperations.cs @@ -0,0 +1,4175 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccountsOperations operations. + /// + internal partial class DatabaseAccountsOperations : IServiceOperations, IDatabaseAccountsOperations + { + /// + /// Initializes a new instance of the DatabaseAccountsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DatabaseAccountsOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the properties of an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates the properties of an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, accountName, updateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates or updates an Azure Cosmos DB database account. The "Update" method + /// is preferred when performing updates on an account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, createUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, accountName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task FailoverPriorityChangeWithHttpMessagesAsync(string resourceGroupName, string accountName, FailoverPolicies failoverParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginFailoverPriorityChangeWithHttpMessagesAsync(resourceGroupName, accountName, failoverParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists all the Azure Cosmos DB database accounts available under the + /// subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all the Azure Cosmos DB database accounts available under the given + /// resource group. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the access keys for the specified Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListKeys", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the connection strings for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListConnectionStringsWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListConnectionStrings", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Offline the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task OfflineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginOfflineRegionWithHttpMessagesAsync(resourceGroupName, accountName, regionParameterForOffline, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Online the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task OnlineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginOnlineRegionWithHttpMessagesAsync(resourceGroupName, accountName, regionParameterForOnline, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetReadOnlyKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetReadOnlyKeys", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListReadOnlyKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListReadOnlyKeys", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Regenerates an access key for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginRegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, keyToRegenerate, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// 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. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CheckNameExistsWithHttpMessagesAsync(string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckNameExists", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}").ToString(); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("HEAD"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 404) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + _result.Body = _statusCode == System.Net.HttpStatusCode.OK; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves the usages (most recent data) for the given database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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). + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListUsages", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves metric definitions for the given database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricDefinitionsWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetricDefinitions", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates the properties of an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (updateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateParameters"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateParameters", updateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an Azure Cosmos DB database account. The "Update" method + /// is preferred when performing updates on an account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (createUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateParameters"); + } + if (createUpdateParameters != null) + { + createUpdateParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateParameters", createUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginFailoverPriorityChangeWithHttpMessagesAsync(string resourceGroupName, string accountName, FailoverPolicies failoverParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (failoverParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "failoverParameters"); + } + if (failoverParameters != null) + { + failoverParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("failoverParameters", failoverParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginFailoverPriorityChange", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(failoverParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(failoverParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Offline the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginOfflineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (regionParameterForOffline == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionParameterForOffline"); + } + if (regionParameterForOffline != null) + { + regionParameterForOffline.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("regionParameterForOffline", regionParameterForOffline); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginOfflineRegion", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(regionParameterForOffline != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regionParameterForOffline, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Online the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginOnlineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (regionParameterForOnline == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionParameterForOnline"); + } + if (regionParameterForOnline != null) + { + regionParameterForOnline.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("regionParameterForOnline", regionParameterForOnline); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginOnlineRegion", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(regionParameterForOnline != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regionParameterForOnline, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Regenerates an access key for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginRegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (keyToRegenerate == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyToRegenerate"); + } + if (keyToRegenerate != null) + { + keyToRegenerate.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("keyToRegenerate", keyToRegenerate); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginRegenerateKey", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(keyToRegenerate != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(keyToRegenerate, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperationsExtensions.cs new file mode 100644 index 000000000000..d4e54c85d3f0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseAccountsOperationsExtensions.cs @@ -0,0 +1,1115 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DatabaseAccountsOperations. + /// + public static partial class DatabaseAccountsOperationsExtensions + { + /// + /// Retrieves the properties of an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static DatabaseAccountGetResults Get(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + return operations.GetAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the properties of an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates the properties of an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + public static DatabaseAccountGetResults Update(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters) + { + return operations.UpdateAsync(resourceGroupName, accountName, updateParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates the properties of an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, updateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an Azure Cosmos DB database account. The "Update" method + /// is preferred when performing updates on an account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + public static DatabaseAccountGetResults CreateOrUpdate(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, accountName, createUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an Azure Cosmos DB database account. The "Update" method + /// is preferred when performing updates on an account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, createUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static void Delete(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + operations.DeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// 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. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + public static void FailoverPriorityChange(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, FailoverPolicies failoverParameters) + { + operations.FailoverPriorityChangeAsync(resourceGroupName, accountName, failoverParameters).GetAwaiter().GetResult(); + } + + /// + /// 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. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + /// + /// The cancellation token. + /// + public static async Task FailoverPriorityChangeAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, FailoverPolicies failoverParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.FailoverPriorityChangeWithHttpMessagesAsync(resourceGroupName, accountName, failoverParameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all the Azure Cosmos DB database accounts available under the + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this IDatabaseAccountsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all the Azure Cosmos DB database accounts available under the + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDatabaseAccountsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the Azure Cosmos DB database accounts available under the given + /// resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + public static IEnumerable ListByResourceGroup(this IDatabaseAccountsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Lists all the Azure Cosmos DB database accounts available under the given + /// resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the access keys for the specified Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static DatabaseAccountListKeysResult ListKeys(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + return operations.ListKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the access keys for the specified Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task ListKeysAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the connection strings for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static DatabaseAccountListConnectionStringsResult ListConnectionStrings(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + return operations.ListConnectionStringsAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the connection strings for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task ListConnectionStringsAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListConnectionStringsWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Offline the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + public static void OfflineRegion(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline) + { + operations.OfflineRegionAsync(resourceGroupName, accountName, regionParameterForOffline).GetAwaiter().GetResult(); + } + + /// + /// Offline the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + /// + /// The cancellation token. + /// + public static async Task OfflineRegionAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.OfflineRegionWithHttpMessagesAsync(resourceGroupName, accountName, regionParameterForOffline, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Online the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + public static void OnlineRegion(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline) + { + operations.OnlineRegionAsync(resourceGroupName, accountName, regionParameterForOnline).GetAwaiter().GetResult(); + } + + /// + /// Online the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + /// + /// The cancellation token. + /// + public static async Task OnlineRegionAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.OnlineRegionWithHttpMessagesAsync(resourceGroupName, accountName, regionParameterForOnline, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static DatabaseAccountListReadOnlyKeysResult GetReadOnlyKeys(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + return operations.GetReadOnlyKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task GetReadOnlyKeysAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetReadOnlyKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static DatabaseAccountListReadOnlyKeysResult ListReadOnlyKeys(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + return operations.ListReadOnlyKeysAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task ListReadOnlyKeysAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListReadOnlyKeysWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Regenerates an access key for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + public static void RegenerateKey(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate) + { + operations.RegenerateKeyAsync(resourceGroupName, accountName, keyToRegenerate).GetAwaiter().GetResult(); + } + + /// + /// Regenerates an access key for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + /// + /// The cancellation token. + /// + public static async Task RegenerateKeyAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, keyToRegenerate, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// 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. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Cosmos DB database account name. + /// + public static bool CheckNameExists(this IDatabaseAccountsOperations operations, string accountName) + { + return operations.CheckNameExistsAsync(accountName).GetAwaiter().GetResult(); + } + + /// + /// 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. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task CheckNameExistsAsync(this IDatabaseAccountsOperations operations, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckNameExistsWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the usages (most recent data) for the given database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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). + /// + public static IEnumerable ListUsages(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, string filter = default(string)) + { + return operations.ListUsagesAsync(resourceGroupName, accountName, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the usages (most recent data) for the given database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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). + /// + /// + /// The cancellation token. + /// + public static async Task> ListUsagesAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListUsagesWithHttpMessagesAsync(resourceGroupName, accountName, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves metric definitions for the given database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListMetricDefinitions(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + return operations.ListMetricDefinitionsAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves metric definitions for the given database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricDefinitionsAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricDefinitionsWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates the properties of an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + public static DatabaseAccountGetResults BeginUpdate(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, accountName, updateParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates the properties of an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, accountName, updateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an Azure Cosmos DB database account. The "Update" method + /// is preferred when performing updates on an account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + public static DatabaseAccountGetResults BeginCreateOrUpdate(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, accountName, createUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an Azure Cosmos DB database account. The "Update" method + /// is preferred when performing updates on an account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, createUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static void BeginDelete(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName) + { + operations.BeginDeleteAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// 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. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + public static void BeginFailoverPriorityChange(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, FailoverPolicies failoverParameters) + { + operations.BeginFailoverPriorityChangeAsync(resourceGroupName, accountName, failoverParameters).GetAwaiter().GetResult(); + } + + /// + /// 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. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + /// + /// The cancellation token. + /// + public static async Task BeginFailoverPriorityChangeAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, FailoverPolicies failoverParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginFailoverPriorityChangeWithHttpMessagesAsync(resourceGroupName, accountName, failoverParameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Offline the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + public static void BeginOfflineRegion(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline) + { + operations.BeginOfflineRegionAsync(resourceGroupName, accountName, regionParameterForOffline).GetAwaiter().GetResult(); + } + + /// + /// Offline the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + /// + /// The cancellation token. + /// + public static async Task BeginOfflineRegionAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginOfflineRegionWithHttpMessagesAsync(resourceGroupName, accountName, regionParameterForOffline, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Online the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + public static void BeginOnlineRegion(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline) + { + operations.BeginOnlineRegionAsync(resourceGroupName, accountName, regionParameterForOnline).GetAwaiter().GetResult(); + } + + /// + /// Online the specified region for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + /// + /// The cancellation token. + /// + public static async Task BeginOnlineRegionAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginOnlineRegionWithHttpMessagesAsync(resourceGroupName, accountName, regionParameterForOnline, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Regenerates an access key for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + public static void BeginRegenerateKey(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate) + { + operations.BeginRegenerateKeyAsync(resourceGroupName, accountName, keyToRegenerate).GetAwaiter().GetResult(); + } + + /// + /// Regenerates an access key for the specified Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginRegenerateKeyAsync(this IDatabaseAccountsOperations operations, string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginRegenerateKeyWithHttpMessagesAsync(resourceGroupName, accountName, keyToRegenerate, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperations.cs new file mode 100644 index 000000000000..0a86955fbe21 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperations.cs @@ -0,0 +1,779 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseOperations operations. + /// + internal partial class DatabaseOperations : IServiceOperations, IDatabaseOperations + { + /// + /// Initializes a new instance of the DatabaseOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DatabaseOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves the usages (most recent data) for the given database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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). + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListUsages", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves metric definitions for the given database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricDefinitionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetricDefinitions", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperationsExtensions.cs new file mode 100644 index 000000000000..09af3229b5ba --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/DatabaseOperationsExtensions.cs @@ -0,0 +1,189 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DatabaseOperations. + /// + public static partial class DatabaseOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IDatabaseOperations operations, string resourceGroupName, string accountName, string databaseRid, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, databaseRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account and database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IDatabaseOperations operations, string resourceGroupName, string accountName, string databaseRid, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the usages (most recent data) for the given database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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). + /// + public static IEnumerable ListUsages(this IDatabaseOperations operations, string resourceGroupName, string accountName, string databaseRid, string filter = default(string)) + { + return operations.ListUsagesAsync(resourceGroupName, accountName, databaseRid, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the usages (most recent data) for the given database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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). + /// + /// + /// The cancellation token. + /// + public static async Task> ListUsagesAsync(this IDatabaseOperations operations, string resourceGroupName, string accountName, string databaseRid, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListUsagesWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves metric definitions for the given database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + public static IEnumerable ListMetricDefinitions(this IDatabaseOperations operations, string resourceGroupName, string accountName, string databaseRid) + { + return operations.ListMetricDefinitionsAsync(resourceGroupName, accountName, databaseRid).GetAwaiter().GetResult(); + } + + /// + /// Retrieves metric definitions for the given database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricDefinitionsAsync(this IDatabaseOperations operations, string resourceGroupName, string accountName, string databaseRid, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricDefinitionsWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperations.cs new file mode 100644 index 000000000000..82dc32473eba --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperations.cs @@ -0,0 +1,3095 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GremlinResourcesOperations operations. + /// + internal partial class GremlinResourcesOperations : IServiceOperations, IGremlinResourcesOperations + { + /// + /// Initializes a new instance of the GremlinResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GremlinResourcesOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Lists the Gremlin databases under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListGremlinDatabasesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListGremlinDatabases", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the Gremlin databases under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetGremlinDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateGremlinDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteGremlinDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the Gremlin database under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetGremlinDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetGremlinDatabaseThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateGremlinDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateGremlinDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the Gremlin graph under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListGremlinGraphsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListGremlinGraphs", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the Gremlin graph under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (graphName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "graphName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("graphName", graphName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetGremlinGraph", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{graphName}", System.Uri.EscapeDataString(graphName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateGremlinGraphWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteGremlinGraphWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the Gremlin graph throughput under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetGremlinGraphThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (graphName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "graphName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("graphName", graphName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetGremlinGraphThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{graphName}", System.Uri.EscapeDataString(graphName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// graph. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateGremlinGraphThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateGremlinGraphThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (createUpdateGremlinDatabaseParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateGremlinDatabaseParameters"); + } + if (createUpdateGremlinDatabaseParameters != null) + { + createUpdateGremlinDatabaseParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateGremlinDatabaseParameters", createUpdateGremlinDatabaseParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateGremlinDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateGremlinDatabaseParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateGremlinDatabaseParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteGremlinDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateGremlinDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateGremlinDatabaseThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (graphName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "graphName"); + } + if (createUpdateGremlinGraphParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateGremlinGraphParameters"); + } + if (createUpdateGremlinGraphParameters != null) + { + createUpdateGremlinGraphParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("graphName", graphName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateGremlinGraphParameters", createUpdateGremlinGraphParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateGremlinGraph", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{graphName}", System.Uri.EscapeDataString(graphName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateGremlinGraphParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateGremlinGraphParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (graphName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "graphName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("graphName", graphName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteGremlinGraph", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{graphName}", System.Uri.EscapeDataString(graphName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// graph. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateGremlinGraphThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (graphName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "graphName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("graphName", graphName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateGremlinGraphThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{graphName}", System.Uri.EscapeDataString(graphName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..2f3de3aa95bc --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/GremlinResourcesOperationsExtensions.cs @@ -0,0 +1,949 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GremlinResourcesOperations. + /// + public static partial class GremlinResourcesOperationsExtensions + { + /// + /// Lists the Gremlin databases under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListGremlinDatabases(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName) + { + return operations.ListGremlinDatabasesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the Gremlin databases under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListGremlinDatabasesAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListGremlinDatabasesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the Gremlin databases under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static GremlinDatabaseGetResults GetGremlinDatabase(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.GetGremlinDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Gets the Gremlin databases under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task GetGremlinDatabaseAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetGremlinDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + public static GremlinDatabaseGetResults CreateUpdateGremlinDatabase(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters) + { + return operations.CreateUpdateGremlinDatabaseAsync(resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateGremlinDatabaseAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateGremlinDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static void DeleteGremlinDatabase(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + operations.DeleteGremlinDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteGremlinDatabaseAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteGremlinDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the Gremlin database under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static ThroughputSettingsGetResults GetGremlinDatabaseThroughput(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.GetGremlinDatabaseThroughputAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the Gremlin database under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task GetGremlinDatabaseThroughputAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetGremlinDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// database. + /// + public static ThroughputSettingsGetResults UpdateGremlinDatabaseThroughput(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateGremlinDatabaseThroughputAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// database. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateGremlinDatabaseThroughputAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateGremlinDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the Gremlin graph under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static IEnumerable ListGremlinGraphs(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.ListGremlinGraphsAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Lists the Gremlin graph under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListGremlinGraphsAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListGremlinGraphsWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the Gremlin graph under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + public static GremlinGraphGetResults GetGremlinGraph(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName) + { + return operations.GetGremlinGraphAsync(resourceGroupName, accountName, databaseName, graphName).GetAwaiter().GetResult(); + } + + /// + /// Gets the Gremlin graph under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The cancellation token. + /// + public static async Task GetGremlinGraphAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetGremlinGraphWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + public static GremlinGraphGetResults CreateUpdateGremlinGraph(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters) + { + return operations.CreateUpdateGremlinGraphAsync(resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateGremlinGraphAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateGremlinGraphWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + public static void DeleteGremlinGraph(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName) + { + operations.DeleteGremlinGraphAsync(resourceGroupName, accountName, databaseName, graphName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteGremlinGraphAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteGremlinGraphWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the Gremlin graph throughput under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + public static ThroughputSettingsGetResults GetGremlinGraphThroughput(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName) + { + return operations.GetGremlinGraphThroughputAsync(resourceGroupName, accountName, databaseName, graphName).GetAwaiter().GetResult(); + } + + /// + /// Gets the Gremlin graph throughput under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The cancellation token. + /// + public static async Task GetGremlinGraphThroughputAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetGremlinGraphThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// graph. + /// + public static ThroughputSettingsGetResults UpdateGremlinGraphThroughput(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateGremlinGraphThroughputAsync(resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// graph. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateGremlinGraphThroughputAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateGremlinGraphThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + public static GremlinDatabaseGetResults BeginCreateUpdateGremlinDatabase(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters) + { + return operations.BeginCreateUpdateGremlinDatabaseAsync(resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateGremlinDatabaseAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateGremlinDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static void BeginDeleteGremlinDatabase(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + operations.BeginDeleteGremlinDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteGremlinDatabaseAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteGremlinDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// database. + /// + public static ThroughputSettingsGetResults BeginUpdateGremlinDatabaseThroughput(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateGremlinDatabaseThroughputAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateGremlinDatabaseThroughputAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateGremlinDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + public static GremlinGraphGetResults BeginCreateUpdateGremlinGraph(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters) + { + return operations.BeginCreateUpdateGremlinGraphAsync(resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateGremlinGraphAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateGremlinGraphWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + public static void BeginDeleteGremlinGraph(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName) + { + operations.BeginDeleteGremlinGraphAsync(resourceGroupName, accountName, databaseName, graphName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteGremlinGraphAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteGremlinGraphWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// graph. + /// + public static ThroughputSettingsGetResults BeginUpdateGremlinGraphThroughput(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateGremlinGraphThroughputAsync(resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current Gremlin + /// graph. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateGremlinGraphThroughputAsync(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateGremlinGraphThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICassandraResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICassandraResourcesOperations.cs new file mode 100644 index 000000000000..161755adf2a4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICassandraResourcesOperations.cs @@ -0,0 +1,574 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CassandraResourcesOperations operations. + /// + public partial interface ICassandraResourcesOperations + { + /// + /// Lists the Cassandra keyspaces under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListCassandraKeyspacesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the Cassandra keyspaces under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the Cassandra Keyspace under an existing + /// Azure Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetCassandraKeyspaceThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Cassandra Keyspace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the Cassandra table under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListCassandraTablesWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the Cassandra table under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the Cassandra table under an existing + /// Azure Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetCassandraTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Cassandra table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateCassandraTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Cassandra keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The parameters to provide for the current Cassandra keyspace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Cassandra keyspace. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteCassandraKeyspaceWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Cassandra Keyspace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Cassandra Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Cassandra Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, CassandraTableCreateUpdateParameters createUpdateCassandraTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Cassandra table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteCassandraTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Cassandra table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB keyspace name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Cassandra table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateCassandraTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string keyspaceName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionOperations.cs new file mode 100644 index 000000000000..a1e398d36729 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionOperations.cs @@ -0,0 +1,133 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionOperations operations. + /// + public partial interface ICollectionOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// database account and collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the usages (most recent storage data) for the given + /// collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves metric definitions for the given collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricDefinitionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionOperations.cs new file mode 100644 index 000000000000..057758abd5d8 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionOperations.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartitionOperations operations. + /// + public partial interface ICollectionPartitionOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection, split by partition. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the usages (most recent storage data) for the given + /// collection, split by partition. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionRegionOperations.cs new file mode 100644 index 000000000000..433df81a8213 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionPartitionRegionOperations.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartitionRegionOperations operations. + /// + public partial interface ICollectionPartitionRegionOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// collection and region, split by partition. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word + /// capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionRegionOperations.cs new file mode 100644 index 000000000000..edec27d3307c --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICollectionRegionOperations.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionRegionOperations operations. + /// + public partial interface ICollectionRegionOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// database account, collection and region. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word + /// capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICosmosDBManagementClient.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICosmosDBManagementClient.cs new file mode 100644 index 000000000000..e1cbd9db1c2e --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ICosmosDBManagementClient.cs @@ -0,0 +1,173 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Azure Cosmos DB Database Service Resource Provider REST API + /// + public partial interface ICosmosDBManagementClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// Azure subscription ID. + /// + string SubscriptionId { get; set; } + + /// + /// The ID of the target subscription. + /// + string SubscriptionId1 { get; set; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IDatabaseAccountsOperations. + /// + IDatabaseAccountsOperations DatabaseAccounts { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IDatabaseOperations. + /// + IDatabaseOperations Database { get; } + + /// + /// Gets the ICollectionOperations. + /// + ICollectionOperations Collection { get; } + + /// + /// Gets the ICollectionRegionOperations. + /// + ICollectionRegionOperations CollectionRegion { get; } + + /// + /// Gets the IDatabaseAccountRegionOperations. + /// + IDatabaseAccountRegionOperations DatabaseAccountRegion { get; } + + /// + /// Gets the IPercentileSourceTargetOperations. + /// + IPercentileSourceTargetOperations PercentileSourceTarget { get; } + + /// + /// Gets the IPercentileTargetOperations. + /// + IPercentileTargetOperations PercentileTarget { get; } + + /// + /// Gets the IPercentileOperations. + /// + IPercentileOperations Percentile { get; } + + /// + /// Gets the ICollectionPartitionRegionOperations. + /// + ICollectionPartitionRegionOperations CollectionPartitionRegion { get; } + + /// + /// Gets the ICollectionPartitionOperations. + /// + ICollectionPartitionOperations CollectionPartition { get; } + + /// + /// Gets the IPartitionKeyRangeIdOperations. + /// + IPartitionKeyRangeIdOperations PartitionKeyRangeId { get; } + + /// + /// Gets the IPartitionKeyRangeIdRegionOperations. + /// + IPartitionKeyRangeIdRegionOperations PartitionKeyRangeIdRegion { get; } + + /// + /// Gets the ISqlResourcesOperations. + /// + ISqlResourcesOperations SqlResources { get; } + + /// + /// Gets the IMongoDBResourcesOperations. + /// + IMongoDBResourcesOperations MongoDBResources { get; } + + /// + /// Gets the ITableResourcesOperations. + /// + ITableResourcesOperations TableResources { get; } + + /// + /// Gets the ICassandraResourcesOperations. + /// + ICassandraResourcesOperations CassandraResources { get; } + + /// + /// Gets the IGremlinResourcesOperations. + /// + IGremlinResourcesOperations GremlinResources { get; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + IPrivateLinkResourcesOperations PrivateLinkResources { get; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountRegionOperations.cs new file mode 100644 index 000000000000..0d59cac5fdaf --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountRegionOperations.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccountRegionOperations operations. + /// + public partial interface IDatabaseAccountRegionOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// database account and region. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word + /// capitalized. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountsOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountsOperations.cs new file mode 100644 index 000000000000..386b2c831421 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseAccountsOperations.cs @@ -0,0 +1,683 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccountsOperations operations. + /// + public partial interface IDatabaseAccountsOperations + { + /// + /// Retrieves the properties of an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates the properties of an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an Azure Cosmos DB database account. The + /// "Update" method is preferred when performing updates on an account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task FailoverPriorityChangeWithHttpMessagesAsync(string resourceGroupName, string accountName, FailoverPolicies failoverParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Azure Cosmos DB database accounts available under the + /// subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Azure Cosmos DB database accounts available under the + /// given resource group. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the access keys for the specified Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the connection strings for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListConnectionStringsWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Offline the specified region for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task OfflineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Online the specified region for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task OnlineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetReadOnlyKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the read-only access keys for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListReadOnlyKeysWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Regenerates an access key for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// 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. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> CheckNameExistsWithHttpMessagesAsync(string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the metrics determined by the given filter for the given + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the usages (most recent data) for the given database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves metric definitions for the given database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricDefinitionsWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates the properties of an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountUpdateParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an Azure Cosmos DB database account. The + /// "Update" method is preferred when performing updates on an account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The parameters to provide for the current database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountCreateUpdateParameters createUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The new failover policies for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginFailoverPriorityChangeWithHttpMessagesAsync(string resourceGroupName, string accountName, FailoverPolicies failoverParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Offline the specified region for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to offline for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginOfflineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOffline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Online the specified region for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region to online for the database account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginOnlineRegionWithHttpMessagesAsync(string resourceGroupName, string accountName, RegionForOnlineOffline regionParameterForOnline, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Regenerates an access key for the specified Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the key to regenerate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginRegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountRegenerateKeyParameters keyToRegenerate, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseOperations.cs new file mode 100644 index 000000000000..2dfd8e669d43 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IDatabaseOperations.cs @@ -0,0 +1,123 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseOperations operations. + /// + public partial interface IDatabaseOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// database account and database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the usages (most recent data) for the given database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// 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). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListUsagesWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves metric definitions for the given database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricDefinitionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IGremlinResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IGremlinResourcesOperations.cs new file mode 100644 index 000000000000..85e47025e83e --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IGremlinResourcesOperations.cs @@ -0,0 +1,574 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GremlinResourcesOperations operations. + /// + public partial interface IGremlinResourcesOperations + { + /// + /// Lists the Gremlin databases under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListGremlinDatabasesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the Gremlin databases under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the Gremlin database under an existing + /// Azure Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetGremlinDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Gremlin database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateGremlinDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the Gremlin graph under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListGremlinGraphsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the Gremlin graph under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the Gremlin graph throughput under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetGremlinGraphThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Gremlin graph. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateGremlinGraphThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current Gremlin database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, GremlinDatabaseCreateUpdateParameters createUpdateGremlinDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Gremlin database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteGremlinDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Gremlin database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateGremlinDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The parameters to provide for the current Gremlin graph. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, GremlinGraphCreateUpdateParameters createUpdateGremlinGraphParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Gremlin graph. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteGremlinGraphWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Gremlin graph + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB graph name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// Gremlin graph. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateGremlinGraphThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IMongoDBResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IMongoDBResourcesOperations.cs new file mode 100644 index 000000000000..4a610a6368c4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IMongoDBResourcesOperations.cs @@ -0,0 +1,574 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MongoDBResourcesOperations operations. + /// + public partial interface IMongoDBResourcesOperations + { + /// + /// Lists the MongoDB databases under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMongoDBDatabasesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the MongoDB databases under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the MongoDB database under an existing + /// Azure Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetMongoDBDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// MongoDB database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the MongoDB collection under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMongoDBCollectionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the MongoDB collection under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the MongoDB collection under an existing + /// Azure Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetMongoDBCollectionThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// MongoDB collection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateMongoDBCollectionThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// MongoDB database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current + /// MongoDB collection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateMongoDBCollectionThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IOperations.cs new file mode 100644 index 000000000000..b61cee9ee198 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IOperations.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdOperations.cs new file mode 100644 index 000000000000..13664429f54d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdOperations.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeIdOperations operations. + /// + public partial interface IPartitionKeyRangeIdOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdRegionOperations.cs new file mode 100644 index 000000000000..a6d8f3e06639 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPartitionKeyRangeIdRegionOperations.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeIdRegionOperations operations. + /// + public partial interface IPartitionKeyRangeIdRegionOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id and region. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word + /// capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileOperations.cs new file mode 100644 index 000000000000..d6c36167cc1b --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileOperations.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileOperations operations. + /// + public partial interface IPercentileOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// database account. This url is only for PBS and Replication Latency + /// data + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileSourceTargetOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileSourceTargetOperations.cs new file mode 100644 index 000000000000..73713ff7a739 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileSourceTargetOperations.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileSourceTargetOperations operations. + /// + public partial interface IPercentileSourceTargetOperations + { + /// + /// 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 + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Source region from which data is written. Cosmos DB region, with + /// spaces between words and each word capitalized. + /// + /// + /// Target region to which data is written. Cosmos DB region, with + /// spaces between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string sourceRegion, string targetRegion, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileTargetOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileTargetOperations.cs new file mode 100644 index 000000000000..719a1bf96e15 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPercentileTargetOperations.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileTargetOperations operations. + /// + public partial interface IPercentileTargetOperations + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// account target region. This url is only for PBS and Replication + /// Latency data + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Target region to which data is written. Cosmos DB region, with + /// spaces between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string targetRegion, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateEndpointConnectionsOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..35a42490eb99 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateEndpointConnectionsOperations.cs @@ -0,0 +1,190 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + public partial interface IPrivateEndpointConnectionsOperations + { + /// + /// List all private endpoint connections on a Cosmos DB account. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByDatabaseAccountWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateLinkResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..9f87c9055b17 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/IPrivateLinkResourcesOperations.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + public partial interface IPrivateLinkResourcesOperations + { + /// + /// Gets the private link resources that need to be created for a + /// Cosmos DB account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByDatabaseAccountWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the private link resources that need to be created for a + /// Cosmos DB account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private link resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ISqlResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ISqlResourcesOperations.cs new file mode 100644 index 000000000000..78ff634614bc --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ISqlResourcesOperations.cs @@ -0,0 +1,1183 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SqlResourcesOperations operations. + /// + public partial interface ISqlResourcesOperations + { + /// + /// Lists the SQL databases under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListSqlDatabasesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the SQL database under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the SQL database under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSqlDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateSqlDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the SQL container under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListSqlContainersWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the SQL container under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the SQL container under an existing + /// Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSqlContainerThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateSqlContainerThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the SQL storedProcedure under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListSqlStoredProceduresWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the SQL storedProcedure under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the SQL userDefinedFunction under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListSqlUserDefinedFunctionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the SQL userDefinedFunction under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the SQL trigger under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListSqlTriggersWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the SQL trigger under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateSqlDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateSqlContainerThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ITableResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ITableResourcesOperations.cs new file mode 100644 index 000000000000..2ca46c0d3883 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/ITableResourcesOperations.cs @@ -0,0 +1,287 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TableResourcesOperations operations. + /// + public partial interface ITableResourcesOperations + { + /// + /// Lists the Tables under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListTablesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the Tables under an existing Azure Cosmos DB database account + /// with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateUpdateTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the RUs per second of the Table under an existing Azure Cosmos + /// DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current + /// Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateUpdateTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current + /// Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMProxyResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMProxyResource.cs new file mode 100644 index 000000000000..6dc67e3d5cbf --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMProxyResource.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource model definition for a ARM proxy resource. It will have + /// everything other than required location and tags + /// + public partial class ARMProxyResource : IResource + { + /// + /// Initializes a new instance of the ARMProxyResource class. + /// + public ARMProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ARMProxyResource class. + /// + /// The unique resource identifier of the database + /// account. + /// The name of the database account. + /// The type of Azure resource. + public ARMProxyResource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the unique resource identifier of the database account. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the database account. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of Azure resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMResourceProperties.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMResourceProperties.cs new file mode 100644 index 000000000000..e1d99e84fc14 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ARMResourceProperties.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The core properties of ARM resources. + /// + public partial class ARMResourceProperties : IResource + { + /// + /// Initializes a new instance of the ARMResourceProperties class. + /// + public ARMResourceProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ARMResourceProperties class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public ARMResourceProperties(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the unique resource identifier of the ARM resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the ARM resource. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of Azure resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the location of the resource group to which the + /// resource belongs. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AutoUpgradePolicyResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AutoUpgradePolicyResource.cs new file mode 100644 index 000000000000..a828feea7bb4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AutoUpgradePolicyResource.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB resource auto-upgrade policy + /// + public partial class AutoUpgradePolicyResource + { + /// + /// Initializes a new instance of the AutoUpgradePolicyResource class. + /// + public AutoUpgradePolicyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AutoUpgradePolicyResource class. + /// + /// Represents throughput policy which + /// service must adhere to for auto-upgrade + public AutoUpgradePolicyResource(ThroughputPolicyResource throughputPolicy = default(ThroughputPolicyResource)) + { + ThroughputPolicy = throughputPolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets represents throughput policy which service must adhere + /// to for auto-upgrade + /// + [JsonProperty(PropertyName = "throughputPolicy")] + public ThroughputPolicyResource ThroughputPolicy { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AzureEntityResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AzureEntityResource.cs new file mode 100644 index 000000000000..efc0fc8dea4e --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/AzureEntityResource.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource model definition for a Azure Resource Manager resource + /// with an etag. + /// + public partial class AzureEntityResource : Resource + { + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + public AzureEntityResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + /// Fully qualified resource Id for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. Ex- + /// Microsoft.Compute/virtualMachines or + /// Microsoft.Storage/storageAccounts. + /// Resource Etag. + public AzureEntityResource(string id = default(string), string name = default(string), string type = default(string), string etag = default(string)) + : base(id, name, type) + { + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Etag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Capability.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Capability.cs new file mode 100644 index 000000000000..a43cc567b311 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Capability.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB capability object + /// + public partial class Capability + { + /// + /// Initializes a new instance of the Capability class. + /// + public Capability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Capability class. + /// + /// Name of the Cosmos DB capability. For example, + /// "name": "EnableCassandra". Current values also include + /// "EnableTable" and "EnableGremlin". + public Capability(string name = default(string)) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB capability. For example, "name": + /// "EnableCassandra". Current values also include "EnableTable" and + /// "EnableGremlin". + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceCreateUpdateParameters.cs new file mode 100644 index 000000000000..83ad2fe9bae1 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB Cassandra keyspace. + /// + [Rest.Serialization.JsonTransformation] + public partial class CassandraKeyspaceCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// CassandraKeyspaceCreateUpdateParameters class. + /// + public CassandraKeyspaceCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// CassandraKeyspaceCreateUpdateParameters class. + /// + /// The standard JSON format of a Cassandra + /// keyspace + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public CassandraKeyspaceCreateUpdateParameters(CassandraKeyspaceResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a Cassandra keyspace + /// + [JsonProperty(PropertyName = "properties.resource")] + public CassandraKeyspaceResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetPropertiesResource.cs new file mode 100644 index 000000000000..c8bbf22d789f --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetPropertiesResource.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class CassandraKeyspaceGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// CassandraKeyspaceGetPropertiesResource class. + /// + public CassandraKeyspaceGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// CassandraKeyspaceGetPropertiesResource class. + /// + /// Name of the Cosmos DB Cassandra keyspace + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public CassandraKeyspaceGetPropertiesResource(string id, string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Cassandra keyspace + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetResults.cs new file mode 100644 index 000000000000..4cf74824ad86 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceGetResults.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB Cassandra keyspace. + /// + [Rest.Serialization.JsonTransformation] + public partial class CassandraKeyspaceGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the CassandraKeyspaceGetResults + /// class. + /// + public CassandraKeyspaceGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraKeyspaceGetResults + /// class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public CassandraKeyspaceGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), CassandraKeyspaceGetPropertiesResource resource = default(CassandraKeyspaceGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public CassandraKeyspaceGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceResource.cs new file mode 100644 index 000000000000..4ac0977aa23c --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraKeyspaceResource.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB Cassandra keyspace resource object + /// + public partial class CassandraKeyspaceResource + { + /// + /// Initializes a new instance of the CassandraKeyspaceResource class. + /// + public CassandraKeyspaceResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraKeyspaceResource class. + /// + /// Name of the Cosmos DB Cassandra keyspace + public CassandraKeyspaceResource(string id) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Cassandra keyspace + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraPartitionKey.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraPartitionKey.cs new file mode 100644 index 000000000000..23d5acf7c470 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraPartitionKey.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB Cassandra table partition key + /// + public partial class CassandraPartitionKey + { + /// + /// Initializes a new instance of the CassandraPartitionKey class. + /// + public CassandraPartitionKey() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraPartitionKey class. + /// + /// Name of the Cosmos DB Cassandra table partition + /// key + public CassandraPartitionKey(string name = default(string)) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Cassandra table partition key + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraSchema.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraSchema.cs new file mode 100644 index 000000000000..3eec67c3f98d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraSchema.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Cosmos DB Cassandra table schema + /// + public partial class CassandraSchema + { + /// + /// Initializes a new instance of the CassandraSchema class. + /// + public CassandraSchema() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraSchema class. + /// + /// List of Cassandra table columns. + /// List of partition key. + /// List of cluster key. + public CassandraSchema(IList columns = default(IList), IList partitionKeys = default(IList), IList clusterKeys = default(IList)) + { + Columns = columns; + PartitionKeys = partitionKeys; + ClusterKeys = clusterKeys; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of Cassandra table columns. + /// + [JsonProperty(PropertyName = "columns")] + public IList Columns { get; set; } + + /// + /// Gets or sets list of partition key. + /// + [JsonProperty(PropertyName = "partitionKeys")] + public IList PartitionKeys { get; set; } + + /// + /// Gets or sets list of cluster key. + /// + [JsonProperty(PropertyName = "clusterKeys")] + public IList ClusterKeys { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableCreateUpdateParameters.cs new file mode 100644 index 000000000000..0076d64c9d8f --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB Cassandra table. + /// + [Rest.Serialization.JsonTransformation] + public partial class CassandraTableCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// CassandraTableCreateUpdateParameters class. + /// + public CassandraTableCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// CassandraTableCreateUpdateParameters class. + /// + /// The standard JSON format of a Cassandra + /// table + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public CassandraTableCreateUpdateParameters(CassandraTableResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a Cassandra table + /// + [JsonProperty(PropertyName = "properties.resource")] + public CassandraTableResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetPropertiesResource.cs new file mode 100644 index 000000000000..0e6f7b6753df --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetPropertiesResource.cs @@ -0,0 +1,111 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class CassandraTableGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// CassandraTableGetPropertiesResource class. + /// + public CassandraTableGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// CassandraTableGetPropertiesResource class. + /// + /// Name of the Cosmos DB Cassandra table + /// Time to live of the Cosmos DB Cassandra + /// table + /// Schema of the Cosmos DB Cassandra + /// table + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public CassandraTableGetPropertiesResource(string id, int? defaultTtl = default(int?), CassandraSchema schema = default(CassandraSchema), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + DefaultTtl = defaultTtl; + Schema = schema; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets time to live of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "defaultTtl")] + public int? DefaultTtl { get; set; } + + /// + /// Gets or sets schema of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "schema")] + public CassandraSchema Schema { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetResults.cs new file mode 100644 index 000000000000..4b5478d478c4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB Cassandra table. + /// + [Rest.Serialization.JsonTransformation] + public partial class CassandraTableGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the CassandraTableGetResults class. + /// + public CassandraTableGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraTableGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public CassandraTableGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), CassandraTableGetPropertiesResource resource = default(CassandraTableGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public CassandraTableGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableResource.cs new file mode 100644 index 000000000000..68e8391c2815 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CassandraTableResource.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB Cassandra table resource object + /// + public partial class CassandraTableResource + { + /// + /// Initializes a new instance of the CassandraTableResource class. + /// + public CassandraTableResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraTableResource class. + /// + /// Name of the Cosmos DB Cassandra table + /// Time to live of the Cosmos DB Cassandra + /// table + /// Schema of the Cosmos DB Cassandra + /// table + public CassandraTableResource(string id, int? defaultTtl = default(int?), CassandraSchema schema = default(CassandraSchema)) + { + Id = id; + DefaultTtl = defaultTtl; + Schema = schema; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets time to live of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "defaultTtl")] + public int? DefaultTtl { get; set; } + + /// + /// Gets or sets schema of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "schema")] + public CassandraSchema Schema { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ClusterKey.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ClusterKey.cs new file mode 100644 index 000000000000..1f9dfe17d60f --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ClusterKey.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB Cassandra table cluster key + /// + public partial class ClusterKey + { + /// + /// Initializes a new instance of the ClusterKey class. + /// + public ClusterKey() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClusterKey class. + /// + /// Name of the Cosmos DB Cassandra table cluster + /// key + /// Order of the Cosmos DB Cassandra table + /// cluster key, only support "Asc" and "Desc" + public ClusterKey(string name = default(string), string orderBy = default(string)) + { + Name = name; + OrderBy = orderBy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Cassandra table cluster key + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets order of the Cosmos DB Cassandra table cluster key, + /// only support "Asc" and "Desc" + /// + [JsonProperty(PropertyName = "orderBy")] + public string OrderBy { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Column.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Column.cs new file mode 100644 index 000000000000..e16cd0dcbb90 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Column.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB Cassandra table column + /// + public partial class Column + { + /// + /// Initializes a new instance of the Column class. + /// + public Column() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Column class. + /// + /// Name of the Cosmos DB Cassandra table + /// column + /// Type of the Cosmos DB Cassandra table + /// column + public Column(string name = default(string), string type = default(string)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Cassandra table column + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets type of the Cosmos DB Cassandra table column + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePath.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePath.cs new file mode 100644 index 000000000000..d693907918c7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePath.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class CompositePath + { + /// + /// Initializes a new instance of the CompositePath class. + /// + public CompositePath() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CompositePath class. + /// + /// The path for which the indexing behavior applies + /// to. Index paths typically start with root and end with wildcard + /// (/path/*) + /// Sort order for composite paths. Possible values + /// include: 'Ascending', 'Descending' + public CompositePath(string path = default(string), string order = default(string)) + { + Path = path; + Order = order; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the path for which the indexing behavior applies to. + /// Index paths typically start with root and end with wildcard + /// (/path/*) + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + /// + /// Gets or sets sort order for composite paths. Possible values + /// include: 'Ascending', 'Descending' + /// + [JsonProperty(PropertyName = "order")] + public string Order { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePathSortOrder.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePathSortOrder.cs new file mode 100644 index 000000000000..d8361ea9faab --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CompositePathSortOrder.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for CompositePathSortOrder. + /// + public static class CompositePathSortOrder + { + public const string Ascending = "Ascending"; + public const string Descending = "Descending"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionMode.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionMode.cs new file mode 100644 index 000000000000..a4f7ae0596b2 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionMode.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for ConflictResolutionMode. + /// + public static class ConflictResolutionMode + { + public const string LastWriterWins = "LastWriterWins"; + public const string Custom = "Custom"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionPolicy.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionPolicy.cs new file mode 100644 index 000000000000..b90de66eb236 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConflictResolutionPolicy.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The conflict resolution policy for the container. + /// + public partial class ConflictResolutionPolicy + { + /// + /// Initializes a new instance of the ConflictResolutionPolicy class. + /// + public ConflictResolutionPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConflictResolutionPolicy class. + /// + /// Indicates the conflict resolution mode. Possible + /// values include: 'LastWriterWins', 'Custom' + /// The conflict resolution path + /// in the case of LastWriterWins mode. + /// The procedure to resolve + /// conflicts in the case of custom mode. + public ConflictResolutionPolicy(string mode = default(string), string conflictResolutionPath = default(string), string conflictResolutionProcedure = default(string)) + { + Mode = mode; + ConflictResolutionPath = conflictResolutionPath; + ConflictResolutionProcedure = conflictResolutionProcedure; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates the conflict resolution mode. Possible + /// values include: 'LastWriterWins', 'Custom' + /// + [JsonProperty(PropertyName = "mode")] + public string Mode { get; set; } + + /// + /// Gets or sets the conflict resolution path in the case of + /// LastWriterWins mode. + /// + [JsonProperty(PropertyName = "conflictResolutionPath")] + public string ConflictResolutionPath { get; set; } + + /// + /// Gets or sets the procedure to resolve conflicts in the case of + /// custom mode. + /// + [JsonProperty(PropertyName = "conflictResolutionProcedure")] + public string ConflictResolutionProcedure { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConnectorOffer.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConnectorOffer.cs new file mode 100644 index 000000000000..780126ad5bb5 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConnectorOffer.cs @@ -0,0 +1,21 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for ConnectorOffer. + /// + public static class ConnectorOffer + { + public const string Small = "Small"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConsistencyPolicy.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConsistencyPolicy.cs new file mode 100644 index 000000000000..7c1bcd6dc606 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ConsistencyPolicy.cs @@ -0,0 +1,115 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The consistency policy for the Cosmos DB database account. + /// + public partial class ConsistencyPolicy + { + /// + /// Initializes a new instance of the ConsistencyPolicy class. + /// + public ConsistencyPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConsistencyPolicy class. + /// + /// The default consistency level + /// and configuration settings of the Cosmos DB account. Possible + /// values include: 'Eventual', 'Session', 'BoundedStaleness', + /// 'Strong', 'ConsistentPrefix' + /// 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'. + /// 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'. + public ConsistencyPolicy(DefaultConsistencyLevel defaultConsistencyLevel, long? maxStalenessPrefix = default(long?), int? maxIntervalInSeconds = default(int?)) + { + DefaultConsistencyLevel = defaultConsistencyLevel; + MaxStalenessPrefix = maxStalenessPrefix; + MaxIntervalInSeconds = maxIntervalInSeconds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the default consistency level and configuration + /// settings of the Cosmos DB account. Possible values include: + /// 'Eventual', 'Session', 'BoundedStaleness', 'Strong', + /// 'ConsistentPrefix' + /// + [JsonProperty(PropertyName = "defaultConsistencyLevel")] + public DefaultConsistencyLevel DefaultConsistencyLevel { get; set; } + + /// + /// Gets or sets 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'. + /// + [JsonProperty(PropertyName = "maxStalenessPrefix")] + public long? MaxStalenessPrefix { get; set; } + + /// + /// Gets or sets 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'. + /// + [JsonProperty(PropertyName = "maxIntervalInSeconds")] + public int? MaxIntervalInSeconds { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (MaxStalenessPrefix > 2147483647) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "MaxStalenessPrefix", 2147483647); + } + if (MaxStalenessPrefix < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "MaxStalenessPrefix", 1); + } + if (MaxIntervalInSeconds > 86400) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "MaxIntervalInSeconds", 86400); + } + if (MaxIntervalInSeconds < 5) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "MaxIntervalInSeconds", 5); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ContainerPartitionKey.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ContainerPartitionKey.cs new file mode 100644 index 000000000000..1a526a048eaf --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ContainerPartitionKey.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The configuration of the partition key to be used for partitioning data + /// into multiple partitions + /// + public partial class ContainerPartitionKey + { + /// + /// Initializes a new instance of the ContainerPartitionKey class. + /// + public ContainerPartitionKey() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContainerPartitionKey class. + /// + /// List of paths using which data within the + /// container can be partitioned + /// Indicates the kind of algorithm used for + /// partitioning. Possible values include: 'Hash', 'Range' + /// Indicates the version of the partition key + /// definition + public ContainerPartitionKey(IList paths = default(IList), string kind = default(string), int? version = default(int?)) + { + Paths = paths; + Kind = kind; + Version = version; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of paths using which data within the container + /// can be partitioned + /// + [JsonProperty(PropertyName = "paths")] + public IList Paths { get; set; } + + /// + /// Gets or sets indicates the kind of algorithm used for partitioning. + /// Possible values include: 'Hash', 'Range' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets indicates the version of the partition key definition + /// + [JsonProperty(PropertyName = "version")] + public int? Version { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Version > 2) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Version", 2); + } + if (Version < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Version", 1); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CreateUpdateOptions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CreateUpdateOptions.cs new file mode 100644 index 000000000000..7ccd52085168 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/CreateUpdateOptions.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// CreateUpdateOptions are a list of key-value pairs that describe the + /// resource. Supported keys are "If-Match", "If-None-Match", + /// "Session-Token" and "Throughput" + /// + public partial class CreateUpdateOptions + { + /// + /// Initializes a new instance of the CreateUpdateOptions class. + /// + public CreateUpdateOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CreateUpdateOptions class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + /// Request Units per second. For example, + /// "throughput": "10000". + public CreateUpdateOptions(IDictionary additionalProperties = default(IDictionary), string throughput = default(string)) + { + AdditionalProperties = additionalProperties; + Throughput = throughput; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Gets or sets request Units per second. For example, "throughput": + /// "10000". + /// + [JsonProperty(PropertyName = "throughput")] + public string Throughput { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DataType.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DataType.cs new file mode 100644 index 000000000000..b0e5d89618d0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DataType.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for DataType. + /// + public static class DataType + { + public const string String = "String"; + public const string Number = "Number"; + public const string Point = "Point"; + public const string Polygon = "Polygon"; + public const string LineString = "LineString"; + public const string MultiPolygon = "MultiPolygon"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountConnectionString.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountConnectionString.cs new file mode 100644 index 000000000000..8dc416ec15e0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountConnectionString.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Connection string for the Cosmos DB account + /// + public partial class DatabaseAccountConnectionString + { + /// + /// Initializes a new instance of the DatabaseAccountConnectionString + /// class. + /// + public DatabaseAccountConnectionString() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatabaseAccountConnectionString + /// class. + /// + /// Value of the connection + /// string + /// Description of the connection + /// string + public DatabaseAccountConnectionString(string connectionString = default(string), string description = default(string)) + { + ConnectionString = connectionString; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets value of the connection string + /// + [JsonProperty(PropertyName = "connectionString")] + public string ConnectionString { get; private set; } + + /// + /// Gets description of the connection string + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountCreateUpdateParameters.cs new file mode 100644 index 000000000000..05fcd4a76161 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountCreateUpdateParameters.cs @@ -0,0 +1,238 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB database accounts. + /// + [Rest.Serialization.JsonTransformation] + public partial class DatabaseAccountCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// DatabaseAccountCreateUpdateParameters class. + /// + public DatabaseAccountCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DatabaseAccountCreateUpdateParameters class. + /// + /// An array that contains the georeplication + /// locations enabled for the Cosmos DB account. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + /// Indicates the type of database account. This can + /// only be set at database account creation. Possible values include: + /// 'GlobalDocumentDB', 'MongoDB', 'Parse' + /// The consistency policy for the + /// Cosmos DB account. + /// 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. + /// Flag to indicate + /// whether to enable/disable Virtual Network ACL rules. + /// 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. + /// List of Cosmos DB capabilities for the + /// account + /// List of Virtual Network ACL rules + /// configured for the Cosmos DB account. + /// Enables the account to + /// write in multiple locations + /// Enables the cassandra + /// connector on the Cosmos DB C* account + /// The cassandra connector offer type for + /// the Cosmos DB database C* account. Possible values include: + /// 'Small' + /// Disable write + /// operations on metadata resources (databases, containers, + /// throughput) via account keys + /// The URI of the key vault + public DatabaseAccountCreateUpdateParameters(IList locations, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string kind = default(string), ConsistencyPolicy consistencyPolicy = default(ConsistencyPolicy), string ipRangeFilter = default(string), bool? isVirtualNetworkFilterEnabled = default(bool?), bool? enableAutomaticFailover = default(bool?), IList capabilities = default(IList), IList virtualNetworkRules = default(IList), bool? enableMultipleWriteLocations = default(bool?), bool? enableCassandraConnector = default(bool?), string connectorOffer = default(string), bool? disableKeyBasedMetadataWriteAccess = default(bool?), string keyVaultKeyUri = default(string)) + : base(id, name, type, location, tags) + { + Kind = kind; + ConsistencyPolicy = consistencyPolicy; + Locations = locations; + IpRangeFilter = ipRangeFilter; + IsVirtualNetworkFilterEnabled = isVirtualNetworkFilterEnabled; + EnableAutomaticFailover = enableAutomaticFailover; + Capabilities = capabilities; + VirtualNetworkRules = virtualNetworkRules; + EnableMultipleWriteLocations = enableMultipleWriteLocations; + EnableCassandraConnector = enableCassandraConnector; + ConnectorOffer = connectorOffer; + DisableKeyBasedMetadataWriteAccess = disableKeyBasedMetadataWriteAccess; + KeyVaultKeyUri = keyVaultKeyUri; + CustomInit(); + } + /// + /// Static constructor for DatabaseAccountCreateUpdateParameters class. + /// + static DatabaseAccountCreateUpdateParameters() + { + DatabaseAccountOfferType = "Standard"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates the type of database account. This can only + /// be set at database account creation. Possible values include: + /// 'GlobalDocumentDB', 'MongoDB', 'Parse' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets the consistency policy for the Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.consistencyPolicy")] + public ConsistencyPolicy ConsistencyPolicy { get; set; } + + /// + /// Gets or sets an array that contains the georeplication locations + /// enabled for the Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.locations")] + public IList Locations { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "properties.ipRangeFilter")] + public string IpRangeFilter { get; set; } + + /// + /// Gets or sets flag to indicate whether to enable/disable Virtual + /// Network ACL rules. + /// + [JsonProperty(PropertyName = "properties.isVirtualNetworkFilterEnabled")] + public bool? IsVirtualNetworkFilterEnabled { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "properties.enableAutomaticFailover")] + public bool? EnableAutomaticFailover { get; set; } + + /// + /// Gets or sets list of Cosmos DB capabilities for the account + /// + [JsonProperty(PropertyName = "properties.capabilities")] + public IList Capabilities { get; set; } + + /// + /// Gets or sets list of Virtual Network ACL rules configured for the + /// Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.virtualNetworkRules")] + public IList VirtualNetworkRules { get; set; } + + /// + /// Gets or sets enables the account to write in multiple locations + /// + [JsonProperty(PropertyName = "properties.enableMultipleWriteLocations")] + public bool? EnableMultipleWriteLocations { get; set; } + + /// + /// Gets or sets enables the cassandra connector on the Cosmos DB C* + /// account + /// + [JsonProperty(PropertyName = "properties.enableCassandraConnector")] + public bool? EnableCassandraConnector { get; set; } + + /// + /// Gets or sets the cassandra connector offer type for the Cosmos DB + /// database C* account. Possible values include: 'Small' + /// + [JsonProperty(PropertyName = "properties.connectorOffer")] + public string ConnectorOffer { get; set; } + + /// + /// Gets or sets disable write operations on metadata resources + /// (databases, containers, throughput) via account keys + /// + [JsonProperty(PropertyName = "properties.disableKeyBasedMetadataWriteAccess")] + public bool? DisableKeyBasedMetadataWriteAccess { get; set; } + + /// + /// Gets or sets the URI of the key vault + /// + [JsonProperty(PropertyName = "properties.keyVaultKeyUri")] + public string KeyVaultKeyUri { get; set; } + + /// + /// The offer type for the database + /// + [JsonProperty(PropertyName = "properties.databaseAccountOfferType")] + public static string DatabaseAccountOfferType { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Locations == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Locations"); + } + if (ConsistencyPolicy != null) + { + ConsistencyPolicy.Validate(); + } + if (Locations != null) + { + foreach (var element in Locations) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountGetResults.cs new file mode 100644 index 000000000000..3b8cafc0c324 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountGetResults.cs @@ -0,0 +1,306 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB database account. + /// + [Rest.Serialization.JsonTransformation] + public partial class DatabaseAccountGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the DatabaseAccountGetResults class. + /// + public DatabaseAccountGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatabaseAccountGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + /// Indicates the type of database account. This can + /// only be set at database account creation. Possible values include: + /// 'GlobalDocumentDB', 'MongoDB', 'Parse' + /// The connection endpoint for the + /// Cosmos DB database account. + /// The offer type for the + /// Cosmos DB database account. Default value: Standard. Possible + /// values include: 'Standard' + /// 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. + /// Flag to indicate + /// whether to enable/disable Virtual Network ACL rules. + /// 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. + /// The consistency policy for the + /// Cosmos DB database account. + /// List of Cosmos DB capabilities for the + /// account + /// An array that contains the write + /// location for the Cosmos DB account. + /// An array that contains of the read + /// locations enabled for the Cosmos DB account. + /// An array that contains all of the locations + /// enabled for the Cosmos DB account. + /// An array that contains the regions + /// ordered by their failover priorities. + /// List of Virtual Network ACL rules + /// configured for the Cosmos DB account. + /// Enables the account to + /// write in multiple locations + /// Enables the cassandra + /// connector on the Cosmos DB C* account + /// The cassandra connector offer type for + /// the Cosmos DB database C* account. Possible values include: + /// 'Small' + /// Disable write + /// operations on metadata resources (databases, containers, + /// throughput) via account keys + /// The URI of the key vault + public DatabaseAccountGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string kind = default(string), string provisioningState = default(string), string documentEndpoint = default(string), DatabaseAccountOfferType? databaseAccountOfferType = default(DatabaseAccountOfferType?), string ipRangeFilter = default(string), bool? isVirtualNetworkFilterEnabled = default(bool?), bool? enableAutomaticFailover = default(bool?), ConsistencyPolicy consistencyPolicy = default(ConsistencyPolicy), IList capabilities = default(IList), IList writeLocations = default(IList), IList readLocations = default(IList), IList locations = default(IList), IList failoverPolicies = default(IList), IList virtualNetworkRules = default(IList), bool? enableMultipleWriteLocations = default(bool?), bool? enableCassandraConnector = default(bool?), string connectorOffer = default(string), bool? disableKeyBasedMetadataWriteAccess = default(bool?), string keyVaultKeyUri = default(string)) + : base(id, name, type, location, tags) + { + Kind = kind; + ProvisioningState = provisioningState; + DocumentEndpoint = documentEndpoint; + DatabaseAccountOfferType = databaseAccountOfferType; + IpRangeFilter = ipRangeFilter; + IsVirtualNetworkFilterEnabled = isVirtualNetworkFilterEnabled; + EnableAutomaticFailover = enableAutomaticFailover; + ConsistencyPolicy = consistencyPolicy; + Capabilities = capabilities; + WriteLocations = writeLocations; + ReadLocations = readLocations; + Locations = locations; + FailoverPolicies = failoverPolicies; + VirtualNetworkRules = virtualNetworkRules; + EnableMultipleWriteLocations = enableMultipleWriteLocations; + EnableCassandraConnector = enableCassandraConnector; + ConnectorOffer = connectorOffer; + DisableKeyBasedMetadataWriteAccess = disableKeyBasedMetadataWriteAccess; + KeyVaultKeyUri = keyVaultKeyUri; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates the type of database account. This can only + /// be set at database account creation. Possible values include: + /// 'GlobalDocumentDB', 'MongoDB', 'Parse' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets the connection endpoint for the Cosmos DB database account. + /// + [JsonProperty(PropertyName = "properties.documentEndpoint")] + public string DocumentEndpoint { get; private set; } + + /// + /// Gets the offer type for the Cosmos DB database account. Default + /// value: Standard. Possible values include: 'Standard' + /// + [JsonProperty(PropertyName = "properties.databaseAccountOfferType")] + public DatabaseAccountOfferType? DatabaseAccountOfferType { get; private set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "properties.ipRangeFilter")] + public string IpRangeFilter { get; set; } + + /// + /// Gets or sets flag to indicate whether to enable/disable Virtual + /// Network ACL rules. + /// + [JsonProperty(PropertyName = "properties.isVirtualNetworkFilterEnabled")] + public bool? IsVirtualNetworkFilterEnabled { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "properties.enableAutomaticFailover")] + public bool? EnableAutomaticFailover { get; set; } + + /// + /// Gets or sets the consistency policy for the Cosmos DB database + /// account. + /// + [JsonProperty(PropertyName = "properties.consistencyPolicy")] + public ConsistencyPolicy ConsistencyPolicy { get; set; } + + /// + /// Gets or sets list of Cosmos DB capabilities for the account + /// + [JsonProperty(PropertyName = "properties.capabilities")] + public IList Capabilities { get; set; } + + /// + /// Gets an array that contains the write location for the Cosmos DB + /// account. + /// + [JsonProperty(PropertyName = "properties.writeLocations")] + public IList WriteLocations { get; private set; } + + /// + /// Gets an array that contains of the read locations enabled for the + /// Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.readLocations")] + public IList ReadLocations { get; private set; } + + /// + /// Gets an array that contains all of the locations enabled for the + /// Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.locations")] + public IList Locations { get; private set; } + + /// + /// Gets an array that contains the regions ordered by their failover + /// priorities. + /// + [JsonProperty(PropertyName = "properties.failoverPolicies")] + public IList FailoverPolicies { get; private set; } + + /// + /// Gets or sets list of Virtual Network ACL rules configured for the + /// Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.virtualNetworkRules")] + public IList VirtualNetworkRules { get; set; } + + /// + /// Gets or sets enables the account to write in multiple locations + /// + [JsonProperty(PropertyName = "properties.enableMultipleWriteLocations")] + public bool? EnableMultipleWriteLocations { get; set; } + + /// + /// Gets or sets enables the cassandra connector on the Cosmos DB C* + /// account + /// + [JsonProperty(PropertyName = "properties.enableCassandraConnector")] + public bool? EnableCassandraConnector { get; set; } + + /// + /// Gets or sets the cassandra connector offer type for the Cosmos DB + /// database C* account. Possible values include: 'Small' + /// + [JsonProperty(PropertyName = "properties.connectorOffer")] + public string ConnectorOffer { get; set; } + + /// + /// Gets or sets disable write operations on metadata resources + /// (databases, containers, throughput) via account keys + /// + [JsonProperty(PropertyName = "properties.disableKeyBasedMetadataWriteAccess")] + public bool? DisableKeyBasedMetadataWriteAccess { get; set; } + + /// + /// Gets or sets the URI of the key vault + /// + [JsonProperty(PropertyName = "properties.keyVaultKeyUri")] + public string KeyVaultKeyUri { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ConsistencyPolicy != null) + { + ConsistencyPolicy.Validate(); + } + if (WriteLocations != null) + { + foreach (var element in WriteLocations) + { + if (element != null) + { + element.Validate(); + } + } + } + if (ReadLocations != null) + { + foreach (var element1 in ReadLocations) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (Locations != null) + { + foreach (var element2 in Locations) + { + if (element2 != null) + { + element2.Validate(); + } + } + } + if (FailoverPolicies != null) + { + foreach (var element3 in FailoverPolicies) + { + if (element3 != null) + { + element3.Validate(); + } + } + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountKind.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountKind.cs new file mode 100644 index 000000000000..8e5f8d6a58a3 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountKind.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for DatabaseAccountKind. + /// + public static class DatabaseAccountKind + { + public const string GlobalDocumentDB = "GlobalDocumentDB"; + public const string MongoDB = "MongoDB"; + public const string Parse = "Parse"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListConnectionStringsResult.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListConnectionStringsResult.cs new file mode 100644 index 000000000000..34dabbee7e5d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListConnectionStringsResult.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The connection strings for the given database account. + /// + public partial class DatabaseAccountListConnectionStringsResult + { + /// + /// Initializes a new instance of the + /// DatabaseAccountListConnectionStringsResult class. + /// + public DatabaseAccountListConnectionStringsResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DatabaseAccountListConnectionStringsResult class. + /// + /// An array that contains the + /// connection strings for the Cosmos DB account. + public DatabaseAccountListConnectionStringsResult(IList connectionStrings = default(IList)) + { + ConnectionStrings = connectionStrings; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets an array that contains the connection strings for the + /// Cosmos DB account. + /// + [JsonProperty(PropertyName = "connectionStrings")] + public IList ConnectionStrings { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListKeysResult.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListKeysResult.cs new file mode 100644 index 000000000000..28ba9640161d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListKeysResult.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The access keys for the given database account. + /// + public partial class DatabaseAccountListKeysResult : DatabaseAccountListReadOnlyKeysResult + { + /// + /// Initializes a new instance of the DatabaseAccountListKeysResult + /// class. + /// + public DatabaseAccountListKeysResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatabaseAccountListKeysResult + /// class. + /// + /// Base 64 encoded value of the + /// primary read-only key. + /// Base 64 encoded value of + /// the secondary read-only key. + /// Base 64 encoded value of the primary + /// read-write key. + /// Base 64 encoded value of the + /// secondary read-write key. + public DatabaseAccountListKeysResult(string primaryReadonlyMasterKey = default(string), string secondaryReadonlyMasterKey = default(string), string primaryMasterKey = default(string), string secondaryMasterKey = default(string)) + : base(primaryReadonlyMasterKey, secondaryReadonlyMasterKey) + { + PrimaryMasterKey = primaryMasterKey; + SecondaryMasterKey = secondaryMasterKey; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets base 64 encoded value of the primary read-write key. + /// + [JsonProperty(PropertyName = "primaryMasterKey")] + public string PrimaryMasterKey { get; private set; } + + /// + /// Gets base 64 encoded value of the secondary read-write key. + /// + [JsonProperty(PropertyName = "secondaryMasterKey")] + public string SecondaryMasterKey { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListReadOnlyKeysResult.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListReadOnlyKeysResult.cs new file mode 100644 index 000000000000..eaa260152fe2 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountListReadOnlyKeysResult.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The read-only access keys for the given database account. + /// + public partial class DatabaseAccountListReadOnlyKeysResult + { + /// + /// Initializes a new instance of the + /// DatabaseAccountListReadOnlyKeysResult class. + /// + public DatabaseAccountListReadOnlyKeysResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DatabaseAccountListReadOnlyKeysResult class. + /// + /// Base 64 encoded value of the + /// primary read-only key. + /// Base 64 encoded value of + /// the secondary read-only key. + public DatabaseAccountListReadOnlyKeysResult(string primaryReadonlyMasterKey = default(string), string secondaryReadonlyMasterKey = default(string)) + { + PrimaryReadonlyMasterKey = primaryReadonlyMasterKey; + SecondaryReadonlyMasterKey = secondaryReadonlyMasterKey; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets base 64 encoded value of the primary read-only key. + /// + [JsonProperty(PropertyName = "primaryReadonlyMasterKey")] + public string PrimaryReadonlyMasterKey { get; private set; } + + /// + /// Gets base 64 encoded value of the secondary read-only key. + /// + [JsonProperty(PropertyName = "secondaryReadonlyMasterKey")] + public string SecondaryReadonlyMasterKey { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountOfferType.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountOfferType.cs new file mode 100644 index 000000000000..fa489617737c --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountOfferType.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for DatabaseAccountOfferType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum DatabaseAccountOfferType + { + [EnumMember(Value = "Standard")] + Standard + } + internal static class DatabaseAccountOfferTypeEnumExtension + { + internal static string ToSerializedValue(this DatabaseAccountOfferType? value) + { + return value == null ? null : ((DatabaseAccountOfferType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this DatabaseAccountOfferType value) + { + switch( value ) + { + case DatabaseAccountOfferType.Standard: + return "Standard"; + } + return null; + } + + internal static DatabaseAccountOfferType? ParseDatabaseAccountOfferType(this string value) + { + switch( value ) + { + case "Standard": + return DatabaseAccountOfferType.Standard; + } + return null; + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountRegenerateKeyParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountRegenerateKeyParameters.cs new file mode 100644 index 000000000000..58c039fb12c7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountRegenerateKeyParameters.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Parameters to regenerate the keys within the database account. + /// + public partial class DatabaseAccountRegenerateKeyParameters + { + /// + /// Initializes a new instance of the + /// DatabaseAccountRegenerateKeyParameters class. + /// + public DatabaseAccountRegenerateKeyParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DatabaseAccountRegenerateKeyParameters class. + /// + /// The access key to regenerate. Possible values + /// include: 'primary', 'secondary', 'primaryReadonly', + /// 'secondaryReadonly' + public DatabaseAccountRegenerateKeyParameters(string keyKind) + { + KeyKind = keyKind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the access key to regenerate. Possible values include: + /// 'primary', 'secondary', 'primaryReadonly', 'secondaryReadonly' + /// + [JsonProperty(PropertyName = "keyKind")] + public string KeyKind { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (KeyKind == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "KeyKind"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountUpdateParameters.cs new file mode 100644 index 000000000000..8f4b3602fbad --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DatabaseAccountUpdateParameters.cs @@ -0,0 +1,218 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters for patching Azure Cosmos DB database account properties. + /// + [Rest.Serialization.JsonTransformation] + public partial class DatabaseAccountUpdateParameters + { + /// + /// Initializes a new instance of the DatabaseAccountUpdateParameters + /// class. + /// + public DatabaseAccountUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatabaseAccountUpdateParameters + /// class. + /// + /// The location of the resource group to which + /// the resource belongs. + /// The consistency policy for the + /// Cosmos DB account. + /// An array that contains the georeplication + /// locations enabled for the Cosmos DB account. + /// 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. + /// Flag to indicate + /// whether to enable/disable Virtual Network ACL rules. + /// 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. + /// List of Cosmos DB capabilities for the + /// account + /// List of Virtual Network ACL rules + /// configured for the Cosmos DB account. + /// Enables the account to + /// write in multiple locations + /// Enables the cassandra + /// connector on the Cosmos DB C* account + /// The cassandra connector offer type for + /// the Cosmos DB database C* account. Possible values include: + /// 'Small' + /// Disable write + /// operations on metadata resources (databases, containers, + /// throughput) via account keys + /// The URI of the key vault + public DatabaseAccountUpdateParameters(IDictionary tags = default(IDictionary), string location = default(string), ConsistencyPolicy consistencyPolicy = default(ConsistencyPolicy), IList locations = default(IList), string ipRangeFilter = default(string), bool? isVirtualNetworkFilterEnabled = default(bool?), bool? enableAutomaticFailover = default(bool?), IList capabilities = default(IList), IList virtualNetworkRules = default(IList), bool? enableMultipleWriteLocations = default(bool?), bool? enableCassandraConnector = default(bool?), string connectorOffer = default(string), bool? disableKeyBasedMetadataWriteAccess = default(bool?), string keyVaultKeyUri = default(string)) + { + Tags = tags; + Location = location; + ConsistencyPolicy = consistencyPolicy; + Locations = locations; + IpRangeFilter = ipRangeFilter; + IsVirtualNetworkFilterEnabled = isVirtualNetworkFilterEnabled; + EnableAutomaticFailover = enableAutomaticFailover; + Capabilities = capabilities; + VirtualNetworkRules = virtualNetworkRules; + EnableMultipleWriteLocations = enableMultipleWriteLocations; + EnableCassandraConnector = enableCassandraConnector; + ConnectorOffer = connectorOffer; + DisableKeyBasedMetadataWriteAccess = disableKeyBasedMetadataWriteAccess; + KeyVaultKeyUri = keyVaultKeyUri; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the location of the resource group to which the + /// resource belongs. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the consistency policy for the Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.consistencyPolicy")] + public ConsistencyPolicy ConsistencyPolicy { get; set; } + + /// + /// Gets or sets an array that contains the georeplication locations + /// enabled for the Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.locations")] + public IList Locations { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "properties.ipRangeFilter")] + public string IpRangeFilter { get; set; } + + /// + /// Gets or sets flag to indicate whether to enable/disable Virtual + /// Network ACL rules. + /// + [JsonProperty(PropertyName = "properties.isVirtualNetworkFilterEnabled")] + public bool? IsVirtualNetworkFilterEnabled { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "properties.enableAutomaticFailover")] + public bool? EnableAutomaticFailover { get; set; } + + /// + /// Gets or sets list of Cosmos DB capabilities for the account + /// + [JsonProperty(PropertyName = "properties.capabilities")] + public IList Capabilities { get; set; } + + /// + /// Gets or sets list of Virtual Network ACL rules configured for the + /// Cosmos DB account. + /// + [JsonProperty(PropertyName = "properties.virtualNetworkRules")] + public IList VirtualNetworkRules { get; set; } + + /// + /// Gets or sets enables the account to write in multiple locations + /// + [JsonProperty(PropertyName = "properties.enableMultipleWriteLocations")] + public bool? EnableMultipleWriteLocations { get; set; } + + /// + /// Gets or sets enables the cassandra connector on the Cosmos DB C* + /// account + /// + [JsonProperty(PropertyName = "properties.enableCassandraConnector")] + public bool? EnableCassandraConnector { get; set; } + + /// + /// Gets or sets the cassandra connector offer type for the Cosmos DB + /// database C* account. Possible values include: 'Small' + /// + [JsonProperty(PropertyName = "properties.connectorOffer")] + public string ConnectorOffer { get; set; } + + /// + /// Gets or sets disable write operations on metadata resources + /// (databases, containers, throughput) via account keys + /// + [JsonProperty(PropertyName = "properties.disableKeyBasedMetadataWriteAccess")] + public bool? DisableKeyBasedMetadataWriteAccess { get; set; } + + /// + /// Gets or sets the URI of the key vault + /// + [JsonProperty(PropertyName = "properties.keyVaultKeyUri")] + public string KeyVaultKeyUri { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ConsistencyPolicy != null) + { + ConsistencyPolicy.Validate(); + } + if (Locations != null) + { + foreach (var element in Locations) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DefaultConsistencyLevel.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DefaultConsistencyLevel.cs new file mode 100644 index 000000000000..f32e2e6b36a5 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/DefaultConsistencyLevel.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for DefaultConsistencyLevel. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum DefaultConsistencyLevel + { + [EnumMember(Value = "Eventual")] + Eventual, + [EnumMember(Value = "Session")] + Session, + [EnumMember(Value = "BoundedStaleness")] + BoundedStaleness, + [EnumMember(Value = "Strong")] + Strong, + [EnumMember(Value = "ConsistentPrefix")] + ConsistentPrefix + } + internal static class DefaultConsistencyLevelEnumExtension + { + internal static string ToSerializedValue(this DefaultConsistencyLevel? value) + { + return value == null ? null : ((DefaultConsistencyLevel)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this DefaultConsistencyLevel value) + { + switch( value ) + { + case DefaultConsistencyLevel.Eventual: + return "Eventual"; + case DefaultConsistencyLevel.Session: + return "Session"; + case DefaultConsistencyLevel.BoundedStaleness: + return "BoundedStaleness"; + case DefaultConsistencyLevel.Strong: + return "Strong"; + case DefaultConsistencyLevel.ConsistentPrefix: + return "ConsistentPrefix"; + } + return null; + } + + internal static DefaultConsistencyLevel? ParseDefaultConsistencyLevel(this string value) + { + switch( value ) + { + case "Eventual": + return DefaultConsistencyLevel.Eventual; + case "Session": + return DefaultConsistencyLevel.Session; + case "BoundedStaleness": + return DefaultConsistencyLevel.BoundedStaleness; + case "Strong": + return DefaultConsistencyLevel.Strong; + case "ConsistentPrefix": + return DefaultConsistencyLevel.ConsistentPrefix; + } + return null; + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponse.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..dd232290ab3c --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponse.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error Response. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// Error code. + /// Error message indicating why the operation + /// failed. + public ErrorResponse(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error message indicating why the operation failed. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponseException.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..a9e3b41f64e4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse + /// information. + /// + public partial class ErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExcludedPath.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExcludedPath.cs new file mode 100644 index 000000000000..6765c177a4e7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExcludedPath.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ExcludedPath + { + /// + /// Initializes a new instance of the ExcludedPath class. + /// + public ExcludedPath() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExcludedPath class. + /// + /// The path for which the indexing behavior applies + /// to. Index paths typically start with root and end with wildcard + /// (/path/*) + public ExcludedPath(string path = default(string)) + { + Path = path; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the path for which the indexing behavior applies to. + /// Index paths typically start with root and end with wildcard + /// (/path/*) + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExtendedResourceProperties.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExtendedResourceProperties.cs new file mode 100644 index 000000000000..f33c9ad4f92d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ExtendedResourceProperties.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The system generated resource properties associated with SQL databases, + /// SQL containers, Gremlin databases and Gremlin graphs. + /// + public partial class ExtendedResourceProperties + { + /// + /// Initializes a new instance of the ExtendedResourceProperties class. + /// + public ExtendedResourceProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExtendedResourceProperties class. + /// + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public ExtendedResourceProperties(string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicies.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicies.cs new file mode 100644 index 000000000000..a964db180d41 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicies.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The list of new failover policies for the failover priority change. + /// + public partial class FailoverPolicies + { + /// + /// Initializes a new instance of the FailoverPolicies class. + /// + public FailoverPolicies() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FailoverPolicies class. + /// + /// List of failover + /// policies. + public FailoverPolicies(IList failoverPoliciesProperty) + { + FailoverPoliciesProperty = failoverPoliciesProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of failover policies. + /// + [JsonProperty(PropertyName = "failoverPolicies")] + public IList FailoverPoliciesProperty { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (FailoverPoliciesProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "FailoverPoliciesProperty"); + } + if (FailoverPoliciesProperty != null) + { + foreach (var element in FailoverPoliciesProperty) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicy.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicy.cs new file mode 100644 index 000000000000..7856e348dd68 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/FailoverPolicy.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The failover policy for a given region of a database account. + /// + public partial class FailoverPolicy + { + /// + /// Initializes a new instance of the FailoverPolicy class. + /// + public FailoverPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FailoverPolicy class. + /// + /// The unique identifier of the region in which the + /// database account replicates to. Example: + /// &lt;accountName&gt;-&lt;locationName&gt;. + /// The name of the region in which the + /// database account exists. + /// 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. + public FailoverPolicy(string id = default(string), string locationName = default(string), int? failoverPriority = default(int?)) + { + Id = id; + LocationName = locationName; + FailoverPriority = failoverPriority; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the unique identifier of the region in which the database + /// account replicates to. Example: + /// &amp;lt;accountName&amp;gt;-&amp;lt;locationName&amp;gt;. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the name of the region in which the database account + /// exists. + /// + [JsonProperty(PropertyName = "locationName")] + public string LocationName { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "failoverPriority")] + public int? FailoverPriority { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (FailoverPriority < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "FailoverPriority", 0); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseCreateUpdateParameters.cs new file mode 100644 index 000000000000..d8844e6af44b --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB Gremlin database. + /// + [Rest.Serialization.JsonTransformation] + public partial class GremlinDatabaseCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// GremlinDatabaseCreateUpdateParameters class. + /// + public GremlinDatabaseCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GremlinDatabaseCreateUpdateParameters class. + /// + /// The standard JSON format of a Gremlin + /// database + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public GremlinDatabaseCreateUpdateParameters(GremlinDatabaseResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a Gremlin database + /// + [JsonProperty(PropertyName = "properties.resource")] + public GremlinDatabaseResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetPropertiesResource.cs new file mode 100644 index 000000000000..ca0350082c65 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetPropertiesResource.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class GremlinDatabaseGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// GremlinDatabaseGetPropertiesResource class. + /// + public GremlinDatabaseGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GremlinDatabaseGetPropertiesResource class. + /// + /// Name of the Cosmos DB Gremlin database + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public GremlinDatabaseGetPropertiesResource(string id, string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Gremlin database + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetResults.cs new file mode 100644 index 000000000000..313c16cf09d6 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB Gremlin database. + /// + [Rest.Serialization.JsonTransformation] + public partial class GremlinDatabaseGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the GremlinDatabaseGetResults class. + /// + public GremlinDatabaseGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GremlinDatabaseGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public GremlinDatabaseGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), GremlinDatabaseGetPropertiesResource resource = default(GremlinDatabaseGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public GremlinDatabaseGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseResource.cs new file mode 100644 index 000000000000..f6a824afed37 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinDatabaseResource.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB Gremlin database resource object + /// + public partial class GremlinDatabaseResource + { + /// + /// Initializes a new instance of the GremlinDatabaseResource class. + /// + public GremlinDatabaseResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GremlinDatabaseResource class. + /// + /// Name of the Cosmos DB Gremlin database + public GremlinDatabaseResource(string id) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Gremlin database + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphCreateUpdateParameters.cs new file mode 100644 index 000000000000..15a4bd807799 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB Gremlin graph. + /// + [Rest.Serialization.JsonTransformation] + public partial class GremlinGraphCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// GremlinGraphCreateUpdateParameters class. + /// + public GremlinGraphCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// GremlinGraphCreateUpdateParameters class. + /// + /// The standard JSON format of a Gremlin + /// graph + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public GremlinGraphCreateUpdateParameters(GremlinGraphResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a Gremlin graph + /// + [JsonProperty(PropertyName = "properties.resource")] + public GremlinGraphResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetPropertiesResource.cs new file mode 100644 index 000000000000..48c99533bb26 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetPropertiesResource.cs @@ -0,0 +1,147 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class GremlinGraphGetPropertiesResource + { + /// + /// Initializes a new instance of the GremlinGraphGetPropertiesResource + /// class. + /// + public GremlinGraphGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GremlinGraphGetPropertiesResource + /// class. + /// + /// Name of the Cosmos DB Gremlin graph + /// The configuration of the indexing + /// policy. By default, the indexing is automatic for all document + /// paths within the graph + /// The configuration of the partition key + /// to be used for partitioning data into multiple partitions + /// Default time to live + /// The unique key policy configuration + /// for specifying uniqueness constraints on documents in the + /// collection in the Azure Cosmos DB service. + /// The conflict resolution + /// policy for the graph. + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public GremlinGraphGetPropertiesResource(string id, IndexingPolicy indexingPolicy = default(IndexingPolicy), ContainerPartitionKey partitionKey = default(ContainerPartitionKey), int? defaultTtl = default(int?), UniqueKeyPolicy uniqueKeyPolicy = default(UniqueKeyPolicy), ConflictResolutionPolicy conflictResolutionPolicy = default(ConflictResolutionPolicy), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + IndexingPolicy = indexingPolicy; + PartitionKey = partitionKey; + DefaultTtl = defaultTtl; + UniqueKeyPolicy = uniqueKeyPolicy; + ConflictResolutionPolicy = conflictResolutionPolicy; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Gremlin graph + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the configuration of the indexing policy. By default, + /// the indexing is automatic for all document paths within the graph + /// + [JsonProperty(PropertyName = "indexingPolicy")] + public IndexingPolicy IndexingPolicy { get; set; } + + /// + /// Gets or sets the configuration of the partition key to be used for + /// partitioning data into multiple partitions + /// + [JsonProperty(PropertyName = "partitionKey")] + public ContainerPartitionKey PartitionKey { get; set; } + + /// + /// Gets or sets default time to live + /// + [JsonProperty(PropertyName = "defaultTtl")] + public int? DefaultTtl { get; set; } + + /// + /// Gets or sets the unique key policy configuration for specifying + /// uniqueness constraints on documents in the collection in the Azure + /// Cosmos DB service. + /// + [JsonProperty(PropertyName = "uniqueKeyPolicy")] + public UniqueKeyPolicy UniqueKeyPolicy { get; set; } + + /// + /// Gets or sets the conflict resolution policy for the graph. + /// + [JsonProperty(PropertyName = "conflictResolutionPolicy")] + public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (PartitionKey != null) + { + PartitionKey.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetResults.cs new file mode 100644 index 000000000000..9989bf70f8b1 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB Gremlin graph. + /// + [Rest.Serialization.JsonTransformation] + public partial class GremlinGraphGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the GremlinGraphGetResults class. + /// + public GremlinGraphGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GremlinGraphGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public GremlinGraphGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), GremlinGraphGetPropertiesResource resource = default(GremlinGraphGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public GremlinGraphGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphResource.cs new file mode 100644 index 000000000000..688b14ab6ffd --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/GremlinGraphResource.cs @@ -0,0 +1,119 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB Gremlin graph resource object + /// + public partial class GremlinGraphResource + { + /// + /// Initializes a new instance of the GremlinGraphResource class. + /// + public GremlinGraphResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GremlinGraphResource class. + /// + /// Name of the Cosmos DB Gremlin graph + /// The configuration of the indexing + /// policy. By default, the indexing is automatic for all document + /// paths within the graph + /// The configuration of the partition key + /// to be used for partitioning data into multiple partitions + /// Default time to live + /// The unique key policy configuration + /// for specifying uniqueness constraints on documents in the + /// collection in the Azure Cosmos DB service. + /// The conflict resolution + /// policy for the graph. + public GremlinGraphResource(string id, IndexingPolicy indexingPolicy = default(IndexingPolicy), ContainerPartitionKey partitionKey = default(ContainerPartitionKey), int? defaultTtl = default(int?), UniqueKeyPolicy uniqueKeyPolicy = default(UniqueKeyPolicy), ConflictResolutionPolicy conflictResolutionPolicy = default(ConflictResolutionPolicy)) + { + Id = id; + IndexingPolicy = indexingPolicy; + PartitionKey = partitionKey; + DefaultTtl = defaultTtl; + UniqueKeyPolicy = uniqueKeyPolicy; + ConflictResolutionPolicy = conflictResolutionPolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB Gremlin graph + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the configuration of the indexing policy. By default, + /// the indexing is automatic for all document paths within the graph + /// + [JsonProperty(PropertyName = "indexingPolicy")] + public IndexingPolicy IndexingPolicy { get; set; } + + /// + /// Gets or sets the configuration of the partition key to be used for + /// partitioning data into multiple partitions + /// + [JsonProperty(PropertyName = "partitionKey")] + public ContainerPartitionKey PartitionKey { get; set; } + + /// + /// Gets or sets default time to live + /// + [JsonProperty(PropertyName = "defaultTtl")] + public int? DefaultTtl { get; set; } + + /// + /// Gets or sets the unique key policy configuration for specifying + /// uniqueness constraints on documents in the collection in the Azure + /// Cosmos DB service. + /// + [JsonProperty(PropertyName = "uniqueKeyPolicy")] + public UniqueKeyPolicy UniqueKeyPolicy { get; set; } + + /// + /// Gets or sets the conflict resolution policy for the graph. + /// + [JsonProperty(PropertyName = "conflictResolutionPolicy")] + public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (PartitionKey != null) + { + PartitionKey.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IncludedPath.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IncludedPath.cs new file mode 100644 index 000000000000..4e979ea03484 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IncludedPath.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The paths that are included in indexing + /// + public partial class IncludedPath + { + /// + /// Initializes a new instance of the IncludedPath class. + /// + public IncludedPath() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IncludedPath class. + /// + /// The path for which the indexing behavior applies + /// to. Index paths typically start with root and end with wildcard + /// (/path/*) + /// List of indexes for this path + public IncludedPath(string path = default(string), IList indexes = default(IList)) + { + Path = path; + Indexes = indexes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the path for which the indexing behavior applies to. + /// Index paths typically start with root and end with wildcard + /// (/path/*) + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + /// + /// Gets or sets list of indexes for this path + /// + [JsonProperty(PropertyName = "indexes")] + public IList Indexes { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexKind.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexKind.cs new file mode 100644 index 000000000000..3aa6d840861c --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexKind.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for IndexKind. + /// + public static class IndexKind + { + public const string Hash = "Hash"; + public const string Range = "Range"; + public const string Spatial = "Spatial"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Indexes.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Indexes.cs new file mode 100644 index 000000000000..0c7ae3823b64 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Indexes.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The indexes for the path. + /// + public partial class Indexes + { + /// + /// Initializes a new instance of the Indexes class. + /// + public Indexes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Indexes class. + /// + /// The datatype for which the indexing behavior + /// is applied to. Possible values include: 'String', 'Number', + /// 'Point', 'Polygon', 'LineString', 'MultiPolygon' + /// The precision of the index. -1 is maximum + /// precision. + /// Indicates the type of index. Possible values + /// include: 'Hash', 'Range', 'Spatial' + public Indexes(string dataType = default(string), int? precision = default(int?), string kind = default(string)) + { + DataType = dataType; + Precision = precision; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the datatype for which the indexing behavior is + /// applied to. Possible values include: 'String', 'Number', 'Point', + /// 'Polygon', 'LineString', 'MultiPolygon' + /// + [JsonProperty(PropertyName = "dataType")] + public string DataType { get; set; } + + /// + /// Gets or sets the precision of the index. -1 is maximum precision. + /// + [JsonProperty(PropertyName = "precision")] + public int? Precision { get; set; } + + /// + /// Gets or sets indicates the type of index. Possible values include: + /// 'Hash', 'Range', 'Spatial' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingMode.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingMode.cs new file mode 100644 index 000000000000..dcc3d7f446a4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingMode.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for IndexingMode. + /// + public static class IndexingMode + { + public const string Consistent = "Consistent"; + public const string Lazy = "Lazy"; + public const string None = "None"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingPolicy.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingPolicy.cs new file mode 100644 index 000000000000..6ddaed22f96e --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/IndexingPolicy.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Cosmos DB indexing policy + /// + public partial class IndexingPolicy + { + /// + /// Initializes a new instance of the IndexingPolicy class. + /// + public IndexingPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IndexingPolicy class. + /// + /// Indicates if the indexing policy is + /// automatic + /// Indicates the indexing mode. Possible + /// values include: 'Consistent', 'Lazy', 'None' + /// List of paths to include in the + /// indexing + /// List of paths to exclude from + /// indexing + /// List of composite path list + /// List of spatial specifics + public IndexingPolicy(bool? automatic = default(bool?), string indexingMode = default(string), IList includedPaths = default(IList), IList excludedPaths = default(IList), IList> compositeIndexes = default(IList>), IList spatialIndexes = default(IList)) + { + Automatic = automatic; + IndexingMode = indexingMode; + IncludedPaths = includedPaths; + ExcludedPaths = excludedPaths; + CompositeIndexes = compositeIndexes; + SpatialIndexes = spatialIndexes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates if the indexing policy is automatic + /// + [JsonProperty(PropertyName = "automatic")] + public bool? Automatic { get; set; } + + /// + /// Gets or sets indicates the indexing mode. Possible values include: + /// 'Consistent', 'Lazy', 'None' + /// + [JsonProperty(PropertyName = "indexingMode")] + public string IndexingMode { get; set; } + + /// + /// Gets or sets list of paths to include in the indexing + /// + [JsonProperty(PropertyName = "includedPaths")] + public IList IncludedPaths { get; set; } + + /// + /// Gets or sets list of paths to exclude from indexing + /// + [JsonProperty(PropertyName = "excludedPaths")] + public IList ExcludedPaths { get; set; } + + /// + /// Gets or sets list of composite path list + /// + [JsonProperty(PropertyName = "compositeIndexes")] + public IList> CompositeIndexes { get; set; } + + /// + /// Gets or sets list of spatial specifics + /// + [JsonProperty(PropertyName = "spatialIndexes")] + public IList SpatialIndexes { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/KeyKind.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/KeyKind.cs new file mode 100644 index 000000000000..bcbb177e0dff --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/KeyKind.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for KeyKind. + /// + public static class KeyKind + { + public const string Primary = "primary"; + public const string Secondary = "secondary"; + public const string PrimaryReadonly = "primaryReadonly"; + public const string SecondaryReadonly = "secondaryReadonly"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Location.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Location.cs new file mode 100644 index 000000000000..2173a404b77a --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Location.cs @@ -0,0 +1,120 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A region in which the Azure Cosmos DB database account is deployed. + /// + public partial class Location + { + /// + /// Initializes a new instance of the Location class. + /// + public Location() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Location class. + /// + /// The unique identifier of the region within the + /// database account. Example: + /// &lt;accountName&gt;-&lt;locationName&gt;. + /// The name of the region. + /// The connection endpoint for the + /// specific region. Example: + /// https://&lt;accountName&gt;-&lt;locationName&gt;.documents.azure.com:443/ + /// 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. + /// Flag to indicate whether or not this + /// region is an AvailabilityZone region + public Location(string id = default(string), string locationName = default(string), string documentEndpoint = default(string), string provisioningState = default(string), int? failoverPriority = default(int?), bool? isZoneRedundant = default(bool?)) + { + Id = id; + LocationName = locationName; + DocumentEndpoint = documentEndpoint; + ProvisioningState = provisioningState; + FailoverPriority = failoverPriority; + IsZoneRedundant = isZoneRedundant; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the unique identifier of the region within the database + /// account. Example: + /// &amp;lt;accountName&amp;gt;-&amp;lt;locationName&amp;gt;. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the name of the region. + /// + [JsonProperty(PropertyName = "locationName")] + public string LocationName { get; set; } + + /// + /// Gets the connection endpoint for the specific region. Example: + /// https://&amp;lt;accountName&amp;gt;-&amp;lt;locationName&amp;gt;.documents.azure.com:443/ + /// + [JsonProperty(PropertyName = "documentEndpoint")] + public string DocumentEndpoint { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "failoverPriority")] + public int? FailoverPriority { get; set; } + + /// + /// Gets or sets flag to indicate whether or not this region is an + /// AvailabilityZone region + /// + [JsonProperty(PropertyName = "isZoneRedundant")] + public bool? IsZoneRedundant { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (FailoverPriority < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "FailoverPriority", 0); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Metric.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Metric.cs new file mode 100644 index 000000000000..3085916d9a1e --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Metric.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Metric data + /// + public partial class Metric + { + /// + /// Initializes a new instance of the Metric class. + /// + public Metric() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Metric class. + /// + /// The start time for the metric (ISO-8601 + /// format). + /// The end time for the metric (ISO-8601 + /// format). + /// The time grain to be used to summarize the + /// metric values. + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// The name information for the metric. + /// The metric values for the specified time + /// window and timestep. + public Metric(System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), string timeGrain = default(string), string unit = default(string), MetricName name = default(MetricName), IList metricValues = default(IList)) + { + StartTime = startTime; + EndTime = endTime; + TimeGrain = timeGrain; + Unit = unit; + Name = name; + MetricValues = metricValues; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the start time for the metric (ISO-8601 format). + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; private set; } + + /// + /// Gets the end time for the metric (ISO-8601 format). + /// + [JsonProperty(PropertyName = "endTime")] + public System.DateTime? EndTime { get; private set; } + + /// + /// Gets the time grain to be used to summarize the metric values. + /// + [JsonProperty(PropertyName = "timeGrain")] + public string TimeGrain { get; private set; } + + /// + /// Gets or sets the unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Gets the name information for the metric. + /// + [JsonProperty(PropertyName = "name")] + public MetricName Name { get; private set; } + + /// + /// Gets the metric values for the specified time window and timestep. + /// + [JsonProperty(PropertyName = "metricValues")] + public IList MetricValues { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricAvailability.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricAvailability.cs new file mode 100644 index 000000000000..7ba1d1f7c74f --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricAvailability.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The availability of the metric. + /// + public partial class MetricAvailability + { + /// + /// Initializes a new instance of the MetricAvailability class. + /// + public MetricAvailability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAvailability class. + /// + /// The time grain to be used to summarize the + /// metric values. + /// The retention for the metric + /// values. + public MetricAvailability(string timeGrain = default(string), string retention = default(string)) + { + TimeGrain = timeGrain; + Retention = retention; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the time grain to be used to summarize the metric values. + /// + [JsonProperty(PropertyName = "timeGrain")] + public string TimeGrain { get; private set; } + + /// + /// Gets the retention for the metric values. + /// + [JsonProperty(PropertyName = "retention")] + public string Retention { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricDefinition.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricDefinition.cs new file mode 100644 index 000000000000..fedaece59d5f --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricDefinition.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The definition of a metric. + /// + public partial class MetricDefinition + { + /// + /// Initializes a new instance of the MetricDefinition class. + /// + public MetricDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricDefinition class. + /// + /// The list of metric + /// availabilities for the account. + /// The primary aggregation type + /// of the metric. Possible values include: 'None', 'Average', 'Total', + /// 'Minimum', 'Maximum', 'Last' + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// The resource uri of the database. + /// The name information for the metric. + public MetricDefinition(IList metricAvailabilities = default(IList), string primaryAggregationType = default(string), string unit = default(string), string resourceUri = default(string), MetricName name = default(MetricName)) + { + MetricAvailabilities = metricAvailabilities; + PrimaryAggregationType = primaryAggregationType; + Unit = unit; + ResourceUri = resourceUri; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of metric availabilities for the account. + /// + [JsonProperty(PropertyName = "metricAvailabilities")] + public IList MetricAvailabilities { get; private set; } + + /// + /// Gets the primary aggregation type of the metric. Possible values + /// include: 'None', 'Average', 'Total', 'Minimum', 'Maximum', 'Last' + /// + [JsonProperty(PropertyName = "primaryAggregationType")] + public string PrimaryAggregationType { get; private set; } + + /// + /// Gets or sets the unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Gets the resource uri of the database. + /// + [JsonProperty(PropertyName = "resourceUri")] + public string ResourceUri { get; private set; } + + /// + /// Gets the name information for the metric. + /// + [JsonProperty(PropertyName = "name")] + public MetricName Name { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricName.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricName.cs new file mode 100644 index 000000000000..02f006f013bb --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricName.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A metric name. + /// + public partial class MetricName + { + /// + /// Initializes a new instance of the MetricName class. + /// + public MetricName() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricName class. + /// + /// The name of the metric. + /// The friendly name of the + /// metric. + public MetricName(string value = default(string), string localizedValue = default(string)) + { + Value = value; + LocalizedValue = localizedValue; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the metric. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; private set; } + + /// + /// Gets the friendly name of the metric. + /// + [JsonProperty(PropertyName = "localizedValue")] + public string LocalizedValue { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricValue.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricValue.cs new file mode 100644 index 000000000000..a261a8dd2e72 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MetricValue.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents metrics values. + /// + public partial class MetricValue + { + /// + /// Initializes a new instance of the MetricValue class. + /// + public MetricValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricValue class. + /// + /// The number of values for the metric. + /// The average value of the metric. + /// The max value of the metric. + /// The min value of the metric. + /// The metric timestamp (ISO-8601 + /// format). + /// The total value of the metric. + public MetricValue(double? _count = default(double?), double? average = default(double?), double? maximum = default(double?), double? minimum = default(double?), System.DateTime? timestamp = default(System.DateTime?), double? total = default(double?)) + { + this._count = _count; + Average = average; + Maximum = maximum; + Minimum = minimum; + Timestamp = timestamp; + Total = total; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the number of values for the metric. + /// + [JsonProperty(PropertyName = "_count")] + public double? _count { get; private set; } + + /// + /// Gets the average value of the metric. + /// + [JsonProperty(PropertyName = "average")] + public double? Average { get; private set; } + + /// + /// Gets the max value of the metric. + /// + [JsonProperty(PropertyName = "maximum")] + public double? Maximum { get; private set; } + + /// + /// Gets the min value of the metric. + /// + [JsonProperty(PropertyName = "minimum")] + public double? Minimum { get; private set; } + + /// + /// Gets the metric timestamp (ISO-8601 format). + /// + [JsonProperty(PropertyName = "timestamp")] + public System.DateTime? Timestamp { get; private set; } + + /// + /// Gets the total value of the metric. + /// + [JsonProperty(PropertyName = "total")] + public double? Total { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionCreateUpdateParameters.cs new file mode 100644 index 000000000000..ec275b3847e9 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB MongoDB collection. + /// + [Rest.Serialization.JsonTransformation] + public partial class MongoDBCollectionCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// MongoDBCollectionCreateUpdateParameters class. + /// + public MongoDBCollectionCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MongoDBCollectionCreateUpdateParameters class. + /// + /// The standard JSON format of a MongoDB + /// collection + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public MongoDBCollectionCreateUpdateParameters(MongoDBCollectionResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a MongoDB collection + /// + [JsonProperty(PropertyName = "properties.resource")] + public MongoDBCollectionResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetPropertiesResource.cs new file mode 100644 index 000000000000..8d9367694d15 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetPropertiesResource.cs @@ -0,0 +1,113 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class MongoDBCollectionGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// MongoDBCollectionGetPropertiesResource class. + /// + public MongoDBCollectionGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MongoDBCollectionGetPropertiesResource class. + /// + /// Name of the Cosmos DB MongoDB collection + /// A key-value pair of shard keys to be applied + /// for the request. + /// List of index keys + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public MongoDBCollectionGetPropertiesResource(string id, IDictionary shardKey = default(IDictionary), IList indexes = default(IList), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + ShardKey = shardKey; + Indexes = indexes; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB MongoDB collection + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets a key-value pair of shard keys to be applied for the + /// request. + /// + [JsonProperty(PropertyName = "shardKey")] + public IDictionary ShardKey { get; set; } + + /// + /// Gets or sets list of index keys + /// + [JsonProperty(PropertyName = "indexes")] + public IList Indexes { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetResults.cs new file mode 100644 index 000000000000..e1718b52cf27 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionGetResults.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB MongoDB collection. + /// + [Rest.Serialization.JsonTransformation] + public partial class MongoDBCollectionGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the MongoDBCollectionGetResults + /// class. + /// + public MongoDBCollectionGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoDBCollectionGetResults + /// class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public MongoDBCollectionGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), MongoDBCollectionGetPropertiesResource resource = default(MongoDBCollectionGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public MongoDBCollectionGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionResource.cs new file mode 100644 index 000000000000..a16343826547 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBCollectionResource.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Cosmos DB MongoDB collection resource object + /// + public partial class MongoDBCollectionResource + { + /// + /// Initializes a new instance of the MongoDBCollectionResource class. + /// + public MongoDBCollectionResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoDBCollectionResource class. + /// + /// Name of the Cosmos DB MongoDB collection + /// A key-value pair of shard keys to be applied + /// for the request. + /// List of index keys + public MongoDBCollectionResource(string id, IDictionary shardKey = default(IDictionary), IList indexes = default(IList)) + { + Id = id; + ShardKey = shardKey; + Indexes = indexes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB MongoDB collection + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets a key-value pair of shard keys to be applied for the + /// request. + /// + [JsonProperty(PropertyName = "shardKey")] + public IDictionary ShardKey { get; set; } + + /// + /// Gets or sets list of index keys + /// + [JsonProperty(PropertyName = "indexes")] + public IList Indexes { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseCreateUpdateParameters.cs new file mode 100644 index 000000000000..72c3030b4ccf --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB MongoDB database. + /// + [Rest.Serialization.JsonTransformation] + public partial class MongoDBDatabaseCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// MongoDBDatabaseCreateUpdateParameters class. + /// + public MongoDBDatabaseCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MongoDBDatabaseCreateUpdateParameters class. + /// + /// The standard JSON format of a MongoDB + /// database + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public MongoDBDatabaseCreateUpdateParameters(MongoDBDatabaseResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a MongoDB database + /// + [JsonProperty(PropertyName = "properties.resource")] + public MongoDBDatabaseResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetPropertiesResource.cs new file mode 100644 index 000000000000..d3e1504655ef --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetPropertiesResource.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class MongoDBDatabaseGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// MongoDBDatabaseGetPropertiesResource class. + /// + public MongoDBDatabaseGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MongoDBDatabaseGetPropertiesResource class. + /// + /// Name of the Cosmos DB MongoDB database + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public MongoDBDatabaseGetPropertiesResource(string id, string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB MongoDB database + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetResults.cs new file mode 100644 index 000000000000..74e34cd999ed --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB MongoDB database. + /// + [Rest.Serialization.JsonTransformation] + public partial class MongoDBDatabaseGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the MongoDBDatabaseGetResults class. + /// + public MongoDBDatabaseGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoDBDatabaseGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public MongoDBDatabaseGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), MongoDBDatabaseGetPropertiesResource resource = default(MongoDBDatabaseGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public MongoDBDatabaseGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseResource.cs new file mode 100644 index 000000000000..a650d35d11fd --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoDBDatabaseResource.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB MongoDB database resource object + /// + public partial class MongoDBDatabaseResource + { + /// + /// Initializes a new instance of the MongoDBDatabaseResource class. + /// + public MongoDBDatabaseResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoDBDatabaseResource class. + /// + /// Name of the Cosmos DB MongoDB database + public MongoDBDatabaseResource(string id) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB MongoDB database + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndex.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndex.cs new file mode 100644 index 000000000000..e5bf39ee01ef --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndex.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB MongoDB collection index key + /// + public partial class MongoIndex + { + /// + /// Initializes a new instance of the MongoIndex class. + /// + public MongoIndex() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoIndex class. + /// + /// Cosmos DB MongoDB collection index keys + /// Cosmos DB MongoDB collection index key + /// options + public MongoIndex(MongoIndexKeys key = default(MongoIndexKeys), MongoIndexOptions options = default(MongoIndexOptions)) + { + Key = key; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets cosmos DB MongoDB collection index keys + /// + [JsonProperty(PropertyName = "key")] + public MongoIndexKeys Key { get; set; } + + /// + /// Gets or sets cosmos DB MongoDB collection index key options + /// + [JsonProperty(PropertyName = "options")] + public MongoIndexOptions Options { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexKeys.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexKeys.cs new file mode 100644 index 000000000000..36a36b86f094 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexKeys.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Cosmos DB MongoDB collection resource object + /// + public partial class MongoIndexKeys + { + /// + /// Initializes a new instance of the MongoIndexKeys class. + /// + public MongoIndexKeys() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoIndexKeys class. + /// + /// List of keys for each MongoDB collection in the + /// Azure Cosmos DB service + public MongoIndexKeys(IList keys = default(IList)) + { + Keys = keys; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of keys for each MongoDB collection in the Azure + /// Cosmos DB service + /// + [JsonProperty(PropertyName = "keys")] + public IList Keys { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexOptions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexOptions.cs new file mode 100644 index 000000000000..cfe6e59259d9 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/MongoIndexOptions.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB MongoDB collection index options + /// + public partial class MongoIndexOptions + { + /// + /// Initializes a new instance of the MongoIndexOptions class. + /// + public MongoIndexOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoIndexOptions class. + /// + /// Expire after seconds + /// Is unique or not + public MongoIndexOptions(int? expireAfterSeconds = default(int?), bool? unique = default(bool?)) + { + ExpireAfterSeconds = expireAfterSeconds; + Unique = unique; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets expire after seconds + /// + [JsonProperty(PropertyName = "expireAfterSeconds")] + public int? ExpireAfterSeconds { get; set; } + + /// + /// Gets or sets is unique or not + /// + [JsonProperty(PropertyName = "unique")] + public bool? Unique { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Operation.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..e6a1d22bfaf6 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Operation.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// REST API operation + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// Operation name: + /// {provider}/{resource}/{operation} + /// The object that represents the + /// operation. + public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay)) + { + Name = name; + Display = display; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation name: {provider}/{resource}/{operation} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the object that represents the operation. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/OperationDisplay.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..1f15ff25bdae --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,79 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The object that represents the operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// Service provider: + /// Microsoft.ResourceProvider + /// Resource on which the operation is + /// performed: Profile, endpoint, etc. + /// Operation type: Read, write, delete, + /// etc. + /// Description of operation + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets service provider: Microsoft.ResourceProvider + /// + [JsonProperty(PropertyName = "Provider")] + public string Provider { get; set; } + + /// + /// Gets or sets resource on which the operation is performed: Profile, + /// endpoint, etc. + /// + [JsonProperty(PropertyName = "Resource")] + public string Resource { get; set; } + + /// + /// Gets or sets operation type: Read, write, delete, etc. + /// + [JsonProperty(PropertyName = "Operation")] + public string Operation { get; set; } + + /// + /// Gets or sets description of operation + /// + [JsonProperty(PropertyName = "Description")] + public string Description { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..8cce1c95b7ed --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page1.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page1.cs new file mode 100644 index 000000000000..446fa943bd5a --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Page1.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionKind.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionKind.cs new file mode 100644 index 000000000000..331b07048d27 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionKind.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for PartitionKind. + /// + public static class PartitionKind + { + public const string Hash = "Hash"; + public const string Range = "Range"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionMetric.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionMetric.cs new file mode 100644 index 000000000000..853500856608 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionMetric.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The metric values for a single partition. + /// + public partial class PartitionMetric : Metric + { + /// + /// Initializes a new instance of the PartitionMetric class. + /// + public PartitionMetric() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartitionMetric class. + /// + /// The start time for the metric (ISO-8601 + /// format). + /// The end time for the metric (ISO-8601 + /// format). + /// The time grain to be used to summarize the + /// metric values. + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// The name information for the metric. + /// The metric values for the specified time + /// window and timestep. + /// The partition id (GUID identifier) of the + /// metric values. + /// The partition key range id + /// (integer identifier) of the metric values. + public PartitionMetric(System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), string timeGrain = default(string), string unit = default(string), MetricName name = default(MetricName), IList metricValues = default(IList), string partitionId = default(string), string partitionKeyRangeId = default(string)) + : base(startTime, endTime, timeGrain, unit, name, metricValues) + { + PartitionId = partitionId; + PartitionKeyRangeId = partitionKeyRangeId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the partition id (GUID identifier) of the metric values. + /// + [JsonProperty(PropertyName = "partitionId")] + public string PartitionId { get; private set; } + + /// + /// Gets the partition key range id (integer identifier) of the metric + /// values. + /// + [JsonProperty(PropertyName = "partitionKeyRangeId")] + public string PartitionKeyRangeId { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionUsage.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionUsage.cs new file mode 100644 index 000000000000..deb58f0575cf --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PartitionUsage.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The partition level usage data for a usage request. + /// + public partial class PartitionUsage : Usage + { + /// + /// Initializes a new instance of the PartitionUsage class. + /// + public PartitionUsage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartitionUsage class. + /// + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// The name information for the metric. + /// The quota period used to summarize the + /// usage values. + /// Maximum value for this metric + /// Current value for this metric + /// The partition id (GUID identifier) of the + /// usages. + /// The partition key range id + /// (integer identifier) of the usages. + public PartitionUsage(string unit = default(string), MetricName name = default(MetricName), string quotaPeriod = default(string), long? limit = default(long?), long? currentValue = default(long?), string partitionId = default(string), string partitionKeyRangeId = default(string)) + : base(unit, name, quotaPeriod, limit, currentValue) + { + PartitionId = partitionId; + PartitionKeyRangeId = partitionKeyRangeId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the partition id (GUID identifier) of the usages. + /// + [JsonProperty(PropertyName = "partitionId")] + public string PartitionId { get; private set; } + + /// + /// Gets the partition key range id (integer identifier) of the usages. + /// + [JsonProperty(PropertyName = "partitionKeyRangeId")] + public string PartitionKeyRangeId { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetric.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetric.cs new file mode 100644 index 000000000000..54d1b7c9d3fb --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetric.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Percentile Metric data + /// + public partial class PercentileMetric + { + /// + /// Initializes a new instance of the PercentileMetric class. + /// + public PercentileMetric() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PercentileMetric class. + /// + /// The start time for the metric (ISO-8601 + /// format). + /// The end time for the metric (ISO-8601 + /// format). + /// The time grain to be used to summarize the + /// metric values. + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// The name information for the metric. + /// The percentile metric values for the + /// specified time window and timestep. + public PercentileMetric(System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), string timeGrain = default(string), string unit = default(string), MetricName name = default(MetricName), IList metricValues = default(IList)) + { + StartTime = startTime; + EndTime = endTime; + TimeGrain = timeGrain; + Unit = unit; + Name = name; + MetricValues = metricValues; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the start time for the metric (ISO-8601 format). + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; private set; } + + /// + /// Gets the end time for the metric (ISO-8601 format). + /// + [JsonProperty(PropertyName = "endTime")] + public System.DateTime? EndTime { get; private set; } + + /// + /// Gets the time grain to be used to summarize the metric values. + /// + [JsonProperty(PropertyName = "timeGrain")] + public string TimeGrain { get; private set; } + + /// + /// Gets or sets the unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Gets the name information for the metric. + /// + [JsonProperty(PropertyName = "name")] + public MetricName Name { get; private set; } + + /// + /// Gets the percentile metric values for the specified time window and + /// timestep. + /// + [JsonProperty(PropertyName = "metricValues")] + public IList MetricValues { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetricValue.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetricValue.cs new file mode 100644 index 000000000000..3a1e3c29cfc0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PercentileMetricValue.cs @@ -0,0 +1,107 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents percentile metrics values. + /// + public partial class PercentileMetricValue : MetricValue + { + /// + /// Initializes a new instance of the PercentileMetricValue class. + /// + public PercentileMetricValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PercentileMetricValue class. + /// + /// The number of values for the metric. + /// The average value of the metric. + /// The max value of the metric. + /// The min value of the metric. + /// The metric timestamp (ISO-8601 + /// format). + /// The total value of the metric. + /// The 10th percentile value for the metric. + /// The 25th percentile value for the metric. + /// The 50th percentile value for the metric. + /// The 75th percentile value for the metric. + /// The 90th percentile value for the metric. + /// The 95th percentile value for the metric. + /// The 99th percentile value for the metric. + public PercentileMetricValue(double? _count = default(double?), double? average = default(double?), double? maximum = default(double?), double? minimum = default(double?), System.DateTime? timestamp = default(System.DateTime?), double? total = default(double?), double? p10 = default(double?), double? p25 = default(double?), double? p50 = default(double?), double? p75 = default(double?), double? p90 = default(double?), double? p95 = default(double?), double? p99 = default(double?)) + : base(_count, average, maximum, minimum, timestamp, total) + { + P10 = p10; + P25 = p25; + P50 = p50; + P75 = p75; + P90 = p90; + P95 = p95; + P99 = p99; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the 10th percentile value for the metric. + /// + [JsonProperty(PropertyName = "P10")] + public double? P10 { get; private set; } + + /// + /// Gets the 25th percentile value for the metric. + /// + [JsonProperty(PropertyName = "P25")] + public double? P25 { get; private set; } + + /// + /// Gets the 50th percentile value for the metric. + /// + [JsonProperty(PropertyName = "P50")] + public double? P50 { get; private set; } + + /// + /// Gets the 75th percentile value for the metric. + /// + [JsonProperty(PropertyName = "P75")] + public double? P75 { get; private set; } + + /// + /// Gets the 90th percentile value for the metric. + /// + [JsonProperty(PropertyName = "P90")] + public double? P90 { get; private set; } + + /// + /// Gets the 95th percentile value for the metric. + /// + [JsonProperty(PropertyName = "P95")] + public double? P95 { get; private set; } + + /// + /// Gets the 99th percentile value for the metric. + /// + [JsonProperty(PropertyName = "P99")] + public double? P99 { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrimaryAggregationType.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrimaryAggregationType.cs new file mode 100644 index 000000000000..3b151d54e7c0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrimaryAggregationType.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for PrimaryAggregationType. + /// + public static class PrimaryAggregationType + { + public const string None = "None"; + public const string Average = "Average"; + public const string Total = "Total"; + public const string Minimum = "Minimum"; + public const string Maximum = "Maximum"; + public const string Last = "Last"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointConnection.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointConnection.cs new file mode 100644 index 000000000000..7049f0a98cce --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointConnection.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A private endpoint connection + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateEndpointConnection : ProxyResource + { + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + public PrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + /// Fully qualified resource Id for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. Ex- + /// Microsoft.Compute/virtualMachines or + /// Microsoft.Storage/storageAccounts. + /// Private endpoint which the connection + /// belongs to. + /// Connection State of + /// the Private Endpoint Connection. + public PrivateEndpointConnection(string id = default(string), string name = default(string), string type = default(string), PrivateEndpointProperty privateEndpoint = default(PrivateEndpointProperty), PrivateLinkServiceConnectionStateProperty privateLinkServiceConnectionState = default(PrivateLinkServiceConnectionStateProperty)) + : base(id, name, type) + { + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets private endpoint which the connection belongs to. + /// + [JsonProperty(PropertyName = "properties.privateEndpoint")] + public PrivateEndpointProperty PrivateEndpoint { get; set; } + + /// + /// Gets or sets connection State of the Private Endpoint Connection. + /// + [JsonProperty(PropertyName = "properties.privateLinkServiceConnectionState")] + public PrivateLinkServiceConnectionStateProperty PrivateLinkServiceConnectionState { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointProperty.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointProperty.cs new file mode 100644 index 000000000000..503a6c41e836 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateEndpointProperty.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Private endpoint which the connection belongs to. + /// + public partial class PrivateEndpointProperty + { + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + public PrivateEndpointProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + /// Resource id of the private endpoint. + public PrivateEndpointProperty(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource id of the private endpoint. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkResource.cs new file mode 100644 index 000000000000..516990b36a04 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkResource.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A private link resource + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateLinkResource : ARMProxyResource + { + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + public PrivateLinkResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + /// The unique resource identifier of the database + /// account. + /// The name of the database account. + /// The type of Azure resource. + /// The private link resource group id. + /// The private link resource required + /// member names. + public PrivateLinkResource(string id = default(string), string name = default(string), string type = default(string), string groupId = default(string), IList requiredMembers = default(IList)) + : base(id, name, type) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the private link resource group id. + /// + [JsonProperty(PropertyName = "properties.groupId")] + public string GroupId { get; private set; } + + /// + /// Gets the private link resource required member names. + /// + [JsonProperty(PropertyName = "properties.requiredMembers")] + public IList RequiredMembers { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs new file mode 100644 index 000000000000..729e9869bebf --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Connection State of the Private Endpoint Connection. + /// + public partial class PrivateLinkServiceConnectionStateProperty + { + /// + /// Initializes a new instance of the + /// PrivateLinkServiceConnectionStateProperty class. + /// + public PrivateLinkServiceConnectionStateProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PrivateLinkServiceConnectionStateProperty class. + /// + /// The private link service connection + /// status. + /// The private link service connection + /// description. + /// Any action that is required beyond + /// basic workflow (approve/ reject/ disconnect) + public PrivateLinkServiceConnectionStateProperty(string status = default(string), string description = default(string), string actionsRequired = default(string)) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the private link service connection status. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the private link service connection description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets any action that is required beyond basic workflow (approve/ + /// reject/ disconnect) + /// + [JsonProperty(PropertyName = "actionsRequired")] + public string ActionsRequired { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProvisionedThroughputSettingsResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProvisionedThroughputSettingsResource.cs new file mode 100644 index 000000000000..a4e36862cfc7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProvisionedThroughputSettingsResource.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB provisioned throughput settings object + /// + public partial class ProvisionedThroughputSettingsResource + { + /// + /// Initializes a new instance of the + /// ProvisionedThroughputSettingsResource class. + /// + public ProvisionedThroughputSettingsResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ProvisionedThroughputSettingsResource class. + /// + /// Represents maximum throughput container + /// can scale up to. + /// Cosmos DB resource auto-upgrade + /// policy + /// Represents target maximum + /// throughput container can scale up to once offer is no longer in + /// pending state. + public ProvisionedThroughputSettingsResource(int maxThroughput, AutoUpgradePolicyResource autoUpgradePolicy = default(AutoUpgradePolicyResource), int? targetMaxThroughput = default(int?)) + { + MaxThroughput = maxThroughput; + AutoUpgradePolicy = autoUpgradePolicy; + TargetMaxThroughput = targetMaxThroughput; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets represents maximum throughput container can scale up + /// to. + /// + [JsonProperty(PropertyName = "maxThroughput")] + public int MaxThroughput { get; set; } + + /// + /// Gets or sets cosmos DB resource auto-upgrade policy + /// + [JsonProperty(PropertyName = "autoUpgradePolicy")] + public AutoUpgradePolicyResource AutoUpgradePolicy { get; set; } + + /// + /// Gets represents target maximum throughput container can scale up to + /// once offer is no longer in pending state. + /// + [JsonProperty(PropertyName = "targetMaxThroughput")] + public int? TargetMaxThroughput { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProxyResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProxyResource.cs new file mode 100644 index 000000000000..319a022ba523 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ProxyResource.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using System.Linq; + + /// + /// The resource model definition for a ARM proxy resource. It will have + /// everything other than required location and tags + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Fully qualified resource Id for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. Ex- + /// Microsoft.Compute/virtualMachines or + /// Microsoft.Storage/storageAccounts. + public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/RegionForOnlineOffline.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/RegionForOnlineOffline.cs new file mode 100644 index 000000000000..8abb29ae8c21 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/RegionForOnlineOffline.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB region to online or offline. + /// + public partial class RegionForOnlineOffline + { + /// + /// Initializes a new instance of the RegionForOnlineOffline class. + /// + public RegionForOnlineOffline() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RegionForOnlineOffline class. + /// + /// Cosmos DB region, with spaces between words + /// and each word capitalized. + public RegionForOnlineOffline(string region) + { + Region = region; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets cosmos DB region, with spaces between words and each + /// word capitalized. + /// + [JsonProperty(PropertyName = "region")] + public string Region { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Region == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Region"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Resource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Resource.cs new file mode 100644 index 000000000000..de53dc8b4ee7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Resource.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Fully qualified resource Id for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. Ex- + /// Microsoft.Compute/virtualMachines or + /// Microsoft.Storage/storageAccounts. + public Resource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets fully qualified resource Id for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. Ex- + /// Microsoft.Compute/virtualMachines or + /// Microsoft.Storage/storageAccounts. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialSpec.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialSpec.cs new file mode 100644 index 000000000000..102238723ca8 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialSpec.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class SpatialSpec + { + /// + /// Initializes a new instance of the SpatialSpec class. + /// + public SpatialSpec() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SpatialSpec class. + /// + /// The path for which the indexing behavior applies + /// to. Index paths typically start with root and end with wildcard + /// (/path/*) + /// List of path's spatial type + public SpatialSpec(string path = default(string), IList types = default(IList)) + { + Path = path; + Types = types; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the path for which the indexing behavior applies to. + /// Index paths typically start with root and end with wildcard + /// (/path/*) + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + /// + /// Gets or sets list of path's spatial type + /// + [JsonProperty(PropertyName = "types")] + public IList Types { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialType.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialType.cs new file mode 100644 index 000000000000..66203ef20355 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SpatialType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for SpatialType. + /// + public static class SpatialType + { + public const string Point = "Point"; + public const string LineString = "LineString"; + public const string Polygon = "Polygon"; + public const string MultiPolygon = "MultiPolygon"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerCreateUpdateParameters.cs new file mode 100644 index 000000000000..76a123855aac --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB container. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlContainerCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// SqlContainerCreateUpdateParameters class. + /// + public SqlContainerCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SqlContainerCreateUpdateParameters class. + /// + /// The standard JSON format of a + /// container + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlContainerCreateUpdateParameters(SqlContainerResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a container + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlContainerResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetPropertiesResource.cs new file mode 100644 index 000000000000..322898442de0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetPropertiesResource.cs @@ -0,0 +1,148 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class SqlContainerGetPropertiesResource + { + /// + /// Initializes a new instance of the SqlContainerGetPropertiesResource + /// class. + /// + public SqlContainerGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlContainerGetPropertiesResource + /// class. + /// + /// Name of the Cosmos DB SQL container + /// The configuration of the indexing + /// policy. By default, the indexing is automatic for all document + /// paths within the container + /// The configuration of the partition key + /// to be used for partitioning data into multiple partitions + /// Default time to live + /// The unique key policy configuration + /// for specifying uniqueness constraints on documents in the + /// collection in the Azure Cosmos DB service. + /// The conflict resolution + /// policy for the container. + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public SqlContainerGetPropertiesResource(string id, IndexingPolicy indexingPolicy = default(IndexingPolicy), ContainerPartitionKey partitionKey = default(ContainerPartitionKey), int? defaultTtl = default(int?), UniqueKeyPolicy uniqueKeyPolicy = default(UniqueKeyPolicy), ConflictResolutionPolicy conflictResolutionPolicy = default(ConflictResolutionPolicy), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + IndexingPolicy = indexingPolicy; + PartitionKey = partitionKey; + DefaultTtl = defaultTtl; + UniqueKeyPolicy = uniqueKeyPolicy; + ConflictResolutionPolicy = conflictResolutionPolicy; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL container + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the configuration of the indexing policy. By default, + /// the indexing is automatic for all document paths within the + /// container + /// + [JsonProperty(PropertyName = "indexingPolicy")] + public IndexingPolicy IndexingPolicy { get; set; } + + /// + /// Gets or sets the configuration of the partition key to be used for + /// partitioning data into multiple partitions + /// + [JsonProperty(PropertyName = "partitionKey")] + public ContainerPartitionKey PartitionKey { get; set; } + + /// + /// Gets or sets default time to live + /// + [JsonProperty(PropertyName = "defaultTtl")] + public int? DefaultTtl { get; set; } + + /// + /// Gets or sets the unique key policy configuration for specifying + /// uniqueness constraints on documents in the collection in the Azure + /// Cosmos DB service. + /// + [JsonProperty(PropertyName = "uniqueKeyPolicy")] + public UniqueKeyPolicy UniqueKeyPolicy { get; set; } + + /// + /// Gets or sets the conflict resolution policy for the container. + /// + [JsonProperty(PropertyName = "conflictResolutionPolicy")] + public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (PartitionKey != null) + { + PartitionKey.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetResults.cs new file mode 100644 index 000000000000..4ed50b3c17f1 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB container. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlContainerGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the SqlContainerGetResults class. + /// + public SqlContainerGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlContainerGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlContainerGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), SqlContainerGetPropertiesResource resource = default(SqlContainerGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlContainerGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerResource.cs new file mode 100644 index 000000000000..94620f871498 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlContainerResource.cs @@ -0,0 +1,120 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB SQL container resource object + /// + public partial class SqlContainerResource + { + /// + /// Initializes a new instance of the SqlContainerResource class. + /// + public SqlContainerResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlContainerResource class. + /// + /// Name of the Cosmos DB SQL container + /// The configuration of the indexing + /// policy. By default, the indexing is automatic for all document + /// paths within the container + /// The configuration of the partition key + /// to be used for partitioning data into multiple partitions + /// Default time to live + /// The unique key policy configuration + /// for specifying uniqueness constraints on documents in the + /// collection in the Azure Cosmos DB service. + /// The conflict resolution + /// policy for the container. + public SqlContainerResource(string id, IndexingPolicy indexingPolicy = default(IndexingPolicy), ContainerPartitionKey partitionKey = default(ContainerPartitionKey), int? defaultTtl = default(int?), UniqueKeyPolicy uniqueKeyPolicy = default(UniqueKeyPolicy), ConflictResolutionPolicy conflictResolutionPolicy = default(ConflictResolutionPolicy)) + { + Id = id; + IndexingPolicy = indexingPolicy; + PartitionKey = partitionKey; + DefaultTtl = defaultTtl; + UniqueKeyPolicy = uniqueKeyPolicy; + ConflictResolutionPolicy = conflictResolutionPolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL container + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the configuration of the indexing policy. By default, + /// the indexing is automatic for all document paths within the + /// container + /// + [JsonProperty(PropertyName = "indexingPolicy")] + public IndexingPolicy IndexingPolicy { get; set; } + + /// + /// Gets or sets the configuration of the partition key to be used for + /// partitioning data into multiple partitions + /// + [JsonProperty(PropertyName = "partitionKey")] + public ContainerPartitionKey PartitionKey { get; set; } + + /// + /// Gets or sets default time to live + /// + [JsonProperty(PropertyName = "defaultTtl")] + public int? DefaultTtl { get; set; } + + /// + /// Gets or sets the unique key policy configuration for specifying + /// uniqueness constraints on documents in the collection in the Azure + /// Cosmos DB service. + /// + [JsonProperty(PropertyName = "uniqueKeyPolicy")] + public UniqueKeyPolicy UniqueKeyPolicy { get; set; } + + /// + /// Gets or sets the conflict resolution policy for the container. + /// + [JsonProperty(PropertyName = "conflictResolutionPolicy")] + public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (PartitionKey != null) + { + PartitionKey.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseCreateUpdateParameters.cs new file mode 100644 index 000000000000..64818739cc95 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB SQL database. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlDatabaseCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the SqlDatabaseCreateUpdateParameters + /// class. + /// + public SqlDatabaseCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlDatabaseCreateUpdateParameters + /// class. + /// + /// The standard JSON format of a SQL + /// database + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlDatabaseCreateUpdateParameters(SqlDatabaseResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a SQL database + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlDatabaseResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetPropertiesResource.cs new file mode 100644 index 000000000000..0a4a2a86a947 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetPropertiesResource.cs @@ -0,0 +1,113 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class SqlDatabaseGetPropertiesResource + { + /// + /// Initializes a new instance of the SqlDatabaseGetPropertiesResource + /// class. + /// + public SqlDatabaseGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlDatabaseGetPropertiesResource + /// class. + /// + /// Name of the Cosmos DB SQL database + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + /// A system generated property that specified the + /// addressable path of the collections resource. + /// A system generated property that specifies the + /// addressable path of the users resource. + public SqlDatabaseGetPropertiesResource(string id, string _rid = default(string), object _ts = default(object), string _etag = default(string), string _colls = default(string), string _users = default(string)) + { + Id = id; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + this._colls = _colls; + this._users = _users; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL database + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Gets or sets a system generated property that specified the + /// addressable path of the collections resource. + /// + [JsonProperty(PropertyName = "_colls")] + public string _colls { get; set; } + + /// + /// Gets or sets a system generated property that specifies the + /// addressable path of the users resource. + /// + [JsonProperty(PropertyName = "_users")] + public string _users { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetResults.cs new file mode 100644 index 000000000000..177bf31ead0b --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB SQL database. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlDatabaseGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the SqlDatabaseGetResults class. + /// + public SqlDatabaseGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlDatabaseGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlDatabaseGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), SqlDatabaseGetPropertiesResource resource = default(SqlDatabaseGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlDatabaseGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseResource.cs new file mode 100644 index 000000000000..a3b389007ece --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlDatabaseResource.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB SQL database resource object + /// + public partial class SqlDatabaseResource + { + /// + /// Initializes a new instance of the SqlDatabaseResource class. + /// + public SqlDatabaseResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlDatabaseResource class. + /// + /// Name of the Cosmos DB SQL database + public SqlDatabaseResource(string id) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL database + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureCreateUpdateParameters.cs new file mode 100644 index 000000000000..b80ead127751 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB storedProcedure. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlStoredProcedureCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// SqlStoredProcedureCreateUpdateParameters class. + /// + public SqlStoredProcedureCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SqlStoredProcedureCreateUpdateParameters class. + /// + /// The standard JSON format of a + /// storedProcedure + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlStoredProcedureCreateUpdateParameters(SqlStoredProcedureResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a storedProcedure + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlStoredProcedureResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetPropertiesResource.cs new file mode 100644 index 000000000000..6e9fbeac1e4e --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetPropertiesResource.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class SqlStoredProcedureGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// SqlStoredProcedureGetPropertiesResource class. + /// + public SqlStoredProcedureGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SqlStoredProcedureGetPropertiesResource class. + /// + /// Name of the Cosmos DB SQL storedProcedure + /// Body of the Stored Procedure + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public SqlStoredProcedureGetPropertiesResource(string id, string body = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + Body = body; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL storedProcedure + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets body of the Stored Procedure + /// + [JsonProperty(PropertyName = "body")] + public string Body { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetResults.cs new file mode 100644 index 000000000000..68dccce67dd0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureGetResults.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB storedProcedure. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlStoredProcedureGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the SqlStoredProcedureGetResults + /// class. + /// + public SqlStoredProcedureGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlStoredProcedureGetResults + /// class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlStoredProcedureGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), SqlStoredProcedureGetPropertiesResource resource = default(SqlStoredProcedureGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlStoredProcedureGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureResource.cs new file mode 100644 index 000000000000..8dd35ce767ad --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlStoredProcedureResource.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB SQL storedProcedure resource object + /// + public partial class SqlStoredProcedureResource + { + /// + /// Initializes a new instance of the SqlStoredProcedureResource class. + /// + public SqlStoredProcedureResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlStoredProcedureResource class. + /// + /// Name of the Cosmos DB SQL storedProcedure + /// Body of the Stored Procedure + public SqlStoredProcedureResource(string id, string body = default(string)) + { + Id = id; + Body = body; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL storedProcedure + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets body of the Stored Procedure + /// + [JsonProperty(PropertyName = "body")] + public string Body { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerCreateUpdateParameters.cs new file mode 100644 index 000000000000..e9545a02af6a --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB trigger. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlTriggerCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the SqlTriggerCreateUpdateParameters + /// class. + /// + public SqlTriggerCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlTriggerCreateUpdateParameters + /// class. + /// + /// The standard JSON format of a + /// trigger + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlTriggerCreateUpdateParameters(SqlTriggerResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a trigger + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlTriggerResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetPropertiesResource.cs new file mode 100644 index 000000000000..73023f0e1ed4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetPropertiesResource.cs @@ -0,0 +1,122 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class SqlTriggerGetPropertiesResource + { + /// + /// Initializes a new instance of the SqlTriggerGetPropertiesResource + /// class. + /// + public SqlTriggerGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlTriggerGetPropertiesResource + /// class. + /// + /// Name of the Cosmos DB SQL trigger + /// Body of the Trigger + /// Type of the Trigger. Possible values + /// include: 'Pre', 'Post' + /// The operation the trigger is + /// associated with. Possible values include: 'All', 'Create', + /// 'Update', 'Delete', 'Replace' + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public SqlTriggerGetPropertiesResource(string id, string body = default(string), string triggerType = default(string), string triggerOperation = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + Body = body; + TriggerType = triggerType; + TriggerOperation = triggerOperation; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL trigger + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets body of the Trigger + /// + [JsonProperty(PropertyName = "body")] + public string Body { get; set; } + + /// + /// Gets or sets type of the Trigger. Possible values include: 'Pre', + /// 'Post' + /// + [JsonProperty(PropertyName = "triggerType")] + public string TriggerType { get; set; } + + /// + /// Gets or sets the operation the trigger is associated with. Possible + /// values include: 'All', 'Create', 'Update', 'Delete', 'Replace' + /// + [JsonProperty(PropertyName = "triggerOperation")] + public string TriggerOperation { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetResults.cs new file mode 100644 index 000000000000..8d70e5394e16 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB trigger. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlTriggerGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the SqlTriggerGetResults class. + /// + public SqlTriggerGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlTriggerGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlTriggerGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), SqlTriggerGetPropertiesResource resource = default(SqlTriggerGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlTriggerGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerResource.cs new file mode 100644 index 000000000000..5f3cc9087bde --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlTriggerResource.cs @@ -0,0 +1,94 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB SQL trigger resource object + /// + public partial class SqlTriggerResource + { + /// + /// Initializes a new instance of the SqlTriggerResource class. + /// + public SqlTriggerResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlTriggerResource class. + /// + /// Name of the Cosmos DB SQL trigger + /// Body of the Trigger + /// Type of the Trigger. Possible values + /// include: 'Pre', 'Post' + /// The operation the trigger is + /// associated with. Possible values include: 'All', 'Create', + /// 'Update', 'Delete', 'Replace' + public SqlTriggerResource(string id, string body = default(string), string triggerType = default(string), string triggerOperation = default(string)) + { + Id = id; + Body = body; + TriggerType = triggerType; + TriggerOperation = triggerOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL trigger + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets body of the Trigger + /// + [JsonProperty(PropertyName = "body")] + public string Body { get; set; } + + /// + /// Gets or sets type of the Trigger. Possible values include: 'Pre', + /// 'Post' + /// + [JsonProperty(PropertyName = "triggerType")] + public string TriggerType { get; set; } + + /// + /// Gets or sets the operation the trigger is associated with. Possible + /// values include: 'All', 'Create', 'Update', 'Delete', 'Replace' + /// + [JsonProperty(PropertyName = "triggerOperation")] + public string TriggerOperation { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs new file mode 100644 index 000000000000..0f41cd336230 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB userDefinedFunction. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlUserDefinedFunctionCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// SqlUserDefinedFunctionCreateUpdateParameters class. + /// + public SqlUserDefinedFunctionCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SqlUserDefinedFunctionCreateUpdateParameters class. + /// + /// The standard JSON format of a + /// userDefinedFunction + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlUserDefinedFunctionCreateUpdateParameters(SqlUserDefinedFunctionResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a userDefinedFunction + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlUserDefinedFunctionResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetPropertiesResource.cs new file mode 100644 index 000000000000..04dc28b99b24 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetPropertiesResource.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class SqlUserDefinedFunctionGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// SqlUserDefinedFunctionGetPropertiesResource class. + /// + public SqlUserDefinedFunctionGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SqlUserDefinedFunctionGetPropertiesResource class. + /// + /// Name of the Cosmos DB SQL + /// userDefinedFunction + /// Body of the User Defined Function + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public SqlUserDefinedFunctionGetPropertiesResource(string id, string body = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + Body = body; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL userDefinedFunction + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets body of the User Defined Function + /// + [JsonProperty(PropertyName = "body")] + public string Body { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetResults.cs new file mode 100644 index 000000000000..0a076cb2cdfd --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionGetResults.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB userDefinedFunction. + /// + [Rest.Serialization.JsonTransformation] + public partial class SqlUserDefinedFunctionGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the SqlUserDefinedFunctionGetResults + /// class. + /// + public SqlUserDefinedFunctionGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlUserDefinedFunctionGetResults + /// class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public SqlUserDefinedFunctionGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), SqlUserDefinedFunctionGetPropertiesResource resource = default(SqlUserDefinedFunctionGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public SqlUserDefinedFunctionGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionResource.cs new file mode 100644 index 000000000000..a65afa7fbf5d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/SqlUserDefinedFunctionResource.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB SQL userDefinedFunction resource object + /// + public partial class SqlUserDefinedFunctionResource + { + /// + /// Initializes a new instance of the SqlUserDefinedFunctionResource + /// class. + /// + public SqlUserDefinedFunctionResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlUserDefinedFunctionResource + /// class. + /// + /// Name of the Cosmos DB SQL + /// userDefinedFunction + /// Body of the User Defined Function + public SqlUserDefinedFunctionResource(string id, string body = default(string)) + { + Id = id; + Body = body; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB SQL userDefinedFunction + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets body of the User Defined Function + /// + [JsonProperty(PropertyName = "body")] + public string Body { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableCreateUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableCreateUpdateParameters.cs new file mode 100644 index 000000000000..2a3a93ad8aa7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableCreateUpdateParameters.cs @@ -0,0 +1,97 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to create and update Cosmos DB Table. + /// + [Rest.Serialization.JsonTransformation] + public partial class TableCreateUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the TableCreateUpdateParameters + /// class. + /// + public TableCreateUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TableCreateUpdateParameters + /// class. + /// + /// The standard JSON format of a Table + /// A key-value pair of options to be applied for + /// the request. This corresponds to the headers sent with the + /// request. + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public TableCreateUpdateParameters(TableResource resource, CreateUpdateOptions options, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a Table + /// + [JsonProperty(PropertyName = "properties.resource")] + public TableResource Resource { get; set; } + + /// + /// Gets or sets a key-value pair of options to be applied for the + /// request. This corresponds to the headers sent with the request. + /// + [JsonProperty(PropertyName = "properties.options")] + public CreateUpdateOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Options == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Options"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetPropertiesResource.cs new file mode 100644 index 000000000000..98d2e47cad03 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetPropertiesResource.cs @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class TableGetPropertiesResource + { + /// + /// Initializes a new instance of the TableGetPropertiesResource class. + /// + public TableGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TableGetPropertiesResource class. + /// + /// Name of the Cosmos DB table + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public TableGetPropertiesResource(string id, string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Id = id; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB table + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetResults.cs new file mode 100644 index 000000000000..305a165e4c37 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableGetResults.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB Table. + /// + [Rest.Serialization.JsonTransformation] + public partial class TableGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the TableGetResults class. + /// + public TableGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TableGetResults class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public TableGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), TableGetPropertiesResource resource = default(TableGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public TableGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableResource.cs new file mode 100644 index 000000000000..d03daa45d7aa --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TableResource.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB table resource object + /// + public partial class TableResource + { + /// + /// Initializes a new instance of the TableResource class. + /// + public TableResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TableResource class. + /// + /// Name of the Cosmos DB table + public TableResource(string id) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the Cosmos DB table + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputPolicyResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputPolicyResource.cs new file mode 100644 index 000000000000..74714cab7f87 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputPolicyResource.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB resource throughput policy + /// + public partial class ThroughputPolicyResource + { + /// + /// Initializes a new instance of the ThroughputPolicyResource class. + /// + public ThroughputPolicyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ThroughputPolicyResource class. + /// + /// Determines whether the ThroughputPolicy is + /// active or not + /// Represents the percentage by which + /// throughput can increase every time throughput policy kicks + /// in. + public ThroughputPolicyResource(bool? isEnabled = default(bool?), int? incrementPercent = default(int?)) + { + IsEnabled = isEnabled; + IncrementPercent = incrementPercent; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets determines whether the ThroughputPolicy is active or + /// not + /// + [JsonProperty(PropertyName = "isEnabled")] + public bool? IsEnabled { get; set; } + + /// + /// Gets or sets represents the percentage by which throughput can + /// increase every time throughput policy kicks in. + /// + [JsonProperty(PropertyName = "incrementPercent")] + public int? IncrementPercent { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetPropertiesResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetPropertiesResource.cs new file mode 100644 index 000000000000..4f3f65903ad0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetPropertiesResource.cs @@ -0,0 +1,126 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ThroughputSettingsGetPropertiesResource + { + /// + /// Initializes a new instance of the + /// ThroughputSettingsGetPropertiesResource class. + /// + public ThroughputSettingsGetPropertiesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ThroughputSettingsGetPropertiesResource class. + /// + /// Value of the Cosmos DB resource + /// throughput. Either throughput is required or + /// provisionedThroughputSettings is required, but not both. + /// Cosmos DB resource for + /// provisioned throughput settings. Either throughput is required or + /// provisionedThroughputSettings is required, but not both. + /// The minimum throughput of the + /// resource + /// The throughput replace is + /// pending + /// A system generated property. A unique + /// identifier. + /// A system generated property that denotes the last + /// updated timestamp of the resource. + /// A system generated property representing the + /// resource etag required for optimistic concurrency control. + public ThroughputSettingsGetPropertiesResource(int? throughput = default(int?), ProvisionedThroughputSettingsResource provisionedThroughputSettings = default(ProvisionedThroughputSettingsResource), string minimumThroughput = default(string), string offerReplacePending = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + { + Throughput = throughput; + ProvisionedThroughputSettings = provisionedThroughputSettings; + MinimumThroughput = minimumThroughput; + OfferReplacePending = offerReplacePending; + this._rid = _rid; + this._ts = _ts; + this._etag = _etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets value of the Cosmos DB resource throughput. Either + /// throughput is required or provisionedThroughputSettings is + /// required, but not both. + /// + [JsonProperty(PropertyName = "throughput")] + public int? Throughput { get; set; } + + /// + /// Gets or sets cosmos DB resource for provisioned throughput + /// settings. Either throughput is required or + /// provisionedThroughputSettings is required, but not both. + /// + [JsonProperty(PropertyName = "provisionedThroughputSettings")] + public ProvisionedThroughputSettingsResource ProvisionedThroughputSettings { get; set; } + + /// + /// Gets the minimum throughput of the resource + /// + [JsonProperty(PropertyName = "minimumThroughput")] + public string MinimumThroughput { get; private set; } + + /// + /// Gets the throughput replace is pending + /// + [JsonProperty(PropertyName = "offerReplacePending")] + public string OfferReplacePending { get; private set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "_rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "_ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "_etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ProvisionedThroughputSettings != null) + { + ProvisionedThroughputSettings.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetResults.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetResults.cs new file mode 100644 index 000000000000..7c4e49c1aede --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsGetResults.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Cosmos DB resource throughput. + /// + [Rest.Serialization.JsonTransformation] + public partial class ThroughputSettingsGetResults : ARMResourceProperties + { + /// + /// Initializes a new instance of the ThroughputSettingsGetResults + /// class. + /// + public ThroughputSettingsGetResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ThroughputSettingsGetResults + /// class. + /// + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public ThroughputSettingsGetResults(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ThroughputSettingsGetPropertiesResource resource = default(ThroughputSettingsGetPropertiesResource)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.resource")] + public ThroughputSettingsGetPropertiesResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsResource.cs new file mode 100644 index 000000000000..78e0476bfa6a --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsResource.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB resource throughput object. Either throughput is required or + /// provisionedThroughputSettings is required, but not both. + /// + public partial class ThroughputSettingsResource + { + /// + /// Initializes a new instance of the ThroughputSettingsResource class. + /// + public ThroughputSettingsResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ThroughputSettingsResource class. + /// + /// Value of the Cosmos DB resource + /// throughput. Either throughput is required or + /// provisionedThroughputSettings is required, but not both. + /// Cosmos DB resource for + /// provisioned throughput settings. Either throughput is required or + /// provisionedThroughputSettings is required, but not both. + /// The minimum throughput of the + /// resource + /// The throughput replace is + /// pending + public ThroughputSettingsResource(int? throughput = default(int?), ProvisionedThroughputSettingsResource provisionedThroughputSettings = default(ProvisionedThroughputSettingsResource), string minimumThroughput = default(string), string offerReplacePending = default(string)) + { + Throughput = throughput; + ProvisionedThroughputSettings = provisionedThroughputSettings; + MinimumThroughput = minimumThroughput; + OfferReplacePending = offerReplacePending; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets value of the Cosmos DB resource throughput. Either + /// throughput is required or provisionedThroughputSettings is + /// required, but not both. + /// + [JsonProperty(PropertyName = "throughput")] + public int? Throughput { get; set; } + + /// + /// Gets or sets cosmos DB resource for provisioned throughput + /// settings. Either throughput is required or + /// provisionedThroughputSettings is required, but not both. + /// + [JsonProperty(PropertyName = "provisionedThroughputSettings")] + public ProvisionedThroughputSettingsResource ProvisionedThroughputSettings { get; set; } + + /// + /// Gets the minimum throughput of the resource + /// + [JsonProperty(PropertyName = "minimumThroughput")] + public string MinimumThroughput { get; private set; } + + /// + /// Gets the throughput replace is pending + /// + [JsonProperty(PropertyName = "offerReplacePending")] + public string OfferReplacePending { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ProvisionedThroughputSettings != null) + { + ProvisionedThroughputSettings.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsUpdateParameters.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsUpdateParameters.cs new file mode 100644 index 000000000000..80c6b622390d --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/ThroughputSettingsUpdateParameters.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters to update Cosmos DB resource throughput. + /// + [Rest.Serialization.JsonTransformation] + public partial class ThroughputSettingsUpdateParameters : ARMResourceProperties + { + /// + /// Initializes a new instance of the + /// ThroughputSettingsUpdateParameters class. + /// + public ThroughputSettingsUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ThroughputSettingsUpdateParameters class. + /// + /// The standard JSON format of a resource + /// throughput + /// The unique resource identifier of the ARM + /// resource. + /// The name of the ARM resource. + /// The type of Azure resource. + /// The location of the resource group to which + /// the resource belongs. + public ThroughputSettingsUpdateParameters(ThroughputSettingsResource resource, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type, location, tags) + { + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the standard JSON format of a resource throughput + /// + [JsonProperty(PropertyName = "properties.resource")] + public ThroughputSettingsResource Resource { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Resource != null) + { + Resource.Validate(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TrackedResource.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TrackedResource.cs new file mode 100644 index 000000000000..9d7d1a6780ae --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TrackedResource.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The resource model definition for a ARM tracked top level resource + /// + public partial class TrackedResource : Resource + { + /// + /// Initializes a new instance of the TrackedResource class. + /// + public TrackedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TrackedResource class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource Id for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. Ex- + /// Microsoft.Compute/virtualMachines or + /// Microsoft.Storage/storageAccounts. + /// Resource tags. + public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type) + { + Tags = tags; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the geo-location where the resource lives + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerOperation.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerOperation.cs new file mode 100644 index 000000000000..cd329118d464 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerOperation.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for TriggerOperation. + /// + public static class TriggerOperation + { + public const string All = "All"; + public const string Create = "Create"; + public const string Update = "Update"; + public const string Delete = "Delete"; + public const string Replace = "Replace"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerType.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerType.cs new file mode 100644 index 000000000000..d5c4e2852466 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/TriggerType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for TriggerType. + /// + public static class TriggerType + { + public const string Pre = "Pre"; + public const string Post = "Post"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKey.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKey.cs new file mode 100644 index 000000000000..7c09fbf4a91b --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKey.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The unique key on that enforces uniqueness constraint on documents in + /// the collection in the Azure Cosmos DB service. + /// + public partial class UniqueKey + { + /// + /// Initializes a new instance of the UniqueKey class. + /// + public UniqueKey() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UniqueKey class. + /// + /// List of paths must be unique for each document + /// in the Azure Cosmos DB service + public UniqueKey(IList paths = default(IList)) + { + Paths = paths; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of paths must be unique for each document in the + /// Azure Cosmos DB service + /// + [JsonProperty(PropertyName = "paths")] + public IList Paths { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKeyPolicy.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKeyPolicy.cs new file mode 100644 index 000000000000..b4c4fc47b68a --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UniqueKeyPolicy.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The unique key policy configuration for specifying uniqueness + /// constraints on documents in the collection in the Azure Cosmos DB + /// service. + /// + public partial class UniqueKeyPolicy + { + /// + /// Initializes a new instance of the UniqueKeyPolicy class. + /// + public UniqueKeyPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UniqueKeyPolicy class. + /// + /// List of unique keys on that enforces + /// uniqueness constraint on documents in the collection in the Azure + /// Cosmos DB service. + public UniqueKeyPolicy(IList uniqueKeys = default(IList)) + { + UniqueKeys = uniqueKeys; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of unique keys on that enforces uniqueness + /// constraint on documents in the collection in the Azure Cosmos DB + /// service. + /// + [JsonProperty(PropertyName = "uniqueKeys")] + public IList UniqueKeys { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UnitType.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UnitType.cs new file mode 100644 index 000000000000..6bae7608bda6 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/UnitType.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + + /// + /// Defines values for UnitType. + /// + public static class UnitType + { + public const string Count = "Count"; + public const string Bytes = "Bytes"; + public const string Seconds = "Seconds"; + public const string Percent = "Percent"; + public const string CountPerSecond = "CountPerSecond"; + public const string BytesPerSecond = "BytesPerSecond"; + public const string Milliseconds = "Milliseconds"; + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Usage.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Usage.cs new file mode 100644 index 000000000000..0ad9aa444571 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/Usage.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The usage data for a usage request. + /// + public partial class Usage + { + /// + /// Initializes a new instance of the Usage class. + /// + public Usage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Usage class. + /// + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// The name information for the metric. + /// The quota period used to summarize the + /// usage values. + /// Maximum value for this metric + /// Current value for this metric + public Usage(string unit = default(string), MetricName name = default(MetricName), string quotaPeriod = default(string), long? limit = default(long?), long? currentValue = default(long?)) + { + Unit = unit; + Name = name; + QuotaPeriod = quotaPeriod; + Limit = limit; + CurrentValue = currentValue; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond', 'Milliseconds' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Gets the name information for the metric. + /// + [JsonProperty(PropertyName = "name")] + public MetricName Name { get; private set; } + + /// + /// Gets the quota period used to summarize the usage values. + /// + [JsonProperty(PropertyName = "quotaPeriod")] + public string QuotaPeriod { get; private set; } + + /// + /// Gets maximum value for this metric + /// + [JsonProperty(PropertyName = "limit")] + public long? Limit { get; private set; } + + /// + /// Gets current value for this metric + /// + [JsonProperty(PropertyName = "currentValue")] + public long? CurrentValue { get; private set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/VirtualNetworkRule.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/VirtualNetworkRule.cs new file mode 100644 index 000000000000..6a983d6d5ad6 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Models/VirtualNetworkRule.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Virtual Network ACL Rule object + /// + public partial class VirtualNetworkRule + { + /// + /// Initializes a new instance of the VirtualNetworkRule class. + /// + public VirtualNetworkRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualNetworkRule class. + /// + /// Resource ID of a subnet, for example: + /// /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. + /// Create firewall rule + /// before the virtual network has vnet service endpoint + /// enabled. + public VirtualNetworkRule(string id = default(string), bool? ignoreMissingVNetServiceEndpoint = default(bool?)) + { + Id = id; + IgnoreMissingVNetServiceEndpoint = ignoreMissingVNetServiceEndpoint; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource ID of a subnet, for example: + /// /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets create firewall rule before the virtual network has + /// vnet service endpoint enabled. + /// + [JsonProperty(PropertyName = "ignoreMissingVNetServiceEndpoint")] + public bool? IgnoreMissingVNetServiceEndpoint { get; set; } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperations.cs new file mode 100644 index 000000000000..572d2c085013 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperations.cs @@ -0,0 +1,3097 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MongoDBResourcesOperations operations. + /// + internal partial class MongoDBResourcesOperations : IServiceOperations, IMongoDBResourcesOperations + { + /// + /// Initializes a new instance of the MongoDBResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MongoDBResourcesOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Lists the MongoDB databases under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMongoDBDatabasesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMongoDBDatabases", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the MongoDB databases under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetMongoDBDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateMongoDBDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteMongoDBDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the MongoDB database under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetMongoDBDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetMongoDBDatabaseThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the MongoDB collection under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMongoDBCollectionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMongoDBCollections", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the MongoDB collection under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (collectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("collectionName", collectionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetMongoDBCollection", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{collectionName}", System.Uri.EscapeDataString(collectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateMongoDBCollectionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteMongoDBCollectionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the MongoDB collection under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetMongoDBCollectionThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (collectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("collectionName", collectionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetMongoDBCollectionThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{collectionName}", System.Uri.EscapeDataString(collectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// collection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateMongoDBCollectionThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateMongoDBCollectionThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (createUpdateMongoDBDatabaseParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateMongoDBDatabaseParameters"); + } + if (createUpdateMongoDBDatabaseParameters != null) + { + createUpdateMongoDBDatabaseParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateMongoDBDatabaseParameters", createUpdateMongoDBDatabaseParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateMongoDBDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateMongoDBDatabaseParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateMongoDBDatabaseParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteMongoDBDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteMongoDBDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateMongoDBDatabaseThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (collectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionName"); + } + if (createUpdateMongoDBCollectionParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateMongoDBCollectionParameters"); + } + if (createUpdateMongoDBCollectionParameters != null) + { + createUpdateMongoDBCollectionParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("collectionName", collectionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateMongoDBCollectionParameters", createUpdateMongoDBCollectionParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateMongoDBCollection", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{collectionName}", System.Uri.EscapeDataString(collectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateMongoDBCollectionParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateMongoDBCollectionParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteMongoDBCollectionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (collectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("collectionName", collectionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteMongoDBCollection", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{collectionName}", System.Uri.EscapeDataString(collectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// collection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateMongoDBCollectionThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (collectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("collectionName", collectionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateMongoDBCollectionThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{collectionName}", System.Uri.EscapeDataString(collectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..60840ef04d2a --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/MongoDBResourcesOperationsExtensions.cs @@ -0,0 +1,953 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MongoDBResourcesOperations. + /// + public static partial class MongoDBResourcesOperationsExtensions + { + /// + /// Lists the MongoDB databases under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListMongoDBDatabases(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName) + { + return operations.ListMongoDBDatabasesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the MongoDB databases under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMongoDBDatabasesAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMongoDBDatabasesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the MongoDB databases under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static MongoDBDatabaseGetResults GetMongoDBDatabase(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.GetMongoDBDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Gets the MongoDB databases under an existing Azure Cosmos DB database + /// account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task GetMongoDBDatabaseAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetMongoDBDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + public static MongoDBDatabaseGetResults CreateUpdateMongoDBDatabase(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters) + { + return operations.CreateUpdateMongoDBDatabaseAsync(resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateMongoDBDatabaseAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateMongoDBDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static void DeleteMongoDBDatabase(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + operations.DeleteMongoDBDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteMongoDBDatabaseAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteMongoDBDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the MongoDB database under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static ThroughputSettingsGetResults GetMongoDBDatabaseThroughput(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.GetMongoDBDatabaseThroughputAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the MongoDB database under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task GetMongoDBDatabaseThroughputAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetMongoDBDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// database. + /// + public static ThroughputSettingsGetResults UpdateMongoDBDatabaseThroughput(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateMongoDBDatabaseThroughputAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// database. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateMongoDBDatabaseThroughputAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the MongoDB collection under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static IEnumerable ListMongoDBCollections(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.ListMongoDBCollectionsAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Lists the MongoDB collection under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMongoDBCollectionsAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMongoDBCollectionsWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the MongoDB collection under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + public static MongoDBCollectionGetResults GetMongoDBCollection(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName) + { + return operations.GetMongoDBCollectionAsync(resourceGroupName, accountName, databaseName, collectionName).GetAwaiter().GetResult(); + } + + /// + /// Gets the MongoDB collection under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The cancellation token. + /// + public static async Task GetMongoDBCollectionAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetMongoDBCollectionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + public static MongoDBCollectionGetResults CreateUpdateMongoDBCollection(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters) + { + return operations.CreateUpdateMongoDBCollectionAsync(resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateMongoDBCollectionAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateMongoDBCollectionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + public static void DeleteMongoDBCollection(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName) + { + operations.DeleteMongoDBCollectionAsync(resourceGroupName, accountName, databaseName, collectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteMongoDBCollectionAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteMongoDBCollectionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the MongoDB collection under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + public static ThroughputSettingsGetResults GetMongoDBCollectionThroughput(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName) + { + return operations.GetMongoDBCollectionThroughputAsync(resourceGroupName, accountName, databaseName, collectionName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the MongoDB collection under an existing Azure + /// Cosmos DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The cancellation token. + /// + public static async Task GetMongoDBCollectionThroughputAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetMongoDBCollectionThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// collection. + /// + public static ThroughputSettingsGetResults UpdateMongoDBCollectionThroughput(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateMongoDBCollectionThroughputAsync(resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// collection. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateMongoDBCollectionThroughputAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateMongoDBCollectionThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + public static MongoDBDatabaseGetResults BeginCreateUpdateMongoDBDatabase(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters) + { + return operations.BeginCreateUpdateMongoDBDatabaseAsync(resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or updates Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current MongoDB database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateMongoDBDatabaseAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, MongoDBDatabaseCreateUpdateParameters createUpdateMongoDBDatabaseParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateMongoDBDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static void BeginDeleteMongoDBDatabase(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + operations.BeginDeleteMongoDBDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteMongoDBDatabaseAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteMongoDBDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// database. + /// + public static ThroughputSettingsGetResults BeginUpdateMongoDBDatabaseThroughput(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateMongoDBDatabaseThroughputAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of the an Azure Cosmos DB MongoDB database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateMongoDBDatabaseThroughputAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + public static MongoDBCollectionGetResults BeginCreateUpdateMongoDBCollection(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters) + { + return operations.BeginCreateUpdateMongoDBCollectionAsync(resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB MongoDB Collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The parameters to provide for the current MongoDB Collection. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateMongoDBCollectionAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, MongoDBCollectionCreateUpdateParameters createUpdateMongoDBCollectionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateMongoDBCollectionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + public static void BeginDeleteMongoDBCollection(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName) + { + operations.BeginDeleteMongoDBCollectionAsync(resourceGroupName, accountName, databaseName, collectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB MongoDB Collection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteMongoDBCollectionAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteMongoDBCollectionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// collection. + /// + public static ThroughputSettingsGetResults BeginUpdateMongoDBCollectionThroughput(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateMongoDBCollectionThroughputAsync(resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update the RUs per second of an Azure Cosmos DB MongoDB collection + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB collection name. + /// + /// + /// The RUs per second of the parameters to provide for the current MongoDB + /// collection. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateMongoDBCollectionThroughputAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateMongoDBCollectionThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Operations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Operations.cs new file mode 100644 index 000000000000..80a1bfa52707 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/Operations.cs @@ -0,0 +1,392 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + internal partial class Operations : IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.DocumentDB/operations").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/OperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..e550f915f056 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/OperationsExtensions.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Cosmos DB Resource Provider operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperations.cs new file mode 100644 index 000000000000..da2ad2eddd02 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperations.cs @@ -0,0 +1,321 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeIdOperations operations. + /// + internal partial class PartitionKeyRangeIdOperations : IServiceOperations, IPartitionKeyRangeIdOperations + { + /// + /// Initializes a new instance of the PartitionKeyRangeIdOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartitionKeyRangeIdOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + if (partitionKeyRangeId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partitionKeyRangeId"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("partitionKeyRangeId", partitionKeyRangeId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + _url = _url.Replace("{partitionKeyRangeId}", System.Uri.EscapeDataString(partitionKeyRangeId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperationsExtensions.cs new file mode 100644 index 000000000000..1b6470299e2c --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdOperationsExtensions.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartitionKeyRangeIdOperations. + /// + public static partial class PartitionKeyRangeIdOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IPartitionKeyRangeIdOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, databaseRid, collectionRid, partitionKeyRangeId, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IPartitionKeyRangeIdOperations operations, string resourceGroupName, string accountName, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, databaseRid, collectionRid, partitionKeyRangeId, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperations.cs new file mode 100644 index 000000000000..ebaac88f5b0b --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperations.cs @@ -0,0 +1,330 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeIdRegionOperations operations. + /// + internal partial class PartitionKeyRangeIdRegionOperations : IServiceOperations, IPartitionKeyRangeIdRegionOperations + { + /// + /// Initializes a new instance of the PartitionKeyRangeIdRegionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartitionKeyRangeIdRegionOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id and region. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (region == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "region"); + } + if (databaseRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseRid"); + } + if (collectionRid == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "collectionRid"); + } + if (partitionKeyRangeId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partitionKeyRangeId"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("region", region); + tracingParameters.Add("databaseRid", databaseRid); + tracingParameters.Add("collectionRid", collectionRid); + tracingParameters.Add("partitionKeyRangeId", partitionKeyRangeId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{region}", System.Uri.EscapeDataString(region)); + _url = _url.Replace("{databaseRid}", System.Uri.EscapeDataString(databaseRid)); + _url = _url.Replace("{collectionRid}", System.Uri.EscapeDataString(collectionRid)); + _url = _url.Replace("{partitionKeyRangeId}", System.Uri.EscapeDataString(partitionKeyRangeId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperationsExtensions.cs new file mode 100644 index 000000000000..ac124a6a5830 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PartitionKeyRangeIdRegionOperationsExtensions.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartitionKeyRangeIdRegionOperations. + /// + public static partial class PartitionKeyRangeIdRegionOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id and region. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IPartitionKeyRangeIdRegionOperations operations, string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, region, databaseRid, collectionRid, partitionKeyRangeId, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given + /// partition key range id and region. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB region, with spaces between words and each word capitalized. + /// + /// + /// Cosmos DB database rid. + /// + /// + /// Cosmos DB collection rid. + /// + /// + /// Partition Key Range Id for which to get data. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IPartitionKeyRangeIdRegionOperations operations, string resourceGroupName, string accountName, string region, string databaseRid, string collectionRid, string partitionKeyRangeId, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, region, databaseRid, collectionRid, partitionKeyRangeId, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperations.cs new file mode 100644 index 000000000000..4809860e48b5 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperations.cs @@ -0,0 +1,294 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileOperations operations. + /// + internal partial class PercentileOperations : IServiceOperations, IPercentileOperations + { + /// + /// Initializes a new instance of the PercentileOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PercentileOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account. This url is only for PBS and Replication Latency data + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperationsExtensions.cs new file mode 100644 index 000000000000..324c53ca45ae --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileOperationsExtensions.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PercentileOperations. + /// + public static partial class PercentileOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account. This url is only for PBS and Replication Latency data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IPercentileOperations operations, string resourceGroupName, string accountName, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given database + /// account. This url is only for PBS and Replication Latency data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IPercentileOperations operations, string resourceGroupName, string accountName, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperations.cs new file mode 100644 index 000000000000..7a9a128b46ff --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperations.cs @@ -0,0 +1,315 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileSourceTargetOperations operations. + /// + internal partial class PercentileSourceTargetOperations : IServiceOperations, IPercentileSourceTargetOperations + { + /// + /// Initializes a new instance of the PercentileSourceTargetOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PercentileSourceTargetOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// 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 + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Source region from which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// Target region to which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string sourceRegion, string targetRegion, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (sourceRegion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "sourceRegion"); + } + if (targetRegion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "targetRegion"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("sourceRegion", sourceRegion); + tracingParameters.Add("targetRegion", targetRegion); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{sourceRegion}", System.Uri.EscapeDataString(sourceRegion)); + _url = _url.Replace("{targetRegion}", System.Uri.EscapeDataString(targetRegion)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperationsExtensions.cs new file mode 100644 index 000000000000..05046e5040e0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileSourceTargetOperationsExtensions.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PercentileSourceTargetOperations. + /// + public static partial class PercentileSourceTargetOperationsExtensions + { + /// + /// 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 + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Source region from which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// Target region to which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IPercentileSourceTargetOperations operations, string resourceGroupName, string accountName, string sourceRegion, string targetRegion, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, sourceRegion, targetRegion, filter).GetAwaiter().GetResult(); + } + + /// + /// 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 + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Source region from which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// Target region to which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IPercentileSourceTargetOperations operations, string resourceGroupName, string accountName, string sourceRegion, string targetRegion, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, sourceRegion, targetRegion, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperations.cs new file mode 100644 index 000000000000..6123596261e7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperations.cs @@ -0,0 +1,304 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileTargetOperations operations. + /// + internal partial class PercentileTargetOperations : IServiceOperations, IPercentileTargetOperations + { + /// + /// Initializes a new instance of the PercentileTargetOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PercentileTargetOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Retrieves the metrics determined by the given filter for the given account + /// target region. This url is only for PBS and Replication Latency data + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Target region to which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListMetricsWithHttpMessagesAsync(string resourceGroupName, string accountName, string targetRegion, string filter, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (targetRegion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "targetRegion"); + } + if (filter == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "filter"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("targetRegion", targetRegion); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{targetRegion}", System.Uri.EscapeDataString(targetRegion)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperationsExtensions.cs new file mode 100644 index 000000000000..02fa98041f91 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PercentileTargetOperationsExtensions.cs @@ -0,0 +1,89 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PercentileTargetOperations. + /// + public static partial class PercentileTargetOperationsExtensions + { + /// + /// Retrieves the metrics determined by the given filter for the given account + /// target region. This url is only for PBS and Replication Latency data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Target region to which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// 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. + /// + public static IEnumerable ListMetrics(this IPercentileTargetOperations operations, string resourceGroupName, string accountName, string targetRegion, string filter) + { + return operations.ListMetricsAsync(resourceGroupName, accountName, targetRegion, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the metrics determined by the given filter for the given account + /// target region. This url is only for PBS and Replication Latency data + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Target region to which data is written. Cosmos DB region, with spaces + /// between words and each word capitalized. + /// + /// + /// 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. + /// + /// + /// The cancellation token. + /// + public static async Task> ListMetricsAsync(this IPercentileTargetOperations operations, string resourceGroupName, string accountName, string targetRegion, string filter, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricsWithHttpMessagesAsync(resourceGroupName, accountName, targetRegion, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..8d9863acf765 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperations.cs @@ -0,0 +1,1039 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + internal partial class PrivateEndpointConnectionsOperations : IServiceOperations, IPrivateEndpointConnectionsOperations + { + /// + /// Initializes a new instance of the PrivateEndpointConnectionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateEndpointConnectionsOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// List all private endpoint connections on a Cosmos DB account. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByDatabaseAccountWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-08-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByDatabaseAccount", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + string apiVersion = "2019-08-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2019-08-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + string apiVersion = "2019-08-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs new file mode 100644 index 000000000000..de8cdf105f26 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs @@ -0,0 +1,299 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateEndpointConnectionsOperations. + /// + public static partial class PrivateEndpointConnectionsOperationsExtensions + { + /// + /// List all private endpoint connections on a Cosmos DB account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListByDatabaseAccount(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName) + { + return operations.ListByDatabaseAccountAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// List all private endpoint connections on a Cosmos DB account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByDatabaseAccountAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByDatabaseAccountWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName) + { + return operations.GetAsync(resourceGroupName, accountName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Gets a private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + public static PrivateEndpointConnection CreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, accountName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + public static void Delete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName) + { + operations.DeleteAsync(resourceGroupName, accountName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + public static PrivateEndpointConnection BeginCreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, accountName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + public static void BeginDelete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName) + { + operations.BeginDeleteAsync(resourceGroupName, accountName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..673b9aebd2c7 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperations.cs @@ -0,0 +1,513 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + internal partial class PrivateLinkResourcesOperations : IServiceOperations, IPrivateLinkResourcesOperations + { + /// + /// Initializes a new instance of the PrivateLinkResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateLinkResourcesOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Gets the private link resources that need to be created for a Cosmos DB + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByDatabaseAccountWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-08-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByDatabaseAccount", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the private link resources that need to be created for a Cosmos DB + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private link resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string accountName, string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (groupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupName"); + } + string apiVersion = "2019-08-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("groupName", groupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{groupName}", System.Uri.EscapeDataString(groupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..05fb6d02a0e4 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkResourcesOperations. + /// + public static partial class PrivateLinkResourcesOperationsExtensions + { + /// + /// Gets the private link resources that need to be created for a Cosmos DB + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListByDatabaseAccount(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string accountName) + { + return operations.ListByDatabaseAccountAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources that need to be created for a Cosmos DB + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByDatabaseAccountAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByDatabaseAccountWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the private link resources that need to be created for a Cosmos DB + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private link resource. + /// + public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string accountName, string groupName) + { + return operations.GetAsync(resourceGroupName, accountName, groupName).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources that need to be created for a Cosmos DB + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private link resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string accountName, string groupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, accountName, groupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SdkInfo_CosmosDBManagementClient.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SdkInfo_CosmosDBManagementClient.cs new file mode 100644 index 000000000000..45cb8a146a45 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SdkInfo_CosmosDBManagementClient.cs @@ -0,0 +1,46 @@ + +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_CosmosDBManagementClient + { + get + { + return new Tuple[] + { + new Tuple("DocumentDB", "CassandraResources", "2019-12-12"), + new Tuple("DocumentDB", "Collection", "2019-12-12"), + new Tuple("DocumentDB", "CollectionPartition", "2019-12-12"), + new Tuple("DocumentDB", "CollectionPartitionRegion", "2019-12-12"), + new Tuple("DocumentDB", "CollectionRegion", "2019-12-12"), + new Tuple("DocumentDB", "Database", "2019-12-12"), + new Tuple("DocumentDB", "DatabaseAccountRegion", "2019-12-12"), + new Tuple("DocumentDB", "DatabaseAccounts", "2019-12-12"), + new Tuple("DocumentDB", "GremlinResources", "2019-12-12"), + new Tuple("DocumentDB", "MongoDBResources", "2019-12-12"), + new Tuple("DocumentDB", "Operations", "2019-12-12"), + new Tuple("DocumentDB", "PartitionKeyRangeId", "2019-12-12"), + new Tuple("DocumentDB", "PartitionKeyRangeIdRegion", "2019-12-12"), + new Tuple("DocumentDB", "Percentile", "2019-12-12"), + new Tuple("DocumentDB", "PercentileSourceTarget", "2019-12-12"), + new Tuple("DocumentDB", "PercentileTarget", "2019-12-12"), + new Tuple("DocumentDB", "PrivateEndpointConnections", "2019-08-01-preview"), + new Tuple("DocumentDB", "PrivateLinkResources", "2019-08-01-preview"), + new Tuple("DocumentDB", "SqlResources", "2019-12-12"), + new Tuple("DocumentDB", "TableResources", "2019-12-12"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperations.cs new file mode 100644 index 000000000000..6c35166a3db1 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperations.cs @@ -0,0 +1,6269 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SqlResourcesOperations operations. + /// + internal partial class SqlResourcesOperations : IServiceOperations, ISqlResourcesOperations + { + /// + /// Initializes a new instance of the SqlResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SqlResourcesOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Lists the SQL databases under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListSqlDatabasesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListSqlDatabases", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the SQL database under an existing Azure Cosmos DB database account + /// with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSqlDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateSqlDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateSqlDatabaseParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteSqlDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the SQL database under an existing Azure Cosmos + /// DB database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSqlDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSqlDatabaseThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateSqlDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateSqlDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the SQL container under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListSqlContainersWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListSqlContainers", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the SQL container under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSqlContainer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateSqlContainerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, createUpdateSqlContainerParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteSqlContainerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the SQL container under an existing Azure Cosmos + /// DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSqlContainerThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSqlContainerThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateSqlContainerThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateSqlContainerThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the SQL storedProcedure under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListSqlStoredProceduresWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListSqlStoredProcedures", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the SQL storedProcedure under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (storedProcedureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "storedProcedureName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("storedProcedureName", storedProcedureName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSqlStoredProcedure", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{storedProcedureName}", System.Uri.EscapeDataString(storedProcedureName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateSqlStoredProcedureWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteSqlStoredProcedureWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the SQL userDefinedFunction under an existing Azure Cosmos DB + /// database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListSqlUserDefinedFunctionsWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListSqlUserDefinedFunctions", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (userDefinedFunctionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userDefinedFunctionName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("userDefinedFunctionName", userDefinedFunctionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSqlUserDefinedFunction", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{userDefinedFunctionName}", System.Uri.EscapeDataString(userDefinedFunctionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSqlUserDefinedFunctionParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteSqlUserDefinedFunctionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Lists the SQL trigger under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListSqlTriggersWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListSqlTriggers", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the SQL trigger under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (triggerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "triggerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("triggerName", triggerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSqlTrigger", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{triggerName}", System.Uri.EscapeDataString(triggerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateSqlTriggerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSqlTriggerParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteSqlTriggerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (createUpdateSqlDatabaseParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateSqlDatabaseParameters"); + } + if (createUpdateSqlDatabaseParameters != null) + { + createUpdateSqlDatabaseParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateSqlDatabaseParameters", createUpdateSqlDatabaseParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateSqlDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateSqlDatabaseParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateSqlDatabaseParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteSqlDatabaseWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteSqlDatabase", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateSqlDatabaseThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateSqlDatabaseThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (createUpdateSqlContainerParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateSqlContainerParameters"); + } + if (createUpdateSqlContainerParameters != null) + { + createUpdateSqlContainerParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateSqlContainerParameters", createUpdateSqlContainerParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateSqlContainer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateSqlContainerParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateSqlContainerParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteSqlContainerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteSqlContainer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateSqlContainerThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateSqlContainerThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (storedProcedureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "storedProcedureName"); + } + if (createUpdateSqlStoredProcedureParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateSqlStoredProcedureParameters"); + } + if (createUpdateSqlStoredProcedureParameters != null) + { + createUpdateSqlStoredProcedureParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("storedProcedureName", storedProcedureName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateSqlStoredProcedureParameters", createUpdateSqlStoredProcedureParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateSqlStoredProcedure", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{storedProcedureName}", System.Uri.EscapeDataString(storedProcedureName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateSqlStoredProcedureParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateSqlStoredProcedureParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteSqlStoredProcedureWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (storedProcedureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "storedProcedureName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("storedProcedureName", storedProcedureName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteSqlStoredProcedure", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{storedProcedureName}", System.Uri.EscapeDataString(storedProcedureName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (userDefinedFunctionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userDefinedFunctionName"); + } + if (createUpdateSqlUserDefinedFunctionParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateSqlUserDefinedFunctionParameters"); + } + if (createUpdateSqlUserDefinedFunctionParameters != null) + { + createUpdateSqlUserDefinedFunctionParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("userDefinedFunctionName", userDefinedFunctionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateSqlUserDefinedFunctionParameters", createUpdateSqlUserDefinedFunctionParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateSqlUserDefinedFunction", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{userDefinedFunctionName}", System.Uri.EscapeDataString(userDefinedFunctionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateSqlUserDefinedFunctionParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateSqlUserDefinedFunctionParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteSqlUserDefinedFunctionWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (userDefinedFunctionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userDefinedFunctionName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("userDefinedFunctionName", userDefinedFunctionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteSqlUserDefinedFunction", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{userDefinedFunctionName}", System.Uri.EscapeDataString(userDefinedFunctionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (triggerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "triggerName"); + } + if (createUpdateSqlTriggerParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateSqlTriggerParameters"); + } + if (createUpdateSqlTriggerParameters != null) + { + createUpdateSqlTriggerParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("triggerName", triggerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateSqlTriggerParameters", createUpdateSqlTriggerParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateSqlTrigger", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{triggerName}", System.Uri.EscapeDataString(triggerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateSqlTriggerParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateSqlTriggerParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteSqlTriggerWithHttpMessagesAsync(string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (triggerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "triggerName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("triggerName", triggerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteSqlTrigger", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{triggerName}", System.Uri.EscapeDataString(triggerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..65a996c6ab4c --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/SqlResourcesOperationsExtensions.cs @@ -0,0 +1,1999 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SqlResourcesOperations. + /// + public static partial class SqlResourcesOperationsExtensions + { + /// + /// Lists the SQL databases under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListSqlDatabases(this ISqlResourcesOperations operations, string resourceGroupName, string accountName) + { + return operations.ListSqlDatabasesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the SQL databases under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListSqlDatabasesAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListSqlDatabasesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the SQL database under an existing Azure Cosmos DB database account + /// with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static SqlDatabaseGetResults GetSqlDatabase(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.GetSqlDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Gets the SQL database under an existing Azure Cosmos DB database account + /// with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task GetSqlDatabaseAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSqlDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + public static SqlDatabaseGetResults CreateUpdateSqlDatabase(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters) + { + return operations.CreateUpdateSqlDatabaseAsync(resourceGroupName, accountName, databaseName, createUpdateSqlDatabaseParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateSqlDatabaseAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateSqlDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateSqlDatabaseParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static void DeleteSqlDatabase(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + operations.DeleteSqlDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteSqlDatabaseAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteSqlDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the SQL database under an existing Azure Cosmos + /// DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static ThroughputSettingsGetResults GetSqlDatabaseThroughput(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.GetSqlDatabaseThroughputAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the SQL database under an existing Azure Cosmos + /// DB database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task GetSqlDatabaseThroughputAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSqlDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + public static ThroughputSettingsGetResults UpdateSqlDatabaseThroughput(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateSqlDatabaseThroughputAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateSqlDatabaseThroughputAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateSqlDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the SQL container under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static IEnumerable ListSqlContainers(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + return operations.ListSqlContainersAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Lists the SQL container under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListSqlContainersAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListSqlContainersWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the SQL container under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + public static SqlContainerGetResults GetSqlContainer(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName) + { + return operations.GetSqlContainerAsync(resourceGroupName, accountName, databaseName, containerName).GetAwaiter().GetResult(); + } + + /// + /// Gets the SQL container under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The cancellation token. + /// + public static async Task GetSqlContainerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSqlContainerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + public static SqlContainerGetResults CreateUpdateSqlContainer(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters) + { + return operations.CreateUpdateSqlContainerAsync(resourceGroupName, accountName, databaseName, containerName, createUpdateSqlContainerParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateSqlContainerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateSqlContainerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, createUpdateSqlContainerParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + public static void DeleteSqlContainer(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName) + { + operations.DeleteSqlContainerAsync(resourceGroupName, accountName, databaseName, containerName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteSqlContainerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteSqlContainerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the SQL container under an existing Azure Cosmos + /// DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + public static ThroughputSettingsGetResults GetSqlContainerThroughput(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName) + { + return operations.GetSqlContainerThroughputAsync(resourceGroupName, accountName, databaseName, containerName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the SQL container under an existing Azure Cosmos + /// DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The cancellation token. + /// + public static async Task GetSqlContainerThroughputAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSqlContainerThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + public static ThroughputSettingsGetResults UpdateSqlContainerThroughput(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateSqlContainerThroughputAsync(resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateSqlContainerThroughputAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateSqlContainerThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the SQL storedProcedure under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + public static IEnumerable ListSqlStoredProcedures(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName) + { + return operations.ListSqlStoredProceduresAsync(resourceGroupName, accountName, databaseName, containerName).GetAwaiter().GetResult(); + } + + /// + /// Lists the SQL storedProcedure under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListSqlStoredProceduresAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListSqlStoredProceduresWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the SQL storedProcedure under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + public static SqlStoredProcedureGetResults GetSqlStoredProcedure(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName) + { + return operations.GetSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).GetAwaiter().GetResult(); + } + + /// + /// Gets the SQL storedProcedure under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The cancellation token. + /// + public static async Task GetSqlStoredProcedureAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSqlStoredProcedureWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + public static SqlStoredProcedureGetResults CreateUpdateSqlStoredProcedure(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) + { + return operations.CreateUpdateSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateSqlStoredProcedureAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateSqlStoredProcedureWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + public static void DeleteSqlStoredProcedure(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName) + { + operations.DeleteSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteSqlStoredProcedureAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteSqlStoredProcedureWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists the SQL userDefinedFunction under an existing Azure Cosmos DB + /// database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + public static IEnumerable ListSqlUserDefinedFunctions(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName) + { + return operations.ListSqlUserDefinedFunctionsAsync(resourceGroupName, accountName, databaseName, containerName).GetAwaiter().GetResult(); + } + + /// + /// Lists the SQL userDefinedFunction under an existing Azure Cosmos DB + /// database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListSqlUserDefinedFunctionsAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListSqlUserDefinedFunctionsWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + public static SqlUserDefinedFunctionGetResults GetSqlUserDefinedFunction(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName) + { + return operations.GetSqlUserDefinedFunctionAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName).GetAwaiter().GetResult(); + } + + /// + /// Gets the SQL userDefinedFunction under an existing Azure Cosmos DB database + /// account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The cancellation token. + /// + public static async Task GetSqlUserDefinedFunctionAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSqlUserDefinedFunctionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + public static SqlUserDefinedFunctionGetResults CreateUpdateSqlUserDefinedFunction(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters) + { + return operations.CreateUpdateSqlUserDefinedFunctionAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSqlUserDefinedFunctionParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateSqlUserDefinedFunctionAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSqlUserDefinedFunctionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + public static void DeleteSqlUserDefinedFunction(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName) + { + operations.DeleteSqlUserDefinedFunctionAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteSqlUserDefinedFunctionAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteSqlUserDefinedFunctionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists the SQL trigger under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + public static IEnumerable ListSqlTriggers(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName) + { + return operations.ListSqlTriggersAsync(resourceGroupName, accountName, databaseName, containerName).GetAwaiter().GetResult(); + } + + /// + /// Lists the SQL trigger under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListSqlTriggersAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListSqlTriggersWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the SQL trigger under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + public static SqlTriggerGetResults GetSqlTrigger(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName) + { + return operations.GetSqlTriggerAsync(resourceGroupName, accountName, databaseName, containerName, triggerName).GetAwaiter().GetResult(); + } + + /// + /// Gets the SQL trigger under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The cancellation token. + /// + public static async Task GetSqlTriggerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSqlTriggerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + public static SqlTriggerGetResults CreateUpdateSqlTrigger(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters) + { + return operations.CreateUpdateSqlTriggerAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSqlTriggerParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateSqlTriggerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateSqlTriggerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSqlTriggerParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + public static void DeleteSqlTrigger(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName) + { + operations.DeleteSqlTriggerAsync(resourceGroupName, accountName, databaseName, containerName, triggerName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteSqlTriggerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteSqlTriggerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + public static SqlDatabaseGetResults BeginCreateUpdateSqlDatabase(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters) + { + return operations.BeginCreateUpdateSqlDatabaseAsync(resourceGroupName, accountName, databaseName, createUpdateSqlDatabaseParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the current SQL database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateSqlDatabaseAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, SqlDatabaseCreateUpdateParameters createUpdateSqlDatabaseParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateSqlDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, createUpdateSqlDatabaseParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + public static void BeginDeleteSqlDatabase(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName) + { + operations.BeginDeleteSqlDatabaseAsync(resourceGroupName, accountName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteSqlDatabaseAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteSqlDatabaseWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + public static ThroughputSettingsGetResults BeginUpdateSqlDatabaseThroughput(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateSqlDatabaseThroughputAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL database + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateSqlDatabaseThroughputAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateSqlDatabaseThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + public static SqlContainerGetResults BeginCreateUpdateSqlContainer(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters) + { + return operations.BeginCreateUpdateSqlContainerAsync(resourceGroupName, accountName, databaseName, containerName, createUpdateSqlContainerParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the current SQL container. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateSqlContainerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, SqlContainerCreateUpdateParameters createUpdateSqlContainerParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateSqlContainerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, createUpdateSqlContainerParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + public static void BeginDeleteSqlContainer(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName) + { + operations.BeginDeleteSqlContainerAsync(resourceGroupName, accountName, databaseName, containerName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL container. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteSqlContainerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteSqlContainerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + public static ThroughputSettingsGetResults BeginUpdateSqlContainerThroughput(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateSqlContainerThroughputAsync(resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB SQL container + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// The parameters to provide for the RUs per second of the current SQL + /// container. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateSqlContainerThroughputAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateSqlContainerThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + public static SqlStoredProcedureGetResults BeginCreateUpdateSqlStoredProcedure(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters) + { + return operations.BeginCreateUpdateSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL storedProcedure + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The parameters to provide for the current SQL storedProcedure. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateSqlStoredProcedureAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, SqlStoredProcedureCreateUpdateParameters createUpdateSqlStoredProcedureParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateSqlStoredProcedureWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSqlStoredProcedureParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + public static void BeginDeleteSqlStoredProcedure(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName) + { + operations.BeginDeleteSqlStoredProcedureAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL storedProcedure. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB storedProcedure name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteSqlStoredProcedureAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string storedProcedureName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteSqlStoredProcedureWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, storedProcedureName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + public static SqlUserDefinedFunctionGetResults BeginCreateUpdateSqlUserDefinedFunction(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters) + { + return operations.BeginCreateUpdateSqlUserDefinedFunctionAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSqlUserDefinedFunctionParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL userDefinedFunction + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The parameters to provide for the current SQL userDefinedFunction. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateSqlUserDefinedFunctionAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, SqlUserDefinedFunctionCreateUpdateParameters createUpdateSqlUserDefinedFunctionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSqlUserDefinedFunctionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + public static void BeginDeleteSqlUserDefinedFunction(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName) + { + operations.BeginDeleteSqlUserDefinedFunctionAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL userDefinedFunction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB userDefinedFunction name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteSqlUserDefinedFunctionAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string userDefinedFunctionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteSqlUserDefinedFunctionWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + public static SqlTriggerGetResults BeginCreateUpdateSqlTrigger(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters) + { + return operations.BeginCreateUpdateSqlTriggerAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSqlTriggerParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB SQL trigger + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The parameters to provide for the current SQL trigger. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateSqlTriggerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, SqlTriggerCreateUpdateParameters createUpdateSqlTriggerParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateSqlTriggerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSqlTriggerParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + public static void BeginDeleteSqlTrigger(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName) + { + operations.BeginDeleteSqlTriggerAsync(resourceGroupName, accountName, databaseName, containerName, triggerName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB SQL trigger. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB database name. + /// + /// + /// Cosmos DB container name. + /// + /// + /// Cosmos DB trigger name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteSqlTriggerAsync(this ISqlResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string containerName, string triggerName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteSqlTriggerWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, containerName, triggerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperations.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperations.cs new file mode 100644 index 000000000000..ab5de031dfc8 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperations.cs @@ -0,0 +1,1541 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TableResourcesOperations operations. + /// + internal partial class TableResourcesOperations : IServiceOperations, ITableResourcesOperations + { + /// + /// Initializes a new instance of the TableResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TableResourcesOperations(CosmosDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBManagementClient + /// + public CosmosDBManagementClient Client { get; private set; } + + /// + /// Lists the Tables under an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListTablesWithHttpMessagesAsync(string resourceGroupName, string accountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListTables", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the Tables under an existing Azure Cosmos DB database account with the + /// provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetTable", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateUpdateTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateUpdateTableWithHttpMessagesAsync(resourceGroupName, accountName, tableName, createUpdateTableParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteTableWithHttpMessagesAsync(resourceGroupName, accountName, tableName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the RUs per second of the Table under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetTableThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current Table. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, tableName, updateThroughputParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateUpdateTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + if (createUpdateTableParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createUpdateTableParameters"); + } + if (createUpdateTableParameters != null) + { + createUpdateTableParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("createUpdateTableParameters", createUpdateTableParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateUpdateTable", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createUpdateTableParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createUpdateTableParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteTableWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteTable", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current Table. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateTableThroughputWithHttpMessagesAsync(string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (accountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "accountName"); + } + if (accountName != null) + { + if (accountName.Length > 50) + { + throw new ValidationException(ValidationRules.MaxLength, "accountName", 50); + } + if (accountName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "accountName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(accountName, "^[a-z0-9]+(-[a-z0-9]+)*")) + { + throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-z0-9]+(-[a-z0-9]+)*"); + } + } + if (tableName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tableName"); + } + if (updateThroughputParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "updateThroughputParameters"); + } + if (updateThroughputParameters != null) + { + updateThroughputParameters.Validate(); + } + string apiVersion = "2019-12-12"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("accountName", accountName); + tracingParameters.Add("tableName", tableName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("updateThroughputParameters", updateThroughputParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateTableThroughput", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{accountName}", System.Uri.EscapeDataString(accountName)); + _url = _url.Replace("{tableName}", System.Uri.EscapeDataString(tableName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(updateThroughputParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(updateThroughputParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperationsExtensions.cs b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..327bf09baaa0 --- /dev/null +++ b/sdk/cosmosdb/Microsoft.Azure.Management.CosmosDB/src/Generated/TableResourcesOperationsExtensions.cs @@ -0,0 +1,457 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TableResourcesOperations. + /// + public static partial class TableResourcesOperationsExtensions + { + /// + /// Lists the Tables under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static IEnumerable ListTables(this ITableResourcesOperations operations, string resourceGroupName, string accountName) + { + return operations.ListTablesAsync(resourceGroupName, accountName).GetAwaiter().GetResult(); + } + + /// + /// Lists the Tables under an existing Azure Cosmos DB database account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListTablesAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListTablesWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the Tables under an existing Azure Cosmos DB database account with the + /// provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + public static TableGetResults GetTable(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName) + { + return operations.GetTableAsync(resourceGroupName, accountName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Gets the Tables under an existing Azure Cosmos DB database account with the + /// provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task GetTableAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetTableWithHttpMessagesAsync(resourceGroupName, accountName, tableName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + public static TableGetResults CreateUpdateTable(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters) + { + return operations.CreateUpdateTableAsync(resourceGroupName, accountName, tableName, createUpdateTableParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + /// + /// The cancellation token. + /// + public static async Task CreateUpdateTableAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateUpdateTableWithHttpMessagesAsync(resourceGroupName, accountName, tableName, createUpdateTableParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + public static void DeleteTable(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName) + { + operations.DeleteTableAsync(resourceGroupName, accountName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteTableAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteTableWithHttpMessagesAsync(resourceGroupName, accountName, tableName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the RUs per second of the Table under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + public static ThroughputSettingsGetResults GetTableThroughput(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName) + { + return operations.GetTableThroughputAsync(resourceGroupName, accountName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Gets the RUs per second of the Table under an existing Azure Cosmos DB + /// database account with the provided name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task GetTableThroughputAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, tableName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current Table. + /// + public static ThroughputSettingsGetResults UpdateTableThroughput(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.UpdateTableThroughputAsync(resourceGroupName, accountName, tableName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current Table. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateTableThroughputAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, tableName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + public static TableGetResults BeginCreateUpdateTable(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters) + { + return operations.BeginCreateUpdateTableAsync(resourceGroupName, accountName, tableName, createUpdateTableParameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the current Table. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateUpdateTableAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, TableCreateUpdateParameters createUpdateTableParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateUpdateTableWithHttpMessagesAsync(resourceGroupName, accountName, tableName, createUpdateTableParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + public static void BeginDeleteTable(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName) + { + operations.BeginDeleteTableAsync(resourceGroupName, accountName, tableName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Azure Cosmos DB Table. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteTableAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteTableWithHttpMessagesAsync(resourceGroupName, accountName, tableName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current Table. + /// + public static ThroughputSettingsGetResults BeginUpdateTableThroughput(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters) + { + return operations.BeginUpdateTableThroughputAsync(resourceGroupName, accountName, tableName, updateThroughputParameters).GetAwaiter().GetResult(); + } + + /// + /// Update RUs per second of an Azure Cosmos DB Table + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// Cosmos DB table name. + /// + /// + /// The parameters to provide for the RUs per second of the current Table. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateTableThroughputAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, tableName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}