Example #1
0
        public async Task CassandraKeyspaceCreateAndUpdate()
        {
            var keyspace = await CreateCassandraKeyspace(null);

            Assert.AreEqual(_keyspaceName, keyspace.Data.Resource.Id);
            // Seems bug in swagger definition
            //Assert.AreEqual(TestThroughput1, keyspace.Data.Options.Throughput);

            bool ifExists = await CassandraKeyspaceCollection.ExistsAsync(_keyspaceName);

            Assert.True(ifExists);

            // NOT WORKING API
            //ThroughputSettingsData throughtput = await keyspace.GetMongoDBCollectionThroughputAsync();
            CassandraKeyspace keyspace2 = await CassandraKeyspaceCollection.GetAsync(_keyspaceName);

            Assert.AreEqual(_keyspaceName, keyspace2.Data.Resource.Id);
            //Assert.AreEqual(TestThroughput1, keyspace2.Data.Options.Throughput);

            VerifyCassandraKeyspaces(keyspace, keyspace2);

            // TODO: use original tags see defect: https://github.com/Azure/autorest.csharp/issues/1590
            CassandraKeyspaceCreateUpdateData updateOptions = new CassandraKeyspaceCreateUpdateData(AzureLocation.WestUS, keyspace.Data.Resource)
            {
                Options = new CreateUpdateOptions {
                    Throughput = TestThroughput2
                }
            };

            keyspace = (await CassandraKeyspaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, _keyspaceName, updateOptions)).Value;
            Assert.AreEqual(_keyspaceName, keyspace.Data.Resource.Id);
            keyspace2 = await CassandraKeyspaceCollection.GetAsync(_keyspaceName);

            VerifyCassandraKeyspaces(keyspace, keyspace2);
        }
Example #2
0
        internal static async Task <CassandraKeyspace> CreateCassandraKeyspace(string name, AutoscaleSettings autoscale, CassandraKeyspaceCollection collection)
        {
            CassandraKeyspaceCreateUpdateData cassandraKeyspaceCreateUpdateOptions = new CassandraKeyspaceCreateUpdateData(AzureLocation.WestUS,
                                                                                                                           new CassandraKeyspaceResource(name))
            {
                Options = BuildDatabaseCreateUpdateOptions(TestThroughput1, autoscale),
            };
            var keyspaceLro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, cassandraKeyspaceCreateUpdateOptions);

            return(keyspaceLro.Value);
        }
        public virtual async Task <ArmOperation <CassandraKeyspaceResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string keyspaceName, CassandraKeyspaceCreateUpdateData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(keyspaceName, nameof(keyspaceName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _cassandraKeyspaceCassandraResourcesClientDiagnostics.CreateScope("CassandraKeyspaceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _cassandraKeyspaceCassandraResourcesRestClient.CreateUpdateCassandraKeyspaceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyspaceName, data, cancellationToken).ConfigureAwait(false);

                var operation = new CosmosDBArmOperation <CassandraKeyspaceResource>(new CassandraKeyspaceOperationSource(Client), _cassandraKeyspaceCassandraResourcesClientDiagnostics, Pipeline, _cassandraKeyspaceCassandraResourcesRestClient.CreateCreateUpdateCassandraKeyspaceRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyspaceName, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }