Search in sources :

Example 1 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class AnalyticalContainerCRUDQuickstart method deleteADatabase.

// Database delete
private void deleteADatabase() throws Exception {
    logger.info("Last step: delete database " + databaseName + " by ID.");
    // Delete database
    CosmosDatabaseResponse dbResp = client.getDatabase(databaseName).delete(new CosmosDatabaseRequestOptions());
    logger.info("Status code for database delete: {}", dbResp.getStatusCode());
    logger.info("Done.");
}
Also used : CosmosDatabaseRequestOptions(com.azure.cosmos.models.CosmosDatabaseRequestOptions) CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse)

Example 2 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class AutoscaleDatabaseCRUDQuickstart method createDatabaseIfNotExists.

// Database Create
private void createDatabaseIfNotExists() throws Exception {
    logger.info("Create database " + databaseName + " if not exists...");
    // Autoscale throughput settings
    // Set autoscale max RU/s
    ThroughputProperties autoscaleThroughputProperties = ThroughputProperties.createAutoscaledThroughput(4000);
    // Create the database with autoscale enabled
    CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists(databaseName, autoscaleThroughputProperties);
    database = client.getDatabase(databaseResponse.getProperties().getId());
    logger.info("Done.");
}
Also used : ThroughputProperties(com.azure.cosmos.models.ThroughputProperties) CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse)

Example 3 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class DocumentCRUDQuickstart method deleteADatabase.

// Database delete
private void deleteADatabase() throws Exception {
    logger.info("Last step: delete database " + databaseName + " by ID.");
    // Delete database
    CosmosDatabaseResponse dbResp = client.getDatabase(databaseName).delete(new CosmosDatabaseRequestOptions());
    logger.info("Status code for database delete: {}", dbResp.getStatusCode());
    logger.info("Done.");
}
Also used : CosmosDatabaseRequestOptions(com.azure.cosmos.models.CosmosDatabaseRequestOptions) CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse)

Example 4 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class DocumentCRUDQuickstart method createDatabaseIfNotExists.

// Database Create
private void createDatabaseIfNotExists() throws Exception {
    logger.info("Create database " + databaseName + " if not exists...");
    // Create database if not exists
    CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists(databaseName);
    database = client.getDatabase(databaseResponse.getProperties().getId());
    logger.info("Done.");
}
Also used : CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse)

Example 5 with CosmosDatabaseResponse

use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.

the class CosmosDiagnosticsQuickStart method createDatabaseIfNotExists.

// Database Diagnostics
private void createDatabaseIfNotExists() throws Exception {
    logger.info("Creating database {} if not exists", databaseName);
    // Create database if not exists
    CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists(databaseName);
    CosmosDiagnostics diagnostics = databaseResponse.getDiagnostics();
    logger.info("Create database diagnostics : {}", diagnostics);
    database = client.getDatabase(databaseResponse.getProperties().getId());
    logger.info("Done.");
}
Also used : CosmosDatabaseResponse(com.azure.cosmos.models.CosmosDatabaseResponse) CosmosDiagnostics(com.azure.cosmos.CosmosDiagnostics)

Aggregations

CosmosDatabaseResponse (com.azure.cosmos.models.CosmosDatabaseResponse)31 CosmosDatabaseRequestOptions (com.azure.cosmos.models.CosmosDatabaseRequestOptions)8 AfterAll (org.junit.jupiter.api.AfterAll)5 BeforeAll (org.junit.jupiter.api.BeforeAll)4 CosmosClientBuilder (com.azure.cosmos.CosmosClientBuilder)3 CosmosContainerResponse (com.azure.cosmos.models.CosmosContainerResponse)3 ThroughputProperties (com.azure.cosmos.models.ThroughputProperties)3 CosmosDiagnostics (com.azure.cosmos.CosmosDiagnostics)2 CosmosContainerProperties (com.azure.cosmos.models.CosmosContainerProperties)2 ArrayList (java.util.ArrayList)2 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)2 ConsistencyLevel (com.azure.cosmos.ConsistencyLevel)1 CosmosAsyncClient (com.azure.cosmos.CosmosAsyncClient)1 CosmosClient (com.azure.cosmos.CosmosClient)1 CosmosContainer (com.azure.cosmos.CosmosContainer)1 CosmosDatabase (com.azure.cosmos.CosmosDatabase)1 AccountSettings (com.azure.cosmos.examples.common.AccountSettings)1 Profile (com.azure.cosmos.examples.common.Profile)1 CosmosItemResponse (com.azure.cosmos.models.CosmosItemResponse)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1