use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SamplePatchQuickstart method createDatabaseIfNotExists.
private void createDatabaseIfNotExists() throws Exception {
logger.info("Create database {} if not exists.", databaseName);
// Create database if not exists
// <CreateDatabaseIfNotExists>
CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists(databaseName);
database = client.getDatabase(databaseResponse.getProperties().getId());
// </CreateDatabaseIfNotExists>
logger.info("Checking database {} completed!\n", database.getId());
}
use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class QueriesQuickstart 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.");
}
use of com.azure.cosmos.models.CosmosDatabaseResponse in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SampleCRUDQuickstart method createDatabaseIfNotExists.
private void createDatabaseIfNotExists() throws Exception {
logger.info("Create database " + databaseName + " if not exists.");
// Create database if not exists
// <CreateDatabaseIfNotExists>
CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists(databaseName);
database = client.getDatabase(databaseResponse.getProperties().getId());
// </CreateDatabaseIfNotExists>
logger.info("Checking database " + database.getId() + " completed!\n");
}
use of com.azure.cosmos.models.CosmosDatabaseResponse in project testcontainers-java by testcontainers.
the class CosmosDBEmulatorContainerTest method testWithCosmosClient.
// }
@Test
public void testWithCosmosClient() throws Exception {
// buildAndSaveNewKeyStore {
Path keyStoreFile = tempFolder.newFile("azure-cosmos-emulator.keystore").toPath();
KeyStore keyStore = emulator.buildNewKeyStore();
keyStore.store(new FileOutputStream(keyStoreFile.toFile()), emulator.getEmulatorKey().toCharArray());
// }
// setSystemTrustStoreParameters {
System.setProperty("javax.net.ssl.trustStore", keyStoreFile.toString());
System.setProperty("javax.net.ssl.trustStorePassword", emulator.getEmulatorKey());
System.setProperty("javax.net.ssl.trustStoreType", "PKCS12");
// }
// buildClient {
CosmosAsyncClient client = new CosmosClientBuilder().gatewayMode().endpointDiscoveryEnabled(false).endpoint(emulator.getEmulatorEndpoint()).key(emulator.getEmulatorKey()).buildAsyncClient();
// }
// testWithClientAgainstEmulatorContainer {
CosmosDatabaseResponse databaseResponse = client.createDatabaseIfNotExists("Azure").block();
Assertions.assertThat(databaseResponse.getStatusCode()).isEqualTo(201);
CosmosContainerResponse containerResponse = client.getDatabase("Azure").createContainerIfNotExists("ServiceContainer", "/name").block();
Assertions.assertThat(containerResponse.getStatusCode()).isEqualTo(201);
// }
}
use of com.azure.cosmos.models.CosmosDatabaseResponse in project DataSpaceConnector by eclipse-dataspaceconnector.
the class CosmosContractDefinitionStoreIntegrationTest method deleteDatabase.
@AfterAll
static void deleteDatabase() {
if (database != null) {
CosmosDatabaseResponse delete = database.delete();
assertThat(delete.getStatusCode()).isGreaterThanOrEqualTo(200).isLessThan(300);
}
}
Aggregations