public async override Task <IMongoDB> CreateAsync(CancellationToken cancellationToken = default(CancellationToken)) { var inner = await this.Client.CreateUpdateMongoDBDatabaseAsync( Parent.ResourceGroupName, Parent.Name, this.Name(), this.createUpdateParameters, cancellationToken ); SetInner(inner); InitializeCreateUpdateParameters(); List <Task> childTasks = new List <Task>(); if (this.throughputSettingsToUpdate != null) { this.throughputSettingsToUpdate.Location = Parent.RegionName.ToLower(); childTasks.Add(this.Client.UpdateMongoDBDatabaseThroughputAsync( Parent.ResourceGroupName, Parent.Name, this.Name(), this.throughputSettingsToUpdate, cancellationToken )); this.throughputSettingsToUpdate = null; } childTasks.Add(this.collections.CommitAndGetAllAsync(cancellationToken)); await Task.WhenAll(childTasks); return(this); }
public static ThroughputSettingsUpdateParameters CreateThroughputSettingsObject(int?throughput = null, int?autoscaleMaxThroughput = null) { Throughput = throughput; AutoscaleMaxThroughput = autoscaleMaxThroughput; ThroughputHelper.ThroughputValidation(validateBothPresent: true); ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters = new ThroughputSettingsUpdateParameters(); if (throughput != null) { throughputSettingsUpdateParameters.Resource = new ThroughputSettingsResource { Throughput = throughput.Value }; } else if (autoscaleMaxThroughput != null) { throughputSettingsUpdateParameters.Resource = new ThroughputSettingsResource { AutoscaleSettings = new AutoscaleSettingsResource { MaxThroughput = autoscaleMaxThroughput.Value } }; } return(throughputSettingsUpdateParameters); }
public override void ExecuteCmdlet() { if (ParameterSetName.Equals(ParentObjectParameterSet, StringComparison.Ordinal)) { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(ParentObject.Id); ResourceGroupName = resourceIdentifier.ResourceGroupName; AccountName = resourceIdentifier.ResourceName; } else if (ParameterSetName.Equals(ObjectParameterSet, StringComparison.Ordinal)) { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(InputObject.Id); ResourceGroupName = resourceIdentifier.ResourceGroupName; Name = resourceIdentifier.ResourceName; AccountName = ResourceIdentifierExtensions.GetDatabaseAccountName(resourceIdentifier); } ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters = new ThroughputSettingsUpdateParameters { Resource = new ThroughputSettingsResource { Throughput = Throughput } }; if (ShouldProcess(Name, "Updating the throughput value of a CosmosDB Gremlin Database")) { ThroughputSettingsGetResults throughputSettingsGetResults = CosmosDBManagementClient.GremlinResources.UpdateGremlinDatabaseThroughputWithHttpMessagesAsync(ResourceGroupName, AccountName, Name, throughputSettingsUpdateParameters).GetAwaiter().GetResult().Body; WriteObject(new PSThroughputSettingsGetResults(throughputSettingsGetResults)); } return; }
public async override Task <ICassandraTable> CreateAsync(CancellationToken cancellationToken = default(CancellationToken)) { var inner = await this.Client.CreateUpdateCassandraTableAsync( ResourceGroupName, AccountName, CassandraKeyspaceName, this.Name(), this.createUpdateParameters, cancellationToken ); SetInner(inner); InitializeCreateUpdateParameters(); List <Task> childTasks = new List <Task>(); if (this.throughputSettingsToUpdate != null) { this.throughputSettingsToUpdate.Location = Location; childTasks.Add(this.Client.UpdateCassandraTableThroughputAsync( ResourceGroupName, AccountName, CassandraKeyspaceName, Name(), this.throughputSettingsToUpdate, cancellationToken )); } await Task.WhenAll(childTasks); this.throughputSettingsToUpdate = null; return(this); }
public override void CallSDKMethod(ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters) { if (ShouldProcess(Name, "Updating the throughput value of a CosmosDB Cassandra Keyspace")) { ThroughputSettingsGetResults throughputSettingsGetResults = CosmosDBManagementClient.CassandraResources.UpdateCassandraKeyspaceThroughputWithHttpMessagesAsync(ResourceGroupName, AccountName, Name, throughputSettingsUpdateParameters).GetAwaiter().GetResult().Body; WriteObject(new PSThroughputSettingsGetResults(throughputSettingsGetResults)); } }
public async Task CassandraKeyspaceUpdateThroughputTests() { ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters = new ThroughputSettingsUpdateParameters(new ThroughputSettingsResource(maxThroughput, null, null, null)); var throughputResponse = await WaitForCompletionAsync(await CosmosDBManagementClient.CassandraResources.StartUpdateCassandraKeyspaceThroughputAsync(resourceGroupName, databaseAccountName, keyspaceName, throughputSettingsUpdateParameters)); ThroughputSettingsGetResults throughputSettingsGetResults = throughputResponse.Value; Assert.NotNull(throughputSettingsGetResults); Assert.NotNull(throughputSettingsGetResults.Name); Assert.AreEqual(throughputSettingsGetResults.Resource.Throughput, maxThroughput); Assert.AreEqual(cassandraKeyspacesThroughputType, throughputSettingsGetResults.Type); }
public async Task GremlinGraphUpdateThroughputTests() { ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters = new ThroughputSettingsUpdateParameters(new ThroughputSettingsResource(maxThroughput, null, null, null)); var throughputResponse = await WaitForCompletionAsync(await CosmosDBManagementClient.GremlinResources.StartUpdateGremlinGraphThroughputAsync(resourceGroupName, databaseAccountName, databaseName, gremlinGraphName, throughputSettingsUpdateParameters)); ThroughputSettingsData ThroughputSettingsData = throughputResponse.Value; Assert.NotNull(throughputSettings); Assert.NotNull(throughputSettings.Name); Assert.AreEqual(throughputSettings.Resource.Throughput, maxThroughput); Assert.AreEqual(gremlinGraphsThroughputType, throughputSettings.Type); }
public override void ExecuteCmdlet() { if (ParameterSetName.Equals(ParentObjectParameterSet, StringComparison.Ordinal)) { PopulateFromParentObject(); } else if (ParameterSetName.Equals(ObjectParameterSet, StringComparison.Ordinal)) { PopulateFromInputObject(); } ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters = ThroughputHelper.CreateThroughputSettingsObject(Throughput, AutoscaleMaxThroughput); CallSDKMethod(throughputSettingsUpdateParameters); }
private void InitChildResource(bool firstInitial) { this.throughputSettingsToUpdate = null; if (firstInitial) { this.storedProcedureToUpdate = new Dictionary <string, SqlStoredProcedureCreateUpdateParameters>(); this.storedProcedureToDelete = new List <string>(); this.userDefinedFunctionToUpdate = new Dictionary <string, SqlUserDefinedFunctionCreateUpdateParameters>(); this.userDefinedFunctionToDelete = new List <string>(); this.triggerToUpdate = new Dictionary <string, SqlTriggerCreateUpdateParameters>(); this.triggerToDelete = new List <string>(); } else { this.storedProcedureToDelete.Clear(); this.storedProcedureToUpdate.Clear(); this.userDefinedFunctionToDelete.Clear(); this.userDefinedFunctionToUpdate.Clear(); this.triggerToDelete.Clear(); this.triggerToUpdate.Clear(); } }
public void RetrieveContinuousBackupInfoTest() { var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { // Create client CosmosDBManagementClient cosmosDBManagementClient = CosmosDBTestUtilities.GetCosmosDBClient(context, handler1); ContinuousBackupRestoreLocation restoreLocation = new ContinuousBackupRestoreLocation(location); SqlContainerCreateUpdateParameters sqlContainerCreateUpdateParameters = new SqlContainerCreateUpdateParameters() { Resource = new SqlContainerResource(containerName, partitionKey: new ContainerPartitionKey(new List <String>() { "/id" })), Options = new CreateUpdateOptions { Throughput = 400 } }; SqlContainerGetResults createContainerResult = cosmosDBManagementClient.SqlResources.CreateUpdateSqlContainer( resourceGroupName, databaseAccountName, databaseName, containerName, sqlContainerCreateUpdateParameters); Assert.NotNull(createContainerResult); Assert.NotNull(createContainerResult.Id); BackupInformation backupInformation = cosmosDBManagementClient.SqlResources.RetrieveContinuousBackupInformation( resourceGroupName, databaseAccountName, databaseName, containerName, restoreLocation); Assert.NotNull(backupInformation); Assert.NotNull(backupInformation.ContinuousBackupInformation); Assert.True(Int32.Parse(backupInformation.ContinuousBackupInformation.LatestRestorableTimestamp) > 0); int prevRestoreTime = Int32.Parse(backupInformation.ContinuousBackupInformation.LatestRestorableTimestamp); ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters = new ThroughputSettingsUpdateParameters() { Resource = new ThroughputSettingsResource() { Throughput = 4000 } }; ThroughputSettingsGetResults throughputSettingsGetResults = cosmosDBManagementClient.SqlResources.UpdateSqlContainerThroughput( resourceGroupName, databaseAccountName, databaseName, containerName, throughputSettingsUpdateParameters); Assert.NotNull(throughputSettingsGetResults); Assert.NotNull(throughputSettingsGetResults.Id); backupInformation = cosmosDBManagementClient.SqlResources.RetrieveContinuousBackupInformation( resourceGroupName, databaseAccountName, databaseName, containerName, restoreLocation); Assert.NotNull(backupInformation); Assert.NotNull(backupInformation.ContinuousBackupInformation); Assert.True(Int32.Parse(backupInformation.ContinuousBackupInformation.LatestRestorableTimestamp) >= prevRestoreTime); cosmosDBManagementClient.SqlResources.DeleteSqlContainer(resourceGroupName, databaseAccountName, databaseName, containerName); } }
/// <summary> /// Update RUs per second of an Azure Cosmos DB Cassandra Keyspace /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of an Azure resource group. /// </param> /// <param name='accountName'> /// Cosmos DB database account name. /// </param> /// <param name='keyspaceName'> /// Cosmos DB keyspace name. /// </param> /// <param name='updateThroughputParameters'> /// The RUs per second of the parameters to provide for the current Cassandra /// Keyspace. /// </param> public static ThroughputSettingsGetResults BeginUpdateCassandraKeyspaceThroughput(this ICassandraResourcesOperations operations, string resourceGroupName, string accountName, string keyspaceName, ThroughputSettingsUpdateParameters updateThroughputParameters) { return(operations.BeginUpdateCassandraKeyspaceThroughputAsync(resourceGroupName, accountName, keyspaceName, updateThroughputParameters).GetAwaiter().GetResult()); }
public async Task TableCRUDTest() { // prepare a database account List <Location> locationList = new List <Location>(); locationList.Add(new Location(id: null, locationName: "WEST US", documentEndpoint: null, provisioningState: null, failoverPriority: null, isZoneRedundant: null)); var databaseAccountsCreateOrUpdateParameters = new DatabaseAccountCreateUpdateParameters(locationList); databaseAccountsCreateOrUpdateParameters.Kind = DatabaseAccountKind.GlobalDocumentDB; databaseAccountsCreateOrUpdateParameters.Location = "WEST US"; databaseAccountsCreateOrUpdateParameters.Capabilities.Add(new Capability("EnableTable")); await WaitForCompletionAsync( await CosmosDBManagementClient.DatabaseAccounts.StartCreateOrUpdateAsync(resourceGroupName, databaseAccountName, databaseAccountsCreateOrUpdateParameters)); Response response = await CosmosDBManagementClient.DatabaseAccounts.CheckNameExistsAsync(databaseAccountName); Assert.AreEqual(200, response.Status); var tableCreateUpdateParameters1 = new TableCreateUpdateParameters(new TableResource(tableName), new CreateUpdateOptions()); TableGetResults tableGetResults1 = ( await WaitForCompletionAsync( await CosmosDBManagementClient.TableResources.StartCreateUpdateTableAsync(resourceGroupName, databaseAccountName, tableName, tableCreateUpdateParameters1))).Value; Assert.IsNotNull(tableGetResults1); Assert.AreEqual(tableName, tableGetResults1.Resource.Id); TableGetResults tableGetResults2 = (await CosmosDBManagementClient.TableResources.GetTableAsync(resourceGroupName, databaseAccountName, tableName)).Value; Assert.IsNotNull(tableGetResults2); VerifyTables(tableGetResults1, tableGetResults2); var actualThroughput = ( await CosmosDBManagementClient.TableResources.GetTableThroughputAsync(resourceGroupName, databaseAccountName, tableName)).Value.Resource.Throughput; Assert.AreEqual(defaultThroughput, actualThroughput); var tableCreateUpdateParameters2 = new TableCreateUpdateParameters(new TableResource(tableName), new CreateUpdateOptions(sampleThroughput, new AutoscaleSettings())); TableGetResults tableGetResults3 = ( await WaitForCompletionAsync( await CosmosDBManagementClient.TableResources.StartCreateUpdateTableAsync(resourceGroupName, databaseAccountName, tableName, tableCreateUpdateParameters2))).Value; Assert.IsNotNull(tableGetResults3); Assert.AreEqual(tableName, tableGetResults3.Resource.Id); actualThroughput = (await CosmosDBManagementClient.TableResources.GetTableThroughputAsync(resourceGroupName, databaseAccountName, tableName)).Value.Resource.Throughput; Assert.AreEqual(sampleThroughput, actualThroughput); TableGetResults tableGetResults4 = (await CosmosDBManagementClient.TableResources.GetTableAsync(resourceGroupName, databaseAccountName, tableName)).Value; Assert.IsNotNull(tableGetResults4); VerifyTables(tableGetResults3, tableGetResults4); List <TableGetResults> tables = await CosmosDBManagementClient.TableResources.ListTablesAsync(resourceGroupName, databaseAccountName).ToEnumerableAsync(); Assert.IsNotNull(tables); Assert.AreEqual(1, tables.Count); VerifyTables(tableGetResults4, tables[0]); ThroughputSettingsGetResults throughputSettingsGetResults1 = await WaitForCompletionAsync(await CosmosDBManagementClient.TableResources.StartMigrateTableToAutoscaleAsync(resourceGroupName, databaseAccountName, tableName)); Assert.IsNotNull(throughputSettingsGetResults1.Resource.AutoscaleSettings); Assert.AreEqual(defaultMaxThroughput, throughputSettingsGetResults1.Resource.AutoscaleSettings.MaxThroughput); Assert.AreEqual(defaultThroughput, throughputSettingsGetResults1.Resource.Throughput); ThroughputSettingsGetResults throughputSettingsGetResults2 = await WaitForCompletionAsync(await CosmosDBManagementClient.TableResources.StartMigrateTableToManualThroughputAsync(resourceGroupName, databaseAccountName, tableName)); Assert.IsNull(throughputSettingsGetResults2.Resource.AutoscaleSettings); Assert.AreEqual(defaultMaxThroughput, throughputSettingsGetResults2.Resource.Throughput); var throughputSettingsUpdateParameters = new ThroughputSettingsUpdateParameters(new ThroughputSettingsResource(defaultThroughput, null, null, null)); ThroughputSettingsGetResults throughputSettingsGetResults = ( await WaitForCompletionAsync( await CosmosDBManagementClient.TableResources.StartUpdateTableThroughputAsync(resourceGroupName, databaseAccountName, tableName, throughputSettingsUpdateParameters))).Value; Assert.AreEqual(defaultThroughput, throughputSettingsGetResults.Resource.Throughput); await WaitForCompletionAsync(await CosmosDBManagementClient.TableResources.StartDeleteTableAsync(resourceGroupName, databaseAccountName, tableName)); tables = await CosmosDBManagementClient.TableResources.ListTablesAsync(resourceGroupName, databaseAccountName).ToEnumerableAsync(); Assert.IsNotNull(tables); Assert.AreEqual(0, tables.Count); }
public virtual void CallSDKMethod(ThroughputSettingsUpdateParameters throughputSettingsUpdateParameters) { }
public virtual TableResourcesUpdateTableThroughputOperation StartUpdateTableThroughput(string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (accountName == null) { throw new ArgumentNullException(nameof(accountName)); } if (tableName == null) { throw new ArgumentNullException(nameof(tableName)); } if (updateThroughputParameters == null) { throw new ArgumentNullException(nameof(updateThroughputParameters)); } using var scope = _clientDiagnostics.CreateScope("TableResourcesOperations.StartUpdateTableThroughput"); scope.Start(); try { var originalResponse = RestClient.UpdateTableThroughput(resourceGroupName, accountName, tableName, updateThroughputParameters, cancellationToken); return(new TableResourcesUpdateTableThroughputOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateTableThroughputRequest(resourceGroupName, accountName, tableName, updateThroughputParameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Update RUs per second of an Azure Cosmos DB Table /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='accountName'> /// Cosmos DB database account name. /// </param> /// <param name='tableName'> /// Cosmos DB table name. /// </param> /// <param name='updateThroughputParameters'> /// The parameters to provide for the RUs per second of the current Table. /// </param> public static ThroughputSettingsGetResults BeginUpdateTableThroughput(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters) { return(operations.BeginUpdateTableThroughputAsync(resourceGroupName, accountName, tableName, updateThroughputParameters).GetAwaiter().GetResult()); }
/// <summary> /// Update the RUs per second of an Azure Cosmos DB MongoDB collection /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of an Azure resource group. /// </param> /// <param name='accountName'> /// Cosmos DB database account name. /// </param> /// <param name='databaseName'> /// Cosmos DB database name. /// </param> /// <param name='collectionName'> /// Cosmos DB collection name. /// </param> /// <param name='updateThroughputParameters'> /// The RUs per second of the parameters to provide for the current MongoDB /// collection. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ThroughputSettingsGetResultsInner> UpdateMongoDBCollectionThroughputAsync(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateMongoDBCollectionThroughputWithHttpMessagesAsync(resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Update RUs per second of an Azure Cosmos DB Gremlin graph /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of an Azure resource group. /// </param> /// <param name='accountName'> /// Cosmos DB database account name. /// </param> /// <param name='databaseName'> /// Cosmos DB database name. /// </param> /// <param name='graphName'> /// Cosmos DB graph name. /// </param> /// <param name='updateThroughputParameters'> /// The RUs per second of the parameters to provide for the current Gremlin /// graph. /// </param> public static ThroughputSettingsGetResults BeginUpdateGremlinGraphThroughput(this IGremlinResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string graphName, ThroughputSettingsUpdateParameters updateThroughputParameters) { return(operations.BeginUpdateGremlinGraphThroughputAsync(resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters).GetAwaiter().GetResult()); }
private void InitChildResource() { this.throughputSettingsToUpdate = null; }
/// <summary> /// Update RUs per second of an Azure Cosmos DB Table /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='accountName'> /// Cosmos DB database account name. /// </param> /// <param name='tableName'> /// Cosmos DB table name. /// </param> /// <param name='updateThroughputParameters'> /// The parameters to provide for the RUs per second of the current Table. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ThroughputSettingsGetResults> BeginUpdateTableThroughputAsync(this ITableResourcesOperations operations, string resourceGroupName, string accountName, string tableName, ThroughputSettingsUpdateParameters updateThroughputParameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginUpdateTableThroughputWithHttpMessagesAsync(resourceGroupName, accountName, tableName, updateThroughputParameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Update the RUs per second of an Azure Cosmos DB MongoDB collection /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of an Azure resource group. /// </param> /// <param name='accountName'> /// Cosmos DB database account name. /// </param> /// <param name='databaseName'> /// Cosmos DB database name. /// </param> /// <param name='collectionName'> /// Cosmos DB collection name. /// </param> /// <param name='updateThroughputParameters'> /// The RUs per second of the parameters to provide for the current MongoDB /// collection. /// </param> public static ThroughputSettingsGetResults BeginUpdateMongoDBCollectionThroughput(this IMongoDBResourcesOperations operations, string resourceGroupName, string accountName, string databaseName, string collectionName, ThroughputSettingsUpdateParameters updateThroughputParameters) { return(operations.BeginUpdateMongoDBCollectionThroughputAsync(resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters).GetAwaiter().GetResult()); }