public async Task MongoDBCollectionCreateAndUpdate() { var collection = await CreateMongoDBCollection(null); Assert.AreEqual(_collectionName, collection.Data.Resource.Id); // Seems bug in swagger definition //Assert.AreEqual(TestThroughput1, collection.Data.Options.Throughput); bool ifExists = await MongoDBCollectionCollection.ExistsAsync(_collectionName); Assert.True(ifExists); // NOT WORKING API //ThroughputSettingsData throughtput = await collection.GetMongoDBCollectionThroughputAsync(); MongoDBCollectionResource collection2 = await MongoDBCollectionCollection.GetAsync(_collectionName); Assert.AreEqual(_collectionName, collection2.Data.Resource.Id); //Assert.AreEqual(TestThroughput1, collection2.Data.Options.Throughput); VerifyMongoDBCollections(collection, collection2); MongoDBCollectionCreateUpdateData updateOptions = new MongoDBCollectionCreateUpdateData(collection.Id, _collectionName, collection.Data.ResourceType, null, new Dictionary <string, string>(),// TODO: use original tags see defect: https://github.com/Azure/autorest.csharp/issues/1590 AzureLocation.WestUS, collection.Data.Resource, new CreateUpdateOptions { Throughput = TestThroughput2 }); collection = await(await MongoDBCollectionCollection.CreateOrUpdateAsync(WaitUntil.Started, _collectionName, updateOptions)).WaitForCompletionAsync(); Assert.AreEqual(_collectionName, collection.Data.Resource.Id); collection2 = await MongoDBCollectionCollection.GetAsync(_collectionName); VerifyMongoDBCollections(collection, collection2); }
internal static async Task <MongoDBCollectionResource> CreateMongoDBCollection(string name, AutoscaleSettings autoscale, MongoDBCollectionCollection mongoDBContainerCollection) { MongoDBCollectionCreateUpdateData mongoDBDatabaseCreateUpdateOptions = new MongoDBCollectionCreateUpdateData(AzureLocation.WestUS, new Models.MongoDBCollectionResource(name)) { Options = BuildDatabaseCreateUpdateOptions(TestThroughput1, autoscale), }; var mongoDBContainerLro = await mongoDBContainerCollection.CreateOrUpdateAsync(WaitUntil.Completed, name, mongoDBDatabaseCreateUpdateOptions); return(mongoDBContainerLro.Value); }
public virtual async Task <ArmOperation <MongoDBCollection> > CreateOrUpdateAsync(WaitUntil waitUntil, string collectionName, MongoDBCollectionCreateUpdateData createUpdateMongoDBCollectionParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(collectionName, nameof(collectionName)); Argument.AssertNotNull(createUpdateMongoDBCollectionParameters, nameof(createUpdateMongoDBCollectionParameters)); using var scope = _mongoDBCollectionMongoDBResourcesClientDiagnostics.CreateScope("MongoDBCollectionCollection.CreateOrUpdate"); scope.Start(); try { var response = await _mongoDBCollectionMongoDBResourcesRestClient.CreateUpdateMongoDBCollectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, collectionName, createUpdateMongoDBCollectionParameters, cancellationToken).ConfigureAwait(false); var operation = new CosmosDBArmOperation <MongoDBCollection>(new MongoDBCollectionOperationSource(Client), _mongoDBCollectionMongoDBResourcesClientDiagnostics, Pipeline, _mongoDBCollectionMongoDBResourcesRestClient.CreateCreateUpdateMongoDBCollectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, collectionName, createUpdateMongoDBCollectionParameters).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }