11# Client Library Endpoint
22Google Client libraries will automatically resolve an endpoint to connect to Google Cloud services.
3- The default resolved endpoint will be to Google servers (i.e. ` https://{serviceName} .googleapis.com:443 ` ).
3+ The default resolved endpoint will be to Google servers (i.e. ` https://speech .googleapis.com:443 ` ).
44
55## Anatomy of an Endpoint
66Using the default Java-Speech endpoint as an example: ` https://speech.googleapis.com:443 ` :
@@ -9,23 +9,23 @@ Using the default Java-Speech endpoint as an example: `https://speech.googleapis
99| ---------- | -------------- | ----------------- | ------ |
1010| https:// | speech | googleapis.com | 443 |
1111
12- Default values for client libraries:
12+ Default values for Java SDK Client libraries:
1313- Scheme: https://
1414- [ Universe Domain] ( universe_domain.md ) : googleapis.com
1515- Port: 443
1616
17- Service Name doesn't have a default value. This is different for each cloud service.
17+ Note: Service Name does not have a default value and is different for each cloud service.
1818
1919## Configuring a Specific Endpoint
2020There are two ways to configure the endpoint in Java Client Libraries: ServiceSettings and
2121TransportChannelProvider.
2222
23- ### Set through the generated {Service}Settings
23+ ### (Recommended) Set through the generated {Service}Settings
2424The following example is using Java-KMS v2.42.0 as an example:
2525
26261 . Set the endpoint in {Service}Settings.Builder and create the Settings object
2727``` java
28- String endpoint = " settingsendpoint .com" ;
28+ String endpoint = " settingsEndpoint .com" ;
2929KeyManagementServiceSettings keyManagementServiceSettings =
3030 KeyManagementServiceSettings . newBuilder()
3131 .setEndpoint(endpoint)
@@ -35,17 +35,17 @@ KeyManagementServiceSettings keyManagementServiceSettings =
3535``` java
3636try (KeyManagementServiceClient keyManagementServiceClient =
3737 KeyManagementServiceClient . create(keyManagementServiceSettings)) {
38+ ...
39+ }
3840```
39- The endpoint will be resolved to `settingsendpoint. com`.
40-
41- Note : This is the recommend way to set the endpoint.
41+ The endpoint will be resolved to ` settingsEndpoint.com ` .
4242
4343### Set through the Instantiating{Transport}ChannelProvider
4444The following example is using Java-KMS v2.42.0 as an example:
4545
46461 . Create the transport specific TransportChannelProvider
4747``` java
48- String endpoint = " transportendpoint .com" ;
48+ String endpoint = " transportEndpoint .com" ;
4949InstantiatingGrpcChannelProvider instantiatingGrpcChannelProvider =
5050 InstantiatingGrpcChannelProvider . newBuilder()
5151 .setEndpoint(endpoint)
@@ -63,10 +63,12 @@ KeyManagementServiceSettings keyManagementServiceSettings =
6363``` java
6464try (KeyManagementServiceClient keyManagementServiceClient =
6565 KeyManagementServiceClient . create(keyManagementServiceSettings)) {
66+ ...
67+ }
6668```
67- The endpoint will be resolved to `transportendpoint . com`.
69+ The endpoint will be resolved to ` transportEndpoint .com` .
6870
69- ### Set through both ways
71+ ### Set through ServiceSettings and TransportChannelProvider
7072If you are setting an endpoint via both methods above, like:
7173``` java
7274String endpoint1 = " transportEndpoint.com" ;
@@ -83,25 +85,31 @@ KeyManagementServiceSettings keyManagementServiceSettings =
8385 .setTransportChannelProvider(instantiatingGrpcChannelProvider)
8486 .build();
8587```
86- The endpoint will be resolved to `transportendpoint . com`.
88+ The endpoint will be resolved to ` transportEndpoint .com` .
8789
8890### Endpoint Hierarchy
89911 . If set in the TransportChannelProvider, use this value. Otherwise, go to the next step.
90922 . If set via the ClientSettings, use this value. Otherwise, go to the next step.
91933 . Use the default endpoint (i.e. ` https://{serviceName}.googleapis.com:443 ` )
9294
93- ### How can I confirm the endpoint the library is using
95+ #### How can I check which endpoint the client library is using
9496Assuming you have configured a custom endpoint, like:
9597``` java
9698String endpoint = " ..." ;
9799KeyManagementServiceSettings keyManagementServiceSettings =
98100 KeyManagementServiceSettings . newBuilder()
99101 .setEndpoint(endpoint)
100102 .build();
103+ try (KeyManagementServiceClient keyManagementServiceClient =
104+ KeyManagementServiceClient . create(keyManagementServiceSettings)) {
105+ ...
106+ }
101107```
102108
103- You can retrieve the endpoint from the Setting ' s `getEndpoint()` method. This will return
104- the resolved endpoint back.
109+ Retrieve the resolved endpoint from the Setting's ` getEndpoint() ` method
110+ ``` java
111+ keyManagementServiceClient. getSettings(). getEndpoint();
112+ ```
105113
106114## When should I specify my custom endpoint
107115There are a few use cases:
0 commit comments