azure-docs-sdk-java/docs-ref-autogen/com.azure.cosmos.CosmosClie...

407 строки
43 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.cosmos.CosmosClientBuilder"
fullName: "com.azure.cosmos.CosmosClientBuilder"
name: "CosmosClientBuilder"
nameWithType: "CosmosClientBuilder"
summary: "Helper class to build Cosmos<wbr>Async<wbr>Client <xref uid=\"com.azure.cosmos.CosmosAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosAsyncClient\"></xref> and Cosmos<wbr>Client <xref uid=\"com.azure.cosmos.CosmosClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosClient\"></xref> instances as logical representation of the Azure Cosmos database service."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public class **CosmosClientBuilder**</br> implements <xref href=\"com.azure.core.client.traits.TokenCredentialTrait?alt=com.azure.core.client.traits.TokenCredentialTrait&text=TokenCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;, <xref href=\"com.azure.core.client.traits.AzureKeyCredentialTrait?alt=com.azure.core.client.traits.AzureKeyCredentialTrait&text=AzureKeyCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;, <xref href=\"com.azure.core.client.traits.EndpointTrait?alt=com.azure.core.client.traits.EndpointTrait&text=EndpointTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
constructors:
- uid: "com.azure.cosmos.CosmosClientBuilder.CosmosClientBuilder()"
fullName: "com.azure.cosmos.CosmosClientBuilder.CosmosClientBuilder()"
name: "CosmosClientBuilder()"
nameWithType: "CosmosClientBuilder.CosmosClientBuilder()"
summary: "Instantiates a new Cosmos client builder."
syntax: "public CosmosClientBuilder()"
desc: "Instantiates a new Cosmos client builder."
methods:
- uid: "com.azure.cosmos.CosmosClientBuilder.authorizationTokenResolver(com.azure.cosmos.models.CosmosAuthorizationTokenResolver)"
fullName: "com.azure.cosmos.CosmosClientBuilder.authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)"
name: "authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)"
nameWithType: "CosmosClientBuilder.authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)"
summary: "Sets the token resolver"
parameters:
- description: "the token resolver"
name: "cosmosAuthorizationTokenResolver"
type: "<xref href=\"com.azure.cosmos.models.CosmosAuthorizationTokenResolver?alt=com.azure.cosmos.models.CosmosAuthorizationTokenResolver&text=CosmosAuthorizationTokenResolver\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder authorizationTokenResolver(CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver)"
desc: "Sets the token resolver"
returns:
description: "current cosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.buildAsyncClient()"
fullName: "com.azure.cosmos.CosmosClientBuilder.buildAsyncClient()"
name: "buildAsyncClient()"
nameWithType: "CosmosClientBuilder.buildAsyncClient()"
summary: "Builds a cosmos async client with the provided properties"
syntax: "public CosmosAsyncClient buildAsyncClient()"
desc: "Builds a cosmos async client with the provided properties"
returns:
description: "CosmosAsyncClient"
type: "<xref href=\"com.azure.cosmos.CosmosAsyncClient?alt=com.azure.cosmos.CosmosAsyncClient&text=CosmosAsyncClient\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.buildClient()"
fullName: "com.azure.cosmos.CosmosClientBuilder.buildClient()"
name: "buildClient()"
nameWithType: "CosmosClientBuilder.buildClient()"
summary: "Builds a cosmos sync client with the provided properties"
syntax: "public CosmosClient buildClient()"
desc: "Builds a cosmos sync client with the provided properties"
returns:
description: "CosmosClient"
type: "<xref href=\"com.azure.cosmos.CosmosClient?alt=com.azure.cosmos.CosmosClient&text=CosmosClient\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryConfig(com.azure.cosmos.models.CosmosClientTelemetryConfig)"
fullName: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)"
name: "clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)"
nameWithType: "CosmosClientBuilder.clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)"
summary: "Returns the client telemetry config instance for this builder"
parameters:
- description: "the client telemetry configuration to be used"
name: "telemetryConfig"
type: "<xref href=\"com.azure.cosmos.models.CosmosClientTelemetryConfig?alt=com.azure.cosmos.models.CosmosClientTelemetryConfig&text=CosmosClientTelemetryConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder clientTelemetryConfig(CosmosClientTelemetryConfig telemetryConfig)"
desc: "Returns the client telemetry config instance for this builder"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryEnabled(boolean)"
fullName: "com.azure.cosmos.CosmosClientBuilder.clientTelemetryEnabled(boolean clientTelemetryEnabled)"
name: "clientTelemetryEnabled(boolean clientTelemetryEnabled)"
nameWithType: "CosmosClientBuilder.clientTelemetryEnabled(boolean clientTelemetryEnabled)"
summary: "Sets the flag to enable client telemetry which will periodically collect database operations aggregation statistics, system information like cpu/memory and send it to cosmos monitoring service, which will be helpful during debugging."
parameters:
- description: "flag to enable client telemetry."
name: "clientTelemetryEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder clientTelemetryEnabled(boolean clientTelemetryEnabled)"
desc: "Sets the flag to enable client telemetry which will periodically collect database operations aggregation statistics, system information like cpu/memory and send it to cosmos monitoring service, which will be helpful during debugging.\n\nDEFAULT value is false indicating this is opt in feature, by default no telemetry collection."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.connectionSharingAcrossClientsEnabled(boolean)"
fullName: "com.azure.cosmos.CosmosClientBuilder.connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)"
name: "connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)"
nameWithType: "CosmosClientBuilder.connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)"
summary: "Enables connections sharing across multiple Cosmos Clients."
parameters:
- description: "connection sharing"
name: "connectionSharingAcrossClientsEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder connectionSharingAcrossClientsEnabled(boolean connectionSharingAcrossClientsEnabled)"
desc: "Enables connections sharing across multiple Cosmos Clients. The default is false.\n\n\n\n```java\nCosmosAsyncClient client1 = new CosmosClientBuilder()\n .endpoint(serviceEndpoint1)\n .key(key1)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .buildAsyncClient();\n\n CosmosAsyncClient client2 = new CosmosClientBuilder()\n .endpoint(serviceEndpoint2)\n .key(key2)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .buildAsyncClient();\n\n // when configured this way client1 and client2 will share connections when possible.\n```\n\n\nWhen you have multiple instances of Cosmos Client in the same JVM interacting to multiple Cosmos accounts, enabling this allows connection sharing in Direct mode if possible between instances of Cosmos Client.\nPlease note, when setting this option, the connection configuration (e.g., socket timeout config, idle timeout config) of the first instantiated client will be used for all other client instances.\n"
returns:
description: "current cosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.consistencyLevel(com.azure.cosmos.ConsistencyLevel)"
fullName: "com.azure.cosmos.CosmosClientBuilder.consistencyLevel(ConsistencyLevel desiredConsistencyLevel)"
name: "consistencyLevel(ConsistencyLevel desiredConsistencyLevel)"
nameWithType: "CosmosClientBuilder.consistencyLevel(ConsistencyLevel desiredConsistencyLevel)"
summary: "Sets the <xref uid=\"com.azure.cosmos.ConsistencyLevel\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel\"></xref> to be used\nBy default, <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref> consistency will be used."
parameters:
- description: "<xref uid=\"com.azure.cosmos.ConsistencyLevel\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel\"></xref>"
name: "desiredConsistencyLevel"
type: "<xref href=\"com.azure.cosmos.ConsistencyLevel?alt=com.azure.cosmos.ConsistencyLevel&text=ConsistencyLevel\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder consistencyLevel(ConsistencyLevel desiredConsistencyLevel)"
desc: "Sets the <xref uid=\"com.azure.cosmos.ConsistencyLevel\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel\"></xref> to be used\nBy default, <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref> consistency will be used."
returns:
description: "current Builder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.contentResponseOnWriteEnabled(boolean)"
fullName: "com.azure.cosmos.CosmosClientBuilder.contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)"
name: "contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)"
nameWithType: "CosmosClientBuilder.contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)"
summary: "Sets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on Cosmos<wbr>Item."
parameters:
- description: "a boolean indicating whether payload will be included in the response or not"
name: "contentResponseOnWriteEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled)"
desc: "Sets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on CosmosItem.\nIf set to false (which is by default), service doesn't return payload in the response. It reduces networking and CPU load by not sending the payload back over the network and serializing it on the client.\nThis feature does not impact RU usage for read or write operations.\nBy-default, this is false."
returns:
description: "current cosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.credential(com.azure.core.credential.AzureKeyCredential)"
fullName: "com.azure.cosmos.CosmosClientBuilder.credential(AzureKeyCredential credential)"
name: "credential(AzureKeyCredential credential)"
nameWithType: "CosmosClientBuilder.credential(AzureKeyCredential credential)"
summary: "Sets the <xref uid=\"com.azure.core.credential.AzureKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureKeyCredential\"></xref> to be used"
parameters:
- description: "<xref uid=\"com.azure.core.credential.AzureKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureKeyCredential\"></xref>"
name: "credential"
type: "<xref href=\"com.azure.core.credential.AzureKeyCredential?alt=com.azure.core.credential.AzureKeyCredential&text=AzureKeyCredential\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder credential(AzureKeyCredential credential)"
desc: "Sets the <xref uid=\"com.azure.core.credential.AzureKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureKeyCredential\"></xref> to be used"
returns:
description: "current cosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.credential(com.azure.core.credential.TokenCredential)"
fullName: "com.azure.cosmos.CosmosClientBuilder.credential(TokenCredential credential)"
name: "credential(TokenCredential credential)"
nameWithType: "CosmosClientBuilder.credential(TokenCredential credential)"
summary: "Sets the <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> used to authorize requests sent to the service."
parameters:
- description: "<xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> used to authorize requests sent to the service."
name: "credential"
type: "<xref href=\"com.azure.core.credential.TokenCredential?alt=com.azure.core.credential.TokenCredential&text=TokenCredential\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder credential(TokenCredential credential)"
desc: "Sets the <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> used to authorize requests sent to the service. Refer to the Azure SDK for Java [identity and authentication][] documentation for more details on proper usage of the <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> type.\n\n\n[identity and authentication]: https://aka.ms/azsdk/java/docs/identity"
returns:
description: "the updated CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.directMode()"
fullName: "com.azure.cosmos.CosmosClientBuilder.directMode()"
name: "directMode()"
nameWithType: "CosmosClientBuilder.directMode()"
summary: "Sets the default DIRECT connection configuration to be used."
syntax: "public CosmosClientBuilder directMode()"
desc: "Sets the default DIRECT connection configuration to be used.\nBy default, the builder is initialized with directMode()"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.directMode(com.azure.cosmos.DirectConnectionConfig)"
fullName: "com.azure.cosmos.CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig)"
name: "directMode(DirectConnectionConfig directConnectionConfig)"
nameWithType: "CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig)"
summary: "Sets the DIRECT connection configuration to be used."
parameters:
- description: "direct connection configuration"
name: "directConnectionConfig"
type: "<xref href=\"com.azure.cosmos.DirectConnectionConfig?alt=com.azure.cosmos.DirectConnectionConfig&text=DirectConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder directMode(DirectConnectionConfig directConnectionConfig)"
desc: "Sets the DIRECT connection configuration to be used.\nBy default, the builder is initialized with directMode()"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.directMode(com.azure.cosmos.DirectConnectionConfig,com.azure.cosmos.GatewayConnectionConfig)"
fullName: "com.azure.cosmos.CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)"
name: "directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)"
nameWithType: "CosmosClientBuilder.directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)"
summary: "Sets the DIRECT connection configuration to be used."
parameters:
- description: "direct connection configuration to be used"
name: "directConnectionConfig"
type: "<xref href=\"com.azure.cosmos.DirectConnectionConfig?alt=com.azure.cosmos.DirectConnectionConfig&text=DirectConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
- description: "gateway connection configuration to be used"
name: "gatewayConnectionConfig"
type: "<xref href=\"com.azure.cosmos.GatewayConnectionConfig?alt=com.azure.cosmos.GatewayConnectionConfig&text=GatewayConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig)"
desc: "Sets the DIRECT connection configuration to be used. gatewayConnectionConfig - represents basic configuration to be used for gateway client.\nEven in direct connection mode, some of the meta data operations go through gateway client,\nSetting gateway connection config in this API doesn't affect the connection mode, which will be Direct in this case."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.endpoint(java.lang.String)"
fullName: "com.azure.cosmos.CosmosClientBuilder.endpoint(String endpoint)"
name: "endpoint(String endpoint)"
nameWithType: "CosmosClientBuilder.endpoint(String endpoint)"
summary: "Sets the Azure Cosmos DB endpoint the SDK will connect to"
parameters:
- description: "the service endpoint"
name: "endpoint"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosClientBuilder endpoint(String endpoint)"
desc: "Sets the Azure Cosmos DB endpoint the SDK will connect to"
returns:
description: "current Builder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.endpointDiscoveryEnabled(boolean)"
fullName: "com.azure.cosmos.CosmosClientBuilder.endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)"
name: "endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)"
nameWithType: "CosmosClientBuilder.endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)"
summary: "Sets the flag to enable endpoint discovery for geo-replicated database accounts."
parameters:
- description: "true if EndpointDiscovery is enabled."
name: "endpointDiscoveryEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder endpointDiscoveryEnabled(boolean endpointDiscoveryEnabled)"
desc: "Sets the flag to enable endpoint discovery for geo-replicated database accounts.\n\nWhen EnableEndpointDiscovery is true, the SDK will automatically discover the current write and read regions to ensure requests are sent to the correct region based on the capability of the region and the user's preference.\n\nThe default value for this property is true indicating endpoint discovery is enabled."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.gatewayMode()"
fullName: "com.azure.cosmos.CosmosClientBuilder.gatewayMode()"
name: "gatewayMode()"
nameWithType: "CosmosClientBuilder.gatewayMode()"
summary: "Sets the default GATEWAY connection configuration to be used."
syntax: "public CosmosClientBuilder gatewayMode()"
desc: "Sets the default GATEWAY connection configuration to be used."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.gatewayMode(com.azure.cosmos.GatewayConnectionConfig)"
fullName: "com.azure.cosmos.CosmosClientBuilder.gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)"
name: "gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)"
nameWithType: "CosmosClientBuilder.gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)"
summary: "Sets the GATEWAY connection configuration to be used."
parameters:
- description: "gateway connection configuration"
name: "gatewayConnectionConfig"
type: "<xref href=\"com.azure.cosmos.GatewayConnectionConfig?alt=com.azure.cosmos.GatewayConnectionConfig&text=GatewayConnectionConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder gatewayMode(GatewayConnectionConfig gatewayConnectionConfig)"
desc: "Sets the GATEWAY connection configuration to be used."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.key(java.lang.String)"
fullName: "com.azure.cosmos.CosmosClientBuilder.key(String key)"
name: "key(String key)"
nameWithType: "CosmosClientBuilder.key(String key)"
summary: "Sets either a master or readonly key used to perform authentication for accessing resource."
parameters:
- description: "master or readonly key"
name: "key"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosClientBuilder key(String key)"
desc: "Sets either a master or readonly key used to perform authentication for accessing resource."
returns:
description: "current Builder."
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.multipleWriteRegionsEnabled(boolean)"
fullName: "com.azure.cosmos.CosmosClientBuilder.multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)"
name: "multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)"
nameWithType: "CosmosClientBuilder.multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)"
summary: "Sets the flag to enable writes on any regions for geo-replicated database accounts in the Azure Cosmos DB service."
parameters:
- description: "flag to enable writes on any regions for geo-replicated\n database accounts."
name: "multipleWriteRegionsEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder multipleWriteRegionsEnabled(boolean multipleWriteRegionsEnabled)"
desc: "Sets the flag to enable writes on any regions for geo-replicated database accounts in the Azure Cosmos DB service.\n\nWhen the value of this property is true, the SDK will direct write operations to available writable regions of geo-replicated database account. Writable regions are ordered by PreferredRegions property. Setting the property value to true has no effect until EnableMultipleWriteRegions in DatabaseAccount is also set to true.\n\nDEFAULT value is true indicating that writes are directed to available writable regions of geo-replicated database account."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.openConnectionsAndInitCaches(com.azure.cosmos.CosmosContainerProactiveInitConfig)"
fullName: "com.azure.cosmos.CosmosClientBuilder.openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)"
name: "openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)"
nameWithType: "CosmosClientBuilder.openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)"
summary: "Sets the <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig\"></xref> which enable warming up of caches and connections associated with containers obtained from <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getCosmosContainerIdentities()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getCosmosContainerIdentities()\"></xref> to replicas obtained from the first *k* preferred regions where *k* evaluates to <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getProactiveConnectionRegionsCount()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getProactiveConnectionRegionsCount()\"></xref>."
parameters:
- description: "which encapsulates a list of container identities and no of\n proactive connection regions"
name: "proactiveContainerInitConfig"
type: "<xref href=\"com.azure.cosmos.CosmosContainerProactiveInitConfig?alt=com.azure.cosmos.CosmosContainerProactiveInitConfig&text=CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder openConnectionsAndInitCaches(CosmosContainerProactiveInitConfig proactiveContainerInitConfig)"
desc: "Sets the <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig\"></xref> which enable warming up of caches and connections associated with containers obtained from <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getCosmosContainerIdentities()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getCosmosContainerIdentities()\"></xref> to replicas obtained from the first *k* preferred regions where *k* evaluates to <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig.getProactiveConnectionRegionsCount()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig#getProactiveConnectionRegionsCount()\"></xref>.\n\nUse the <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfigBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfigBuilder\"></xref> class to instantiate <xref uid=\"com.azure.cosmos.CosmosContainerProactiveInitConfig\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosContainerProactiveInitConfig\"></xref> class"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.permissions(java.util.List<com.azure.cosmos.models.CosmosPermissionProperties>)"
fullName: "com.azure.cosmos.CosmosClientBuilder.permissions(List<CosmosPermissionProperties> permissions)"
name: "permissions(List<CosmosPermissionProperties> permissions)"
nameWithType: "CosmosClientBuilder.permissions(List<CosmosPermissionProperties> permissions)"
summary: "Sets the permission list, which contains the resource tokens needed to access resources."
parameters:
- description: "Permission list for authentication."
name: "permissions"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a>&lt;<xref href=\"com.azure.cosmos.models.CosmosPermissionProperties?alt=com.azure.cosmos.models.CosmosPermissionProperties&text=CosmosPermissionProperties\" data-throw-if-not-resolved=\"False\" />&gt;"
syntax: "public CosmosClientBuilder permissions(List<CosmosPermissionProperties> permissions)"
desc: "Sets the permission list, which contains the resource tokens needed to access resources."
returns:
description: "current Builder."
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.preferredRegions(java.util.List<java.lang.String>)"
fullName: "com.azure.cosmos.CosmosClientBuilder.preferredRegions(List<String> preferredRegions)"
name: "preferredRegions(List<String> preferredRegions)"
nameWithType: "CosmosClientBuilder.preferredRegions(List<String> preferredRegions)"
summary: "Sets the preferred regions for geo-replicated database accounts."
parameters:
- description: "the list of preferred regions."
name: "preferredRegions"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>&gt;"
syntax: "public CosmosClientBuilder preferredRegions(List<String> preferredRegions)"
desc: "Sets the preferred regions for geo-replicated database accounts. For example, \"East US\" as the preferred region.\n\nWhen EnableEndpointDiscovery is true and PreferredRegions is non-empty, the SDK will prefer to use the regions in the container in the order they are specified to perform operations.\n\nIf EnableEndpointDiscovery is set to false, this property is ignored."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.readRequestsFallbackEnabled(boolean)"
fullName: "com.azure.cosmos.CosmosClientBuilder.readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)"
name: "readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)"
nameWithType: "CosmosClientBuilder.readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)"
summary: "Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service."
parameters:
- description: "flag to enable reads to go to multiple regions configured on an account of\n Azure Cosmos DB service."
name: "readRequestsFallbackEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder readRequestsFallbackEnabled(boolean readRequestsFallbackEnabled)"
desc: "Sets whether to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.\n\nDEFAULT value is true.\n\nIf this property is not set, the default is true for all Consistency Levels other than Bounded Staleness, The default is false for Bounded Staleness. 1. <xref uid=\"com.azure.cosmos.CosmosClientBuilder.endpointDiscoveryEnabled*\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#endpointDiscoveryEnabled\"></xref> is true 2. the Azure Cosmos DB account has more than one region"
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.resourceToken(java.lang.String)"
fullName: "com.azure.cosmos.CosmosClientBuilder.resourceToken(String resourceToken)"
name: "resourceToken(String resourceToken)"
nameWithType: "CosmosClientBuilder.resourceToken(String resourceToken)"
summary: "Sets a resource token used to perform authentication for accessing resource."
parameters:
- description: "resourceToken for authentication"
name: "resourceToken"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosClientBuilder resourceToken(String resourceToken)"
desc: "Sets a resource token used to perform authentication for accessing resource."
returns:
description: "current Builder."
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.sessionCapturingOverrideEnabled(boolean)"
fullName: "com.azure.cosmos.CosmosClientBuilder.sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)"
name: "sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)"
nameWithType: "CosmosClientBuilder.sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)"
summary: "Session capturing is enabled by default for <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref>."
parameters:
- description: "session capturing override"
name: "sessionCapturingOverrideEnabled"
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder sessionCapturingOverrideEnabled(boolean sessionCapturingOverrideEnabled)"
desc: "Session capturing is enabled by default for <xref uid=\"com.azure.cosmos.ConsistencyLevel.SESSION\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ConsistencyLevel#SESSION\"></xref>. For other consistency levels, it is not needed, unless if you need occasionally send requests with Session Consistency while the client is not configured in session.\n\nenabling Session capturing for Session mode has no effect."
returns:
description: "current cosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.throttlingRetryOptions(com.azure.cosmos.ThrottlingRetryOptions)"
fullName: "com.azure.cosmos.CosmosClientBuilder.throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)"
name: "throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)"
nameWithType: "CosmosClientBuilder.throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)"
summary: "Sets the retry policy options associated with the Document<wbr>Client instance."
parameters:
- description: "the RetryOptions instance."
name: "throttlingRetryOptions"
type: "<xref href=\"com.azure.cosmos.ThrottlingRetryOptions?alt=com.azure.cosmos.ThrottlingRetryOptions&text=ThrottlingRetryOptions\" data-throw-if-not-resolved=\"False\" />"
syntax: "public CosmosClientBuilder throttlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions)"
desc: "Sets the retry policy options associated with the DocumentClient instance.\n\nProperties in the RetryOptions class allow application to customize the built-in retry policies. This property is optional. When it's not set, the SDK uses the default values for configuring the retry policies. See RetryOptions class for more details."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.cosmos.CosmosClientBuilder.userAgentSuffix(java.lang.String)"
fullName: "com.azure.cosmos.CosmosClientBuilder.userAgentSuffix(String userAgentSuffix)"
name: "userAgentSuffix(String userAgentSuffix)"
nameWithType: "CosmosClientBuilder.userAgentSuffix(String userAgentSuffix)"
summary: "sets the value of the user-agent suffix."
parameters:
- description: "The value to be appended to the user-agent header, this is\n used for monitoring purposes."
name: "userAgentSuffix"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public CosmosClientBuilder userAgentSuffix(String userAgentSuffix)"
desc: "sets the value of the user-agent suffix."
returns:
description: "current CosmosClientBuilder"
type: "<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />"
type: "class"
desc: "Helper class to build CosmosAsyncClient <xref uid=\"com.azure.cosmos.CosmosAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosAsyncClient\"></xref> and CosmosClient <xref uid=\"com.azure.cosmos.CosmosClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CosmosClient\"></xref> instances as logical representation of the Azure Cosmos database service.\n\nWhen building client, endpoint() and key() are mandatory APIs, without these the initialization will fail.\n\nThough consistencyLevel is not mandatory, but we strongly suggest to pay attention to this API when building client. By default, account consistency level is used if none is provided.\n\nBy default, direct connection mode is used if none specified.\n\n```java\nBuilding Cosmos Async Client minimal APIs (without any customized configurations)\n \n CosmosAsyncClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .buildAsyncClient();\n```\n\n```java\nBuilding Cosmos Async Client with customizations\n \n CosmosAsyncClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .directMode(directConnectionConfig, gatewayConnectionConfig)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .contentResponseOnWriteEnabled(true)\n .userAgentSuffix(\"my-application1-client\")\n .preferredRegions(Collections.singletonList(\"West US\", \"East US\"))\n .buildAsyncClient();\n```\n\n```java\nBuilding Cosmos Sync Client minimal APIs (without any customized configurations)\n \n CosmosClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .buildClient();\n```\n\n```java\nBuilding Cosmos Sync Client with customizations\n \n CosmosClient client = new CosmosClientBuilder()\n .endpoint(serviceEndpoint)\n .key(key)\n .directMode(directConnectionConfig, gatewayConnectionConfig)\n .consistencyLevel(ConsistencyLevel.SESSION)\n .connectionSharingAcrossClientsEnabled(true)\n .contentResponseOnWriteEnabled(true)\n .userAgentSuffix(\"my-application1-client\")\n .preferredRegions(Collections.singletonList(\"West US\", \"East US\"))\n .buildClient();\n```"
implements:
- "<xref href=\"com.azure.core.client.traits.AzureKeyCredentialTrait?alt=com.azure.core.client.traits.AzureKeyCredentialTrait&text=AzureKeyCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
- "<xref href=\"com.azure.core.client.traits.EndpointTrait?alt=com.azure.core.client.traits.EndpointTrait&text=EndpointTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
- "<xref href=\"com.azure.core.client.traits.TokenCredentialTrait?alt=com.azure.core.client.traits.TokenCredentialTrait&text=TokenCredentialTrait\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.cosmos.CosmosClientBuilder?alt=com.azure.cosmos.CosmosClientBuilder&text=CosmosClientBuilder\" data-throw-if-not-resolved=\"False\" />&gt;"
metadata: {}
package: "com.azure.cosmos"
artifact: com.azure:azure-cosmos:4.43.0