Class ConnectionServiceClient (2.12.0)
Stay organized with collections
Save and categorize content based on your preferences.
- 2.82.0 (latest)
- 2.80.0
- 2.78.0
- 2.77.0
- 2.76.0
- 2.75.0
- 2.74.0
- 2.72.0
- 2.70.0
- 2.69.0
- 2.66.0
- 2.65.0
- 2.64.0
- 2.62.0
- 2.61.0
- 2.60.0
- 2.59.0
- 2.58.0
- 2.57.0
- 2.56.0
- 2.55.0
- 2.54.0
- 2.53.0
- 2.51.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.26.0
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.6
- 2.4.0
- 2.2.4
- 2.1.11
publicclass ConnectionServiceClientimplementsBackgroundResourceService Description: Manages external data source connections and credentials.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
Connectionconnection=Connection.newBuilder().build();
StringconnectionId="connectionId1923106969";
Connectionresponse=
connectionServiceClient.createConnection(parent,connection,connectionId);
}
Note: close() needs to be called on the ConnectionServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ConnectionServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ConnectionServiceSettingsconnectionServiceSettings=
ConnectionServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ConnectionServiceClientconnectionServiceClient=
ConnectionServiceClient.create(connectionServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ConnectionServiceSettingsconnectionServiceSettings=
ConnectionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ConnectionServiceClientconnectionServiceClient=
ConnectionServiceClient.create(connectionServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ConnectionServiceSettingsconnectionServiceSettings=
ConnectionServiceSettings.newHttpJsonBuilder().build();
ConnectionServiceClientconnectionServiceClient=
ConnectionServiceClient.create(connectionServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceInherited Members
Static Methods
create()
publicstaticfinalConnectionServiceClientcreate()Constructs an instance of ConnectionServiceClient with default settings.
create(ConnectionServiceSettings settings)
publicstaticfinalConnectionServiceClientcreate(ConnectionServiceSettingssettings)Constructs an instance of ConnectionServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
create(ConnectionServiceStub stub)
publicstaticfinalConnectionServiceClientcreate(ConnectionServiceStubstub)Constructs an instance of ConnectionServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ConnectionServiceSettings).
Constructors
ConnectionServiceClient(ConnectionServiceSettings settings)
protectedConnectionServiceClient(ConnectionServiceSettingssettings)Constructs an instance of ConnectionServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
ConnectionServiceClient(ConnectionServiceStub stub)
protectedConnectionServiceClient(ConnectionServiceStubstub)Methods
awaitTermination(long duration, TimeUnit unit)
publicbooleanawaitTermination(longduration,TimeUnitunit)close()
publicfinalvoidclose()createConnection(CreateConnectionRequest request)
publicfinalConnectioncreateConnection(CreateConnectionRequestrequest)Creates a new connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
CreateConnectionRequestrequest=
CreateConnectionRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setConnectionId("connectionId1923106969")
.setConnection(Connection.newBuilder().build())
.build();
Connectionresponse=connectionServiceClient.createConnection(request);
}
request
CreateConnectionRequest The request object containing all of the parameters for the API call.
createConnection(LocationName parent, Connection connection, String connectionId)
publicfinalConnectioncreateConnection(LocationNameparent,Connectionconnection,StringconnectionId)Creates a new connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
Connectionconnection=Connection.newBuilder().build();
StringconnectionId="connectionId1923106969";
Connectionresponse=
connectionServiceClient.createConnection(parent,connection,connectionId);
}
parent
LocationName Required. Parent resource name. Must be in the format
projects/{project_id}/locations/{location_id}
createConnection(String parent, Connection connection, String connectionId)
publicfinalConnectioncreateConnection(Stringparent,Connectionconnection,StringconnectionId)Creates a new connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
Connectionconnection=Connection.newBuilder().build();
StringconnectionId="connectionId1923106969";
Connectionresponse=
connectionServiceClient.createConnection(parent,connection,connectionId);
}
parent
String Required. Parent resource name. Must be in the format
projects/{project_id}/locations/{location_id}
createConnectionCallable()
publicfinalUnaryCallable<CreateConnectionRequest,Connection>createConnectionCallable()Creates a new connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
CreateConnectionRequestrequest=
CreateConnectionRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setConnectionId("connectionId1923106969")
.setConnection(Connection.newBuilder().build())
.build();
ApiFuture<Connection>future=
connectionServiceClient.createConnectionCallable().futureCall(request);
// Do something.
Connectionresponse=future.get();
}
deleteConnection(ConnectionName name)
publicfinalvoiddeleteConnection(ConnectionNamename)Deletes connection and associated credential.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ConnectionNamename=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]");
connectionServiceClient.deleteConnection(name);
}
name
ConnectionName Required. Name of the deleted connection, for example:
projects/{project_id}/locations/{location_id}/connections/{connection_id}
deleteConnection(DeleteConnectionRequest request)
publicfinalvoiddeleteConnection(DeleteConnectionRequestrequest)Deletes connection and associated credential.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
DeleteConnectionRequestrequest=
DeleteConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.build();
connectionServiceClient.deleteConnection(request);
}
request
DeleteConnectionRequest The request object containing all of the parameters for the API call.
deleteConnection(String name)
publicfinalvoiddeleteConnection(Stringname)Deletes connection and associated credential.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringname=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString();
connectionServiceClient.deleteConnection(name);
}
name
String Required. Name of the deleted connection, for example:
projects/{project_id}/locations/{location_id}/connections/{connection_id}
deleteConnectionCallable()
publicfinalUnaryCallable<DeleteConnectionRequest,Empty>deleteConnectionCallable()Deletes connection and associated credential.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
DeleteConnectionRequestrequest=
DeleteConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.build();
ApiFuture<Empty>future=
connectionServiceClient.deleteConnectionCallable().futureCall(request);
// Do something.
future.get();
}
getConnection(ConnectionName name)
publicfinalConnectiongetConnection(ConnectionNamename)Returns specified connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ConnectionNamename=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]");
Connectionresponse=connectionServiceClient.getConnection(name);
}
name
ConnectionName Required. Name of the requested connection, for example:
projects/{project_id}/locations/{location_id}/connections/{connection_id}
getConnection(GetConnectionRequest request)
publicfinalConnectiongetConnection(GetConnectionRequestrequest)Returns specified connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
GetConnectionRequestrequest=
GetConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.build();
Connectionresponse=connectionServiceClient.getConnection(request);
}
getConnection(String name)
publicfinalConnectiongetConnection(Stringname)Returns specified connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringname=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString();
Connectionresponse=connectionServiceClient.getConnection(name);
}
name
String Required. Name of the requested connection, for example:
projects/{project_id}/locations/{location_id}/connections/{connection_id}
getConnectionCallable()
publicfinalUnaryCallable<GetConnectionRequest,Connection>getConnectionCallable()Returns specified connection.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
GetConnectionRequestrequest=
GetConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.build();
ApiFuture<Connection>future=
connectionServiceClient.getConnectionCallable().futureCall(request);
// Do something.
Connectionresponse=future.get();
}
getIamPolicy(ResourceName resource, GetPolicyOptions options)
publicfinalPolicygetIamPolicy(ResourceNameresource,GetPolicyOptionsoptions)Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ResourceNameresource=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]");
GetPolicyOptionsoptions=GetPolicyOptions.newBuilder().build();
Policyresponse=connectionServiceClient.getIamPolicy(resource,options);
}
resource
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
options
com.google.iam.v1.GetPolicyOptionsOPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.
com.google.iam.v1.Policy
getIamPolicy(GetIamPolicyRequest request)
publicfinalPolicygetIamPolicy(GetIamPolicyRequestrequest)Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policyresponse=connectionServiceClient.getIamPolicy(request);
}
request
com.google.iam.v1.GetIamPolicyRequestThe request object containing all of the parameters for the API call.
com.google.iam.v1.Policy
getIamPolicy(String resource, GetPolicyOptions options)
publicfinalPolicygetIamPolicy(Stringresource,GetPolicyOptionsoptions)Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringresource=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString();
GetPolicyOptionsoptions=GetPolicyOptions.newBuilder().build();
Policyresponse=connectionServiceClient.getIamPolicy(resource,options);
}
resource
String REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
options
com.google.iam.v1.GetPolicyOptionsOPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.
com.google.iam.v1.Policy
getIamPolicyCallable()
publicfinalUnaryCallable<GetIamPolicyRequest,Policy>getIamPolicyCallable()Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy>future=connectionServiceClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>
getSettings()
publicfinalConnectionServiceSettingsgetSettings()getStub()
publicConnectionServiceStubgetStub()isShutdown()
publicbooleanisShutdown()isTerminated()
publicbooleanisTerminated()listConnections(ListConnectionsRequest request)
publicfinalConnectionServiceClient.ListConnectionsPagedResponselistConnections(ListConnectionsRequestrequest)Returns a list of connections in the given project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ListConnectionsRequestrequest=
ListConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Connectionelement:connectionServiceClient.listConnections(request).iterateAll()){
// doThingsWith(element);
}
}
request
ListConnectionsRequest The request object containing all of the parameters for the API call.
listConnections(LocationName parent)
publicfinalConnectionServiceClient.ListConnectionsPagedResponselistConnections(LocationNameparent)Returns a list of connections in the given project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
for(Connectionelement:connectionServiceClient.listConnections(parent).iterateAll()){
// doThingsWith(element);
}
}
parent
LocationName Required. Parent resource name. Must be in the form:
projects/{project_id}/locations/{location_id}
listConnections(String parent)
publicfinalConnectionServiceClient.ListConnectionsPagedResponselistConnections(Stringparent)Returns a list of connections in the given project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
for(Connectionelement:connectionServiceClient.listConnections(parent).iterateAll()){
// doThingsWith(element);
}
}
parent
String Required. Parent resource name. Must be in the form:
projects/{project_id}/locations/{location_id}
listConnectionsCallable()
publicfinalUnaryCallable<ListConnectionsRequest,ListConnectionsResponse>listConnectionsCallable()Returns a list of connections in the given project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ListConnectionsRequestrequest=
ListConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListConnectionsResponseresponse=
connectionServiceClient.listConnectionsCallable().call(request);
for(Connectionelement:response.getConnectionsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
listConnectionsPagedCallable()
publicfinalUnaryCallable<ListConnectionsRequest,ConnectionServiceClient.ListConnectionsPagedResponse>listConnectionsPagedCallable()Returns a list of connections in the given project.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ListConnectionsRequestrequest=
ListConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Connection>future=
connectionServiceClient.listConnectionsPagedCallable().futureCall(request);
// Do something.
for(Connectionelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
setIamPolicy(ResourceName resource, Policy policy)
publicfinalPolicysetIamPolicy(ResourceNameresource,Policypolicy)Sets the access control policy on the specified resource. Replaces any existing policy.
Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ResourceNameresource=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]");
Policypolicy=Policy.newBuilder().build();
Policyresponse=connectionServiceClient.setIamPolicy(resource,policy);
}
resource
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
policy
com.google.iam.v1.PolicyREQUIRED: The complete policy to be applied to the resource. The size of the
policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
Platform services (such as Projects) might reject them.
com.google.iam.v1.Policy
setIamPolicy(SetIamPolicyRequest request)
publicfinalPolicysetIamPolicy(SetIamPolicyRequestrequest)Sets the access control policy on the specified resource. Replaces any existing policy.
Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policyresponse=connectionServiceClient.setIamPolicy(request);
}
request
com.google.iam.v1.SetIamPolicyRequestThe request object containing all of the parameters for the API call.
com.google.iam.v1.Policy
setIamPolicy(String resource, Policy policy)
publicfinalPolicysetIamPolicy(Stringresource,Policypolicy)Sets the access control policy on the specified resource. Replaces any existing policy.
Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringresource=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString();
Policypolicy=Policy.newBuilder().build();
Policyresponse=connectionServiceClient.setIamPolicy(resource,policy);
}
resource
String REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
policy
com.google.iam.v1.PolicyREQUIRED: The complete policy to be applied to the resource. The size of the
policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
Platform services (such as Projects) might reject them.
com.google.iam.v1.Policy
setIamPolicyCallable()
publicfinalUnaryCallable<SetIamPolicyRequest,Policy>setIamPolicyCallable()Sets the access control policy on the specified resource. Replaces any existing policy.
Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy>future=connectionServiceClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>
shutdown()
publicvoidshutdown()shutdownNow()
publicvoidshutdownNow()testIamPermissions(ResourceName resource, List<String> permissions)
publicfinalTestIamPermissionsResponsetestIamPermissions(ResourceNameresource,List<String>permissions)Returns permissions that a caller has on the specified resource. If the resource does not
exist, this will return an empty set of permissions, not a NOT_FOUND error.
Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ResourceNameresource=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]");
List<String>permissions=newArrayList<>();
TestIamPermissionsResponseresponse=
connectionServiceClient.testIamPermissions(resource,permissions);
}
resource
com.google.api.resourcenames.ResourceNameREQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
permissions
List<String>The set of permissions to check for the resource. Permissions with
wildcards (such as '*' or 'storage.*') are not allowed. For more information see
IAM Overview.
com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(TestIamPermissionsRequest request)
publicfinalTestIamPermissionsResponsetestIamPermissions(TestIamPermissionsRequestrequest)Returns permissions that a caller has on the specified resource. If the resource does not
exist, this will return an empty set of permissions, not a NOT_FOUND error.
Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.addAllPermissions(newArrayList<String>())
.build();
TestIamPermissionsResponseresponse=connectionServiceClient.testIamPermissions(request);
}
request
com.google.iam.v1.TestIamPermissionsRequestThe request object containing all of the parameters for the API call.
com.google.iam.v1.TestIamPermissionsResponse
testIamPermissions(String resource, List<String> permissions)
publicfinalTestIamPermissionsResponsetestIamPermissions(Stringresource,List<String>permissions)Returns permissions that a caller has on the specified resource. If the resource does not
exist, this will return an empty set of permissions, not a NOT_FOUND error.
Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringresource=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString();
List<String>permissions=newArrayList<>();
TestIamPermissionsResponseresponse=
connectionServiceClient.testIamPermissions(resource,permissions);
}
resource
String REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
permissions
List<String>The set of permissions to check for the resource. Permissions with
wildcards (such as '*' or 'storage.*') are not allowed. For more information see
IAM Overview.
com.google.iam.v1.TestIamPermissionsResponse
testIamPermissionsCallable()
publicfinalUnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse>testIamPermissionsCallable()Returns permissions that a caller has on the specified resource. If the resource does not
exist, this will return an empty set of permissions, not a NOT_FOUND error.
Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.addAllPermissions(newArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse>future=
connectionServiceClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponseresponse=future.get();
}
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>
updateConnection(ConnectionName name, Connection connection, FieldMask updateMask)
publicfinalConnectionupdateConnection(ConnectionNamename,Connectionconnection,FieldMaskupdateMask)Updates the specified connection. For security reasons, also resets credential if connection properties are in the update field mask.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
ConnectionNamename=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]");
Connectionconnection=Connection.newBuilder().build();
FieldMaskupdateMask=FieldMask.newBuilder().build();
Connectionresponse=connectionServiceClient.updateConnection(name,connection,updateMask);
}
name
ConnectionName Required. Name of the connection to update, for example:
projects/{project_id}/locations/{location_id}/connections/{connection_id}
updateConnection(UpdateConnectionRequest request)
publicfinalConnectionupdateConnection(UpdateConnectionRequestrequest)Updates the specified connection. For security reasons, also resets credential if connection properties are in the update field mask.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
UpdateConnectionRequestrequest=
UpdateConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.setConnection(Connection.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Connectionresponse=connectionServiceClient.updateConnection(request);
}
request
UpdateConnectionRequest The request object containing all of the parameters for the API call.
updateConnection(String name, Connection connection, FieldMask updateMask)
publicfinalConnectionupdateConnection(Stringname,Connectionconnection,FieldMaskupdateMask)Updates the specified connection. For security reasons, also resets credential if connection properties are in the update field mask.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
Stringname=ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString();
Connectionconnection=Connection.newBuilder().build();
FieldMaskupdateMask=FieldMask.newBuilder().build();
Connectionresponse=connectionServiceClient.updateConnection(name,connection,updateMask);
}
name
String Required. Name of the connection to update, for example:
projects/{project_id}/locations/{location_id}/connections/{connection_id}
updateConnectionCallable()
publicfinalUnaryCallable<UpdateConnectionRequest,Connection>updateConnectionCallable()Updates the specified connection. For security reasons, also resets credential if connection properties are in the update field mask.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ConnectionServiceClientconnectionServiceClient=ConnectionServiceClient.create()){
UpdateConnectionRequestrequest=
UpdateConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]","[LOCATION]","[CONNECTION]").toString())
.setConnection(Connection.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Connection>future=
connectionServiceClient.updateConnectionCallable().futureCall(request);
// Do something.
Connectionresponse=future.get();
}