public async Task TableCreateAndUpdate() { var table = await CreateTable(null); Assert.AreEqual(_databaseName, table.Data.Resource.Id); // Seems bug in swagger definition //Assert.AreEqual(TestThroughput1, database.Data.Options.Throughput); bool ifExists = await TableCollection.ExistsAsync(_databaseName); Assert.True(ifExists); // NOT WORKING API //ThroughputSettingsData throughtput = await database.GetMongoDBCollectionThroughputAsync(); CosmosTable table2 = await TableCollection.GetAsync(_databaseName); Assert.AreEqual(_databaseName, table2.Data.Resource.Id); //Assert.AreEqual(TestThroughput1, database2.Data.Options.Throughput); VerifyTables(table, table2); // TODO: use original tags see defect: https://github.com/Azure/autorest.csharp/issues/1590 TableCreateUpdateData updateOptions = new TableCreateUpdateData(AzureLocation.WestUS, table.Data.Resource) { Options = new CreateUpdateOptions { Throughput = TestThroughput2 } }; table = (await TableCollection.CreateOrUpdateAsync(WaitUntil.Completed, _databaseName, updateOptions)).Value; Assert.AreEqual(_databaseName, table.Data.Resource.Id); table2 = await TableCollection.GetAsync(_databaseName); VerifyTables(table, table2); }
internal static async Task <CosmosTable> CreateTable(string name, AutoscaleSettings autoscale, CosmosTableCollection collection) { TableCreateUpdateData mongoDBDatabaseCreateUpdateOptions = new TableCreateUpdateData(AzureLocation.WestUS, new TableResource(name)) { Options = BuildDatabaseCreateUpdateOptions(TestThroughput1, autoscale), }; var databaseLro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, mongoDBDatabaseCreateUpdateOptions); return(databaseLro.Value); }
public virtual async Task <ArmOperation <CosmosTableResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string tableName, TableCreateUpdateData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(tableName, nameof(tableName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _cosmosTableTableResourcesClientDiagnostics.CreateScope("CosmosTableCollection.CreateOrUpdate"); scope.Start(); try { var response = await _cosmosTableTableResourcesRestClient.CreateUpdateTableAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, tableName, data, cancellationToken).ConfigureAwait(false); var operation = new CosmosDBArmOperation <CosmosTableResource>(new CosmosTableOperationSource(Client), _cosmosTableTableResourcesClientDiagnostics, Pipeline, _cosmosTableTableResourcesRestClient.CreateCreateUpdateTableRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, tableName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }