### YamlMime:JavaType uid: "com.azure.cosmos.CosmosClient" fullName: "com.azure.cosmos.CosmosClient" name: "CosmosClient" nameWithType: "CosmosClient" summary: "Provides a client-side logical representation of the Azure Cosmos DB service." inheritances: - "" inheritedClassMethods: - classRef: "java.lang.Object" methodsRef: - "clone" - "equals" - "finalize" - "getClass" - "hashCode" - "notify" - "notifyAll" - "toString" - "wait" - "wait" - "wait" syntax: "public final class **CosmosClient**
implements Closeable" methods: - uid: "com.azure.cosmos.CosmosClient.close()" fullName: "com.azure.cosmos.CosmosClient.close()" name: "close()" nameWithType: "CosmosClient.close()" summary: "Close this instance." syntax: "public void close()" desc: "Close this instance." - uid: "com.azure.cosmos.CosmosClient.createDatabase(com.azure.cosmos.models.CosmosDatabaseProperties)" fullName: "com.azure.cosmos.CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties)" name: "createDatabase(CosmosDatabaseProperties databaseProperties)" nameWithType: "CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties)" summary: "Creates a Cosmos database." parameters: - description: " the database properties." name: "databaseProperties" type: "" syntax: "public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties)" desc: "Creates a Cosmos database.\n\n```java\nCosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);\n cosmosClient.createDatabase(databaseProperties);\n```" returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createDatabase(com.azure.cosmos.models.CosmosDatabaseProperties,com.azure.cosmos.models.CosmosDatabaseRequestOptions)" fullName: "com.azure.cosmos.CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options)" name: "createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options)" nameWithType: "CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options)" summary: "Creates a database." parameters: - description: " the database properties." name: "databaseProperties" type: "" - description: "the request options." name: "options" type: "" syntax: "public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options)" desc: "Creates a database.\n\n```java\nCosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);\n cosmosClient.createDatabase(databaseProperties);\n```" returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createDatabase(com.azure.cosmos.models.CosmosDatabaseProperties,com.azure.cosmos.models.ThroughputProperties)" fullName: "com.azure.cosmos.CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties)" name: "createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties)" nameWithType: "CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties)" summary: "Creates a Cosmos database." parameters: - description: " the database properties." name: "databaseProperties" type: "" - description: "the throughput properties." name: "throughputProperties" type: "" syntax: "public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties)" desc: "Creates a Cosmos database.\n\n```java\nThroughputProperties throughputProperties = ThroughputProperties\n .createAutoscaledThroughput(autoScaleMaxThroughput);\n cosmosClient.createDatabase(databaseName, throughputProperties);\n```" returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createDatabase(com.azure.cosmos.models.CosmosDatabaseProperties,com.azure.cosmos.models.ThroughputProperties,com.azure.cosmos.models.CosmosDatabaseRequestOptions)" fullName: "com.azure.cosmos.CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options)" name: "createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options)" nameWithType: "CosmosClient.createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options)" summary: "Creates a Cosmos database." parameters: - description: " the database properties." name: "databaseProperties" type: "" - description: "the throughput properties." name: "throughputProperties" type: "" - description: " the request options." name: "options" type: "" syntax: "public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options)" desc: "Creates a Cosmos database.\n\n```java\nThroughputProperties throughputProperties = ThroughputProperties\n .createAutoscaledThroughput(autoScaleMaxThroughput);\n cosmosClient.createDatabase(databaseName, throughputProperties);\n```" returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createDatabase(java.lang.String)" fullName: "com.azure.cosmos.CosmosClient.createDatabase(String id)" name: "createDatabase(String id)" nameWithType: "CosmosClient.createDatabase(String id)" summary: "Creates a Cosmos database." parameters: - description: "the id of the database." name: "id" type: "String" syntax: "public CosmosDatabaseResponse createDatabase(String id)" desc: "Creates a Cosmos database.\n\n```java\nCosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);\n cosmosClient.createDatabase(databaseProperties);\n```" returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createDatabase(java.lang.String,com.azure.cosmos.models.ThroughputProperties)" fullName: "com.azure.cosmos.CosmosClient.createDatabase(String id, ThroughputProperties throughputProperties)" name: "createDatabase(String id, ThroughputProperties throughputProperties)" nameWithType: "CosmosClient.createDatabase(String id, ThroughputProperties throughputProperties)" summary: "Creates a Cosmos database." parameters: - description: "the id of the database." name: "id" type: "String" - description: "the throughput properties." name: "throughputProperties" type: "" syntax: "public CosmosDatabaseResponse createDatabase(String id, ThroughputProperties throughputProperties)" desc: "Creates a Cosmos database.\n\n```java\nThroughputProperties throughputProperties = ThroughputProperties\n .createAutoscaledThroughput(autoScaleMaxThroughput);\n cosmosClient.createDatabase(databaseName, throughputProperties);\n```" returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createDatabaseIfNotExists(java.lang.String)" fullName: "com.azure.cosmos.CosmosClient.createDatabaseIfNotExists(String id)" name: "createDatabaseIfNotExists(String id)" nameWithType: "CosmosClient.createDatabaseIfNotExists(String id)" summary: "Create a Cosmos database if it does not already exist on the service." parameters: - description: "the id of the database." name: "id" type: "String" syntax: "public CosmosDatabaseResponse createDatabaseIfNotExists(String id)" desc: "Create a Cosmos database if it does not already exist on the service.\n\n```java\nCosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);\n cosmosClient.createDatabaseIfNotExists(databaseProperties);\n```" returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createDatabaseIfNotExists(java.lang.String,com.azure.cosmos.models.ThroughputProperties)" fullName: "com.azure.cosmos.CosmosClient.createDatabaseIfNotExists(String id, ThroughputProperties throughputProperties)" name: "createDatabaseIfNotExists(String id, ThroughputProperties throughputProperties)" nameWithType: "CosmosClient.createDatabaseIfNotExists(String id, ThroughputProperties throughputProperties)" summary: "Create a Cosmos database if it does not already exist on the service." parameters: - description: "the id of the database." name: "id" type: "String" - description: "the throughputProperties." name: "throughputProperties" type: "" syntax: "public CosmosDatabaseResponse createDatabaseIfNotExists(String id, ThroughputProperties throughputProperties)" desc: "Create a Cosmos database if it does not already exist on the service.\n\n```java\nThroughputProperties throughputProperties = ThroughputProperties\n .createAutoscaledThroughput(autoScaleMaxThroughput);\n cosmosClient.createDatabaseIfNotExists(databaseName, throughputProperties);\n```\n\nThe throughputProperties will only be used if the specified database does not exist and therefor a new database will be created with throughputProperties." returns: description: "the with the created database." type: "" - uid: "com.azure.cosmos.CosmosClient.createGlobalThroughputControlConfigBuilder(java.lang.String,java.lang.String)" fullName: "com.azure.cosmos.CosmosClient.createGlobalThroughputControlConfigBuilder(String databaseId, String containerId)" name: "createGlobalThroughputControlConfigBuilder(String databaseId, String containerId)" nameWithType: "CosmosClient.createGlobalThroughputControlConfigBuilder(String databaseId, String containerId)" summary: "Create global throughput control config builder which will be used to build ." parameters: - description: "The database id of the control container." name: "databaseId" type: "String" - description: "The container id of the control container." name: "containerId" type: "String" syntax: "public GlobalThroughputControlConfigBuilder createGlobalThroughputControlConfigBuilder(String databaseId, String containerId)" desc: "Create global throughput control config builder which will be used to build ." returns: description: "A ." type: "" - uid: "com.azure.cosmos.CosmosClient.getDatabase(java.lang.String)" fullName: "com.azure.cosmos.CosmosClient.getDatabase(String id)" name: "getDatabase(String id)" nameWithType: "CosmosClient.getDatabase(String id)" summary: "Gets the Cosmos database instance without making a service call." parameters: - description: "the id of the database." name: "id" type: "String" syntax: "public CosmosDatabase getDatabase(String id)" desc: "Gets the Cosmos database instance without making a service call." returns: description: " the cosmos sync database." type: "" - uid: "com.azure.cosmos.CosmosClient.queryDatabases(com.azure.cosmos.models.SqlQuerySpec,com.azure.cosmos.models.CosmosQueryRequestOptions)" fullName: "com.azure.cosmos.CosmosClient.queryDatabases(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)" name: "queryDatabases(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)" nameWithType: "CosmosClient.queryDatabases(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)" summary: "Query a Cosmos database." parameters: - description: " the query spec." name: "querySpec" type: "" - description: "the query request options." name: "options" type: "" syntax: "public CosmosPagedIterable queryDatabases(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)" desc: "Query a Cosmos database.\n\n```java\nCosmosQueryRequestOptions options = new CosmosQueryRequestOptions();\n CosmosPagedIterable databaseProperties =\n cosmosClient.queryDatabases(\"select * from d\", options);\n databaseProperties.forEach(properties -> {\n System.out.println(properties.getId());\n });\n```" returns: description: "the for feed response with the obtained databases." type: "<>" - uid: "com.azure.cosmos.CosmosClient.queryDatabases(java.lang.String,com.azure.cosmos.models.CosmosQueryRequestOptions)" fullName: "com.azure.cosmos.CosmosClient.queryDatabases(String query, CosmosQueryRequestOptions options)" name: "queryDatabases(String query, CosmosQueryRequestOptions options)" nameWithType: "CosmosClient.queryDatabases(String query, CosmosQueryRequestOptions options)" summary: "Query a Cosmos database." parameters: - description: "the query." name: "query" type: "String" - description: "the feed options." name: "options" type: "" syntax: "public CosmosPagedIterable queryDatabases(String query, CosmosQueryRequestOptions options)" desc: "Query a Cosmos database.\n\n```java\nCosmosQueryRequestOptions options = new CosmosQueryRequestOptions();\n CosmosPagedIterable databaseProperties =\n cosmosClient.queryDatabases(\"select * from d\", options);\n databaseProperties.forEach(properties -> {\n System.out.println(properties.getId());\n });\n```" returns: description: "the for feed response with the obtained databases." type: "<>" - uid: "com.azure.cosmos.CosmosClient.readAllDatabases()" fullName: "com.azure.cosmos.CosmosClient.readAllDatabases()" name: "readAllDatabases()" nameWithType: "CosmosClient.readAllDatabases()" summary: "Reads all Cosmos databases." syntax: "public CosmosPagedIterable readAllDatabases()" desc: "Reads all Cosmos databases.\n\n```java\nCosmosPagedIterable cosmosDatabaseProperties =\n cosmosClient.readAllDatabases();\n cosmosDatabaseProperties.forEach(databaseProperties -> {\n System.out.println(databaseProperties);\n });\n```" returns: description: "the for feed response with the read databases." type: "<>" type: "class" desc: "Provides a client-side logical representation of the Azure Cosmos DB service. Calls to CosmosClient API's are blocked for completion.\n\nCosmosClient is thread-safe. It's recommended to maintain a single instance of CosmosClient per lifetime of the application which enables efficient connection management and performance. CosmosClient initialization is a heavy operation - don't use initialization CosmosClient instances as credentials or network connectivity validations." implements: - "Closeable" metadata: {} package: "com.azure.cosmos" artifact: com.azure:azure-cosmos:4.63.4