From 2dbed7e7db5409948f67d5c229e3017fef62e9c1 Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Mon, 21 Oct 2019 12:29:20 -0700 Subject: [PATCH 1/9] Added Private Endpoint Cosmos DB Swagger spec --- ...smosDBPrivateEndpointConnectionDelete.json | 14 + .../CosmosDBPrivateEndpointConnectionGet.json | 28 + ...mosDBPrivateEndpointConnectionListGet.json | 46 + ...smosDBPrivateEndpointConnectionUpdate.json | 12 + .../privateEndpointConnection.json | 291 + .../generated/CassandraResources.cs | 2512 ++++++++ .../generated/CassandraResourcesExtensions.cs | 629 ++ .../resource-manager/generated/Collection.cs | 700 +++ .../generated/CollectionExtensions.cs | 199 + .../generated/CollectionPartition.cs | 493 ++ .../CollectionPartitionExtensions.cs | 149 + .../generated/CollectionPartitionRegion.cs | 283 + .../CollectionPartitionRegionExtensions.cs | 91 + .../generated/CollectionRegion.cs | 283 + .../generated/CollectionRegionExtensions.cs | 91 + .../resource-manager/generated/CosmosDB.cs | 286 + .../resource-manager/generated/Database.cs | 673 +++ .../generated/DatabaseAccountRegion.cs | 265 + .../DatabaseAccountRegionExtensions.cs | 79 + .../generated/DatabaseAccounts.cs | 3401 +++++++++++ .../generated/DatabaseAccountsExtensions.cs | 785 +++ .../generated/DatabaseExtensions.cs | 181 + .../generated/GremlinResources.cs | 2510 ++++++++ .../generated/GremlinResourcesExtensions.cs | 625 ++ .../generated/ICassandraResources.cs | 384 ++ .../resource-manager/generated/ICollection.cs | 128 + .../generated/ICollectionPartition.cs | 97 + .../generated/ICollectionPartitionRegion.cs | 64 + .../generated/ICollectionRegion.cs | 64 + .../resource-manager/generated/ICosmosDB.cs | 139 + .../resource-manager/generated/IDatabase.cs | 118 + .../generated/IDatabaseAccountRegion.cs | 58 + .../generated/IDatabaseAccounts.cs | 490 ++ .../generated/IGremlinResources.cs | 384 ++ .../generated/IMongoDBResources.cs | 384 ++ .../resource-manager/generated/IOperations.cs | 41 + .../generated/IPartitionKeyRangeId.cs | 63 + .../generated/IPartitionKeyRangeIdRegion.cs | 67 + .../resource-manager/generated/IPercentile.cs | 55 + .../generated/IPercentileSourceTarget.cs | 63 + .../generated/IPercentileTarget.cs | 59 + .../generated/IPrivateEndpointConnections.cs | 128 + .../generated/IPrivateLinkResources.cs | 77 + .../generated/ISqlResources.cs | 789 +++ .../generated/ITableResources.cs | 194 + .../generated/Models/ARMProxyResource.cs | 65 + .../generated/Models/ARMResourceProperties.cs | 82 + .../generated/Models/Capability.cs | 51 + ...CassandraKeyspaceCreateUpdateParameters.cs | 94 + .../Models/CassandraKeyspaceGetResults.cs | 104 + .../Models/CassandraKeyspaceListResult.cs | 53 + .../Models/CassandraKeyspaceResource.cs | 61 + .../generated/Models/CassandraPartitionKey.cs | 48 + .../generated/Models/CassandraSchema.cs | 65 + .../CassandraTableCreateUpdateParameters.cs | 94 + .../Models/CassandraTableGetResults.cs | 120 + .../Models/CassandraTableListResult.cs | 51 + .../Models/CassandraTableResource.cs | 79 + .../generated/Models/ClusterKey.cs | 58 + .../generated/Models/Column.cs | 57 + .../Models/ConflictResolutionMode.cs | 18 + .../Models/ConflictResolutionPolicy.cs | 69 + .../generated/Models/ConnectorOffer.cs | 17 + .../generated/Models/ConsistencyPolicy.cs | 111 + .../generated/Models/ContainerPartitionKey.cs | 62 + .../generated/Models/DataType.cs | 22 + .../Models/DatabaseAccountConnectionString.cs | 59 + .../DatabaseAccountCreateUpdateParameters.cs | 215 + .../Models/DatabaseAccountGetResults.cs | 263 + .../generated/Models/DatabaseAccountKind.cs | 19 + ...abaseAccountListConnectionStringsResult.cs | 53 + .../Models/DatabaseAccountListKeysResult.cs | 64 + .../DatabaseAccountListReadOnlyKeysResult.cs | 59 + .../Models/DatabaseAccountOfferType.cs | 50 + .../Models/DatabaseAccountPatchParameters.cs | 61 + .../DatabaseAccountRegenerateKeyParameters.cs | 66 + .../Models/DatabaseAccountsListResult.cs | 51 + .../Models/DefaultConsistencyLevel.cs | 74 + .../generated/Models/ErrorResponse.cs | 56 + .../Models/ErrorResponseException.cs | 58 + .../generated/Models/ExcludedPath.cs | 48 + .../Models/ExtendedResourceProperties.cs | 69 + .../generated/Models/FailoverPolicies.cs | 74 + .../generated/Models/FailoverPolicy.cs | 91 + .../GremlinDatabaseCreateUpdateParameters.cs | 94 + .../Models/GremlinDatabaseGetResults.cs | 102 + .../Models/GremlinDatabaseListResult.cs | 51 + .../Models/GremlinDatabaseResource.cs | 61 + .../GremlinGraphCreateUpdateParameters.cs | 94 + .../Models/GremlinGraphGetResults.cs | 152 + .../Models/GremlinGraphListResult.cs | 50 + .../generated/Models/GremlinGraphResource.cs | 111 + .../generated/Models/IncludedPath.cs | 61 + .../generated/Models/IndexKind.cs | 19 + .../generated/Models/Indexes.cs | 70 + .../generated/Models/IndexingMode.cs | 19 + .../generated/Models/IndexingPolicy.cs | 78 + .../generated/Models/KeyKind.cs | 20 + .../generated/Models/Location.cs | 116 + .../generated/Models/Metric.cs | 97 + .../generated/Models/MetricAvailability.cs | 57 + .../generated/Models/MetricDefinition.cs | 89 + .../Models/MetricDefinitionsListResult.cs | 52 + .../generated/Models/MetricListResult.cs | 49 + .../generated/Models/MetricName.cs | 56 + .../generated/Models/MetricValue.cs | 88 + ...MongoDBCollectionCreateUpdateParameters.cs | 94 + .../Models/MongoDBCollectionGetResults.cs | 122 + .../Models/MongoDBCollectionListResult.cs | 53 + .../Models/MongoDBCollectionResource.cs | 81 + .../MongoDBDatabaseCreateUpdateParameters.cs | 94 + .../Models/MongoDBDatabaseGetResults.cs | 102 + .../Models/MongoDBDatabaseListResult.cs | 51 + .../Models/MongoDBDatabaseResource.cs | 61 + .../generated/Models/MongoIndex.cs | 56 + .../generated/Models/MongoIndexKeys.cs | 51 + .../generated/Models/MongoIndexOptions.cs | 55 + .../generated/Models/Operation.cs | 57 + .../generated/Models/OperationDisplay.cs | 75 + .../generated/Models/OperationListResult.cs | 61 + .../generated/Models/PartitionKind.cs | 18 + .../generated/Models/PartitionMetric.cs | 73 + .../Models/PartitionMetricListResult.cs | 50 + .../generated/Models/PartitionUsage.cs | 66 + .../generated/Models/PartitionUsagesResult.cs | 51 + .../generated/Models/PercentileMetric.cs | 98 + .../Models/PercentileMetricListResult.cs | 50 + .../generated/Models/PercentileMetricValue.cs | 103 + .../Models/PrimaryAggregationType.cs | 22 + .../Models/PrivateEndpointConnection.cs | 65 + .../PrivateEndpointConnectionListResult.cs | 51 + .../Models/PrivateEndpointProperty.cs | 47 + .../generated/Models/PrivateLinkResource.cs | 66 + .../Models/PrivateLinkResourceListResult.cs | 51 + ...ivateLinkServiceConnectionStateProperty.cs | 69 + .../Models/RegionForOnlineOffline.cs | 63 + .../SqlContainerCreateUpdateParameters.cs | 94 + .../Models/SqlContainerGetResults.cs | 153 + .../Models/SqlContainerListResult.cs | 51 + .../generated/Models/SqlContainerResource.cs | 112 + .../SqlDatabaseCreateUpdateParameters.cs | 94 + .../generated/Models/SqlDatabaseGetResults.cs | 122 + .../generated/Models/SqlDatabaseListResult.cs | 51 + .../generated/Models/SqlDatabaseResource.cs | 61 + ...qlStoredProcedureCreateUpdateParameters.cs | 94 + .../Models/SqlStoredProcedureGetResults.cs | 112 + .../Models/SqlStoredProcedureListResult.cs | 53 + .../Models/SqlStoredProcedureResource.cs | 69 + .../SqlTriggerCreateUpdateParameters.cs | 94 + .../generated/Models/SqlTriggerGetResults.cs | 131 + .../generated/Models/SqlTriggerListResult.cs | 50 + .../generated/Models/SqlTriggerResource.cs | 90 + ...erDefinedFunctionCreateUpdateParameters.cs | 94 + .../SqlUserDefinedFunctionGetResults.cs | 112 + .../SqlUserDefinedFunctionListResult.cs | 53 + .../Models/SqlUserDefinedFunctionResource.cs | 72 + .../Models/TableCreateUpdateParameters.cs | 93 + .../generated/Models/TableGetResults.cs | 101 + .../generated/Models/TableListResult.cs | 50 + .../generated/Models/TableResource.cs | 61 + .../Models/ThroughputSettingsGetResults.cs | 90 + .../Models/ThroughputSettingsResource.cs | 76 + .../ThroughputSettingsUpdateParameters.cs | 79 + .../generated/Models/TriggerOperation.cs | 21 + .../generated/Models/TriggerType.cs | 18 + .../generated/Models/UniqueKey.cs | 52 + .../generated/Models/UniqueKeyPolicy.cs | 55 + .../generated/Models/UnitType.cs | 23 + .../generated/Models/Usage.cs | 84 + .../generated/Models/UsagesResult.cs | 51 + .../generated/Models/VirtualNetworkRule.cs | 60 + .../generated/MongoDBResources.cs | 2512 ++++++++ .../generated/MongoDBResourcesExtensions.cs | 629 ++ .../resource-manager/generated/Operations.cs | 181 + .../generated/OperationsExtensions.cs | 47 + .../generated/PartitionKeyRangeId.cs | 283 + .../PartitionKeyRangeIdExtensions.cs | 91 + .../generated/PartitionKeyRangeIdRegion.cs | 292 + .../PartitionKeyRangeIdRegionExtensions.cs | 97 + .../resource-manager/generated/Percentile.cs | 256 + .../generated/PercentileExtensions.cs | 73 + .../generated/PercentileSourceTarget.cs | 277 + .../PercentileSourceTargetExtensions.cs | 91 + .../generated/PercentileTarget.cs | 266 + .../generated/PercentileTargetExtensions.cs | 81 + .../generated/PrivateEndpointConnections.cs | 830 +++ .../PrivateEndpointConnectionsExtensions.cs | 194 + .../generated/PrivateLinkResources.cs | 441 ++ .../PrivateLinkResourcesExtensions.cs | 109 + .../generated/SqlResources.cs | 5081 +++++++++++++++++ .../generated/SqlResourcesExtensions.cs | 1318 +++++ .../generated/TableResources.cs | 1252 ++++ .../generated/TableResourcesExtensions.cs | 302 + .../cosmos-db/resource-manager/readme.md | 1 + 194 files changed, 42205 insertions(+) create mode 100644 specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json create mode 100644 specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json create mode 100644 specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionListGet.json create mode 100644 specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json create mode 100644 specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json create mode 100644 specification/cosmos-db/resource-manager/generated/CassandraResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Collection.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartition.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CollectionRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/CosmosDB.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Database.cs create mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs create mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/GremlinResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ICassandraResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ICollection.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ICosmosDB.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IDatabase.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IGremlinResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IOperations.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IPercentile.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs create mode 100644 specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ISqlResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/ITableResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/Capability.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/Column.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DataType.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/Indexes.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/Location.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/Metric.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricName.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/Operation.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/UnitType.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/Usage.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs create mode 100644 specification/cosmos-db/resource-manager/generated/MongoDBResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Operations.cs create mode 100644 specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/Percentile.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PercentileTarget.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/SqlResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs create mode 100644 specification/cosmos-db/resource-manager/generated/TableResources.cs create mode 100644 specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json new file mode 100644 index 000000000000..1eeb2bbdabf2 --- /dev/null +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json @@ -0,0 +1,14 @@ +{ + "parameters": { + "subscriptionId": "00000000-1111-2222-3333-444444444444", + "resourceGroupName": "rg1", + "accountName": "ddb1", + "api-version": "2019-08-01-preview", + "privateEndpointConnectionName": "privateEndpointConnectionName" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json new file mode 100644 index 000000000000..a3e0e29b04cc --- /dev/null +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json @@ -0,0 +1,28 @@ +{ + "parameters": { + "subscriptionId": "00000000-1111-2222-3333-444444444444", + "resourceGroupName": "rg1", + "accountName": "ddb1", + "api-version": "2019-08-01-preview", + "privateEndpointConnectionName": "privateEndpointConnectionName" + }, + "responses": { + "200": { + "body": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName", + "name": "privateEndpointConnectionName", + "type": "Microsoft.DocumentDb/databaseAccounts/privateEndpointConnections", + "properties": { + "privateEndpoint": { + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName" + }, + "privateLinkServiceConnectionState": { + "status": "Approved", + "description": "Auto-approved", + "actionsRequired": "None" + } + } + } + } + } +} \ No newline at end of file diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionListGet.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionListGet.json new file mode 100644 index 000000000000..1810c8253c06 --- /dev/null +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionListGet.json @@ -0,0 +1,46 @@ +{ + "parameters": { + "subscriptionId": "00000000-1111-2222-3333-444444444444", + "resourceGroupName": "rg1", + "accountName": "ddb1", + "api-version": "2019-08-01-preview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName", + "name": "privateEndpointConnectionName", + "type": "Microsoft.DocumentDb/databaseAccounts/privateEndpointConnections", + "properties": { + "privateEndpoint": { + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName" + }, + "privateLinkServiceConnectionState": { + "status": "Approved", + "description": "Auto-approved", + "actionsRequired": "None" + } + } + }, + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName2", + "name": "privateEndpointConnectionName", + "type": "Microsoft.DocumentDb/databaseAccounts/privateEndpointConnections", + "properties": { + "privateEndpoint": { + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName2" + }, + "privateLinkServiceConnectionState": { + "status": "Approved", + "description": "Auto-approved", + "actionsRequired": "None" + } + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json new file mode 100644 index 000000000000..656efb925bf0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json @@ -0,0 +1,12 @@ +{ + "parameters": { + "subscriptionId": "00000000-1111-2222-3333-444444444444", + "resourceGroupName": "rg1", + "accountName": "ddb1", + "api-version": "2019-08-01-preview", + "privateEndpointConnectionName": "privateEndpointConnectionName" + }, + "responses": { + "202": {} + } +} \ No newline at end of file diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json new file mode 100644 index 000000000000..f5705a1ef4e6 --- /dev/null +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json @@ -0,0 +1,291 @@ +{ + "swagger": "2.0", + "info": { + "title": "Cosmos DB", + "description": "Azure Cosmos DB Database Service Resource Provider REST API", + "version": "2019-08-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "flow": "implicit", + "description": "Azure Active Directory OAuth2 Flow", + "scopes": { + "user_impersonation": "Impersonate your user account" + } + } + }, + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections": { + "get": { + "tags": [ + "PrivateEndpointConnections" + ], + "description": "List all private endpoint connections on a Cosmos DB account.", + "operationId": "PrivateEndpointConnections_ListByDatabaseAccount", + "x-ms-pageable": { + "nextLinkName": null + }, + "parameters": [ + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + } + ], + "responses": { + "200": { + "description": "Successfully retrieved private link resources.", + "schema": { + "$ref": "#/definitions/PrivateEndpointConnectionListResult" + } + } + }, + "x-ms-examples": { + "Gets private endpoint connection.": { + "$ref": "./examples/CosmosDBPrivateEndpointConnectionListGet.json" + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}": { + "get": { + "tags": [ + "PrivateEndpointConnections" + ], + "description": "Gets a private endpoint connection.", + "operationId": "PrivateEndpointConnections_Get", + "parameters": [ + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + }, + { + "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" + } + ], + "responses": { + "200": { + "description": "Successfully retrieved a specified private endpoint connection.", + "schema": { + "$ref": "#/definitions/PrivateEndpointConnection" + } + } + }, + "x-ms-examples": { + "Gets private endpoint connection.": { + "$ref": "./examples/CosmosDBPrivateEndpointConnectionGet.json" + } + } + }, + "put": { + "tags": [ + "PrivateEndpointConnections" + ], + "description": "Approve or reject a private endpoint connection with a given name.", + "operationId": "PrivateEndpointConnections_CreateOrUpdate", + "parameters": [ + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + }, + { + "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" + } + ], + "responses": { + "200": { + "description": "Successfully approved or rejected private endpoint connection.", + "schema": { + "$ref": "#/definitions/PrivateEndpointConnection" + } + }, + "202": { + "description": "Accepted. The private endpoint connection update will complete asynchronously." + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation": true, + "x-ms-examples": { + "Approve or reject a private endpoint connection with a given name.": { + "$ref": "./examples/CosmosDBPrivateEndpointConnectionUpdate.json" + } + } + }, + "delete": { + "tags": [ + "PrivateEndpointConnections" + ], + "description": "Deletes a private endpoint connection with a given name.", + "operationId": "PrivateEndpointConnections_Delete", + "parameters": [ + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + }, + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + }, + { + "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" + } + ], + "responses": { + "202": { + "description": "Accepted. The private endpoint connection delete will complete asynchronously." + }, + "204": { + "description": "Private endpoint connection does not exist." + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation": true, + "x-ms-examples": { + "Deletes a private endpoint connection with a given name.": { + "$ref": "./examples/CosmosDBPrivateEndpointConnectionDelete.json" + } + } + } + } + }, + "definitions": { + "PrivateEndpointConnectionListResult": { + "description": "A list of private endpoint connections", + "type": "object", + "properties": { + "value": { + "type": "array", + "description": "Array of private endpoint connections", + "items": { + "$ref": "#/definitions/PrivateEndpointConnection" + } + } + } + }, + "PrivateEndpointConnection": { + "description": "A private endpoint connection", + "type": "object", + "properties": { + "properties": { + "$ref": "#/definitions/PrivateEndpointConnectionProperties", + "description": "Resource properties.", + "x-ms-client-flatten": true + } + }, + "allOf": [ + { + "$ref": "../../stable/2019-08-01/cosmos-db.json#/definitions/ARMProxyResource" + } + ] + }, + "PrivateEndpointConnectionProperties": { + "description": "Properties of a private endpoint connection.", + "type": "object", + "properties": { + "privateEndpoint": { + "$ref": "#/definitions/PrivateEndpointProperty", + "description": "Private endpoint which the connection belongs to." + }, + "privateLinkServiceConnectionState": { + "$ref": "#/definitions/PrivateLinkServiceConnectionStateProperty", + "description": "Connection State of the Private Endpoint Connection." + } + } + }, + "PrivateEndpointProperty": { + "type": "object", + "description": "Private endpoint which the connection belongs to.", + "properties": { + "id": { + "type": "string", + "description": "Resource id of the private endpoint." + } + } + }, + "PrivateLinkServiceConnectionStateProperty": { + "type": "object", + "description": "Connection State of the Private Endpoint Connection.", + "properties": { + "status": { + "type": "string", + "description": "The private link service connection status." + }, + "description": { + "type": "string", + "description": "The private link service connection description." + }, + "actionsRequired": { + "type": "string", + "description": "Any action that is required beyond basic workflow (approve/ reject/ disconnect)", + "readOnly": true + } + } + } + }, + "parameters": { + "PrivateEndpointConnectionNameParameter": { + "name": "privateEndpointConnectionName", + "in": "path", + "required": true, + "type": "string", + "x-ms-parameter-location": "method", + "description": "The name of the private endpoint connection." + } + } +} \ No newline at end of file diff --git a/specification/cosmos-db/resource-manager/generated/CassandraResources.cs b/specification/cosmos-db/resource-manager/generated/CassandraResources.cs new file mode 100644 index 000000000000..5d7b1e83f77d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CassandraResources.cs @@ -0,0 +1,2512 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CassandraResources operations. + /// + public partial class CassandraResources : IServiceOperations, ICassandraResources + { + /// + /// Initializes a new instance of the CassandraResources class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public CassandraResources(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateUpdateCassandraKeyspaceWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateCassandraKeyspace", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteCassandraKeyspaceWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteCassandraKeyspace", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateCassandraKeyspaceThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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> CreateUpdateCassandraTableWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateCassandraTable", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteCassandraTableWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteCassandraTable", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateCassandraTableThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateCassandraTableThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs new file mode 100644 index 000000000000..c58574fbf91c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs @@ -0,0 +1,629 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CassandraResources. + /// + public static partial class CassandraResourcesExtensions + { + /// + /// 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 CassandraKeyspaceListResult ListCassandraKeyspaces(this ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 CassandraTableListResult ListCassandraTables(this ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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; + } + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Collection.cs b/specification/cosmos-db/resource-manager/generated/Collection.cs new file mode 100644 index 000000000000..bd8622cf918d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Collection.cs @@ -0,0 +1,700 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Collection operations. + /// + public partial class Collection : IServiceOperations, ICollection + { + /// + /// Initializes a new instance of the Collection class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public Collection(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs new file mode 100644 index 000000000000..d5e5bd79f9f1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs @@ -0,0 +1,199 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Collection. + /// + public static partial class CollectionExtensions + { + /// + /// 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 MetricListResult ListMetrics(this ICollection 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 ICollection 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 UsagesResult ListUsages(this ICollection 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 ICollection 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 MetricDefinitionsListResult ListMetricDefinitions(this ICollection 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 ICollection 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/specification/cosmos-db/resource-manager/generated/CollectionPartition.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartition.cs new file mode 100644 index 000000000000..e5d85c98ab7f --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CollectionPartition.cs @@ -0,0 +1,493 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartition operations. + /// + public partial class CollectionPartition : IServiceOperations, ICollectionPartition + { + /// + /// Initializes a new instance of the CollectionPartition class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public CollectionPartition(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs new file mode 100644 index 000000000000..dd09503b3f4f --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs @@ -0,0 +1,149 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CollectionPartition. + /// + public static partial class CollectionPartitionExtensions + { + /// + /// 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 PartitionMetricListResult ListMetrics(this ICollectionPartition 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 ICollectionPartition 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 PartitionUsagesResult ListUsages(this ICollectionPartition 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 ICollectionPartition 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/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs new file mode 100644 index 000000000000..dc73c6c8fa0f --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs @@ -0,0 +1,283 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartitionRegion operations. + /// + public partial class CollectionPartitionRegion : IServiceOperations, ICollectionPartitionRegion + { + /// + /// Initializes a new instance of the CollectionPartitionRegion class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public CollectionPartitionRegion(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs new file mode 100644 index 000000000000..f9b577e4b994 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs @@ -0,0 +1,91 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CollectionPartitionRegion. + /// + public static partial class CollectionPartitionRegionExtensions + { + /// + /// 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 PartitionMetricListResult ListMetrics(this ICollectionPartitionRegion 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 ICollectionPartitionRegion 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/specification/cosmos-db/resource-manager/generated/CollectionRegion.cs b/specification/cosmos-db/resource-manager/generated/CollectionRegion.cs new file mode 100644 index 000000000000..8d2cdb9d09c0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CollectionRegion.cs @@ -0,0 +1,283 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionRegion operations. + /// + public partial class CollectionRegion : IServiceOperations, ICollectionRegion + { + /// + /// Initializes a new instance of the CollectionRegion class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public CollectionRegion(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs new file mode 100644 index 000000000000..7ff43f946a85 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs @@ -0,0 +1,91 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CollectionRegion. + /// + public static partial class CollectionRegionExtensions + { + /// + /// 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 MetricListResult ListMetrics(this ICollectionRegion 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 ICollectionRegion 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/specification/cosmos-db/resource-manager/generated/CosmosDB.cs b/specification/cosmos-db/resource-manager/generated/CosmosDB.cs new file mode 100644 index 000000000000..365a5c988c2a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/CosmosDB.cs @@ -0,0 +1,286 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Net; + using System.Net.Http; + + /// + /// Azure Cosmos DB Database Service Resource Provider REST API + /// + public partial class CosmosDB : ServiceClient, ICosmosDB + { + /// + /// 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; } + + /// + /// Azure subscription ID. + /// + public string SubscriptionId { get; set; } + + /// + /// Gets the IDatabaseAccounts. + /// + public virtual IDatabaseAccounts DatabaseAccounts { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IDatabase. + /// + public virtual IDatabase Database { get; private set; } + + /// + /// Gets the ICollection. + /// + public virtual ICollection Collection { get; private set; } + + /// + /// Gets the ICollectionRegion. + /// + public virtual ICollectionRegion CollectionRegion { get; private set; } + + /// + /// Gets the IDatabaseAccountRegion. + /// + public virtual IDatabaseAccountRegion DatabaseAccountRegion { get; private set; } + + /// + /// Gets the IPercentileSourceTarget. + /// + public virtual IPercentileSourceTarget PercentileSourceTarget { get; private set; } + + /// + /// Gets the IPercentileTarget. + /// + public virtual IPercentileTarget PercentileTarget { get; private set; } + + /// + /// Gets the IPercentile. + /// + public virtual IPercentile Percentile { get; private set; } + + /// + /// Gets the ICollectionPartitionRegion. + /// + public virtual ICollectionPartitionRegion CollectionPartitionRegion { get; private set; } + + /// + /// Gets the ICollectionPartition. + /// + public virtual ICollectionPartition CollectionPartition { get; private set; } + + /// + /// Gets the IPartitionKeyRangeId. + /// + public virtual IPartitionKeyRangeId PartitionKeyRangeId { get; private set; } + + /// + /// Gets the IPartitionKeyRangeIdRegion. + /// + public virtual IPartitionKeyRangeIdRegion PartitionKeyRangeIdRegion { get; private set; } + + /// + /// Gets the ISqlResources. + /// + public virtual ISqlResources SqlResources { get; private set; } + + /// + /// Gets the IMongoDBResources. + /// + public virtual IMongoDBResources MongoDBResources { get; private set; } + + /// + /// Gets the ITableResources. + /// + public virtual ITableResources TableResources { get; private set; } + + /// + /// Gets the ICassandraResources. + /// + public virtual ICassandraResources CassandraResources { get; private set; } + + /// + /// Gets the IGremlinResources. + /// + public virtual IGremlinResources GremlinResources { get; private set; } + + /// + /// Gets the IPrivateLinkResources. + /// + public virtual IPrivateLinkResources PrivateLinkResources { get; private set; } + + /// + /// Gets the IPrivateEndpointConnections. + /// + public virtual IPrivateEndpointConnections PrivateEndpointConnections { get; private set; } + + /// + /// Initializes a new instance of the CosmosDB class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling CosmosDB.Dispose(). False: will not dispose provided httpClient + public CosmosDB(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDB class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public CosmosDB(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDB class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public CosmosDB(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDB 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 + /// + public CosmosDB(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the CosmosDB 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 + /// + public CosmosDB(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + DatabaseAccounts = new DatabaseAccounts(this); + Operations = new Operations(this); + Database = new Database(this); + Collection = new Collection(this); + CollectionRegion = new CollectionRegion(this); + DatabaseAccountRegion = new DatabaseAccountRegion(this); + PercentileSourceTarget = new PercentileSourceTarget(this); + PercentileTarget = new PercentileTarget(this); + Percentile = new Percentile(this); + CollectionPartitionRegion = new CollectionPartitionRegion(this); + CollectionPartition = new CollectionPartition(this); + PartitionKeyRangeId = new PartitionKeyRangeId(this); + PartitionKeyRangeIdRegion = new PartitionKeyRangeIdRegion(this); + SqlResources = new SqlResources(this); + MongoDBResources = new MongoDBResources(this); + TableResources = new TableResources(this); + CassandraResources = new CassandraResources(this); + GremlinResources = new GremlinResources(this); + PrivateLinkResources = new PrivateLinkResources(this); + PrivateEndpointConnections = new PrivateEndpointConnections(this); + BaseUri = new System.Uri("https://management.azure.com"); + 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()); + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Database.cs b/specification/cosmos-db/resource-manager/generated/Database.cs new file mode 100644 index 000000000000..2239267b1858 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Database.cs @@ -0,0 +1,673 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Database operations. + /// + public partial class Database : IServiceOperations, IDatabase + { + /// + /// Initializes a new instance of the Database class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public Database(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs new file mode 100644 index 000000000000..2c55c947f4ba --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs @@ -0,0 +1,265 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccountRegion operations. + /// + public partial class DatabaseAccountRegion : IServiceOperations, IDatabaseAccountRegion + { + /// + /// Initializes a new instance of the DatabaseAccountRegion class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public DatabaseAccountRegion(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs new file mode 100644 index 000000000000..ef204899cc05 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs @@ -0,0 +1,79 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DatabaseAccountRegion. + /// + public static partial class DatabaseAccountRegionExtensions + { + /// + /// 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 MetricListResult ListMetrics(this IDatabaseAccountRegion 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 IDatabaseAccountRegion 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/specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs new file mode 100644 index 000000000000..67d16eccef9a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs @@ -0,0 +1,3401 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccounts operations. + /// + public partial class DatabaseAccounts : IServiceOperations, IDatabaseAccounts + { + /// + /// Initializes a new instance of the DatabaseAccounts class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public DatabaseAccounts(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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; + } + + /// + /// Patches the properties of an existing Azure Cosmos DB database account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The tags parameter to patch 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> PatchWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountPatchParameters 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-08-01"; + // 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, "Patch", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(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-08-01"; + // 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, "CreateOrUpdate", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteWithHttpMessagesAsync(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"; + // 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, "Delete", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + 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 FailoverPriorityChangeWithHttpMessagesAsync(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-08-01"; + // 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, "FailoverPriorityChange", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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 OfflineRegionWithHttpMessagesAsync(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-08-01"; + // 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, "OfflineRegion", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 = Microsoft.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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + 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 OnlineRegionWithHttpMessagesAsync(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-08-01"; + // 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, "OnlineRegion", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 = Microsoft.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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + 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> 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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 RegenerateKeyWithHttpMessagesAsync(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-08-01"; + // 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, "RegenerateKey", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs new file mode 100644 index 000000000000..4ec278979ac1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs @@ -0,0 +1,785 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DatabaseAccounts. + /// + public static partial class DatabaseAccountsExtensions + { + /// + /// 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 IDatabaseAccounts 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 IDatabaseAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Patches 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 tags parameter to patch for the current database account. + /// + public static DatabaseAccountGetResults Patch(this IDatabaseAccounts operations, string resourceGroupName, string accountName, DatabaseAccountPatchParameters updateParameters) + { + return operations.PatchAsync(resourceGroupName, accountName, updateParameters).GetAwaiter().GetResult(); + } + + /// + /// Patches 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 tags parameter to patch for the current database account. + /// + /// + /// The cancellation token. + /// + public static async Task PatchAsync(this IDatabaseAccounts operations, string resourceGroupName, string accountName, DatabaseAccountPatchParameters updateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PatchWithHttpMessagesAsync(resourceGroupName, accountName, updateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an 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 CreateOrUpdate(this IDatabaseAccounts 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 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 DatabaseAccountsListResult List(this IDatabaseAccounts 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 IDatabaseAccounts 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 DatabaseAccountsListResult ListByResourceGroup(this IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 void CheckNameExists(this IDatabaseAccounts operations, string accountName) + { + 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 IDatabaseAccounts operations, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CheckNameExistsWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// 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 MetricListResult ListMetrics(this IDatabaseAccounts 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 IDatabaseAccounts 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 UsagesResult ListUsages(this IDatabaseAccounts 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 IDatabaseAccounts 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 MetricDefinitionsListResult ListMetricDefinitions(this IDatabaseAccounts 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 IDatabaseAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListMetricDefinitionsWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs b/specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs new file mode 100644 index 000000000000..64b3717c4368 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs @@ -0,0 +1,181 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Database. + /// + public static partial class DatabaseExtensions + { + /// + /// 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 MetricListResult ListMetrics(this IDatabase 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 IDatabase 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 UsagesResult ListUsages(this IDatabase 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 IDatabase 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 MetricDefinitionsListResult ListMetricDefinitions(this IDatabase 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 IDatabase 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/specification/cosmos-db/resource-manager/generated/GremlinResources.cs b/specification/cosmos-db/resource-manager/generated/GremlinResources.cs new file mode 100644 index 000000000000..fd55b8404228 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/GremlinResources.cs @@ -0,0 +1,2510 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GremlinResources operations. + /// + public partial class GremlinResources : IServiceOperations, IGremlinResources + { + /// + /// Initializes a new instance of the GremlinResources class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public GremlinResources(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateUpdateGremlinDatabaseWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateGremlinDatabase", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteGremlinDatabaseWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteGremlinDatabase", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateGremlinDatabaseThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateGremlinDatabaseThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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> CreateUpdateGremlinGraphWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateGremlinGraph", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteGremlinGraphWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteGremlinGraph", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateGremlinGraphThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateGremlinGraphThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs new file mode 100644 index 000000000000..9c13dd55cf41 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs @@ -0,0 +1,625 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GremlinResources. + /// + public static partial class GremlinResourcesExtensions + { + /// + /// 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 GremlinDatabaseListResult ListGremlinDatabases(this IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 GremlinGraphListResult ListGremlinGraphs(this IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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; + } + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/ICassandraResources.cs b/specification/cosmos-db/resource-manager/generated/ICassandraResources.cs new file mode 100644 index 000000000000..bd1e97d47299 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ICassandraResources.cs @@ -0,0 +1,384 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CassandraResources operations. + /// + public partial interface ICassandraResources + { + /// + /// 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/ICollection.cs b/specification/cosmos-db/resource-manager/generated/ICollection.cs new file mode 100644 index 000000000000..add26c1f95f1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ICollection.cs @@ -0,0 +1,128 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Collection operations. + /// + public partial interface ICollection + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs b/specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs new file mode 100644 index 000000000000..2859a23775d0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs @@ -0,0 +1,97 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartition operations. + /// + public partial interface ICollectionPartition + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs b/specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs new file mode 100644 index 000000000000..39e224688c34 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs @@ -0,0 +1,64 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionPartitionRegion operations. + /// + public partial interface ICollectionPartitionRegion + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs b/specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs new file mode 100644 index 000000000000..6eb2133c8847 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs @@ -0,0 +1,64 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CollectionRegion operations. + /// + public partial interface ICollectionRegion + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/ICosmosDB.cs b/specification/cosmos-db/resource-manager/generated/ICosmosDB.cs new file mode 100644 index 000000000000..dc23ceb71e4c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ICosmosDB.cs @@ -0,0 +1,139 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using Newtonsoft.Json; + + /// + /// Azure Cosmos DB Database Service Resource Provider REST API + /// + public partial interface ICosmosDB : 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; } + + /// + /// Azure subscription ID. + /// + string SubscriptionId { get; set; } + + + /// + /// Gets the IDatabaseAccounts. + /// + IDatabaseAccounts DatabaseAccounts { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IDatabase. + /// + IDatabase Database { get; } + + /// + /// Gets the ICollection. + /// + ICollection Collection { get; } + + /// + /// Gets the ICollectionRegion. + /// + ICollectionRegion CollectionRegion { get; } + + /// + /// Gets the IDatabaseAccountRegion. + /// + IDatabaseAccountRegion DatabaseAccountRegion { get; } + + /// + /// Gets the IPercentileSourceTarget. + /// + IPercentileSourceTarget PercentileSourceTarget { get; } + + /// + /// Gets the IPercentileTarget. + /// + IPercentileTarget PercentileTarget { get; } + + /// + /// Gets the IPercentile. + /// + IPercentile Percentile { get; } + + /// + /// Gets the ICollectionPartitionRegion. + /// + ICollectionPartitionRegion CollectionPartitionRegion { get; } + + /// + /// Gets the ICollectionPartition. + /// + ICollectionPartition CollectionPartition { get; } + + /// + /// Gets the IPartitionKeyRangeId. + /// + IPartitionKeyRangeId PartitionKeyRangeId { get; } + + /// + /// Gets the IPartitionKeyRangeIdRegion. + /// + IPartitionKeyRangeIdRegion PartitionKeyRangeIdRegion { get; } + + /// + /// Gets the ISqlResources. + /// + ISqlResources SqlResources { get; } + + /// + /// Gets the IMongoDBResources. + /// + IMongoDBResources MongoDBResources { get; } + + /// + /// Gets the ITableResources. + /// + ITableResources TableResources { get; } + + /// + /// Gets the ICassandraResources. + /// + ICassandraResources CassandraResources { get; } + + /// + /// Gets the IGremlinResources. + /// + IGremlinResources GremlinResources { get; } + + /// + /// Gets the IPrivateLinkResources. + /// + IPrivateLinkResources PrivateLinkResources { get; } + + /// + /// Gets the IPrivateEndpointConnections. + /// + IPrivateEndpointConnections PrivateEndpointConnections { get; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/IDatabase.cs b/specification/cosmos-db/resource-manager/generated/IDatabase.cs new file mode 100644 index 000000000000..a14ca5467eff --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IDatabase.cs @@ -0,0 +1,118 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Database operations. + /// + public partial interface IDatabase + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs b/specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs new file mode 100644 index 000000000000..bc255c17b6df --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs @@ -0,0 +1,58 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccountRegion operations. + /// + public partial interface IDatabaseAccountRegion + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs b/specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs new file mode 100644 index 000000000000..b3da709279f6 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs @@ -0,0 +1,490 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabaseAccounts operations. + /// + public partial interface IDatabaseAccounts + { + /// + /// 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)); + /// + /// Patches the properties of an existing Azure Cosmos DB database + /// account. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The tags parameter to patch 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> PatchWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountPatchParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an 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> 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/IGremlinResources.cs b/specification/cosmos-db/resource-manager/generated/IGremlinResources.cs new file mode 100644 index 000000000000..520971e64164 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IGremlinResources.cs @@ -0,0 +1,384 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GremlinResources operations. + /// + public partial interface IGremlinResources + { + /// + /// 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs b/specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs new file mode 100644 index 000000000000..219a4c469aa1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs @@ -0,0 +1,384 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MongoDBResources operations. + /// + public partial interface IMongoDBResources + { + /// + /// 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/IOperations.cs b/specification/cosmos-db/resource-manager/generated/IOperations.cs new file mode 100644 index 000000000000..eae757541ba8 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IOperations.cs @@ -0,0 +1,41 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs b/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs new file mode 100644 index 000000000000..4b3deb16127d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs @@ -0,0 +1,63 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeId operations. + /// + public partial interface IPartitionKeyRangeId + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs b/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs new file mode 100644 index 000000000000..ad4e0d007115 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs @@ -0,0 +1,67 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeIdRegion operations. + /// + public partial interface IPartitionKeyRangeIdRegion + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/IPercentile.cs b/specification/cosmos-db/resource-manager/generated/IPercentile.cs new file mode 100644 index 000000000000..658115e66c03 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IPercentile.cs @@ -0,0 +1,55 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Percentile operations. + /// + public partial interface IPercentile + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs b/specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs new file mode 100644 index 000000000000..deab4d01aad6 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs @@ -0,0 +1,63 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileSourceTarget operations. + /// + public partial interface IPercentileSourceTarget + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs b/specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs new file mode 100644 index 000000000000..5630a205b7b1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs @@ -0,0 +1,59 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileTarget operations. + /// + public partial interface IPercentileTarget + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs b/specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs new file mode 100644 index 000000000000..ae53c25840a7 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs @@ -0,0 +1,128 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnections operations. + /// + public partial interface IPrivateEndpointConnections + { + /// + /// List all private endpoint connections on 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 a private endpoint connection. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// 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, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs b/specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs new file mode 100644 index 000000000000..4e38d2f8b828 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs @@ -0,0 +1,77 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResources operations. + /// + public partial interface IPrivateLinkResources + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/ISqlResources.cs b/specification/cosmos-db/resource-manager/generated/ISqlResources.cs new file mode 100644 index 000000000000..76cdd9176bf6 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ISqlResources.cs @@ -0,0 +1,789 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SqlResources operations. + /// + public partial interface ISqlResources + { + /// + /// 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/ITableResources.cs b/specification/cosmos-db/resource-manager/generated/ITableResources.cs new file mode 100644 index 000000000000..af3b2620771f --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/ITableResources.cs @@ -0,0 +1,194 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TableResources operations. + /// + public partial interface ITableResources + { + /// + /// 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)); + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs b/specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs new file mode 100644 index 000000000000..d11e220cdd1e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs @@ -0,0 +1,65 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + 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 + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs b/specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs new file mode 100644 index 000000000000..e04d164df0e0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs @@ -0,0 +1,82 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The core properties of ARM resources. + /// + public partial class ARMResourceProperties + { + /// + /// 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/specification/cosmos-db/resource-manager/generated/Models/Capability.cs b/specification/cosmos-db/resource-manager/generated/Models/Capability.cs new file mode 100644 index 000000000000..7c1a77abd8fe --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/Capability.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs new file mode 100644 index 000000000000..bf435924d93d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs new file mode 100644 index 000000000000..21c29b405cf6 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs @@ -0,0 +1,104 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB + /// Cassandra keyspace + /// 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. + /// 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 CassandraKeyspaceGetResults(string cassandraKeyspaceGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + CassandraKeyspaceGetResultsId = cassandraKeyspaceGetResultsId; + 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 = "properties.id")] + public string CassandraKeyspaceGetResultsId { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (CassandraKeyspaceGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CassandraKeyspaceGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs new file mode 100644 index 000000000000..42fa5e4710a7 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs @@ -0,0 +1,53 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the Cassandra keyspaces and + /// their properties. + /// + public partial class CassandraKeyspaceListResult + { + /// + /// Initializes a new instance of the CassandraKeyspaceListResult + /// class. + /// + public CassandraKeyspaceListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraKeyspaceListResult + /// class. + /// + /// List of Cassandra keyspaces and their + /// properties. + public CassandraKeyspaceListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of Cassandra keyspaces and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs new file mode 100644 index 000000000000..a51b6ebdbdd2 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs new file mode 100644 index 000000000000..14996ba52a01 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs @@ -0,0 +1,48 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs new file mode 100644 index 000000000000..c61521a8a7c9 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs @@ -0,0 +1,65 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs new file mode 100644 index 000000000000..6d02860ed16d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs new file mode 100644 index 000000000000..add57bba80ea --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs @@ -0,0 +1,120 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB + /// Cassandra table + /// 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. + /// 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 CassandraTableGetResults(string cassandraTableGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), int? defaultTtl = default(int?), CassandraSchema schema = default(CassandraSchema), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + CassandraTableGetResultsId = cassandraTableGetResultsId; + 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 = "properties.id")] + public string CassandraTableGetResultsId { get; set; } + + /// + /// Gets or sets time to live of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "properties.defaultTtl")] + public int? DefaultTtl { get; set; } + + /// + /// Gets or sets schema of the Cosmos DB Cassandra table + /// + [JsonProperty(PropertyName = "properties.schema")] + public CassandraSchema Schema { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (CassandraTableGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CassandraTableGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs new file mode 100644 index 000000000000..ab10e0f23403 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the Cassandra tables and + /// their properties. + /// + public partial class CassandraTableListResult + { + /// + /// Initializes a new instance of the CassandraTableListResult class. + /// + public CassandraTableListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CassandraTableListResult class. + /// + /// List of Cassandra tables and their + /// properties. + public CassandraTableListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of Cassandra tables and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs new file mode 100644 index 000000000000..123f928b5c8e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs @@ -0,0 +1,79 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs b/specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs new file mode 100644 index 000000000000..ca3e5f17afe7 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs @@ -0,0 +1,58 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/Column.cs b/specification/cosmos-db/resource-manager/generated/Models/Column.cs new file mode 100644 index 000000000000..1de52b7490e4 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/Column.cs @@ -0,0 +1,57 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs b/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs new file mode 100644 index 000000000000..87ac934eba77 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs @@ -0,0 +1,18 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + + /// + /// Defines values for ConflictResolutionMode. + /// + public static class ConflictResolutionMode + { + public const string LastWriterWins = "LastWriterWins"; + public const string Custom = "Custom"; + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs new file mode 100644 index 000000000000..1cb125ba2952 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs @@ -0,0 +1,69 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs b/specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs new file mode 100644 index 000000000000..004dabec3a14 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs @@ -0,0 +1,17 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + + /// + /// Defines values for ConnectorOffer. + /// + public static class ConnectorOffer + { + public const string Small = "Small"; + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs new file mode 100644 index 000000000000..f6bac404f10d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs @@ -0,0 +1,111 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs b/specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs new file mode 100644 index 000000000000..aa166a05d035 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs @@ -0,0 +1,62 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + 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' + public ContainerPartitionKey(IList paths = default(IList), string kind = default(string)) + { + Paths = paths; + Kind = kind; + 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; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DataType.cs b/specification/cosmos-db/resource-manager/generated/Models/DataType.cs new file mode 100644 index 000000000000..578204925818 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DataType.cs @@ -0,0 +1,22 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs new file mode 100644 index 000000000000..908b74e163f6 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs @@ -0,0 +1,59 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs new file mode 100644 index 000000000000..d71cda17de8a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs @@ -0,0 +1,215 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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' + 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)) + : 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; + 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; } + + /// + /// 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs new file mode 100644 index 000000000000..17cece250323 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs @@ -0,0 +1,263 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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 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' + 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 failoverPolicies = default(IList), IList virtualNetworkRules = default(IList), bool? enableMultipleWriteLocations = default(bool?), bool? enableCassandraConnector = default(bool?), string connectorOffer = 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; + FailoverPolicies = failoverPolicies; + VirtualNetworkRules = virtualNetworkRules; + EnableMultipleWriteLocations = enableMultipleWriteLocations; + EnableCassandraConnector = enableCassandraConnector; + ConnectorOffer = connectorOffer; + 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 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; } + + /// + /// 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 (FailoverPolicies != null) + { + foreach (var element2 in FailoverPolicies) + { + if (element2 != null) + { + element2.Validate(); + } + } + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs new file mode 100644 index 000000000000..9a0eaf23bb57 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs @@ -0,0 +1,19 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs new file mode 100644 index 000000000000..8f312aca3a49 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs @@ -0,0 +1,53 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs new file mode 100644 index 000000000000..c544517d7cb8 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs @@ -0,0 +1,64 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs new file mode 100644 index 000000000000..3bce34fe3d84 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs @@ -0,0 +1,59 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs new file mode 100644 index 000000000000..aefb2b2e37ae --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs @@ -0,0 +1,50 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs new file mode 100644 index 000000000000..a375473cdba9 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [JsonTransformation] + public partial class DatabaseAccountPatchParameters + { + /// + /// Initializes a new instance of the DatabaseAccountPatchParameters + /// class. + /// + public DatabaseAccountPatchParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatabaseAccountPatchParameters + /// class. + /// + /// List of Cosmos DB capabilities for the + /// account + public DatabaseAccountPatchParameters(IDictionary tags = default(IDictionary), IList capabilities = default(IList)) + { + Tags = tags; + Capabilities = capabilities; + 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 list of Cosmos DB capabilities for the account + /// + [JsonProperty(PropertyName = "properties.capabilities")] + public IList Capabilities { get; set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs new file mode 100644 index 000000000000..97584a083382 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs @@ -0,0 +1,66 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs new file mode 100644 index 000000000000..3a2c9dcc324c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the database accounts and + /// their properties. + /// + public partial class DatabaseAccountsListResult + { + /// + /// Initializes a new instance of the DatabaseAccountsListResult class. + /// + public DatabaseAccountsListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatabaseAccountsListResult class. + /// + /// List of database account and their + /// properties. + public DatabaseAccountsListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of database account and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs b/specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs new file mode 100644 index 000000000000..959784f8a6a4 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs @@ -0,0 +1,74 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs b/specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..12a7fdfc6241 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs @@ -0,0 +1,56 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs b/specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..b164faf02411 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs @@ -0,0 +1,58 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs b/specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs new file mode 100644 index 000000000000..67496172538d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs @@ -0,0 +1,48 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs b/specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs new file mode 100644 index 000000000000..21b93416e74d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs @@ -0,0 +1,69 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs b/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs new file mode 100644 index 000000000000..d6f611a32791 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs @@ -0,0 +1,74 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs new file mode 100644 index 000000000000..75aeda232903 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs @@ -0,0 +1,91 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs new file mode 100644 index 000000000000..1419ea265b42 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs new file mode 100644 index 000000000000..c43df824a60c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs @@ -0,0 +1,102 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB + /// Gremlin database + /// 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. + /// 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 GremlinDatabaseGetResults(string gremlinDatabaseGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + GremlinDatabaseGetResultsId = gremlinDatabaseGetResultsId; + 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 = "properties.id")] + public string GremlinDatabaseGetResultsId { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (GremlinDatabaseGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "GremlinDatabaseGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs new file mode 100644 index 000000000000..66d46a7858c0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the Gremlin databases and + /// their properties. + /// + public partial class GremlinDatabaseListResult + { + /// + /// Initializes a new instance of the GremlinDatabaseListResult class. + /// + public GremlinDatabaseListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GremlinDatabaseListResult class. + /// + /// List of Gremlin databases and their + /// properties. + public GremlinDatabaseListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of Gremlin databases and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs new file mode 100644 index 000000000000..0414c2878b9e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs new file mode 100644 index 000000000000..3bc7f5f442e0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs new file mode 100644 index 000000000000..a56768c28aa5 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs @@ -0,0 +1,152 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB + /// Gremlin graph + /// 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. + /// 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 GremlinGraphGetResults(string gremlinGraphGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), 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)) + : base(id, name, type, location, tags) + { + GremlinGraphGetResultsId = gremlinGraphGetResultsId; + 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 = "properties.id")] + public string GremlinGraphGetResultsId { 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 = "properties.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 = "properties.partitionKey")] + public ContainerPartitionKey PartitionKey { get; set; } + + /// + /// Gets or sets default time to live + /// + [JsonProperty(PropertyName = "properties.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 = "properties.uniqueKeyPolicy")] + public UniqueKeyPolicy UniqueKeyPolicy { get; set; } + + /// + /// Gets or sets the conflict resolution policy for the graph. + /// + [JsonProperty(PropertyName = "properties.conflictResolutionPolicy")] + public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (GremlinGraphGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "GremlinGraphGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs new file mode 100644 index 000000000000..edec352fd4bb --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs @@ -0,0 +1,50 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the graphs and their + /// properties. + /// + public partial class GremlinGraphListResult + { + /// + /// Initializes a new instance of the GremlinGraphListResult class. + /// + public GremlinGraphListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GremlinGraphListResult class. + /// + /// List of graphs and their properties. + public GremlinGraphListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of graphs and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs new file mode 100644 index 000000000000..2e7804251a75 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs @@ -0,0 +1,111 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs b/specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs new file mode 100644 index 000000000000..10f0b73b73c1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs b/specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs new file mode 100644 index 000000000000..cc31f8cd9a75 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs @@ -0,0 +1,19 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/Indexes.cs b/specification/cosmos-db/resource-manager/generated/Models/Indexes.cs new file mode 100644 index 000000000000..563f2d866618 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/Indexes.cs @@ -0,0 +1,70 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs b/specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs new file mode 100644 index 000000000000..07e4bf33e7b9 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs @@ -0,0 +1,19 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs new file mode 100644 index 000000000000..097468eeb10b --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs @@ -0,0 +1,78 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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 + public IndexingPolicy(bool? automatic = default(bool?), string indexingMode = default(string), IList includedPaths = default(IList), IList excludedPaths = default(IList)) + { + Automatic = automatic; + IndexingMode = indexingMode; + IncludedPaths = includedPaths; + ExcludedPaths = excludedPaths; + 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; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs b/specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs new file mode 100644 index 000000000000..b1b32e93f0e5 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs @@ -0,0 +1,20 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/Location.cs b/specification/cosmos-db/resource-manager/generated/Models/Location.cs new file mode 100644 index 000000000000..50e8cb763fb0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/Location.cs @@ -0,0 +1,116 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/Metric.cs b/specification/cosmos-db/resource-manager/generated/Models/Metric.cs new file mode 100644 index 000000000000..555bd06a684a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/Metric.cs @@ -0,0 +1,97 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs new file mode 100644 index 000000000000..0835bd7ee7a5 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs @@ -0,0 +1,57 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs new file mode 100644 index 000000000000..b410f6a8d75b --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs @@ -0,0 +1,89 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs new file mode 100644 index 000000000000..c95059e5c616 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs @@ -0,0 +1,52 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response to a list metric definitions request. + /// + public partial class MetricDefinitionsListResult + { + /// + /// Initializes a new instance of the MetricDefinitionsListResult + /// class. + /// + public MetricDefinitionsListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricDefinitionsListResult + /// class. + /// + /// The list of metric definitions for the + /// account. + public MetricDefinitionsListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of metric definitions for the account. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs new file mode 100644 index 000000000000..10a6d88931ff --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs @@ -0,0 +1,49 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response to a list metrics request. + /// + public partial class MetricListResult + { + /// + /// Initializes a new instance of the MetricListResult class. + /// + public MetricListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricListResult class. + /// + /// The list of metrics for the account. + public MetricListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of metrics for the account. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MetricName.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricName.cs new file mode 100644 index 000000000000..96969d365193 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MetricName.cs @@ -0,0 +1,56 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs new file mode 100644 index 000000000000..008f59a4f695 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs @@ -0,0 +1,88 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs new file mode 100644 index 000000000000..bf6dd007f17a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs new file mode 100644 index 000000000000..55edd4e2d9e7 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs @@ -0,0 +1,122 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB + /// MongoDB collection + /// 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. + /// 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 MongoDBCollectionGetResults(string mongoDBCollectionGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IDictionary shardKey = default(IDictionary), IList indexes = default(IList), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + MongoDBCollectionGetResultsId = mongoDBCollectionGetResultsId; + 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 = "properties.id")] + public string MongoDBCollectionGetResultsId { get; set; } + + /// + /// Gets or sets a key-value pair of shard keys to be applied for the + /// request. + /// + [JsonProperty(PropertyName = "properties.shardKey")] + public IDictionary ShardKey { get; set; } + + /// + /// Gets or sets list of index keys + /// + [JsonProperty(PropertyName = "properties.indexes")] + public IList Indexes { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (MongoDBCollectionGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MongoDBCollectionGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs new file mode 100644 index 000000000000..e600111f64e0 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs @@ -0,0 +1,53 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the MongoDB collections and + /// their properties. + /// + public partial class MongoDBCollectionListResult + { + /// + /// Initializes a new instance of the MongoDBCollectionListResult + /// class. + /// + public MongoDBCollectionListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoDBCollectionListResult + /// class. + /// + /// List of MongoDB collections and their + /// properties. + public MongoDBCollectionListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of MongoDB collections and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs new file mode 100644 index 000000000000..70ed92fba811 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs @@ -0,0 +1,81 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs new file mode 100644 index 000000000000..f085d7aac63a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs new file mode 100644 index 000000000000..9c3f265cdbe3 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs @@ -0,0 +1,102 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB + /// MongoDB database + /// 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. + /// 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 MongoDBDatabaseGetResults(string mongoDBDatabaseGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + MongoDBDatabaseGetResultsId = mongoDBDatabaseGetResultsId; + 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 = "properties.id")] + public string MongoDBDatabaseGetResultsId { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (MongoDBDatabaseGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MongoDBDatabaseGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs new file mode 100644 index 000000000000..0fd0a3813775 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the MongoDB databases and + /// their properties. + /// + public partial class MongoDBDatabaseListResult + { + /// + /// Initializes a new instance of the MongoDBDatabaseListResult class. + /// + public MongoDBDatabaseListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MongoDBDatabaseListResult class. + /// + /// List of MongoDB databases and their + /// properties. + public MongoDBDatabaseListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of MongoDB databases and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs new file mode 100644 index 000000000000..1ce40d424d7e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs new file mode 100644 index 000000000000..a43d54d9036c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs @@ -0,0 +1,56 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs new file mode 100644 index 000000000000..aa81b1f9ba65 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs new file mode 100644 index 000000000000..22d671b5b2a6 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs @@ -0,0 +1,55 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/Operation.cs b/specification/cosmos-db/resource-manager/generated/Models/Operation.cs new file mode 100644 index 000000000000..24e2f3b3921e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/Operation.cs @@ -0,0 +1,57 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs b/specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..eedcebb4f31b --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs @@ -0,0 +1,75 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs new file mode 100644 index 000000000000..cbd7db07e250 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the request to list Resource Provider operations. It contains + /// a list of operations and a URL link to get the next set of results. + /// + public partial class OperationListResult + { + /// + /// Initializes a new instance of the OperationListResult class. + /// + public OperationListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationListResult class. + /// + /// List of operations supported by the Resource + /// Provider. + /// URL to get the next set of operation list + /// results if there are any. + public OperationListResult(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of operations supported by the Resource Provider. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + /// + /// Gets or sets URL to get the next set of operation list results if + /// there are any. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs new file mode 100644 index 000000000000..924556d9477c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs @@ -0,0 +1,18 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + + /// + /// Defines values for PartitionKind. + /// + public static class PartitionKind + { + public const string Hash = "Hash"; + public const string Range = "Range"; + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs new file mode 100644 index 000000000000..5c202138321a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs @@ -0,0 +1,73 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs new file mode 100644 index 000000000000..a8d4c57724ef --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs @@ -0,0 +1,50 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response to a list partition metrics request. + /// + public partial class PartitionMetricListResult + { + /// + /// Initializes a new instance of the PartitionMetricListResult class. + /// + public PartitionMetricListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartitionMetricListResult class. + /// + /// The list of partition-level metrics for the + /// account. + public PartitionMetricListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of partition-level metrics for the account. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs new file mode 100644 index 000000000000..ae82ee01c396 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs @@ -0,0 +1,66 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs new file mode 100644 index 000000000000..50a8a96b41bf --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response to a list partition level usage request. + /// + public partial class PartitionUsagesResult + { + /// + /// Initializes a new instance of the PartitionUsagesResult class. + /// + public PartitionUsagesResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartitionUsagesResult class. + /// + /// The list of partition-level usages for the + /// database. A usage is a point in time metric + public PartitionUsagesResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of partition-level usages for the database. A usage + /// is a point in time metric + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs new file mode 100644 index 000000000000..6313c8b71109 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs @@ -0,0 +1,98 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs new file mode 100644 index 000000000000..2caaeb793006 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs @@ -0,0 +1,50 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response to a list percentile metrics request. + /// + public partial class PercentileMetricListResult + { + /// + /// Initializes a new instance of the PercentileMetricListResult class. + /// + public PercentileMetricListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PercentileMetricListResult class. + /// + /// The list of percentile metrics for the + /// account. + public PercentileMetricListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of percentile metrics for the account. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs new file mode 100644 index 000000000000..020e4008da4b --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs @@ -0,0 +1,103 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs b/specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs new file mode 100644 index 000000000000..60c75d57058a --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs @@ -0,0 +1,22 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs new file mode 100644 index 000000000000..ed840f03e056 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs @@ -0,0 +1,65 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A private endpoint connection + /// + [JsonTransformation] + public partial class PrivateEndpointConnection : ARMProxyResource + { + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + public PrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + /// The unique resource identifier of the database + /// account. + /// The name of the database account. + /// The type of Azure resource. + /// 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/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs new file mode 100644 index 000000000000..de0f847c3c1e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of private endpoint connections + /// + public partial class PrivateEndpointConnectionListResult + { + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionListResult class. + /// + public PrivateEndpointConnectionListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionListResult class. + /// + /// Array of private endpoint connections + public PrivateEndpointConnectionListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of private endpoint connections + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs new file mode 100644 index 000000000000..f80a707f7849 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs @@ -0,0 +1,47 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs new file mode 100644 index 000000000000..cf916ca8c6ca --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs @@ -0,0 +1,66 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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 + /// + [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/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs new file mode 100644 index 000000000000..2c03f3727c95 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of private link resources + /// + public partial class PrivateLinkResourceListResult + { + /// + /// Initializes a new instance of the PrivateLinkResourceListResult + /// class. + /// + public PrivateLinkResourceListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkResourceListResult + /// class. + /// + /// Array of private link resources + public PrivateLinkResourceListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of private link resources + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs new file mode 100644 index 000000000000..564638b30a0c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs @@ -0,0 +1,69 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs b/specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs new file mode 100644 index 000000000000..f4301cc635b1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs @@ -0,0 +1,63 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs new file mode 100644 index 000000000000..79ad7a8b2b70 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs new file mode 100644 index 000000000000..7d4266e03d88 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs @@ -0,0 +1,153 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB SQL + /// container + /// 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. + /// 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 SqlContainerGetResults(string sqlContainerGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), 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)) + : base(id, name, type, location, tags) + { + SqlContainerGetResultsId = sqlContainerGetResultsId; + 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 = "properties.id")] + public string SqlContainerGetResultsId { 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 = "properties.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 = "properties.partitionKey")] + public ContainerPartitionKey PartitionKey { get; set; } + + /// + /// Gets or sets default time to live + /// + [JsonProperty(PropertyName = "properties.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 = "properties.uniqueKeyPolicy")] + public UniqueKeyPolicy UniqueKeyPolicy { get; set; } + + /// + /// Gets or sets the conflict resolution policy for the container. + /// + [JsonProperty(PropertyName = "properties.conflictResolutionPolicy")] + public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SqlContainerGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SqlContainerGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs new file mode 100644 index 000000000000..36c9a9366483 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the containers and their + /// properties. + /// + public partial class SqlContainerListResult + { + /// + /// Initializes a new instance of the SqlContainerListResult class. + /// + public SqlContainerListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlContainerListResult class. + /// + /// List of containers and their + /// properties. + public SqlContainerListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of containers and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs new file mode 100644 index 000000000000..e827d1e83d6d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs @@ -0,0 +1,112 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs new file mode 100644 index 000000000000..f1af45ab0a10 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs new file mode 100644 index 000000000000..0efebea1cf58 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs @@ -0,0 +1,122 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB SQL + /// database + /// 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. + /// 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 SqlDatabaseGetResults(string sqlDatabaseGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string), string _colls = default(string), string _users = default(string)) + : base(id, name, type, location, tags) + { + SqlDatabaseGetResultsId = sqlDatabaseGetResultsId; + 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 = "properties.id")] + public string SqlDatabaseGetResultsId { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._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 = "properties._colls")] + public string _colls { get; set; } + + /// + /// Gets or sets a system generated property that specifies the + /// addressable path of the users resource. + /// + [JsonProperty(PropertyName = "properties._users")] + public string _users { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SqlDatabaseGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SqlDatabaseGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs new file mode 100644 index 000000000000..14b2caf2fe3e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the SQL databases and their + /// properties. + /// + public partial class SqlDatabaseListResult + { + /// + /// Initializes a new instance of the SqlDatabaseListResult class. + /// + public SqlDatabaseListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlDatabaseListResult class. + /// + /// List of SQL databases and their + /// properties. + public SqlDatabaseListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of SQL databases and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs new file mode 100644 index 000000000000..2e0d5e812849 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs new file mode 100644 index 000000000000..5e7b5a6bea86 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs new file mode 100644 index 000000000000..184043afe444 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs @@ -0,0 +1,112 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB + /// SQL storedProcedure + /// 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. + /// 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 SqlStoredProcedureGetResults(string sqlStoredProcedureGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string body = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + SqlStoredProcedureGetResultsId = sqlStoredProcedureGetResultsId; + 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 = "properties.id")] + public string SqlStoredProcedureGetResultsId { get; set; } + + /// + /// Gets or sets body of the Stored Procedure + /// + [JsonProperty(PropertyName = "properties.body")] + public string Body { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SqlStoredProcedureGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SqlStoredProcedureGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs new file mode 100644 index 000000000000..5e61ea0eec74 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs @@ -0,0 +1,53 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the storedProcedures and + /// their properties. + /// + public partial class SqlStoredProcedureListResult + { + /// + /// Initializes a new instance of the SqlStoredProcedureListResult + /// class. + /// + public SqlStoredProcedureListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlStoredProcedureListResult + /// class. + /// + /// List of storedProcedures and their + /// properties. + public SqlStoredProcedureListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of storedProcedures and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs new file mode 100644 index 000000000000..f81537543cfe --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs @@ -0,0 +1,69 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs new file mode 100644 index 000000000000..1c5731c74426 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs new file mode 100644 index 000000000000..88edb2939e87 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs @@ -0,0 +1,131 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB SQL + /// trigger + /// 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. + /// 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 SqlTriggerGetResults(string sqlTriggerGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string body = default(string), string triggerType = default(string), string triggerOperation = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + SqlTriggerGetResultsId = sqlTriggerGetResultsId; + 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 = "properties.id")] + public string SqlTriggerGetResultsId { get; set; } + + /// + /// Gets or sets body of the Trigger + /// + [JsonProperty(PropertyName = "properties.body")] + public string Body { get; set; } + + /// + /// Gets or sets type of the Trigger. Possible values include: 'Pre', + /// 'Post' + /// + [JsonProperty(PropertyName = "properties.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 = "properties.triggerOperation")] + public string TriggerOperation { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SqlTriggerGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SqlTriggerGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs new file mode 100644 index 000000000000..2a5669451aed --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs @@ -0,0 +1,50 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the triggers and their + /// properties. + /// + public partial class SqlTriggerListResult + { + /// + /// Initializes a new instance of the SqlTriggerListResult class. + /// + public SqlTriggerListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlTriggerListResult class. + /// + /// List of triggers and their properties. + public SqlTriggerListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of triggers and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs new file mode 100644 index 000000000000..d94995f53c00 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs @@ -0,0 +1,90 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs new file mode 100644 index 000000000000..a9db8582c434 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs @@ -0,0 +1,94 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs new file mode 100644 index 000000000000..f5625be9854f --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs @@ -0,0 +1,112 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos + /// DB SQL userDefinedFunction + /// 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. + /// 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 SqlUserDefinedFunctionGetResults(string sqlUserDefinedFunctionGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string body = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + SqlUserDefinedFunctionGetResultsId = sqlUserDefinedFunctionGetResultsId; + 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 = "properties.id")] + public string SqlUserDefinedFunctionGetResultsId { get; set; } + + /// + /// Gets or sets body of the User Defined Function + /// + [JsonProperty(PropertyName = "properties.body")] + public string Body { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SqlUserDefinedFunctionGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SqlUserDefinedFunctionGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs new file mode 100644 index 000000000000..77cdafb0f5b5 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs @@ -0,0 +1,53 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the userDefinedFunctions and + /// their properties. + /// + public partial class SqlUserDefinedFunctionListResult + { + /// + /// Initializes a new instance of the SqlUserDefinedFunctionListResult + /// class. + /// + public SqlUserDefinedFunctionListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SqlUserDefinedFunctionListResult + /// class. + /// + /// List of userDefinedFunctions and their + /// properties. + public SqlUserDefinedFunctionListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of userDefinedFunctions and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs new file mode 100644 index 000000000000..f96784b37f20 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs @@ -0,0 +1,72 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs new file mode 100644 index 000000000000..2c349cbb65c1 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs @@ -0,0 +1,93 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs new file mode 100644 index 000000000000..febba7e6f4e3 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs @@ -0,0 +1,101 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Name of the Cosmos DB table + /// 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. + /// 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 TableGetResults(string tableGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) + : base(id, name, type, location, tags) + { + TableGetResultsId = tableGetResultsId; + 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 = "properties.id")] + public string TableGetResultsId { get; set; } + + /// + /// Gets a system generated property. A unique identifier. + /// + [JsonProperty(PropertyName = "properties._rid")] + public string _rid { get; private set; } + + /// + /// Gets a system generated property that denotes the last updated + /// timestamp of the resource. + /// + [JsonProperty(PropertyName = "properties._ts")] + public object _ts { get; private set; } + + /// + /// Gets a system generated property representing the resource etag + /// required for optimistic concurrency control. + /// + [JsonProperty(PropertyName = "properties._etag")] + public string _etag { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (TableGetResultsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TableGetResultsId"); + } + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs new file mode 100644 index 000000000000..c106155462c3 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs @@ -0,0 +1,50 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The List operation response, that contains the Table and their + /// properties. + /// + public partial class TableListResult + { + /// + /// Initializes a new instance of the TableListResult class. + /// + public TableListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TableListResult class. + /// + /// List of Table and their properties. + public TableListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets list of Table and their properties. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/TableResource.cs b/specification/cosmos-db/resource-manager/generated/Models/TableResource.cs new file mode 100644 index 000000000000..fa82433abc1b --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/TableResource.cs @@ -0,0 +1,61 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs new file mode 100644 index 000000000000..c0786fe9a280 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs @@ -0,0 +1,90 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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. + /// + /// Value of the Cosmos DB 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. + /// The minimum throughput of the + /// resource + /// The throughput replace is + /// pending + public ThroughputSettingsGetResults(int throughput, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string minimumThroughput = default(string), string offerReplacePending = default(string)) + : base(id, name, type, location, tags) + { + Throughput = throughput; + 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 + /// + [JsonProperty(PropertyName = "properties.throughput")] + public int Throughput { get; set; } + + /// + /// Gets the minimum throughput of the resource + /// + [JsonProperty(PropertyName = "properties.minimumThroughput")] + public string MinimumThroughput { get; private set; } + + /// + /// Gets the throughput replace is pending + /// + [JsonProperty(PropertyName = "properties.offerReplacePending")] + public string OfferReplacePending { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs new file mode 100644 index 000000000000..50c549fde4b8 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs @@ -0,0 +1,76 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Cosmos DB resource throughput object + /// + 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 + /// The minimum throughput of the + /// resource + /// The throughput replace is + /// pending + public ThroughputSettingsResource(int throughput, string minimumThroughput = default(string), string offerReplacePending = default(string)) + { + Throughput = throughput; + 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 + /// + [JsonProperty(PropertyName = "throughput")] + public int Throughput { 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() + { + //Nothing to validate + } + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs new file mode 100644 index 000000000000..72ac24bacac5 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs @@ -0,0 +1,79 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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. + /// + [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/specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs b/specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs new file mode 100644 index 000000000000..50919cb2ed34 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs @@ -0,0 +1,21 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs b/specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs new file mode 100644 index 000000000000..e93eefefd86e --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs @@ -0,0 +1,18 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + + /// + /// Defines values for TriggerType. + /// + public static class TriggerType + { + public const string Pre = "Pre"; + public const string Post = "Post"; + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs b/specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs new file mode 100644 index 000000000000..0f6985c59d8d --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs @@ -0,0 +1,52 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs new file mode 100644 index 000000000000..648c154a8981 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs @@ -0,0 +1,55 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/UnitType.cs b/specification/cosmos-db/resource-manager/generated/Models/UnitType.cs new file mode 100644 index 000000000000..ca7426da97f4 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/UnitType.cs @@ -0,0 +1,23 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/Usage.cs b/specification/cosmos-db/resource-manager/generated/Models/Usage.cs new file mode 100644 index 000000000000..ad5c736e16a9 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/Usage.cs @@ -0,0 +1,84 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs b/specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs new file mode 100644 index 000000000000..beec819c0a91 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs @@ -0,0 +1,51 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response to a list usage request. + /// + public partial class UsagesResult + { + /// + /// Initializes a new instance of the UsagesResult class. + /// + public UsagesResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UsagesResult class. + /// + /// The list of usages for the database. A usage is + /// a point in time metric + public UsagesResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the list of usages for the database. A usage is a point in + /// time metric + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; private set; } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs b/specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs new file mode 100644 index 000000000000..54b15e5bea33 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs @@ -0,0 +1,60 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace 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/specification/cosmos-db/resource-manager/generated/MongoDBResources.cs b/specification/cosmos-db/resource-manager/generated/MongoDBResources.cs new file mode 100644 index 000000000000..24b37faf6d0b --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/MongoDBResources.cs @@ -0,0 +1,2512 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MongoDBResources operations. + /// + public partial class MongoDBResources : IServiceOperations, IMongoDBResources + { + /// + /// Initializes a new instance of the MongoDBResources class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public MongoDBResources(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateUpdateMongoDBDatabaseWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateMongoDBDatabase", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteMongoDBDatabaseWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteMongoDBDatabase", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateMongoDBDatabaseThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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> CreateUpdateMongoDBCollectionWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateMongoDBCollection", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteMongoDBCollectionWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteMongoDBCollection", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateMongoDBCollectionThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateMongoDBCollectionThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs new file mode 100644 index 000000000000..98920ca0f706 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs @@ -0,0 +1,629 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MongoDBResources. + /// + public static partial class MongoDBResourcesExtensions + { + /// + /// 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 MongoDBDatabaseListResult ListMongoDBDatabases(this IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 MongoDBCollectionListResult ListMongoDBCollections(this IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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; + } + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/Operations.cs b/specification/cosmos-db/resource-manager/generated/Operations.cs new file mode 100644 index 000000000000..462ea5720c2f --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Operations.cs @@ -0,0 +1,181 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public 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 + /// + public Operations(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs b/specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs new file mode 100644 index 000000000000..301c49a51b9c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs @@ -0,0 +1,47 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + 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 OperationListResult 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; + } + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs new file mode 100644 index 000000000000..fe1da3f1be61 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs @@ -0,0 +1,283 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeId operations. + /// + public partial class PartitionKeyRangeId : IServiceOperations, IPartitionKeyRangeId + { + /// + /// Initializes a new instance of the PartitionKeyRangeId class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public PartitionKeyRangeId(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs new file mode 100644 index 000000000000..1d23ab9babea --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs @@ -0,0 +1,91 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartitionKeyRangeId. + /// + public static partial class PartitionKeyRangeIdExtensions + { + /// + /// 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 PartitionMetricListResult ListMetrics(this IPartitionKeyRangeId 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 IPartitionKeyRangeId 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/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs new file mode 100644 index 000000000000..05a7c57906f2 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs @@ -0,0 +1,292 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartitionKeyRangeIdRegion operations. + /// + public partial class PartitionKeyRangeIdRegion : IServiceOperations, IPartitionKeyRangeIdRegion + { + /// + /// Initializes a new instance of the PartitionKeyRangeIdRegion class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public PartitionKeyRangeIdRegion(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs new file mode 100644 index 000000000000..75ace90ae152 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs @@ -0,0 +1,97 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartitionKeyRangeIdRegion. + /// + public static partial class PartitionKeyRangeIdRegionExtensions + { + /// + /// 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 PartitionMetricListResult ListMetrics(this IPartitionKeyRangeIdRegion 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 IPartitionKeyRangeIdRegion 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/specification/cosmos-db/resource-manager/generated/Percentile.cs b/specification/cosmos-db/resource-manager/generated/Percentile.cs new file mode 100644 index 000000000000..038652e435b8 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/Percentile.cs @@ -0,0 +1,256 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Percentile operations. + /// + public partial class Percentile : IServiceOperations, IPercentile + { + /// + /// Initializes a new instance of the Percentile class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public Percentile(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs b/specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs new file mode 100644 index 000000000000..1d7538611e1c --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs @@ -0,0 +1,73 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Percentile. + /// + public static partial class PercentileExtensions + { + /// + /// 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 PercentileMetricListResult ListMetrics(this IPercentile 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 IPercentile 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/specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs b/specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs new file mode 100644 index 000000000000..f44754716424 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs @@ -0,0 +1,277 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileSourceTarget operations. + /// + public partial class PercentileSourceTarget : IServiceOperations, IPercentileSourceTarget + { + /// + /// Initializes a new instance of the PercentileSourceTarget class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public PercentileSourceTarget(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs b/specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs new file mode 100644 index 000000000000..5b2bd147297b --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs @@ -0,0 +1,91 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PercentileSourceTarget. + /// + public static partial class PercentileSourceTargetExtensions + { + /// + /// 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 PercentileMetricListResult ListMetrics(this IPercentileSourceTarget 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 IPercentileSourceTarget 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/specification/cosmos-db/resource-manager/generated/PercentileTarget.cs b/specification/cosmos-db/resource-manager/generated/PercentileTarget.cs new file mode 100644 index 000000000000..ba56a7914d40 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PercentileTarget.cs @@ -0,0 +1,266 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PercentileTarget operations. + /// + public partial class PercentileTarget : IServiceOperations, IPercentileTarget + { + /// + /// Initializes a new instance of the PercentileTarget class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public PercentileTarget(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs b/specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs new file mode 100644 index 000000000000..6b77551e3171 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs @@ -0,0 +1,81 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PercentileTarget. + /// + public static partial class PercentileTargetExtensions + { + /// + /// 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 PercentileMetricListResult ListMetrics(this IPercentileTarget 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 IPercentileTarget 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/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs b/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs new file mode 100644 index 000000000000..2c9009536888 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs @@ -0,0 +1,830 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnections operations. + /// + public partial class PrivateEndpointConnections : IServiceOperations, IPrivateEndpointConnections + { + /// + /// Initializes a new instance of the PrivateEndpointConnections class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public PrivateEndpointConnections(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB Client { get; private set; } + + /// + /// List all private endpoint connections on 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}/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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// 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 (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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(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 (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, "CreateOrUpdate", 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 += "?" + 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 (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; + // 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 = Microsoft.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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(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 (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, "Delete", 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 += "?" + 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 (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; + // 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 = Microsoft.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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs b/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs new file mode 100644 index 000000000000..aa17766b3876 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs @@ -0,0 +1,194 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateEndpointConnections. + /// + public static partial class PrivateEndpointConnectionsExtensions + { + /// + /// List all private endpoint connections on a Cosmos DB account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + public static PrivateEndpointConnectionListResult ListByDatabaseAccount(this IPrivateEndpointConnections 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The cancellation token. + /// + public static async Task ListByDatabaseAccountAsync(this IPrivateEndpointConnections 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + public static PrivateEndpointConnection Get(this IPrivateEndpointConnections 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateEndpointConnections 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + public static PrivateEndpointConnection CreateOrUpdate(this IPrivateEndpointConnections operations, string resourceGroupName, string accountName, string privateEndpointConnectionName) + { + return operations.CreateOrUpdateAsync(resourceGroupName, accountName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPrivateEndpointConnections operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + public static void Delete(this IPrivateEndpointConnections 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. + /// + /// + /// Name of an Azure resource group. + /// + /// + /// Cosmos DB database account name. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPrivateEndpointConnections operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs b/specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs new file mode 100644 index 000000000000..4cd70a7e5c96 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs @@ -0,0 +1,441 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResources operations. + /// + public partial class PrivateLinkResources : IServiceOperations, IPrivateLinkResources + { + /// + /// Initializes a new instance of the PrivateLinkResources class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public PrivateLinkResources(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs new file mode 100644 index 000000000000..57641ed6ed64 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs @@ -0,0 +1,109 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkResources. + /// + public static partial class PrivateLinkResourcesExtensions + { + /// + /// 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 PrivateLinkResourceListResult ListByDatabaseAccount(this IPrivateLinkResources 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 IPrivateLinkResources 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 IPrivateLinkResources 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 IPrivateLinkResources 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/specification/cosmos-db/resource-manager/generated/SqlResources.cs b/specification/cosmos-db/resource-manager/generated/SqlResources.cs new file mode 100644 index 000000000000..569eedde4690 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/SqlResources.cs @@ -0,0 +1,5081 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SqlResources operations. + /// + public partial class SqlResources : IServiceOperations, ISqlResources + { + /// + /// Initializes a new instance of the SqlResources class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public SqlResources(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateUpdateSqlDatabaseWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateSqlDatabase", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteSqlDatabaseWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteSqlDatabase", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateSqlDatabaseThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateSqlDatabaseThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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> CreateUpdateSqlContainerWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateSqlContainer", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteSqlContainerWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteSqlContainer", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateSqlContainerThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateSqlContainerThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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> CreateUpdateSqlStoredProcedureWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateSqlStoredProcedure", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteSqlStoredProcedureWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteSqlStoredProcedure", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateSqlUserDefinedFunction", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteSqlUserDefinedFunctionWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteSqlUserDefinedFunction", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateUpdateSqlTriggerWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateSqlTrigger", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteSqlTriggerWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteSqlTrigger", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs new file mode 100644 index 000000000000..1ed032f622a4 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs @@ -0,0 +1,1318 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SqlResources. + /// + public static partial class SqlResourcesExtensions + { + /// + /// 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 SqlDatabaseListResult ListSqlDatabases(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlContainerListResult ListSqlContainers(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlStoredProcedureListResult ListSqlStoredProcedures(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlUserDefinedFunctionListResult ListSqlUserDefinedFunctions(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlTriggerListResult ListSqlTriggers(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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(); + } + + } +} diff --git a/specification/cosmos-db/resource-manager/generated/TableResources.cs b/specification/cosmos-db/resource-manager/generated/TableResources.cs new file mode 100644 index 000000000000..e7e094226ef9 --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/TableResources.cs @@ -0,0 +1,1252 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TableResources operations. + /// + public partial class TableResources : IServiceOperations, ITableResources + { + /// + /// Initializes a new instance of the TableResources class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public TableResources(CosmosDB client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDB + /// + public CosmosDB 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> CreateUpdateTableWithHttpMessagesAsync(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-08-01"; + // 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, "CreateUpdateTable", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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 DeleteTableWithHttpMessagesAsync(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-08-01"; + // 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, "DeleteTable", 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// 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-08-01"; + // 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 += "?" + 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 (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; + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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. + /// + /// + /// 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> UpdateTableThroughputWithHttpMessagesAsync(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-08-01"; + // 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, "UpdateTableThroughput", 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 += "?" + 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 (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 = Microsoft.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"); + } + // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + 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 HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs new file mode 100644 index 000000000000..34c0c99d6ecb --- /dev/null +++ b/specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs @@ -0,0 +1,302 @@ +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace CosmosDb +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TableResources. + /// + public static partial class TableResourcesExtensions + { + /// + /// 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 TableListResult ListTables(this ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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; + } + } + + } +} diff --git a/specification/cosmos-db/resource-manager/readme.md b/specification/cosmos-db/resource-manager/readme.md index ecef4cd32fe3..5ef20766c3a0 100644 --- a/specification/cosmos-db/resource-manager/readme.md +++ b/specification/cosmos-db/resource-manager/readme.md @@ -53,6 +53,7 @@ These settings apply only when `--tag=package-2019-08-preview` is specified on t input-file: - Microsoft.DocumentDB/stable/2019-08-01/cosmos-db.json - Microsoft.DocumentDB/preview/2019-08-01-preview/privateLinkResources.json +- Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json ``` ### Tag: package-2015-04 From 037730119e1729305460d5911057f87bddf89385 Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Mon, 21 Oct 2019 12:29:46 -0700 Subject: [PATCH 2/9] Deleted generated --- .../generated/CassandraResources.cs | 2512 -------- .../generated/CassandraResourcesExtensions.cs | 629 -- .../resource-manager/generated/Collection.cs | 700 --- .../generated/CollectionExtensions.cs | 199 - .../generated/CollectionPartition.cs | 493 -- .../CollectionPartitionExtensions.cs | 149 - .../generated/CollectionPartitionRegion.cs | 283 - .../CollectionPartitionRegionExtensions.cs | 91 - .../generated/CollectionRegion.cs | 283 - .../generated/CollectionRegionExtensions.cs | 91 - .../resource-manager/generated/CosmosDB.cs | 286 - .../resource-manager/generated/Database.cs | 673 --- .../generated/DatabaseAccountRegion.cs | 265 - .../DatabaseAccountRegionExtensions.cs | 79 - .../generated/DatabaseAccounts.cs | 3401 ----------- .../generated/DatabaseAccountsExtensions.cs | 785 --- .../generated/DatabaseExtensions.cs | 181 - .../generated/GremlinResources.cs | 2510 -------- .../generated/GremlinResourcesExtensions.cs | 625 -- .../generated/ICassandraResources.cs | 384 -- .../resource-manager/generated/ICollection.cs | 128 - .../generated/ICollectionPartition.cs | 97 - .../generated/ICollectionPartitionRegion.cs | 64 - .../generated/ICollectionRegion.cs | 64 - .../resource-manager/generated/ICosmosDB.cs | 139 - .../resource-manager/generated/IDatabase.cs | 118 - .../generated/IDatabaseAccountRegion.cs | 58 - .../generated/IDatabaseAccounts.cs | 490 -- .../generated/IGremlinResources.cs | 384 -- .../generated/IMongoDBResources.cs | 384 -- .../resource-manager/generated/IOperations.cs | 41 - .../generated/IPartitionKeyRangeId.cs | 63 - .../generated/IPartitionKeyRangeIdRegion.cs | 67 - .../resource-manager/generated/IPercentile.cs | 55 - .../generated/IPercentileSourceTarget.cs | 63 - .../generated/IPercentileTarget.cs | 59 - .../generated/IPrivateEndpointConnections.cs | 128 - .../generated/IPrivateLinkResources.cs | 77 - .../generated/ISqlResources.cs | 789 --- .../generated/ITableResources.cs | 194 - .../generated/Models/ARMProxyResource.cs | 65 - .../generated/Models/ARMResourceProperties.cs | 82 - .../generated/Models/Capability.cs | 51 - ...CassandraKeyspaceCreateUpdateParameters.cs | 94 - .../Models/CassandraKeyspaceGetResults.cs | 104 - .../Models/CassandraKeyspaceListResult.cs | 53 - .../Models/CassandraKeyspaceResource.cs | 61 - .../generated/Models/CassandraPartitionKey.cs | 48 - .../generated/Models/CassandraSchema.cs | 65 - .../CassandraTableCreateUpdateParameters.cs | 94 - .../Models/CassandraTableGetResults.cs | 120 - .../Models/CassandraTableListResult.cs | 51 - .../Models/CassandraTableResource.cs | 79 - .../generated/Models/ClusterKey.cs | 58 - .../generated/Models/Column.cs | 57 - .../Models/ConflictResolutionMode.cs | 18 - .../Models/ConflictResolutionPolicy.cs | 69 - .../generated/Models/ConnectorOffer.cs | 17 - .../generated/Models/ConsistencyPolicy.cs | 111 - .../generated/Models/ContainerPartitionKey.cs | 62 - .../generated/Models/DataType.cs | 22 - .../Models/DatabaseAccountConnectionString.cs | 59 - .../DatabaseAccountCreateUpdateParameters.cs | 215 - .../Models/DatabaseAccountGetResults.cs | 263 - .../generated/Models/DatabaseAccountKind.cs | 19 - ...abaseAccountListConnectionStringsResult.cs | 53 - .../Models/DatabaseAccountListKeysResult.cs | 64 - .../DatabaseAccountListReadOnlyKeysResult.cs | 59 - .../Models/DatabaseAccountOfferType.cs | 50 - .../Models/DatabaseAccountPatchParameters.cs | 61 - .../DatabaseAccountRegenerateKeyParameters.cs | 66 - .../Models/DatabaseAccountsListResult.cs | 51 - .../Models/DefaultConsistencyLevel.cs | 74 - .../generated/Models/ErrorResponse.cs | 56 - .../Models/ErrorResponseException.cs | 58 - .../generated/Models/ExcludedPath.cs | 48 - .../Models/ExtendedResourceProperties.cs | 69 - .../generated/Models/FailoverPolicies.cs | 74 - .../generated/Models/FailoverPolicy.cs | 91 - .../GremlinDatabaseCreateUpdateParameters.cs | 94 - .../Models/GremlinDatabaseGetResults.cs | 102 - .../Models/GremlinDatabaseListResult.cs | 51 - .../Models/GremlinDatabaseResource.cs | 61 - .../GremlinGraphCreateUpdateParameters.cs | 94 - .../Models/GremlinGraphGetResults.cs | 152 - .../Models/GremlinGraphListResult.cs | 50 - .../generated/Models/GremlinGraphResource.cs | 111 - .../generated/Models/IncludedPath.cs | 61 - .../generated/Models/IndexKind.cs | 19 - .../generated/Models/Indexes.cs | 70 - .../generated/Models/IndexingMode.cs | 19 - .../generated/Models/IndexingPolicy.cs | 78 - .../generated/Models/KeyKind.cs | 20 - .../generated/Models/Location.cs | 116 - .../generated/Models/Metric.cs | 97 - .../generated/Models/MetricAvailability.cs | 57 - .../generated/Models/MetricDefinition.cs | 89 - .../Models/MetricDefinitionsListResult.cs | 52 - .../generated/Models/MetricListResult.cs | 49 - .../generated/Models/MetricName.cs | 56 - .../generated/Models/MetricValue.cs | 88 - ...MongoDBCollectionCreateUpdateParameters.cs | 94 - .../Models/MongoDBCollectionGetResults.cs | 122 - .../Models/MongoDBCollectionListResult.cs | 53 - .../Models/MongoDBCollectionResource.cs | 81 - .../MongoDBDatabaseCreateUpdateParameters.cs | 94 - .../Models/MongoDBDatabaseGetResults.cs | 102 - .../Models/MongoDBDatabaseListResult.cs | 51 - .../Models/MongoDBDatabaseResource.cs | 61 - .../generated/Models/MongoIndex.cs | 56 - .../generated/Models/MongoIndexKeys.cs | 51 - .../generated/Models/MongoIndexOptions.cs | 55 - .../generated/Models/Operation.cs | 57 - .../generated/Models/OperationDisplay.cs | 75 - .../generated/Models/OperationListResult.cs | 61 - .../generated/Models/PartitionKind.cs | 18 - .../generated/Models/PartitionMetric.cs | 73 - .../Models/PartitionMetricListResult.cs | 50 - .../generated/Models/PartitionUsage.cs | 66 - .../generated/Models/PartitionUsagesResult.cs | 51 - .../generated/Models/PercentileMetric.cs | 98 - .../Models/PercentileMetricListResult.cs | 50 - .../generated/Models/PercentileMetricValue.cs | 103 - .../Models/PrimaryAggregationType.cs | 22 - .../Models/PrivateEndpointConnection.cs | 65 - .../PrivateEndpointConnectionListResult.cs | 51 - .../Models/PrivateEndpointProperty.cs | 47 - .../generated/Models/PrivateLinkResource.cs | 66 - .../Models/PrivateLinkResourceListResult.cs | 51 - ...ivateLinkServiceConnectionStateProperty.cs | 69 - .../Models/RegionForOnlineOffline.cs | 63 - .../SqlContainerCreateUpdateParameters.cs | 94 - .../Models/SqlContainerGetResults.cs | 153 - .../Models/SqlContainerListResult.cs | 51 - .../generated/Models/SqlContainerResource.cs | 112 - .../SqlDatabaseCreateUpdateParameters.cs | 94 - .../generated/Models/SqlDatabaseGetResults.cs | 122 - .../generated/Models/SqlDatabaseListResult.cs | 51 - .../generated/Models/SqlDatabaseResource.cs | 61 - ...qlStoredProcedureCreateUpdateParameters.cs | 94 - .../Models/SqlStoredProcedureGetResults.cs | 112 - .../Models/SqlStoredProcedureListResult.cs | 53 - .../Models/SqlStoredProcedureResource.cs | 69 - .../SqlTriggerCreateUpdateParameters.cs | 94 - .../generated/Models/SqlTriggerGetResults.cs | 131 - .../generated/Models/SqlTriggerListResult.cs | 50 - .../generated/Models/SqlTriggerResource.cs | 90 - ...erDefinedFunctionCreateUpdateParameters.cs | 94 - .../SqlUserDefinedFunctionGetResults.cs | 112 - .../SqlUserDefinedFunctionListResult.cs | 53 - .../Models/SqlUserDefinedFunctionResource.cs | 72 - .../Models/TableCreateUpdateParameters.cs | 93 - .../generated/Models/TableGetResults.cs | 101 - .../generated/Models/TableListResult.cs | 50 - .../generated/Models/TableResource.cs | 61 - .../Models/ThroughputSettingsGetResults.cs | 90 - .../Models/ThroughputSettingsResource.cs | 76 - .../ThroughputSettingsUpdateParameters.cs | 79 - .../generated/Models/TriggerOperation.cs | 21 - .../generated/Models/TriggerType.cs | 18 - .../generated/Models/UniqueKey.cs | 52 - .../generated/Models/UniqueKeyPolicy.cs | 55 - .../generated/Models/UnitType.cs | 23 - .../generated/Models/Usage.cs | 84 - .../generated/Models/UsagesResult.cs | 51 - .../generated/Models/VirtualNetworkRule.cs | 60 - .../generated/MongoDBResources.cs | 2512 -------- .../generated/MongoDBResourcesExtensions.cs | 629 -- .../resource-manager/generated/Operations.cs | 181 - .../generated/OperationsExtensions.cs | 47 - .../generated/PartitionKeyRangeId.cs | 283 - .../PartitionKeyRangeIdExtensions.cs | 91 - .../generated/PartitionKeyRangeIdRegion.cs | 292 - .../PartitionKeyRangeIdRegionExtensions.cs | 97 - .../resource-manager/generated/Percentile.cs | 256 - .../generated/PercentileExtensions.cs | 73 - .../generated/PercentileSourceTarget.cs | 277 - .../PercentileSourceTargetExtensions.cs | 91 - .../generated/PercentileTarget.cs | 266 - .../generated/PercentileTargetExtensions.cs | 81 - .../generated/PrivateEndpointConnections.cs | 830 --- .../PrivateEndpointConnectionsExtensions.cs | 194 - .../generated/PrivateLinkResources.cs | 441 -- .../PrivateLinkResourcesExtensions.cs | 109 - .../generated/SqlResources.cs | 5081 ----------------- .../generated/SqlResourcesExtensions.cs | 1318 ----- .../generated/TableResources.cs | 1252 ---- .../generated/TableResourcesExtensions.cs | 302 - 188 files changed, 41813 deletions(-) delete mode 100644 specification/cosmos-db/resource-manager/generated/CassandraResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Collection.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartition.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CollectionRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/CosmosDB.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Database.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/GremlinResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ICassandraResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ICollection.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ICosmosDB.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IDatabase.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IGremlinResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IOperations.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IPercentile.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ISqlResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/ITableResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/Capability.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/Column.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DataType.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/Indexes.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/Location.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/Metric.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricName.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/Operation.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/TableResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/UnitType.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/Usage.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/MongoDBResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Operations.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/Percentile.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PercentileTarget.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/SqlResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/TableResources.cs delete mode 100644 specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs diff --git a/specification/cosmos-db/resource-manager/generated/CassandraResources.cs b/specification/cosmos-db/resource-manager/generated/CassandraResources.cs deleted file mode 100644 index 5d7b1e83f77d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CassandraResources.cs +++ /dev/null @@ -1,2512 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CassandraResources operations. - /// - public partial class CassandraResources : IServiceOperations, ICassandraResources - { - /// - /// Initializes a new instance of the CassandraResources class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CassandraResources(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateUpdateCassandraKeyspaceWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateCassandraKeyspace", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteCassandraKeyspaceWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteCassandraKeyspace", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateCassandraKeyspaceThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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> CreateUpdateCassandraTableWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateCassandraTable", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteCassandraTableWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteCassandraTable", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateCassandraTableThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateCassandraTableThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs deleted file mode 100644 index c58574fbf91c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CassandraResourcesExtensions.cs +++ /dev/null @@ -1,629 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CassandraResources. - /// - public static partial class CassandraResourcesExtensions - { - /// - /// 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 CassandraKeyspaceListResult ListCassandraKeyspaces(this ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 CassandraTableListResult ListCassandraTables(this ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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 ICassandraResources 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; - } - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Collection.cs b/specification/cosmos-db/resource-manager/generated/Collection.cs deleted file mode 100644 index bd8622cf918d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Collection.cs +++ /dev/null @@ -1,700 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Collection operations. - /// - public partial class Collection : IServiceOperations, ICollection - { - /// - /// Initializes a new instance of the Collection class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Collection(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs deleted file mode 100644 index d5e5bd79f9f1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CollectionExtensions.cs +++ /dev/null @@ -1,199 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Collection. - /// - public static partial class CollectionExtensions - { - /// - /// 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 MetricListResult ListMetrics(this ICollection 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 ICollection 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 UsagesResult ListUsages(this ICollection 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 ICollection 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 MetricDefinitionsListResult ListMetricDefinitions(this ICollection 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 ICollection 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/specification/cosmos-db/resource-manager/generated/CollectionPartition.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartition.cs deleted file mode 100644 index e5d85c98ab7f..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CollectionPartition.cs +++ /dev/null @@ -1,493 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CollectionPartition operations. - /// - public partial class CollectionPartition : IServiceOperations, ICollectionPartition - { - /// - /// Initializes a new instance of the CollectionPartition class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CollectionPartition(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs deleted file mode 100644 index dd09503b3f4f..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CollectionPartitionExtensions.cs +++ /dev/null @@ -1,149 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CollectionPartition. - /// - public static partial class CollectionPartitionExtensions - { - /// - /// 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 PartitionMetricListResult ListMetrics(this ICollectionPartition 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 ICollectionPartition 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 PartitionUsagesResult ListUsages(this ICollectionPartition 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 ICollectionPartition 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/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs deleted file mode 100644 index dc73c6c8fa0f..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegion.cs +++ /dev/null @@ -1,283 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CollectionPartitionRegion operations. - /// - public partial class CollectionPartitionRegion : IServiceOperations, ICollectionPartitionRegion - { - /// - /// Initializes a new instance of the CollectionPartitionRegion class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CollectionPartitionRegion(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs deleted file mode 100644 index f9b577e4b994..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CollectionPartitionRegionExtensions.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CollectionPartitionRegion. - /// - public static partial class CollectionPartitionRegionExtensions - { - /// - /// 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 PartitionMetricListResult ListMetrics(this ICollectionPartitionRegion 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 ICollectionPartitionRegion 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/specification/cosmos-db/resource-manager/generated/CollectionRegion.cs b/specification/cosmos-db/resource-manager/generated/CollectionRegion.cs deleted file mode 100644 index 8d2cdb9d09c0..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CollectionRegion.cs +++ /dev/null @@ -1,283 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CollectionRegion operations. - /// - public partial class CollectionRegion : IServiceOperations, ICollectionRegion - { - /// - /// Initializes a new instance of the CollectionRegion class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public CollectionRegion(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs deleted file mode 100644 index 7ff43f946a85..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CollectionRegionExtensions.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for CollectionRegion. - /// - public static partial class CollectionRegionExtensions - { - /// - /// 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 MetricListResult ListMetrics(this ICollectionRegion 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 ICollectionRegion 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/specification/cosmos-db/resource-manager/generated/CosmosDB.cs b/specification/cosmos-db/resource-manager/generated/CosmosDB.cs deleted file mode 100644 index 365a5c988c2a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/CosmosDB.cs +++ /dev/null @@ -1,286 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - - /// - /// Azure Cosmos DB Database Service Resource Provider REST API - /// - public partial class CosmosDB : ServiceClient, ICosmosDB - { - /// - /// 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; } - - /// - /// Azure subscription ID. - /// - public string SubscriptionId { get; set; } - - /// - /// Gets the IDatabaseAccounts. - /// - public virtual IDatabaseAccounts DatabaseAccounts { get; private set; } - - /// - /// Gets the IOperations. - /// - public virtual IOperations Operations { get; private set; } - - /// - /// Gets the IDatabase. - /// - public virtual IDatabase Database { get; private set; } - - /// - /// Gets the ICollection. - /// - public virtual ICollection Collection { get; private set; } - - /// - /// Gets the ICollectionRegion. - /// - public virtual ICollectionRegion CollectionRegion { get; private set; } - - /// - /// Gets the IDatabaseAccountRegion. - /// - public virtual IDatabaseAccountRegion DatabaseAccountRegion { get; private set; } - - /// - /// Gets the IPercentileSourceTarget. - /// - public virtual IPercentileSourceTarget PercentileSourceTarget { get; private set; } - - /// - /// Gets the IPercentileTarget. - /// - public virtual IPercentileTarget PercentileTarget { get; private set; } - - /// - /// Gets the IPercentile. - /// - public virtual IPercentile Percentile { get; private set; } - - /// - /// Gets the ICollectionPartitionRegion. - /// - public virtual ICollectionPartitionRegion CollectionPartitionRegion { get; private set; } - - /// - /// Gets the ICollectionPartition. - /// - public virtual ICollectionPartition CollectionPartition { get; private set; } - - /// - /// Gets the IPartitionKeyRangeId. - /// - public virtual IPartitionKeyRangeId PartitionKeyRangeId { get; private set; } - - /// - /// Gets the IPartitionKeyRangeIdRegion. - /// - public virtual IPartitionKeyRangeIdRegion PartitionKeyRangeIdRegion { get; private set; } - - /// - /// Gets the ISqlResources. - /// - public virtual ISqlResources SqlResources { get; private set; } - - /// - /// Gets the IMongoDBResources. - /// - public virtual IMongoDBResources MongoDBResources { get; private set; } - - /// - /// Gets the ITableResources. - /// - public virtual ITableResources TableResources { get; private set; } - - /// - /// Gets the ICassandraResources. - /// - public virtual ICassandraResources CassandraResources { get; private set; } - - /// - /// Gets the IGremlinResources. - /// - public virtual IGremlinResources GremlinResources { get; private set; } - - /// - /// Gets the IPrivateLinkResources. - /// - public virtual IPrivateLinkResources PrivateLinkResources { get; private set; } - - /// - /// Gets the IPrivateEndpointConnections. - /// - public virtual IPrivateEndpointConnections PrivateEndpointConnections { get; private set; } - - /// - /// Initializes a new instance of the CosmosDB class. - /// - /// - /// HttpClient to be used - /// - /// - /// True: will dispose the provided httpClient on calling CosmosDB.Dispose(). False: will not dispose provided httpClient - public CosmosDB(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CosmosDB class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CosmosDB(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CosmosDB class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - public CosmosDB(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CosmosDB 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 - /// - public CosmosDB(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CosmosDB 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 - /// - public CosmosDB(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// An optional partial-method to perform custom initialization. - /// - partial void CustomInitialize(); - /// - /// Initializes client properties. - /// - private void Initialize() - { - DatabaseAccounts = new DatabaseAccounts(this); - Operations = new Operations(this); - Database = new Database(this); - Collection = new Collection(this); - CollectionRegion = new CollectionRegion(this); - DatabaseAccountRegion = new DatabaseAccountRegion(this); - PercentileSourceTarget = new PercentileSourceTarget(this); - PercentileTarget = new PercentileTarget(this); - Percentile = new Percentile(this); - CollectionPartitionRegion = new CollectionPartitionRegion(this); - CollectionPartition = new CollectionPartition(this); - PartitionKeyRangeId = new PartitionKeyRangeId(this); - PartitionKeyRangeIdRegion = new PartitionKeyRangeIdRegion(this); - SqlResources = new SqlResources(this); - MongoDBResources = new MongoDBResources(this); - TableResources = new TableResources(this); - CassandraResources = new CassandraResources(this); - GremlinResources = new GremlinResources(this); - PrivateLinkResources = new PrivateLinkResources(this); - PrivateEndpointConnections = new PrivateEndpointConnections(this); - BaseUri = new System.Uri("https://management.azure.com"); - 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()); - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Database.cs b/specification/cosmos-db/resource-manager/generated/Database.cs deleted file mode 100644 index 2239267b1858..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Database.cs +++ /dev/null @@ -1,673 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Database operations. - /// - public partial class Database : IServiceOperations, IDatabase - { - /// - /// Initializes a new instance of the Database class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Database(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs deleted file mode 100644 index 2c55c947f4ba..000000000000 --- a/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegion.cs +++ /dev/null @@ -1,265 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// DatabaseAccountRegion operations. - /// - public partial class DatabaseAccountRegion : IServiceOperations, IDatabaseAccountRegion - { - /// - /// Initializes a new instance of the DatabaseAccountRegion class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public DatabaseAccountRegion(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs deleted file mode 100644 index ef204899cc05..000000000000 --- a/specification/cosmos-db/resource-manager/generated/DatabaseAccountRegionExtensions.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for DatabaseAccountRegion. - /// - public static partial class DatabaseAccountRegionExtensions - { - /// - /// 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 MetricListResult ListMetrics(this IDatabaseAccountRegion 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 IDatabaseAccountRegion 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/specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs deleted file mode 100644 index 67d16eccef9a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/DatabaseAccounts.cs +++ /dev/null @@ -1,3401 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// DatabaseAccounts operations. - /// - public partial class DatabaseAccounts : IServiceOperations, IDatabaseAccounts - { - /// - /// Initializes a new instance of the DatabaseAccounts class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public DatabaseAccounts(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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; - } - - /// - /// Patches the properties of an existing Azure Cosmos DB database account. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The tags parameter to patch 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> PatchWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountPatchParameters 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-08-01"; - // 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, "Patch", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateOrUpdateWithHttpMessagesAsync(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-08-01"; - // 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, "CreateOrUpdate", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteWithHttpMessagesAsync(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"; - // 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, "Delete", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - 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 FailoverPriorityChangeWithHttpMessagesAsync(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-08-01"; - // 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, "FailoverPriorityChange", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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 OfflineRegionWithHttpMessagesAsync(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-08-01"; - // 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, "OfflineRegion", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 = Microsoft.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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - 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 OnlineRegionWithHttpMessagesAsync(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-08-01"; - // 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, "OnlineRegion", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 = Microsoft.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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - 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> 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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 RegenerateKeyWithHttpMessagesAsync(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-08-01"; - // 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, "RegenerateKey", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs b/specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs deleted file mode 100644 index 4ec278979ac1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/DatabaseAccountsExtensions.cs +++ /dev/null @@ -1,785 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for DatabaseAccounts. - /// - public static partial class DatabaseAccountsExtensions - { - /// - /// 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 IDatabaseAccounts 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 IDatabaseAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Patches 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 tags parameter to patch for the current database account. - /// - public static DatabaseAccountGetResults Patch(this IDatabaseAccounts operations, string resourceGroupName, string accountName, DatabaseAccountPatchParameters updateParameters) - { - return operations.PatchAsync(resourceGroupName, accountName, updateParameters).GetAwaiter().GetResult(); - } - - /// - /// Patches 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 tags parameter to patch for the current database account. - /// - /// - /// The cancellation token. - /// - public static async Task PatchAsync(this IDatabaseAccounts operations, string resourceGroupName, string accountName, DatabaseAccountPatchParameters updateParameters, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.PatchWithHttpMessagesAsync(resourceGroupName, accountName, updateParameters, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates or updates an 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 CreateOrUpdate(this IDatabaseAccounts 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 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 DatabaseAccountsListResult List(this IDatabaseAccounts 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 IDatabaseAccounts 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 DatabaseAccountsListResult ListByResourceGroup(this IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 IDatabaseAccounts 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 void CheckNameExists(this IDatabaseAccounts operations, string accountName) - { - 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 IDatabaseAccounts operations, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.CheckNameExistsWithHttpMessagesAsync(accountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - /// - /// 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 MetricListResult ListMetrics(this IDatabaseAccounts 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 IDatabaseAccounts 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 UsagesResult ListUsages(this IDatabaseAccounts 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 IDatabaseAccounts 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 MetricDefinitionsListResult ListMetricDefinitions(this IDatabaseAccounts 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 IDatabaseAccounts operations, string resourceGroupName, string accountName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListMetricDefinitionsWithHttpMessagesAsync(resourceGroupName, accountName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs b/specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs deleted file mode 100644 index 64b3717c4368..000000000000 --- a/specification/cosmos-db/resource-manager/generated/DatabaseExtensions.cs +++ /dev/null @@ -1,181 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Database. - /// - public static partial class DatabaseExtensions - { - /// - /// 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 MetricListResult ListMetrics(this IDatabase 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 IDatabase 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 UsagesResult ListUsages(this IDatabase 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 IDatabase 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 MetricDefinitionsListResult ListMetricDefinitions(this IDatabase 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 IDatabase 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/specification/cosmos-db/resource-manager/generated/GremlinResources.cs b/specification/cosmos-db/resource-manager/generated/GremlinResources.cs deleted file mode 100644 index fd55b8404228..000000000000 --- a/specification/cosmos-db/resource-manager/generated/GremlinResources.cs +++ /dev/null @@ -1,2510 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// GremlinResources operations. - /// - public partial class GremlinResources : IServiceOperations, IGremlinResources - { - /// - /// Initializes a new instance of the GremlinResources class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public GremlinResources(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateUpdateGremlinDatabaseWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateGremlinDatabase", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteGremlinDatabaseWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteGremlinDatabase", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateGremlinDatabaseThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateGremlinDatabaseThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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> CreateUpdateGremlinGraphWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateGremlinGraph", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteGremlinGraphWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteGremlinGraph", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateGremlinGraphThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateGremlinGraphThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs deleted file mode 100644 index 9c13dd55cf41..000000000000 --- a/specification/cosmos-db/resource-manager/generated/GremlinResourcesExtensions.cs +++ /dev/null @@ -1,625 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for GremlinResources. - /// - public static partial class GremlinResourcesExtensions - { - /// - /// 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 GremlinDatabaseListResult ListGremlinDatabases(this IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 GremlinGraphListResult ListGremlinGraphs(this IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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 IGremlinResources 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; - } - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/ICassandraResources.cs b/specification/cosmos-db/resource-manager/generated/ICassandraResources.cs deleted file mode 100644 index bd1e97d47299..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ICassandraResources.cs +++ /dev/null @@ -1,384 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CassandraResources operations. - /// - public partial interface ICassandraResources - { - /// - /// 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/ICollection.cs b/specification/cosmos-db/resource-manager/generated/ICollection.cs deleted file mode 100644 index add26c1f95f1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ICollection.cs +++ /dev/null @@ -1,128 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Collection operations. - /// - public partial interface ICollection - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs b/specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs deleted file mode 100644 index 2859a23775d0..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ICollectionPartition.cs +++ /dev/null @@ -1,97 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CollectionPartition operations. - /// - public partial interface ICollectionPartition - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs b/specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs deleted file mode 100644 index 39e224688c34..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ICollectionPartitionRegion.cs +++ /dev/null @@ -1,64 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CollectionPartitionRegion operations. - /// - public partial interface ICollectionPartitionRegion - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs b/specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs deleted file mode 100644 index 6eb2133c8847..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ICollectionRegion.cs +++ /dev/null @@ -1,64 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// CollectionRegion operations. - /// - public partial interface ICollectionRegion - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/ICosmosDB.cs b/specification/cosmos-db/resource-manager/generated/ICosmosDB.cs deleted file mode 100644 index dc23ceb71e4c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ICosmosDB.cs +++ /dev/null @@ -1,139 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using Newtonsoft.Json; - - /// - /// Azure Cosmos DB Database Service Resource Provider REST API - /// - public partial interface ICosmosDB : 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; } - - /// - /// Azure subscription ID. - /// - string SubscriptionId { get; set; } - - - /// - /// Gets the IDatabaseAccounts. - /// - IDatabaseAccounts DatabaseAccounts { get; } - - /// - /// Gets the IOperations. - /// - IOperations Operations { get; } - - /// - /// Gets the IDatabase. - /// - IDatabase Database { get; } - - /// - /// Gets the ICollection. - /// - ICollection Collection { get; } - - /// - /// Gets the ICollectionRegion. - /// - ICollectionRegion CollectionRegion { get; } - - /// - /// Gets the IDatabaseAccountRegion. - /// - IDatabaseAccountRegion DatabaseAccountRegion { get; } - - /// - /// Gets the IPercentileSourceTarget. - /// - IPercentileSourceTarget PercentileSourceTarget { get; } - - /// - /// Gets the IPercentileTarget. - /// - IPercentileTarget PercentileTarget { get; } - - /// - /// Gets the IPercentile. - /// - IPercentile Percentile { get; } - - /// - /// Gets the ICollectionPartitionRegion. - /// - ICollectionPartitionRegion CollectionPartitionRegion { get; } - - /// - /// Gets the ICollectionPartition. - /// - ICollectionPartition CollectionPartition { get; } - - /// - /// Gets the IPartitionKeyRangeId. - /// - IPartitionKeyRangeId PartitionKeyRangeId { get; } - - /// - /// Gets the IPartitionKeyRangeIdRegion. - /// - IPartitionKeyRangeIdRegion PartitionKeyRangeIdRegion { get; } - - /// - /// Gets the ISqlResources. - /// - ISqlResources SqlResources { get; } - - /// - /// Gets the IMongoDBResources. - /// - IMongoDBResources MongoDBResources { get; } - - /// - /// Gets the ITableResources. - /// - ITableResources TableResources { get; } - - /// - /// Gets the ICassandraResources. - /// - ICassandraResources CassandraResources { get; } - - /// - /// Gets the IGremlinResources. - /// - IGremlinResources GremlinResources { get; } - - /// - /// Gets the IPrivateLinkResources. - /// - IPrivateLinkResources PrivateLinkResources { get; } - - /// - /// Gets the IPrivateEndpointConnections. - /// - IPrivateEndpointConnections PrivateEndpointConnections { get; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/IDatabase.cs b/specification/cosmos-db/resource-manager/generated/IDatabase.cs deleted file mode 100644 index a14ca5467eff..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IDatabase.cs +++ /dev/null @@ -1,118 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Database operations. - /// - public partial interface IDatabase - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs b/specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs deleted file mode 100644 index bc255c17b6df..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IDatabaseAccountRegion.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// DatabaseAccountRegion operations. - /// - public partial interface IDatabaseAccountRegion - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs b/specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs deleted file mode 100644 index b3da709279f6..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IDatabaseAccounts.cs +++ /dev/null @@ -1,490 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// DatabaseAccounts operations. - /// - public partial interface IDatabaseAccounts - { - /// - /// 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)); - /// - /// Patches the properties of an existing Azure Cosmos DB database - /// account. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The tags parameter to patch 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> PatchWithHttpMessagesAsync(string resourceGroupName, string accountName, DatabaseAccountPatchParameters updateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates or updates an 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> 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/IGremlinResources.cs b/specification/cosmos-db/resource-manager/generated/IGremlinResources.cs deleted file mode 100644 index 520971e64164..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IGremlinResources.cs +++ /dev/null @@ -1,384 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// GremlinResources operations. - /// - public partial interface IGremlinResources - { - /// - /// 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs b/specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs deleted file mode 100644 index 219a4c469aa1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IMongoDBResources.cs +++ /dev/null @@ -1,384 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// MongoDBResources operations. - /// - public partial interface IMongoDBResources - { - /// - /// 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/IOperations.cs b/specification/cosmos-db/resource-manager/generated/IOperations.cs deleted file mode 100644 index eae757541ba8..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IOperations.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs b/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs deleted file mode 100644 index 4b3deb16127d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeId.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PartitionKeyRangeId operations. - /// - public partial interface IPartitionKeyRangeId - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs b/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs deleted file mode 100644 index ad4e0d007115..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IPartitionKeyRangeIdRegion.cs +++ /dev/null @@ -1,67 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PartitionKeyRangeIdRegion operations. - /// - public partial interface IPartitionKeyRangeIdRegion - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/IPercentile.cs b/specification/cosmos-db/resource-manager/generated/IPercentile.cs deleted file mode 100644 index 658115e66c03..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IPercentile.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Percentile operations. - /// - public partial interface IPercentile - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs b/specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs deleted file mode 100644 index deab4d01aad6..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IPercentileSourceTarget.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PercentileSourceTarget operations. - /// - public partial interface IPercentileSourceTarget - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs b/specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs deleted file mode 100644 index 5630a205b7b1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IPercentileTarget.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PercentileTarget operations. - /// - public partial interface IPercentileTarget - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs b/specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs deleted file mode 100644 index ae53c25840a7..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IPrivateEndpointConnections.cs +++ /dev/null @@ -1,128 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PrivateEndpointConnections operations. - /// - public partial interface IPrivateEndpointConnections - { - /// - /// List all private endpoint connections on 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 a private endpoint connection. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// 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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// 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, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Deletes a private endpoint connection with a given name. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs b/specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs deleted file mode 100644 index 4e38d2f8b828..000000000000 --- a/specification/cosmos-db/resource-manager/generated/IPrivateLinkResources.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PrivateLinkResources operations. - /// - public partial interface IPrivateLinkResources - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/ISqlResources.cs b/specification/cosmos-db/resource-manager/generated/ISqlResources.cs deleted file mode 100644 index 76cdd9176bf6..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ISqlResources.cs +++ /dev/null @@ -1,789 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SqlResources operations. - /// - public partial interface ISqlResources - { - /// - /// 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/ITableResources.cs b/specification/cosmos-db/resource-manager/generated/ITableResources.cs deleted file mode 100644 index af3b2620771f..000000000000 --- a/specification/cosmos-db/resource-manager/generated/ITableResources.cs +++ /dev/null @@ -1,194 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// TableResources operations. - /// - public partial interface ITableResources - { - /// - /// 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)); - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs b/specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs deleted file mode 100644 index d11e220cdd1e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ARMProxyResource.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - 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 - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs b/specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs deleted file mode 100644 index e04d164df0e0..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ARMResourceProperties.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The core properties of ARM resources. - /// - public partial class ARMResourceProperties - { - /// - /// 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/specification/cosmos-db/resource-manager/generated/Models/Capability.cs b/specification/cosmos-db/resource-manager/generated/Models/Capability.cs deleted file mode 100644 index 7c1a77abd8fe..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/Capability.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs deleted file mode 100644 index bf435924d93d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs deleted file mode 100644 index 21c29b405cf6..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceGetResults.cs +++ /dev/null @@ -1,104 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB - /// Cassandra keyspace - /// 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. - /// 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 CassandraKeyspaceGetResults(string cassandraKeyspaceGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - CassandraKeyspaceGetResultsId = cassandraKeyspaceGetResultsId; - 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 = "properties.id")] - public string CassandraKeyspaceGetResultsId { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CassandraKeyspaceGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "CassandraKeyspaceGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs deleted file mode 100644 index 42fa5e4710a7..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceListResult.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the Cassandra keyspaces and - /// their properties. - /// - public partial class CassandraKeyspaceListResult - { - /// - /// Initializes a new instance of the CassandraKeyspaceListResult - /// class. - /// - public CassandraKeyspaceListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CassandraKeyspaceListResult - /// class. - /// - /// List of Cassandra keyspaces and their - /// properties. - public CassandraKeyspaceListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of Cassandra keyspaces and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs deleted file mode 100644 index a51b6ebdbdd2..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraKeyspaceResource.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs deleted file mode 100644 index 14996ba52a01..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraPartitionKey.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs deleted file mode 100644 index c61521a8a7c9..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraSchema.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs deleted file mode 100644 index 6d02860ed16d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs deleted file mode 100644 index add57bba80ea..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableGetResults.cs +++ /dev/null @@ -1,120 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB - /// Cassandra table - /// 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. - /// 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 CassandraTableGetResults(string cassandraTableGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), int? defaultTtl = default(int?), CassandraSchema schema = default(CassandraSchema), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - CassandraTableGetResultsId = cassandraTableGetResultsId; - 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 = "properties.id")] - public string CassandraTableGetResultsId { get; set; } - - /// - /// Gets or sets time to live of the Cosmos DB Cassandra table - /// - [JsonProperty(PropertyName = "properties.defaultTtl")] - public int? DefaultTtl { get; set; } - - /// - /// Gets or sets schema of the Cosmos DB Cassandra table - /// - [JsonProperty(PropertyName = "properties.schema")] - public CassandraSchema Schema { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (CassandraTableGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "CassandraTableGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs deleted file mode 100644 index ab10e0f23403..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the Cassandra tables and - /// their properties. - /// - public partial class CassandraTableListResult - { - /// - /// Initializes a new instance of the CassandraTableListResult class. - /// - public CassandraTableListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the CassandraTableListResult class. - /// - /// List of Cassandra tables and their - /// properties. - public CassandraTableListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of Cassandra tables and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs b/specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs deleted file mode 100644 index 123f928b5c8e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/CassandraTableResource.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs b/specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs deleted file mode 100644 index ca3e5f17afe7..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ClusterKey.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/Column.cs b/specification/cosmos-db/resource-manager/generated/Models/Column.cs deleted file mode 100644 index 1de52b7490e4..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/Column.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs b/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs deleted file mode 100644 index 87ac934eba77..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionMode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - - /// - /// Defines values for ConflictResolutionMode. - /// - public static class ConflictResolutionMode - { - public const string LastWriterWins = "LastWriterWins"; - public const string Custom = "Custom"; - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs deleted file mode 100644 index 1cb125ba2952..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ConflictResolutionPolicy.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs b/specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs deleted file mode 100644 index 004dabec3a14..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ConnectorOffer.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - - /// - /// Defines values for ConnectorOffer. - /// - public static class ConnectorOffer - { - public const string Small = "Small"; - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs deleted file mode 100644 index f6bac404f10d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ConsistencyPolicy.cs +++ /dev/null @@ -1,111 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs b/specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs deleted file mode 100644 index aa166a05d035..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ContainerPartitionKey.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - 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' - public ContainerPartitionKey(IList paths = default(IList), string kind = default(string)) - { - Paths = paths; - Kind = kind; - 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; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DataType.cs b/specification/cosmos-db/resource-manager/generated/Models/DataType.cs deleted file mode 100644 index 578204925818..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DataType.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs deleted file mode 100644 index 908b74e163f6..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountConnectionString.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs deleted file mode 100644 index d71cda17de8a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountCreateUpdateParameters.cs +++ /dev/null @@ -1,215 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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' - 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)) - : 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; - 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; } - - /// - /// 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs deleted file mode 100644 index 17cece250323..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountGetResults.cs +++ /dev/null @@ -1,263 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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 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' - 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 failoverPolicies = default(IList), IList virtualNetworkRules = default(IList), bool? enableMultipleWriteLocations = default(bool?), bool? enableCassandraConnector = default(bool?), string connectorOffer = 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; - FailoverPolicies = failoverPolicies; - VirtualNetworkRules = virtualNetworkRules; - EnableMultipleWriteLocations = enableMultipleWriteLocations; - EnableCassandraConnector = enableCassandraConnector; - ConnectorOffer = connectorOffer; - 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 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; } - - /// - /// 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 (FailoverPolicies != null) - { - foreach (var element2 in FailoverPolicies) - { - if (element2 != null) - { - element2.Validate(); - } - } - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs deleted file mode 100644 index 9a0eaf23bb57..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountKind.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs deleted file mode 100644 index 8f312aca3a49..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListConnectionStringsResult.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs deleted file mode 100644 index c544517d7cb8..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListKeysResult.cs +++ /dev/null @@ -1,64 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs deleted file mode 100644 index 3bce34fe3d84..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountListReadOnlyKeysResult.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs deleted file mode 100644 index aefb2b2e37ae..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountOfferType.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs deleted file mode 100644 index a375473cdba9..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountPatchParameters.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [JsonTransformation] - public partial class DatabaseAccountPatchParameters - { - /// - /// Initializes a new instance of the DatabaseAccountPatchParameters - /// class. - /// - public DatabaseAccountPatchParameters() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the DatabaseAccountPatchParameters - /// class. - /// - /// List of Cosmos DB capabilities for the - /// account - public DatabaseAccountPatchParameters(IDictionary tags = default(IDictionary), IList capabilities = default(IList)) - { - Tags = tags; - Capabilities = capabilities; - 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 list of Cosmos DB capabilities for the account - /// - [JsonProperty(PropertyName = "properties.capabilities")] - public IList Capabilities { get; set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs deleted file mode 100644 index 97584a083382..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountRegenerateKeyParameters.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs deleted file mode 100644 index 3a2c9dcc324c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DatabaseAccountsListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the database accounts and - /// their properties. - /// - public partial class DatabaseAccountsListResult - { - /// - /// Initializes a new instance of the DatabaseAccountsListResult class. - /// - public DatabaseAccountsListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the DatabaseAccountsListResult class. - /// - /// List of database account and their - /// properties. - public DatabaseAccountsListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of database account and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs b/specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs deleted file mode 100644 index 959784f8a6a4..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/DefaultConsistencyLevel.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs b/specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs deleted file mode 100644 index 12a7fdfc6241..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ErrorResponse.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs b/specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs deleted file mode 100644 index b164faf02411..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ErrorResponseException.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs b/specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs deleted file mode 100644 index 67496172538d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ExcludedPath.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs b/specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs deleted file mode 100644 index 21b93416e74d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ExtendedResourceProperties.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs b/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs deleted file mode 100644 index d6f611a32791..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicies.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs deleted file mode 100644 index 75aeda232903..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/FailoverPolicy.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs deleted file mode 100644 index 1419ea265b42..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs deleted file mode 100644 index c43df824a60c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseGetResults.cs +++ /dev/null @@ -1,102 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB - /// Gremlin database - /// 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. - /// 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 GremlinDatabaseGetResults(string gremlinDatabaseGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - GremlinDatabaseGetResultsId = gremlinDatabaseGetResultsId; - 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 = "properties.id")] - public string GremlinDatabaseGetResultsId { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (GremlinDatabaseGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "GremlinDatabaseGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs deleted file mode 100644 index 66d46a7858c0..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the Gremlin databases and - /// their properties. - /// - public partial class GremlinDatabaseListResult - { - /// - /// Initializes a new instance of the GremlinDatabaseListResult class. - /// - public GremlinDatabaseListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the GremlinDatabaseListResult class. - /// - /// List of Gremlin databases and their - /// properties. - public GremlinDatabaseListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of Gremlin databases and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs deleted file mode 100644 index 0414c2878b9e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinDatabaseResource.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs deleted file mode 100644 index 3bc7f5f442e0..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs deleted file mode 100644 index a56768c28aa5..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphGetResults.cs +++ /dev/null @@ -1,152 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB - /// Gremlin graph - /// 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. - /// 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 GremlinGraphGetResults(string gremlinGraphGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), 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)) - : base(id, name, type, location, tags) - { - GremlinGraphGetResultsId = gremlinGraphGetResultsId; - 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 = "properties.id")] - public string GremlinGraphGetResultsId { 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 = "properties.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 = "properties.partitionKey")] - public ContainerPartitionKey PartitionKey { get; set; } - - /// - /// Gets or sets default time to live - /// - [JsonProperty(PropertyName = "properties.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 = "properties.uniqueKeyPolicy")] - public UniqueKeyPolicy UniqueKeyPolicy { get; set; } - - /// - /// Gets or sets the conflict resolution policy for the graph. - /// - [JsonProperty(PropertyName = "properties.conflictResolutionPolicy")] - public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (GremlinGraphGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "GremlinGraphGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs deleted file mode 100644 index edec352fd4bb..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphListResult.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the graphs and their - /// properties. - /// - public partial class GremlinGraphListResult - { - /// - /// Initializes a new instance of the GremlinGraphListResult class. - /// - public GremlinGraphListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the GremlinGraphListResult class. - /// - /// List of graphs and their properties. - public GremlinGraphListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of graphs and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs b/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs deleted file mode 100644 index 2e7804251a75..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/GremlinGraphResource.cs +++ /dev/null @@ -1,111 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs b/specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs deleted file mode 100644 index 10f0b73b73c1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/IncludedPath.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs b/specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs deleted file mode 100644 index cc31f8cd9a75..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/IndexKind.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/Indexes.cs b/specification/cosmos-db/resource-manager/generated/Models/Indexes.cs deleted file mode 100644 index 563f2d866618..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/Indexes.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs b/specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs deleted file mode 100644 index 07e4bf33e7b9..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/IndexingMode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs deleted file mode 100644 index 097468eeb10b..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/IndexingPolicy.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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 - public IndexingPolicy(bool? automatic = default(bool?), string indexingMode = default(string), IList includedPaths = default(IList), IList excludedPaths = default(IList)) - { - Automatic = automatic; - IndexingMode = indexingMode; - IncludedPaths = includedPaths; - ExcludedPaths = excludedPaths; - 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; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs b/specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs deleted file mode 100644 index b1b32e93f0e5..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/KeyKind.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/Location.cs b/specification/cosmos-db/resource-manager/generated/Models/Location.cs deleted file mode 100644 index 50e8cb763fb0..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/Location.cs +++ /dev/null @@ -1,116 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/Metric.cs b/specification/cosmos-db/resource-manager/generated/Models/Metric.cs deleted file mode 100644 index 555bd06a684a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/Metric.cs +++ /dev/null @@ -1,97 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs deleted file mode 100644 index 0835bd7ee7a5..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MetricAvailability.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs deleted file mode 100644 index b410f6a8d75b..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MetricDefinition.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs deleted file mode 100644 index c95059e5c616..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MetricDefinitionsListResult.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The response to a list metric definitions request. - /// - public partial class MetricDefinitionsListResult - { - /// - /// Initializes a new instance of the MetricDefinitionsListResult - /// class. - /// - public MetricDefinitionsListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the MetricDefinitionsListResult - /// class. - /// - /// The list of metric definitions for the - /// account. - public MetricDefinitionsListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of metric definitions for the account. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs deleted file mode 100644 index 10a6d88931ff..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MetricListResult.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The response to a list metrics request. - /// - public partial class MetricListResult - { - /// - /// Initializes a new instance of the MetricListResult class. - /// - public MetricListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the MetricListResult class. - /// - /// The list of metrics for the account. - public MetricListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of metrics for the account. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MetricName.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricName.cs deleted file mode 100644 index 96969d365193..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MetricName.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs b/specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs deleted file mode 100644 index 008f59a4f695..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MetricValue.cs +++ /dev/null @@ -1,88 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs deleted file mode 100644 index bf6dd007f17a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs deleted file mode 100644 index 55edd4e2d9e7..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionGetResults.cs +++ /dev/null @@ -1,122 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB - /// MongoDB collection - /// 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. - /// 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 MongoDBCollectionGetResults(string mongoDBCollectionGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), IDictionary shardKey = default(IDictionary), IList indexes = default(IList), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - MongoDBCollectionGetResultsId = mongoDBCollectionGetResultsId; - 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 = "properties.id")] - public string MongoDBCollectionGetResultsId { get; set; } - - /// - /// Gets or sets a key-value pair of shard keys to be applied for the - /// request. - /// - [JsonProperty(PropertyName = "properties.shardKey")] - public IDictionary ShardKey { get; set; } - - /// - /// Gets or sets list of index keys - /// - [JsonProperty(PropertyName = "properties.indexes")] - public IList Indexes { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (MongoDBCollectionGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MongoDBCollectionGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs deleted file mode 100644 index e600111f64e0..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionListResult.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the MongoDB collections and - /// their properties. - /// - public partial class MongoDBCollectionListResult - { - /// - /// Initializes a new instance of the MongoDBCollectionListResult - /// class. - /// - public MongoDBCollectionListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the MongoDBCollectionListResult - /// class. - /// - /// List of MongoDB collections and their - /// properties. - public MongoDBCollectionListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of MongoDB collections and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs deleted file mode 100644 index 70ed92fba811..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBCollectionResource.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs deleted file mode 100644 index f085d7aac63a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs deleted file mode 100644 index 9c3f265cdbe3..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseGetResults.cs +++ /dev/null @@ -1,102 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB - /// MongoDB database - /// 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. - /// 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 MongoDBDatabaseGetResults(string mongoDBDatabaseGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - MongoDBDatabaseGetResultsId = mongoDBDatabaseGetResultsId; - 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 = "properties.id")] - public string MongoDBDatabaseGetResultsId { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (MongoDBDatabaseGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MongoDBDatabaseGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs deleted file mode 100644 index 0fd0a3813775..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the MongoDB databases and - /// their properties. - /// - public partial class MongoDBDatabaseListResult - { - /// - /// Initializes a new instance of the MongoDBDatabaseListResult class. - /// - public MongoDBDatabaseListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the MongoDBDatabaseListResult class. - /// - /// List of MongoDB databases and their - /// properties. - public MongoDBDatabaseListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of MongoDB databases and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs deleted file mode 100644 index 1ce40d424d7e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoDBDatabaseResource.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs deleted file mode 100644 index a43d54d9036c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoIndex.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs deleted file mode 100644 index aa81b1f9ba65..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoIndexKeys.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs b/specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs deleted file mode 100644 index 22d671b5b2a6..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/MongoIndexOptions.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/Operation.cs b/specification/cosmos-db/resource-manager/generated/Models/Operation.cs deleted file mode 100644 index 24e2f3b3921e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/Operation.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs b/specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs deleted file mode 100644 index eedcebb4f31b..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/OperationDisplay.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs deleted file mode 100644 index cbd7db07e250..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/OperationListResult.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Result of the request to list Resource Provider operations. It contains - /// a list of operations and a URL link to get the next set of results. - /// - public partial class OperationListResult - { - /// - /// Initializes a new instance of the OperationListResult class. - /// - public OperationListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the OperationListResult class. - /// - /// List of operations supported by the Resource - /// Provider. - /// URL to get the next set of operation list - /// results if there are any. - public OperationListResult(IList value = default(IList), string nextLink = default(string)) - { - Value = value; - NextLink = nextLink; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets list of operations supported by the Resource Provider. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - /// - /// Gets or sets URL to get the next set of operation list results if - /// there are any. - /// - [JsonProperty(PropertyName = "nextLink")] - public string NextLink { get; set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs deleted file mode 100644 index 924556d9477c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PartitionKind.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - - /// - /// Defines values for PartitionKind. - /// - public static class PartitionKind - { - public const string Hash = "Hash"; - public const string Range = "Range"; - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs deleted file mode 100644 index 5c202138321a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PartitionMetric.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs deleted file mode 100644 index a8d4c57724ef..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PartitionMetricListResult.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The response to a list partition metrics request. - /// - public partial class PartitionMetricListResult - { - /// - /// Initializes a new instance of the PartitionMetricListResult class. - /// - public PartitionMetricListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PartitionMetricListResult class. - /// - /// The list of partition-level metrics for the - /// account. - public PartitionMetricListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of partition-level metrics for the account. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs deleted file mode 100644 index ae82ee01c396..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PartitionUsage.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs deleted file mode 100644 index 50a8a96b41bf..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PartitionUsagesResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The response to a list partition level usage request. - /// - public partial class PartitionUsagesResult - { - /// - /// Initializes a new instance of the PartitionUsagesResult class. - /// - public PartitionUsagesResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PartitionUsagesResult class. - /// - /// The list of partition-level usages for the - /// database. A usage is a point in time metric - public PartitionUsagesResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of partition-level usages for the database. A usage - /// is a point in time metric - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs deleted file mode 100644 index 6313c8b71109..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PercentileMetric.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs deleted file mode 100644 index 2caaeb793006..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricListResult.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The response to a list percentile metrics request. - /// - public partial class PercentileMetricListResult - { - /// - /// Initializes a new instance of the PercentileMetricListResult class. - /// - public PercentileMetricListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PercentileMetricListResult class. - /// - /// The list of percentile metrics for the - /// account. - public PercentileMetricListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of percentile metrics for the account. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs b/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs deleted file mode 100644 index 020e4008da4b..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PercentileMetricValue.cs +++ /dev/null @@ -1,103 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs b/specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs deleted file mode 100644 index 60c75d57058a..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PrimaryAggregationType.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs deleted file mode 100644 index ed840f03e056..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnection.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; - using System.Linq; - - /// - /// A private endpoint connection - /// - [JsonTransformation] - public partial class PrivateEndpointConnection : ARMProxyResource - { - /// - /// Initializes a new instance of the PrivateEndpointConnection class. - /// - public PrivateEndpointConnection() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PrivateEndpointConnection class. - /// - /// The unique resource identifier of the database - /// account. - /// The name of the database account. - /// The type of Azure resource. - /// 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/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs deleted file mode 100644 index de0f847c3c1e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointConnectionListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A list of private endpoint connections - /// - public partial class PrivateEndpointConnectionListResult - { - /// - /// Initializes a new instance of the - /// PrivateEndpointConnectionListResult class. - /// - public PrivateEndpointConnectionListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the - /// PrivateEndpointConnectionListResult class. - /// - /// Array of private endpoint connections - public PrivateEndpointConnectionListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets array of private endpoint connections - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs deleted file mode 100644 index f80a707f7849..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PrivateEndpointProperty.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs deleted file mode 100644 index cf916ca8c6ca..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResource.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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 - /// - [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/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs deleted file mode 100644 index 2c03f3727c95..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkResourceListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A list of private link resources - /// - public partial class PrivateLinkResourceListResult - { - /// - /// Initializes a new instance of the PrivateLinkResourceListResult - /// class. - /// - public PrivateLinkResourceListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the PrivateLinkResourceListResult - /// class. - /// - /// Array of private link resources - public PrivateLinkResourceListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets array of private link resources - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs b/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs deleted file mode 100644 index 564638b30a0c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/PrivateLinkServiceConnectionStateProperty.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs b/specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs deleted file mode 100644 index f4301cc635b1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/RegionForOnlineOffline.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs deleted file mode 100644 index 79ad7a8b2b70..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs deleted file mode 100644 index 7d4266e03d88..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerGetResults.cs +++ /dev/null @@ -1,153 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB SQL - /// container - /// 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. - /// 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 SqlContainerGetResults(string sqlContainerGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), 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)) - : base(id, name, type, location, tags) - { - SqlContainerGetResultsId = sqlContainerGetResultsId; - 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 = "properties.id")] - public string SqlContainerGetResultsId { 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 = "properties.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 = "properties.partitionKey")] - public ContainerPartitionKey PartitionKey { get; set; } - - /// - /// Gets or sets default time to live - /// - [JsonProperty(PropertyName = "properties.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 = "properties.uniqueKeyPolicy")] - public UniqueKeyPolicy UniqueKeyPolicy { get; set; } - - /// - /// Gets or sets the conflict resolution policy for the container. - /// - [JsonProperty(PropertyName = "properties.conflictResolutionPolicy")] - public ConflictResolutionPolicy ConflictResolutionPolicy { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (SqlContainerGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SqlContainerGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs deleted file mode 100644 index 36c9a9366483..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the containers and their - /// properties. - /// - public partial class SqlContainerListResult - { - /// - /// Initializes a new instance of the SqlContainerListResult class. - /// - public SqlContainerListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SqlContainerListResult class. - /// - /// List of containers and their - /// properties. - public SqlContainerListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of containers and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs deleted file mode 100644 index e827d1e83d6d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlContainerResource.cs +++ /dev/null @@ -1,112 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs deleted file mode 100644 index f1af45ab0a10..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs deleted file mode 100644 index 0efebea1cf58..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseGetResults.cs +++ /dev/null @@ -1,122 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB SQL - /// database - /// 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. - /// 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 SqlDatabaseGetResults(string sqlDatabaseGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string), string _colls = default(string), string _users = default(string)) - : base(id, name, type, location, tags) - { - SqlDatabaseGetResultsId = sqlDatabaseGetResultsId; - 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 = "properties.id")] - public string SqlDatabaseGetResultsId { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._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 = "properties._colls")] - public string _colls { get; set; } - - /// - /// Gets or sets a system generated property that specifies the - /// addressable path of the users resource. - /// - [JsonProperty(PropertyName = "properties._users")] - public string _users { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (SqlDatabaseGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SqlDatabaseGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs deleted file mode 100644 index 14b2caf2fe3e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseListResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the SQL databases and their - /// properties. - /// - public partial class SqlDatabaseListResult - { - /// - /// Initializes a new instance of the SqlDatabaseListResult class. - /// - public SqlDatabaseListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SqlDatabaseListResult class. - /// - /// List of SQL databases and their - /// properties. - public SqlDatabaseListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of SQL databases and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs deleted file mode 100644 index 2e0d5e812849..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlDatabaseResource.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs deleted file mode 100644 index 5e7b5a6bea86..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs deleted file mode 100644 index 184043afe444..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureGetResults.cs +++ /dev/null @@ -1,112 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB - /// SQL storedProcedure - /// 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. - /// 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 SqlStoredProcedureGetResults(string sqlStoredProcedureGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string body = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - SqlStoredProcedureGetResultsId = sqlStoredProcedureGetResultsId; - 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 = "properties.id")] - public string SqlStoredProcedureGetResultsId { get; set; } - - /// - /// Gets or sets body of the Stored Procedure - /// - [JsonProperty(PropertyName = "properties.body")] - public string Body { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (SqlStoredProcedureGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SqlStoredProcedureGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs deleted file mode 100644 index 5e61ea0eec74..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureListResult.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the storedProcedures and - /// their properties. - /// - public partial class SqlStoredProcedureListResult - { - /// - /// Initializes a new instance of the SqlStoredProcedureListResult - /// class. - /// - public SqlStoredProcedureListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SqlStoredProcedureListResult - /// class. - /// - /// List of storedProcedures and their - /// properties. - public SqlStoredProcedureListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of storedProcedures and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs deleted file mode 100644 index f81537543cfe..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlStoredProcedureResource.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs deleted file mode 100644 index 1c5731c74426..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs deleted file mode 100644 index 88edb2939e87..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerGetResults.cs +++ /dev/null @@ -1,131 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB SQL - /// trigger - /// 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. - /// 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 SqlTriggerGetResults(string sqlTriggerGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string body = default(string), string triggerType = default(string), string triggerOperation = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - SqlTriggerGetResultsId = sqlTriggerGetResultsId; - 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 = "properties.id")] - public string SqlTriggerGetResultsId { get; set; } - - /// - /// Gets or sets body of the Trigger - /// - [JsonProperty(PropertyName = "properties.body")] - public string Body { get; set; } - - /// - /// Gets or sets type of the Trigger. Possible values include: 'Pre', - /// 'Post' - /// - [JsonProperty(PropertyName = "properties.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 = "properties.triggerOperation")] - public string TriggerOperation { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (SqlTriggerGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SqlTriggerGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs deleted file mode 100644 index 2a5669451aed..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerListResult.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the triggers and their - /// properties. - /// - public partial class SqlTriggerListResult - { - /// - /// Initializes a new instance of the SqlTriggerListResult class. - /// - public SqlTriggerListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SqlTriggerListResult class. - /// - /// List of triggers and their properties. - public SqlTriggerListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of triggers and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs deleted file mode 100644 index d94995f53c00..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlTriggerResource.cs +++ /dev/null @@ -1,90 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs deleted file mode 100644 index a9db8582c434..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionCreateUpdateParameters.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs deleted file mode 100644 index f5625be9854f..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionGetResults.cs +++ /dev/null @@ -1,112 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos - /// DB SQL userDefinedFunction - /// 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. - /// 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 SqlUserDefinedFunctionGetResults(string sqlUserDefinedFunctionGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string body = default(string), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - SqlUserDefinedFunctionGetResultsId = sqlUserDefinedFunctionGetResultsId; - 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 = "properties.id")] - public string SqlUserDefinedFunctionGetResultsId { get; set; } - - /// - /// Gets or sets body of the User Defined Function - /// - [JsonProperty(PropertyName = "properties.body")] - public string Body { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (SqlUserDefinedFunctionGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SqlUserDefinedFunctionGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs deleted file mode 100644 index 77cdafb0f5b5..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionListResult.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the userDefinedFunctions and - /// their properties. - /// - public partial class SqlUserDefinedFunctionListResult - { - /// - /// Initializes a new instance of the SqlUserDefinedFunctionListResult - /// class. - /// - public SqlUserDefinedFunctionListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SqlUserDefinedFunctionListResult - /// class. - /// - /// List of userDefinedFunctions and their - /// properties. - public SqlUserDefinedFunctionListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of userDefinedFunctions and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs b/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs deleted file mode 100644 index f96784b37f20..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/SqlUserDefinedFunctionResource.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs deleted file mode 100644 index 2c349cbb65c1..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/TableCreateUpdateParameters.cs +++ /dev/null @@ -1,93 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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, IDictionary 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 IDictionary 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/specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs deleted file mode 100644 index febba7e6f4e3..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/TableGetResults.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Name of the Cosmos DB table - /// 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. - /// 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 TableGetResults(string tableGetResultsId, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string _rid = default(string), object _ts = default(object), string _etag = default(string)) - : base(id, name, type, location, tags) - { - TableGetResultsId = tableGetResultsId; - 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 = "properties.id")] - public string TableGetResultsId { get; set; } - - /// - /// Gets a system generated property. A unique identifier. - /// - [JsonProperty(PropertyName = "properties._rid")] - public string _rid { get; private set; } - - /// - /// Gets a system generated property that denotes the last updated - /// timestamp of the resource. - /// - [JsonProperty(PropertyName = "properties._ts")] - public object _ts { get; private set; } - - /// - /// Gets a system generated property representing the resource etag - /// required for optimistic concurrency control. - /// - [JsonProperty(PropertyName = "properties._etag")] - public string _etag { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TableGetResultsId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "TableGetResultsId"); - } - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs b/specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs deleted file mode 100644 index c106155462c3..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/TableListResult.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The List operation response, that contains the Table and their - /// properties. - /// - public partial class TableListResult - { - /// - /// Initializes a new instance of the TableListResult class. - /// - public TableListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TableListResult class. - /// - /// List of Table and their properties. - public TableListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets list of Table and their properties. - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/TableResource.cs b/specification/cosmos-db/resource-manager/generated/Models/TableResource.cs deleted file mode 100644 index fa82433abc1b..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/TableResource.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs deleted file mode 100644 index c0786fe9a280..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsGetResults.cs +++ /dev/null @@ -1,90 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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. - /// - /// Value of the Cosmos DB 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. - /// The minimum throughput of the - /// resource - /// The throughput replace is - /// pending - public ThroughputSettingsGetResults(int throughput, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string minimumThroughput = default(string), string offerReplacePending = default(string)) - : base(id, name, type, location, tags) - { - Throughput = throughput; - 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 - /// - [JsonProperty(PropertyName = "properties.throughput")] - public int Throughput { get; set; } - - /// - /// Gets the minimum throughput of the resource - /// - [JsonProperty(PropertyName = "properties.minimumThroughput")] - public string MinimumThroughput { get; private set; } - - /// - /// Gets the throughput replace is pending - /// - [JsonProperty(PropertyName = "properties.offerReplacePending")] - public string OfferReplacePending { get; private set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - //Nothing to validate - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs deleted file mode 100644 index 50c549fde4b8..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsResource.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Cosmos DB resource throughput object - /// - 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 - /// The minimum throughput of the - /// resource - /// The throughput replace is - /// pending - public ThroughputSettingsResource(int throughput, string minimumThroughput = default(string), string offerReplacePending = default(string)) - { - Throughput = throughput; - 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 - /// - [JsonProperty(PropertyName = "throughput")] - public int Throughput { 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() - { - //Nothing to validate - } - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs b/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs deleted file mode 100644 index 72ac24bacac5..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/ThroughputSettingsUpdateParameters.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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. - /// - [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/specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs b/specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs deleted file mode 100644 index 50919cb2ed34..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/TriggerOperation.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs b/specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs deleted file mode 100644 index e93eefefd86e..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/TriggerType.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - - /// - /// Defines values for TriggerType. - /// - public static class TriggerType - { - public const string Pre = "Pre"; - public const string Post = "Post"; - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs b/specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs deleted file mode 100644 index 0f6985c59d8d..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/UniqueKey.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs b/specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs deleted file mode 100644 index 648c154a8981..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/UniqueKeyPolicy.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/UnitType.cs b/specification/cosmos-db/resource-manager/generated/Models/UnitType.cs deleted file mode 100644 index ca7426da97f4..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/UnitType.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/Usage.cs b/specification/cosmos-db/resource-manager/generated/Models/Usage.cs deleted file mode 100644 index ad5c736e16a9..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/Usage.cs +++ /dev/null @@ -1,84 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs b/specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs deleted file mode 100644 index beec819c0a91..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/UsagesResult.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// The response to a list usage request. - /// - public partial class UsagesResult - { - /// - /// Initializes a new instance of the UsagesResult class. - /// - public UsagesResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the UsagesResult class. - /// - /// The list of usages for the database. A usage is - /// a point in time metric - public UsagesResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the list of usages for the database. A usage is a point in - /// time metric - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; private set; } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs b/specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs deleted file mode 100644 index 54b15e5bea33..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Models/VirtualNetworkRule.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace 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/specification/cosmos-db/resource-manager/generated/MongoDBResources.cs b/specification/cosmos-db/resource-manager/generated/MongoDBResources.cs deleted file mode 100644 index 24b37faf6d0b..000000000000 --- a/specification/cosmos-db/resource-manager/generated/MongoDBResources.cs +++ /dev/null @@ -1,2512 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// MongoDBResources operations. - /// - public partial class MongoDBResources : IServiceOperations, IMongoDBResources - { - /// - /// Initializes a new instance of the MongoDBResources class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public MongoDBResources(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateUpdateMongoDBDatabaseWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateMongoDBDatabase", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteMongoDBDatabaseWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteMongoDBDatabase", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateMongoDBDatabaseThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateMongoDBDatabaseThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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> CreateUpdateMongoDBCollectionWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateMongoDBCollection", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteMongoDBCollectionWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteMongoDBCollection", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateMongoDBCollectionThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateMongoDBCollectionThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs deleted file mode 100644 index 98920ca0f706..000000000000 --- a/specification/cosmos-db/resource-manager/generated/MongoDBResourcesExtensions.cs +++ /dev/null @@ -1,629 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for MongoDBResources. - /// - public static partial class MongoDBResourcesExtensions - { - /// - /// 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 MongoDBDatabaseListResult ListMongoDBDatabases(this IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 MongoDBCollectionListResult ListMongoDBCollections(this IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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 IMongoDBResources 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; - } - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/Operations.cs b/specification/cosmos-db/resource-manager/generated/Operations.cs deleted file mode 100644 index 462ea5720c2f..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Operations.cs +++ /dev/null @@ -1,181 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Operations operations. - /// - public 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 - /// - public Operations(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs b/specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs deleted file mode 100644 index 301c49a51b9c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/OperationsExtensions.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - 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 OperationListResult 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; - } - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs deleted file mode 100644 index fe1da3f1be61..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeId.cs +++ /dev/null @@ -1,283 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PartitionKeyRangeId operations. - /// - public partial class PartitionKeyRangeId : IServiceOperations, IPartitionKeyRangeId - { - /// - /// Initializes a new instance of the PartitionKeyRangeId class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public PartitionKeyRangeId(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs deleted file mode 100644 index 1d23ab9babea..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdExtensions.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PartitionKeyRangeId. - /// - public static partial class PartitionKeyRangeIdExtensions - { - /// - /// 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 PartitionMetricListResult ListMetrics(this IPartitionKeyRangeId 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 IPartitionKeyRangeId 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/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs deleted file mode 100644 index 05a7c57906f2..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegion.cs +++ /dev/null @@ -1,292 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PartitionKeyRangeIdRegion operations. - /// - public partial class PartitionKeyRangeIdRegion : IServiceOperations, IPartitionKeyRangeIdRegion - { - /// - /// Initializes a new instance of the PartitionKeyRangeIdRegion class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public PartitionKeyRangeIdRegion(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs b/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs deleted file mode 100644 index 75ace90ae152..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PartitionKeyRangeIdRegionExtensions.cs +++ /dev/null @@ -1,97 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PartitionKeyRangeIdRegion. - /// - public static partial class PartitionKeyRangeIdRegionExtensions - { - /// - /// 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 PartitionMetricListResult ListMetrics(this IPartitionKeyRangeIdRegion 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 IPartitionKeyRangeIdRegion 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/specification/cosmos-db/resource-manager/generated/Percentile.cs b/specification/cosmos-db/resource-manager/generated/Percentile.cs deleted file mode 100644 index 038652e435b8..000000000000 --- a/specification/cosmos-db/resource-manager/generated/Percentile.cs +++ /dev/null @@ -1,256 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Percentile operations. - /// - public partial class Percentile : IServiceOperations, IPercentile - { - /// - /// Initializes a new instance of the Percentile class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Percentile(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs b/specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs deleted file mode 100644 index 1d7538611e1c..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PercentileExtensions.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Percentile. - /// - public static partial class PercentileExtensions - { - /// - /// 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 PercentileMetricListResult ListMetrics(this IPercentile 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 IPercentile 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/specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs b/specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs deleted file mode 100644 index f44754716424..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PercentileSourceTarget.cs +++ /dev/null @@ -1,277 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PercentileSourceTarget operations. - /// - public partial class PercentileSourceTarget : IServiceOperations, IPercentileSourceTarget - { - /// - /// Initializes a new instance of the PercentileSourceTarget class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public PercentileSourceTarget(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs b/specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs deleted file mode 100644 index 5b2bd147297b..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PercentileSourceTargetExtensions.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PercentileSourceTarget. - /// - public static partial class PercentileSourceTargetExtensions - { - /// - /// 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 PercentileMetricListResult ListMetrics(this IPercentileSourceTarget 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 IPercentileSourceTarget 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/specification/cosmos-db/resource-manager/generated/PercentileTarget.cs b/specification/cosmos-db/resource-manager/generated/PercentileTarget.cs deleted file mode 100644 index ba56a7914d40..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PercentileTarget.cs +++ /dev/null @@ -1,266 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PercentileTarget operations. - /// - public partial class PercentileTarget : IServiceOperations, IPercentileTarget - { - /// - /// Initializes a new instance of the PercentileTarget class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public PercentileTarget(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs b/specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs deleted file mode 100644 index 6b77551e3171..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PercentileTargetExtensions.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PercentileTarget. - /// - public static partial class PercentileTargetExtensions - { - /// - /// 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 PercentileMetricListResult ListMetrics(this IPercentileTarget 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 IPercentileTarget 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/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs b/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs deleted file mode 100644 index 2c9009536888..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnections.cs +++ /dev/null @@ -1,830 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PrivateEndpointConnections operations. - /// - public partial class PrivateEndpointConnections : IServiceOperations, IPrivateEndpointConnections - { - /// - /// Initializes a new instance of the PrivateEndpointConnections class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public PrivateEndpointConnections(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB Client { get; private set; } - - /// - /// List all private endpoint connections on 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}/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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// 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 (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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// 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> CreateOrUpdateWithHttpMessagesAsync(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 (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, "CreateOrUpdate", 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 += "?" + 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 (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; - // 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 = Microsoft.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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// 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 DeleteWithHttpMessagesAsync(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 (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, "Delete", 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 += "?" + 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 (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; - // 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 = Microsoft.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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs b/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs deleted file mode 100644 index aa17766b3876..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PrivateEndpointConnectionsExtensions.cs +++ /dev/null @@ -1,194 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PrivateEndpointConnections. - /// - public static partial class PrivateEndpointConnectionsExtensions - { - /// - /// List all private endpoint connections on a Cosmos DB account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - public static PrivateEndpointConnectionListResult ListByDatabaseAccount(this IPrivateEndpointConnections 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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The cancellation token. - /// - public static async Task ListByDatabaseAccountAsync(this IPrivateEndpointConnections 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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The name of the private endpoint connection. - /// - public static PrivateEndpointConnection Get(this IPrivateEndpointConnections 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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The name of the private endpoint connection. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this IPrivateEndpointConnections 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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The name of the private endpoint connection. - /// - public static PrivateEndpointConnection CreateOrUpdate(this IPrivateEndpointConnections operations, string resourceGroupName, string accountName, string privateEndpointConnectionName) - { - return operations.CreateOrUpdateAsync(resourceGroupName, accountName, privateEndpointConnectionName).GetAwaiter().GetResult(); - } - - /// - /// Approve or reject a private endpoint connection with a given name. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The name of the private endpoint connection. - /// - /// - /// The cancellation token. - /// - public static async Task CreateOrUpdateAsync(this IPrivateEndpointConnections operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Deletes a private endpoint connection with a given name. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The name of the private endpoint connection. - /// - public static void Delete(this IPrivateEndpointConnections 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. - /// - /// - /// Name of an Azure resource group. - /// - /// - /// Cosmos DB database account name. - /// - /// - /// The name of the private endpoint connection. - /// - /// - /// The cancellation token. - /// - public static async Task DeleteAsync(this IPrivateEndpointConnections operations, string resourceGroupName, string accountName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) - { - (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, accountName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs b/specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs deleted file mode 100644 index 4cd70a7e5c96..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PrivateLinkResources.cs +++ /dev/null @@ -1,441 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// PrivateLinkResources operations. - /// - public partial class PrivateLinkResources : IServiceOperations, IPrivateLinkResources - { - /// - /// Initializes a new instance of the PrivateLinkResources class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public PrivateLinkResources(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs deleted file mode 100644 index 57641ed6ed64..000000000000 --- a/specification/cosmos-db/resource-manager/generated/PrivateLinkResourcesExtensions.cs +++ /dev/null @@ -1,109 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for PrivateLinkResources. - /// - public static partial class PrivateLinkResourcesExtensions - { - /// - /// 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 PrivateLinkResourceListResult ListByDatabaseAccount(this IPrivateLinkResources 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 IPrivateLinkResources 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 IPrivateLinkResources 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 IPrivateLinkResources 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/specification/cosmos-db/resource-manager/generated/SqlResources.cs b/specification/cosmos-db/resource-manager/generated/SqlResources.cs deleted file mode 100644 index 569eedde4690..000000000000 --- a/specification/cosmos-db/resource-manager/generated/SqlResources.cs +++ /dev/null @@ -1,5081 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SqlResources operations. - /// - public partial class SqlResources : IServiceOperations, ISqlResources - { - /// - /// Initializes a new instance of the SqlResources class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public SqlResources(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateUpdateSqlDatabaseWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateSqlDatabase", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteSqlDatabaseWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteSqlDatabase", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateSqlDatabaseThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateSqlDatabaseThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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> CreateUpdateSqlContainerWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateSqlContainer", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteSqlContainerWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteSqlContainer", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateSqlContainerThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateSqlContainerThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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> CreateUpdateSqlStoredProcedureWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateSqlStoredProcedure", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteSqlStoredProcedureWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteSqlStoredProcedure", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateUpdateSqlUserDefinedFunctionWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateSqlUserDefinedFunction", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteSqlUserDefinedFunctionWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteSqlUserDefinedFunction", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateUpdateSqlTriggerWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateSqlTrigger", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteSqlTriggerWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteSqlTrigger", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs deleted file mode 100644 index 1ed032f622a4..000000000000 --- a/specification/cosmos-db/resource-manager/generated/SqlResourcesExtensions.cs +++ /dev/null @@ -1,1318 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SqlResources. - /// - public static partial class SqlResourcesExtensions - { - /// - /// 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 SqlDatabaseListResult ListSqlDatabases(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlContainerListResult ListSqlContainers(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlStoredProcedureListResult ListSqlStoredProcedures(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlUserDefinedFunctionListResult ListSqlUserDefinedFunctions(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 SqlTriggerListResult ListSqlTriggers(this ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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 ISqlResources 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(); - } - - } -} diff --git a/specification/cosmos-db/resource-manager/generated/TableResources.cs b/specification/cosmos-db/resource-manager/generated/TableResources.cs deleted file mode 100644 index e7e094226ef9..000000000000 --- a/specification/cosmos-db/resource-manager/generated/TableResources.cs +++ /dev/null @@ -1,1252 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// TableResources operations. - /// - public partial class TableResources : IServiceOperations, ITableResources - { - /// - /// Initializes a new instance of the TableResources class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public TableResources(CosmosDB client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the CosmosDB - /// - public CosmosDB 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> CreateUpdateTableWithHttpMessagesAsync(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-08-01"; - // 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, "CreateUpdateTable", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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 DeleteTableWithHttpMessagesAsync(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-08-01"; - // 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, "DeleteTable", 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// 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-08-01"; - // 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 += "?" + 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 (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; - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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. - /// - /// - /// 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> UpdateTableThroughputWithHttpMessagesAsync(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-08-01"; - // 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, "UpdateTableThroughput", 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 += "?" + 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 (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 = Microsoft.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"); - } - // 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 HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - if (_httpResponse.Content != null) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - } - else { - _responseContent = string.Empty; - } - 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 HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Microsoft.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/specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs b/specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs deleted file mode 100644 index 34c0c99d6ecb..000000000000 --- a/specification/cosmos-db/resource-manager/generated/TableResourcesExtensions.cs +++ /dev/null @@ -1,302 +0,0 @@ -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace CosmosDb -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for TableResources. - /// - public static partial class TableResourcesExtensions - { - /// - /// 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 TableListResult ListTables(this ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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 ITableResources 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; - } - } - - } -} From 95f14afc60eb9ef7963d0c27f3b68845cc399796 Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Tue, 22 Oct 2019 08:49:40 -0700 Subject: [PATCH 3/9] Fixing ErrorResponse reference --- .../preview/2019-08-01-preview/privateEndpointConnection.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json index f5705a1ef4e6..f6291e9f5d6d 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json @@ -147,7 +147,7 @@ "default": { "description": "Error response describing why the operation failed.", "schema": { - "$ref": "#/definitions/ErrorResponse" + "$ref": "../../stable/2019-08-01/cosmos-db.json#/definitions/ErrorResponse" } } }, From fb207b45b36291c4b48df3113dd0866d48207511 Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Tue, 22 Oct 2019 08:57:49 -0700 Subject: [PATCH 4/9] PrivateEndpointConnections_CreateOrUpdate has no 200 return, and removing 200 from CosmosDBPrivateEndpointConnectionDelete.json --- .../examples/CosmosDBPrivateEndpointConnectionDelete.json | 1 - .../2019-08-01-preview/privateEndpointConnection.json | 6 ------ 2 files changed, 7 deletions(-) diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json index 1eeb2bbdabf2..c00aa0f7f2a4 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json @@ -7,7 +7,6 @@ "privateEndpointConnectionName": "privateEndpointConnectionName" }, "responses": { - "200": {}, "202": {}, "204": {} } diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json index f6291e9f5d6d..4794fa8005e0 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json @@ -135,12 +135,6 @@ } ], "responses": { - "200": { - "description": "Successfully approved or rejected private endpoint connection.", - "schema": { - "$ref": "#/definitions/PrivateEndpointConnection" - } - }, "202": { "description": "Accepted. The private endpoint connection update will complete asynchronously." }, From 4dedc27b7b841cf70bf29f147ddd03ff00986095 Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Fri, 25 Oct 2019 10:20:26 -0700 Subject: [PATCH 5/9] Moved Defeinitions to common-types/types.json, and removed references to stable paramaters/definitions --- .../resource-management/v1/types.json | 80 ++++++++++ .../CosmosDBPrivateEndpointConnectionGet.json | 2 +- ...smosDBPrivateEndpointConnectionUpdate.json | 34 +++- .../privateEndpointConnection.json | 146 +++++++----------- 4 files changed, 166 insertions(+), 96 deletions(-) diff --git a/specification/common-types/resource-management/v1/types.json b/specification/common-types/resource-management/v1/types.json index 178a5b236304..b62bcd9879d5 100644 --- a/specification/common-types/resource-management/v1/types.json +++ b/specification/common-types/resource-management/v1/types.json @@ -319,6 +319,78 @@ } }, "description": "The resource management error additional info." + }, + "PrivateEndpointConnectionListResult": { + "description": "A list of private endpoint connections", + "type": "object", + "properties": { + "value": { + "type": "array", + "description": "Array of private endpoint connections", + "items": { + "$ref": "#/definitions/PrivateEndpointConnection" + } + } + } + }, + "PrivateEndpointConnection": { + "description": "A private endpoint connection", + "type": "object", + "properties": { + "properties": { + "$ref": "#/definitions/PrivateEndpointConnectionProperties", + "description": "Resource properties.", + "x-ms-client-flatten": true + } + }, + "allOf": [ + { + "$ref": "#/definitions/ProxyResource" + } + ] + }, + "PrivateEndpointConnectionProperties": { + "description": "Properties of a private endpoint connection.", + "type": "object", + "properties": { + "privateEndpoint": { + "$ref": "#/definitions/PrivateEndpointProperty", + "description": "Private endpoint which the connection belongs to." + }, + "privateLinkServiceConnectionState": { + "$ref": "#/definitions/PrivateLinkServiceConnectionStateProperty", + "description": "Connection State of the Private Endpoint Connection." + } + } + }, + "PrivateEndpointProperty": { + "type": "object", + "description": "Private endpoint which the connection belongs to.", + "properties": { + "id": { + "type": "string", + "description": "Resource id of the private endpoint." + } + } + }, + "PrivateLinkServiceConnectionStateProperty": { + "type": "object", + "description": "Connection State of the Private Endpoint Connection.", + "properties": { + "status": { + "type": "string", + "description": "The private link service connection status." + }, + "description": { + "type": "string", + "description": "The private link service connection description." + }, + "actionsRequired": { + "type": "string", + "description": "Any action that is required beyond basic workflow (approve/ reject/ disconnect)", + "readOnly": true + } + } } }, "parameters": { @@ -348,6 +420,14 @@ "minLength": 1, "maxLength": 90, "x-ms-parameter-location": "method" + }, + "PrivateEndpointConnectionNameParameter": { + "name": "privateEndpointConnectionName", + "in": "path", + "required": true, + "type": "string", + "x-ms-parameter-location": "method", + "description": "The name of the private endpoint connection." } } } diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json index a3e0e29b04cc..efaf62a4ab7e 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json @@ -9,7 +9,7 @@ "responses": { "200": { "body": { - "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName", + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName", "name": "privateEndpointConnectionName", "type": "Microsoft.DocumentDb/databaseAccounts/privateEndpointConnections", "properties": { diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json index 656efb925bf0..b71fd2728e98 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json @@ -4,9 +4,41 @@ "resourceGroupName": "rg1", "accountName": "ddb1", "api-version": "2019-08-01-preview", - "privateEndpointConnectionName": "privateEndpointConnectionName" + "privateEndpointConnectionName": "privateEndpointConnectionName", + "parameters": { + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName", + "name": "privateEndpointConnectionName", + "type": "Microsoft.DocumentDb/databaseAccounts/privateEndpointConnections", + "properties": { + "privateEndpoint": { + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName" + }, + "privateLinkServiceConnectionState": { + "status": "Approved", + "description": "Approved by johndoe@contoso.com", + "actionsRequired": "None" + } + } + } }, "responses": { + "200": { + "body": { + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName", + "name": "privateEndpointConnectionName", + "type": "Microsoft.DocumentDb/databaseAccounts/privateEndpointConnections", + "properties": { + "privateEndpoint": { + "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName" + }, + "privateLinkServiceConnectionState": { + "status": "Approved", + "description": "Auto-approved", + "actionsRequired": "None" + } + } + } + }, "202": {} } } \ No newline at end of file diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json index 4794fa8005e0..a42f94b8187b 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json @@ -46,23 +46,23 @@ }, "parameters": [ { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ResourceGroupNameParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + "$ref": "#/parameters/accountNameParameter" } ], "responses": { "200": { - "description": "Successfully retrieved private link resources.", + "description": "Successfully retrieved private endpoint connections.", "schema": { - "$ref": "#/definitions/PrivateEndpointConnectionListResult" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnectionListResult" } } }, @@ -82,26 +82,26 @@ "operationId": "PrivateEndpointConnections_Get", "parameters": [ { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ResourceGroupNameParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + "$ref": "#/parameters/accountNameParameter" }, { - "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/PrivateEndpointConnectionNameParameter" } ], "responses": { "200": { "description": "Successfully retrieved a specified private endpoint connection.", "schema": { - "$ref": "#/definitions/PrivateEndpointConnection" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnection" } } }, @@ -119,29 +119,43 @@ "operationId": "PrivateEndpointConnections_CreateOrUpdate", "parameters": [ { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ResourceGroupNameParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + "$ref": "#/parameters/accountNameParameter" }, { - "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/PrivateEndpointConnectionNameParameter" + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnection" + } } ], "responses": { + "200": { + "description": "Successfully approved or rejected private endpoint connection.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnection" + } + }, "202": { "description": "Accepted. The private endpoint connection update will complete asynchronously." }, "default": { "description": "Error response describing why the operation failed.", "schema": { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/definitions/ErrorResponse" + "$ref": "#/definitions/ErrorResponse" } } }, @@ -160,19 +174,19 @@ "operationId": "PrivateEndpointConnections_Delete", "parameters": [ { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/subscriptionIdParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/resourceGroupNameParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ResourceGroupNameParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/apiVersionParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/parameters/accountNameParameter" + "$ref": "#/parameters/accountNameParameter" }, { - "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" + "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/PrivateEndpointConnectionNameParameter" } ], "responses": { @@ -199,87 +213,31 @@ } }, "definitions": { - "PrivateEndpointConnectionListResult": { - "description": "A list of private endpoint connections", - "type": "object", - "properties": { - "value": { - "type": "array", - "description": "Array of private endpoint connections", - "items": { - "$ref": "#/definitions/PrivateEndpointConnection" - } - } - } - }, - "PrivateEndpointConnection": { - "description": "A private endpoint connection", - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/PrivateEndpointConnectionProperties", - "description": "Resource properties.", - "x-ms-client-flatten": true - } - }, - "allOf": [ - { - "$ref": "../../stable/2019-08-01/cosmos-db.json#/definitions/ARMProxyResource" - } - ] - }, - "PrivateEndpointConnectionProperties": { - "description": "Properties of a private endpoint connection.", - "type": "object", - "properties": { - "privateEndpoint": { - "$ref": "#/definitions/PrivateEndpointProperty", - "description": "Private endpoint which the connection belongs to." - }, - "privateLinkServiceConnectionState": { - "$ref": "#/definitions/PrivateLinkServiceConnectionStateProperty", - "description": "Connection State of the Private Endpoint Connection." - } - } - }, - "PrivateEndpointProperty": { - "type": "object", - "description": "Private endpoint which the connection belongs to.", - "properties": { - "id": { - "type": "string", - "description": "Resource id of the private endpoint." - } - } - }, - "PrivateLinkServiceConnectionStateProperty": { - "type": "object", - "description": "Connection State of the Private Endpoint Connection.", + "ErrorResponse": { "properties": { - "status": { - "type": "string", - "description": "The private link service connection status." - }, - "description": { - "type": "string", - "description": "The private link service connection description." + "code": { + "description": "Error code.", + "type": "string" }, - "actionsRequired": { - "type": "string", - "description": "Any action that is required beyond basic workflow (approve/ reject/ disconnect)", - "readOnly": true + "message": { + "description": "Error message indicating why the operation failed.", + "type": "string" } - } + }, + "description": "Error Response." } }, "parameters": { - "PrivateEndpointConnectionNameParameter": { - "name": "privateEndpointConnectionName", + "accountNameParameter": { + "name": "accountName", "in": "path", "required": true, "type": "string", "x-ms-parameter-location": "method", - "description": "The name of the private endpoint connection." + "description": "Cosmos DB database account name.", + "minLength": 3, + "maxLength": 50, + "pattern": "^[a-z0-9]+(-[a-z0-9]+)*" } } } \ No newline at end of file From 580c7803f56dc1db96aba97832390bd77270b8ee Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Fri, 25 Oct 2019 10:32:15 -0700 Subject: [PATCH 6/9] Fixing Update example --- .../examples/CosmosDBPrivateEndpointConnectionUpdate.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json index b71fd2728e98..275fde3985ba 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json @@ -6,17 +6,13 @@ "api-version": "2019-08-01-preview", "privateEndpointConnectionName": "privateEndpointConnectionName", "parameters": { - "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1/providers/Microsoft.DocumentDb/databaseAccounts/ddb1/privateEndpointConnections/privateEndpointConnectionName", - "name": "privateEndpointConnectionName", - "type": "Microsoft.DocumentDb/databaseAccounts/privateEndpointConnections", "properties": { "privateEndpoint": { "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName" }, "privateLinkServiceConnectionState": { "status": "Approved", - "description": "Approved by johndoe@contoso.com", - "actionsRequired": "None" + "description": "Approved by johndoe@contoso.com" } } } From afae6d7d7ead21cca6238950e8ddb23f8c1ed275 Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Fri, 25 Oct 2019 10:32:22 -0700 Subject: [PATCH 7/9] Fixing Update example --- .../examples/CosmosDBPrivateEndpointConnectionUpdate.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json index 275fde3985ba..fd532a08f8f0 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json @@ -7,9 +7,6 @@ "privateEndpointConnectionName": "privateEndpointConnectionName", "parameters": { "properties": { - "privateEndpoint": { - "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName" - }, "privateLinkServiceConnectionState": { "status": "Approved", "description": "Approved by johndoe@contoso.com" From 653259771415f5d503b98f1b22f1521a990219b3 Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Mon, 28 Oct 2019 14:54:24 -0700 Subject: [PATCH 8/9] Moving defs back into privateEndpointConnection.json --- .../resource-management/v1/types.json | 84 +---------------- .../privateEndpointConnection.json | 94 +++++++++++++++++-- 2 files changed, 89 insertions(+), 89 deletions(-) diff --git a/specification/common-types/resource-management/v1/types.json b/specification/common-types/resource-management/v1/types.json index b62bcd9879d5..d5694a591724 100644 --- a/specification/common-types/resource-management/v1/types.json +++ b/specification/common-types/resource-management/v1/types.json @@ -319,79 +319,7 @@ } }, "description": "The resource management error additional info." - }, - "PrivateEndpointConnectionListResult": { - "description": "A list of private endpoint connections", - "type": "object", - "properties": { - "value": { - "type": "array", - "description": "Array of private endpoint connections", - "items": { - "$ref": "#/definitions/PrivateEndpointConnection" - } - } - } - }, - "PrivateEndpointConnection": { - "description": "A private endpoint connection", - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/PrivateEndpointConnectionProperties", - "description": "Resource properties.", - "x-ms-client-flatten": true - } - }, - "allOf": [ - { - "$ref": "#/definitions/ProxyResource" - } - ] - }, - "PrivateEndpointConnectionProperties": { - "description": "Properties of a private endpoint connection.", - "type": "object", - "properties": { - "privateEndpoint": { - "$ref": "#/definitions/PrivateEndpointProperty", - "description": "Private endpoint which the connection belongs to." - }, - "privateLinkServiceConnectionState": { - "$ref": "#/definitions/PrivateLinkServiceConnectionStateProperty", - "description": "Connection State of the Private Endpoint Connection." - } - } - }, - "PrivateEndpointProperty": { - "type": "object", - "description": "Private endpoint which the connection belongs to.", - "properties": { - "id": { - "type": "string", - "description": "Resource id of the private endpoint." - } - } - }, - "PrivateLinkServiceConnectionStateProperty": { - "type": "object", - "description": "Connection State of the Private Endpoint Connection.", - "properties": { - "status": { - "type": "string", - "description": "The private link service connection status." - }, - "description": { - "type": "string", - "description": "The private link service connection description." - }, - "actionsRequired": { - "type": "string", - "description": "Any action that is required beyond basic workflow (approve/ reject/ disconnect)", - "readOnly": true - } - } - } + } }, "parameters": { "SubscriptionIdParameter": { @@ -420,14 +348,6 @@ "minLength": 1, "maxLength": 90, "x-ms-parameter-location": "method" - }, - "PrivateEndpointConnectionNameParameter": { - "name": "privateEndpointConnectionName", - "in": "path", - "required": true, - "type": "string", - "x-ms-parameter-location": "method", - "description": "The name of the private endpoint connection." - } + } } } diff --git a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json index a42f94b8187b..1f60ee390eec 100644 --- a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json +++ b/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2019-08-01-preview/privateEndpointConnection.json @@ -62,7 +62,7 @@ "200": { "description": "Successfully retrieved private endpoint connections.", "schema": { - "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnectionListResult" + "$ref": "#/definitions/PrivateEndpointConnectionListResult" } } }, @@ -94,14 +94,14 @@ "$ref": "#/parameters/accountNameParameter" }, { - "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/PrivateEndpointConnectionNameParameter" + "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" } ], "responses": { "200": { "description": "Successfully retrieved a specified private endpoint connection.", "schema": { - "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnection" + "$ref": "#/definitions/PrivateEndpointConnection" } } }, @@ -131,14 +131,14 @@ "$ref": "#/parameters/accountNameParameter" }, { - "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/PrivateEndpointConnectionNameParameter" + "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" }, { "name": "parameters", "in": "body", "required": true, "schema": { - "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnection" + "$ref": "#/definitions/PrivateEndpointConnection" } } ], @@ -146,7 +146,7 @@ "200": { "description": "Successfully approved or rejected private endpoint connection.", "schema": { - "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/PrivateEndpointConnection" + "$ref": "#/definitions/PrivateEndpointConnection" } }, "202": { @@ -186,7 +186,7 @@ "$ref": "#/parameters/accountNameParameter" }, { - "$ref": "../../../../../common-types/resource-management/v1/types.json#/parameters/PrivateEndpointConnectionNameParameter" + "$ref": "#/parameters/PrivateEndpointConnectionNameParameter" } ], "responses": { @@ -225,6 +225,78 @@ } }, "description": "Error Response." + }, + "PrivateEndpointConnectionListResult": { + "description": "A list of private endpoint connections", + "type": "object", + "properties": { + "value": { + "type": "array", + "description": "Array of private endpoint connections", + "items": { + "$ref": "#/definitions/PrivateEndpointConnection" + } + } + } + }, + "PrivateEndpointConnection": { + "description": "A private endpoint connection", + "type": "object", + "properties": { + "properties": { + "$ref": "#/definitions/PrivateEndpointConnectionProperties", + "description": "Resource properties.", + "x-ms-client-flatten": true + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v1/types.json#/definitions/ProxyResource" + } + ] + }, + "PrivateEndpointConnectionProperties": { + "description": "Properties of a private endpoint connection.", + "type": "object", + "properties": { + "privateEndpoint": { + "$ref": "#/definitions/PrivateEndpointProperty", + "description": "Private endpoint which the connection belongs to." + }, + "privateLinkServiceConnectionState": { + "$ref": "#/definitions/PrivateLinkServiceConnectionStateProperty", + "description": "Connection State of the Private Endpoint Connection." + } + } + }, + "PrivateEndpointProperty": { + "type": "object", + "description": "Private endpoint which the connection belongs to.", + "properties": { + "id": { + "type": "string", + "description": "Resource id of the private endpoint." + } + } + }, + "PrivateLinkServiceConnectionStateProperty": { + "type": "object", + "description": "Connection State of the Private Endpoint Connection.", + "properties": { + "status": { + "type": "string", + "description": "The private link service connection status." + }, + "description": { + "type": "string", + "description": "The private link service connection description." + }, + "actionsRequired": { + "type": "string", + "description": "Any action that is required beyond basic workflow (approve/ reject/ disconnect)", + "readOnly": true + } + } } }, "parameters": { @@ -238,6 +310,14 @@ "minLength": 3, "maxLength": 50, "pattern": "^[a-z0-9]+(-[a-z0-9]+)*" + }, + "PrivateEndpointConnectionNameParameter": { + "name": "privateEndpointConnectionName", + "in": "path", + "required": true, + "type": "string", + "x-ms-parameter-location": "method", + "description": "The name of the private endpoint connection." } } } \ No newline at end of file From 73991d795a634326a88ddf54a2aa85cf2c2ac0bf Mon Sep 17 00:00:00 2001 From: Ayan Sarkar Date: Mon, 28 Oct 2019 14:55:54 -0700 Subject: [PATCH 9/9] reverting changes to types.json --- specification/common-types/resource-management/v1/types.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/common-types/resource-management/v1/types.json b/specification/common-types/resource-management/v1/types.json index d5694a591724..178a5b236304 100644 --- a/specification/common-types/resource-management/v1/types.json +++ b/specification/common-types/resource-management/v1/types.json @@ -319,7 +319,7 @@ } }, "description": "The resource management error additional info." - } + } }, "parameters": { "SubscriptionIdParameter": { @@ -348,6 +348,6 @@ "minLength": 1, "maxLength": 90, "x-ms-parameter-location": "method" - } + } } }