Search in sources :

Example 21 with CosmosDatabaseResponse

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

the class CosmosDiagnosticsQuickStartAsync method createDatabaseIfNotExists.

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

Example 22 with CosmosDatabaseResponse

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

the class CosmosDiagnosticsQuickStartAsync method deleteDatabase.

// Database delete
private void deleteDatabase() throws Exception {
    logger.info("Last step: delete database {} by ID", databaseName);
    // Delete database
    CosmosDatabaseResponse dbResp = client.getDatabase(databaseName).delete(new CosmosDatabaseRequestOptions()).block();
    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 23 with CosmosDatabaseResponse

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

the class CosmosDiagnosticsQuickStart method deleteDatabase.

// Database delete
private void deleteDatabase() throws Exception {
    logger.info("Last step: delete database {} by ID", databaseName);
    // 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 24 with CosmosDatabaseResponse

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

the class AnalyticalContainerCRUDQuickstart 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 25 with CosmosDatabaseResponse

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

the class AutoscaleContainerCRUDQuickstart 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)

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