CosmosClient クラス

  • java.lang.Object
    • com.azure.cosmos.CosmosClient

実装

public final class CosmosClient
implements Closeable

Azure Cosmos DB サービスのクライアント側の論理表現を提供します。 CosmosClient API の への呼び出しは、完了のためにブロックされます。

CosmosClient はスレッド セーフです。 効率的な接続管理とパフォーマンスを可能にするアプリケーションの有効期間ごとに、CosmosClient の 1 つのインスタンスを維持することをお勧めします。 CosmosClient の初期化は負荷の高い操作です。資格情報やネットワーク接続の検証には、初期化 CosmosClient インスタンスを使用しないでください。

メソッドの概要

修飾子と型 メソッドと説明
void close()

このインスタンスを CosmosClient 閉じます。

CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties)

Cosmos データベースを作成します。

CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options)

データベースを作成します。

CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties)

Cosmos データベースを作成します。

CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options)

Cosmos データベースを作成します。

CosmosDatabaseResponse createDatabase(String id)

Cosmos データベースを作成します。

CosmosDatabaseResponse createDatabase(String id, ThroughputProperties throughputProperties)

Cosmos データベースを作成します。

CosmosDatabaseResponse createDatabaseIfNotExists(String id)

Cosmos データベースがサービスにまだ存在しない場合は作成します。

CosmosDatabaseResponse createDatabaseIfNotExists(String id, ThroughputProperties throughputProperties)

Cosmos データベースがサービスにまだ存在しない場合は作成します。

GlobalThroughputControlConfigBuilder createGlobalThroughputControlConfigBuilder(String databaseId, String containerId)

をビルド GlobalThroughputControlConfigするために使用するグローバル スループット制御構成ビルダーを作成します。

CosmosDatabase getDatabase(String id)

サービス呼び出しを行わずに Cosmos データベース インスタンスを取得します。

CosmosPagedIterable<CosmosDatabaseProperties> queryDatabases(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Cosmos データベースに対してクエリを実行します。

CosmosPagedIterable<CosmosDatabaseProperties> queryDatabases(String query, CosmosQueryRequestOptions options)

Cosmos データベースに対してクエリを実行します。

CosmosPagedIterable<CosmosDatabaseProperties> readAllDatabases()

すべての Cosmos データベースを読み取ります。

メソッドの継承元: java.lang.Object

メソッドの詳細

close

public void close()

このインスタンスを CosmosClient 閉じます。

createDatabase

public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties)

Cosmos データベースを作成します。

CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);
 cosmosClient.createDatabase(databaseProperties);

Parameters:

databaseProperties - CosmosDatabaseProperties データベースのプロパティ。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createDatabase

public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, CosmosDatabaseRequestOptions options)

データベースを作成します。

CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);
 cosmosClient.createDatabase(databaseProperties);

Parameters:

databaseProperties - CosmosDatabaseProperties データベースのプロパティ。
options - 要求オプション。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createDatabase

public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties)

Cosmos データベースを作成します。

ThroughputProperties throughputProperties = ThroughputProperties
     .createAutoscaledThroughput(autoScaleMaxThroughput);
 cosmosClient.createDatabase(databaseName, throughputProperties);

Parameters:

databaseProperties - CosmosDatabaseProperties データベースのプロパティ。
throughputProperties - スループットのプロパティ。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createDatabase

public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties, ThroughputProperties throughputProperties, CosmosDatabaseRequestOptions options)

Cosmos データベースを作成します。

ThroughputProperties throughputProperties = ThroughputProperties
     .createAutoscaledThroughput(autoScaleMaxThroughput);
 cosmosClient.createDatabase(databaseName, throughputProperties);

Parameters:

databaseProperties - CosmosDatabaseProperties データベースのプロパティ。
throughputProperties - スループットのプロパティ。
options - CosmosDatabaseRequestOptions 要求オプション。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createDatabase

public CosmosDatabaseResponse createDatabase(String id)

Cosmos データベースを作成します。

CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);
 cosmosClient.createDatabase(databaseProperties);

Parameters:

id - データベースの ID。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createDatabase

public CosmosDatabaseResponse createDatabase(String id, ThroughputProperties throughputProperties)

Cosmos データベースを作成します。

ThroughputProperties throughputProperties = ThroughputProperties
     .createAutoscaledThroughput(autoScaleMaxThroughput);
 cosmosClient.createDatabase(databaseName, throughputProperties);

Parameters:

id - データベースの ID。
throughputProperties - スループットのプロパティ。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createDatabaseIfNotExists

public CosmosDatabaseResponse createDatabaseIfNotExists(String id)

Cosmos データベースがサービスにまだ存在しない場合は作成します。

CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseName);
 cosmosClient.createDatabaseIfNotExists(databaseProperties);

Parameters:

id - データベースの ID。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createDatabaseIfNotExists

public CosmosDatabaseResponse createDatabaseIfNotExists(String id, ThroughputProperties throughputProperties)

Cosmos データベースがサービスにまだ存在しない場合は作成します。

ThroughputProperties throughputProperties = ThroughputProperties
     .createAutoscaledThroughput(autoScaleMaxThroughput);
 cosmosClient.createDatabaseIfNotExists(databaseName, throughputProperties);

throughputProperties が使用されるのは、指定されたデータベースが存在せず、新しいデータベースが throughputProperties で作成される場合のみです。

Parameters:

id - データベースの ID。
throughputProperties - throughputProperties。

Returns:

作成 CosmosDatabaseResponse されたデータベースを含む 。

createGlobalThroughputControlConfigBuilder

public GlobalThroughputControlConfigBuilder createGlobalThroughputControlConfigBuilder(String databaseId, String containerId)

をビルド GlobalThroughputControlConfigするために使用するグローバル スループット制御構成ビルダーを作成します。

Parameters:

databaseId - コントロール コンテナーのデータベース ID。
containerId - コントロール コンテナーのコンテナー ID。

Returns:

getDatabase

public CosmosDatabase getDatabase(String id)

サービス呼び出しを行わずに Cosmos データベース インスタンスを取得します。

Parameters:

id - データベースの ID。

Returns:

CosmosDatabase Cosmos 同期データベース。

queryDatabases

public CosmosPagedIterable queryDatabases(SqlQuerySpec querySpec, CosmosQueryRequestOptions options)

Cosmos データベースに対してクエリを実行します。

CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
 CosmosPagedIterable<CosmosDatabaseProperties> databaseProperties =
     cosmosClient.queryDatabases("select * from d", options);
 databaseProperties.forEach(properties -> {
     System.out.println(properties.getId());
 });

Parameters:

querySpec - SqlQuerySpec クエリ スペック。
options - クエリ要求オプション。

Returns:

は、 CosmosPagedIterable<T> 取得したデータベースに対するフィード応答の です。

queryDatabases

public CosmosPagedIterable queryDatabases(String query, CosmosQueryRequestOptions options)

Cosmos データベースに対してクエリを実行します。

CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
 CosmosPagedIterable<CosmosDatabaseProperties> databaseProperties =
     cosmosClient.queryDatabases("select * from d", options);
 databaseProperties.forEach(properties -> {
     System.out.println(properties.getId());
 });

Parameters:

query - クエリ。
options - CosmosQueryRequestOptionsフィード オプション。

Returns:

は、 CosmosPagedIterable<T> 取得したデータベースに対するフィード応答の です。

readAllDatabases

public CosmosPagedIterable readAllDatabases()

すべての Cosmos データベースを読み取ります。

CosmosPagedIterable<CosmosDatabaseProperties> cosmosDatabaseProperties =
     cosmosClient.readAllDatabases();
 cosmosDatabaseProperties.forEach(databaseProperties -> {
     System.out.println(databaseProperties);
 });

Returns:

CosmosPagedIterable<T>読み取りデータベースを使用したフィード応答の 。

適用対象