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(); CosmosTableResource 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 var updateOptions = new CosmosTableCreateOrUpdateContent(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 <CosmosTableResource> CreateTable(string name, AutoscaleSettings autoscale, CosmosTableCollection collection) { var mongoDBDatabaseCreateUpdateOptions = new CosmosTableCreateOrUpdateContent(AzureLocation.WestUS, new TableResource(name)) { Options = BuildDatabaseCreateUpdateOptions(TestThroughput1, autoscale), }; var databaseLro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, mongoDBDatabaseCreateUpdateOptions); return(databaseLro.Value); }
public virtual ArmOperation <CosmosTableResource> Update(WaitUntil waitUntil, CosmosTableCreateOrUpdateContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); using var scope = _cosmosTableTableResourcesClientDiagnostics.CreateScope("CosmosTableResource.Update"); scope.Start(); try { var response = _cosmosTableTableResourcesRestClient.CreateUpdateTable(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); var operation = new CosmosDBArmOperation <CosmosTableResource>(new CosmosTableOperationSource(Client), _cosmosTableTableResourcesClientDiagnostics, Pipeline, _cosmosTableTableResourcesRestClient.CreateCreateUpdateTableRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <CosmosTableResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string tableName, CosmosTableCreateOrUpdateContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(tableName, nameof(tableName)); Argument.AssertNotNull(content, nameof(content)); using var scope = _cosmosTableTableResourcesClientDiagnostics.CreateScope("CosmosTableCollection.CreateOrUpdate"); scope.Start(); try { var response = await _cosmosTableTableResourcesRestClient.CreateUpdateTableAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, tableName, content, cancellationToken).ConfigureAwait(false); var operation = new CosmosDBArmOperation <CosmosTableResource>(new CosmosTableOperationSource(Client), _cosmosTableTableResourcesClientDiagnostics, Pipeline, _cosmosTableTableResourcesRestClient.CreateCreateUpdateTableRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, tableName, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }