@BetaApi @Generated(value="by gapic-generator-java") public class ConnectionServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ConnectionProto.Connection connection = ConnectionProto.Connection.newBuilder().build();
String connectionId = "connectionId1923106969";
ConnectionProto.Connection response =
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:
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
ConnectionServiceSettings connectionServiceSettings =
ConnectionServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ConnectionServiceClient connectionServiceClient =
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
ConnectionServiceSettings connectionServiceSettings =
ConnectionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ConnectionServiceClient connectionServiceClient =
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
ConnectionServiceSettings connectionServiceSettings =
ConnectionServiceSettings.newHttpJsonBuilder().build();
ConnectionServiceClient connectionServiceClient =
ConnectionServiceClient.create(connectionServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier | Constructor and Description |
|---|---|
protected |
ConnectionServiceClient(ConnectionServiceSettings settings)
Constructs an instance of ConnectionServiceClient, using the given settings.
|
protected |
ConnectionServiceClient(ConnectionServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ConnectionServiceClient |
create()
Constructs an instance of ConnectionServiceClient with default settings.
|
static ConnectionServiceClient |
create(ConnectionServiceSettings settings)
Constructs an instance of ConnectionServiceClient, using the given settings.
|
static ConnectionServiceClient |
create(ConnectionServiceStub stub)
Constructs an instance of ConnectionServiceClient, using the given stub for making calls.
|
ConnectionProto.Connection |
createConnection(ConnectionProto.CreateConnectionRequest request)
Creates a new connection.
|
ConnectionProto.Connection |
createConnection(LocationName parent,
ConnectionProto.Connection connection,
String connectionId)
Creates a new connection.
|
ConnectionProto.Connection |
createConnection(String parent,
ConnectionProto.Connection connection,
String connectionId)
Creates a new connection.
|
com.google.api.gax.rpc.UnaryCallable<ConnectionProto.CreateConnectionRequest,ConnectionProto.Connection> |
createConnectionCallable()
Creates a new connection.
|
void |
deleteConnection(ConnectionName name)
Deletes connection and associated credential.
|
void |
deleteConnection(ConnectionProto.DeleteConnectionRequest request)
Deletes connection and associated credential.
|
void |
deleteConnection(String name)
Deletes connection and associated credential.
|
com.google.api.gax.rpc.UnaryCallable<ConnectionProto.DeleteConnectionRequest,com.google.protobuf.Empty> |
deleteConnectionCallable()
Deletes connection and associated credential.
|
ConnectionProto.Connection |
getConnection(ConnectionName name)
Returns specified connection.
|
ConnectionProto.Connection |
getConnection(ConnectionProto.GetConnectionRequest request)
Returns specified connection.
|
ConnectionProto.Connection |
getConnection(String name)
Returns specified connection.
|
com.google.api.gax.rpc.UnaryCallable<ConnectionProto.GetConnectionRequest,ConnectionProto.Connection> |
getConnectionCallable()
Returns specified connection.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a resource.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.api.resourcenames.ResourceName resource,
com.google.iam.v1.GetPolicyOptions options)
Gets the access control policy for a resource.
|
com.google.iam.v1.Policy |
getIamPolicy(String resource,
com.google.iam.v1.GetPolicyOptions options)
Gets the access control policy for a resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for a resource.
|
ConnectionServiceSettings |
getSettings() |
ConnectionServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ConnectionProto.ListConnectionsResponse |
listConnections(ConnectionProto.ListConnectionsRequest request)
Returns a list of connections in the given project.
|
ConnectionProto.ListConnectionsResponse |
listConnections(LocationName parent,
com.google.protobuf.UInt32Value maxResults)
Returns a list of connections in the given project.
|
ConnectionProto.ListConnectionsResponse |
listConnections(String parent,
com.google.protobuf.UInt32Value maxResults)
Returns a list of connections in the given project.
|
com.google.api.gax.rpc.UnaryCallable<ConnectionProto.ListConnectionsRequest,ConnectionProto.ListConnectionsResponse> |
listConnectionsCallable()
Returns a list of connections in the given project.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.api.resourcenames.ResourceName resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on the specified resource.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on the specified resource.
|
com.google.iam.v1.Policy |
setIamPolicy(String resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the access control policy on the specified resource.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.api.resourcenames.ResourceName resource,
List<String> permissions)
Returns permissions that a caller has on the specified resource.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(String resource,
List<String> permissions)
Returns permissions that a caller has on the specified resource.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.
|
ConnectionProto.Connection |
updateConnection(ConnectionName name,
ConnectionProto.Connection connection,
com.google.protobuf.FieldMask updateMask)
Updates the specified connection.
|
ConnectionProto.Connection |
updateConnection(ConnectionProto.UpdateConnectionRequest request)
Updates the specified connection.
|
ConnectionProto.Connection |
updateConnection(String name,
ConnectionProto.Connection connection,
com.google.protobuf.FieldMask updateMask)
Updates the specified connection.
|
com.google.api.gax.rpc.UnaryCallable<ConnectionProto.UpdateConnectionRequest,ConnectionProto.Connection> |
updateConnectionCallable()
Updates the specified connection.
|
void |
updateConnectionCredential(ConnectionProto.UpdateConnectionCredentialRequest request)
Sets the credential for the specified connection.
|
void |
updateConnectionCredential(String name,
ConnectionProto.ConnectionCredential credential)
Sets the credential for the specified connection.
|
com.google.api.gax.rpc.UnaryCallable<ConnectionProto.UpdateConnectionCredentialRequest,com.google.protobuf.Empty> |
updateConnectionCredentialCallable()
Sets the credential for the specified connection.
|
protected ConnectionServiceClient(ConnectionServiceSettings settings) throws IOException
IOExceptionprotected ConnectionServiceClient(ConnectionServiceStub stub)
public static final ConnectionServiceClient create() throws IOException
IOExceptionpublic static final ConnectionServiceClient create(ConnectionServiceSettings settings) throws IOException
IOExceptionpublic static final ConnectionServiceClient create(ConnectionServiceStub stub)
public final ConnectionServiceSettings getSettings()
public ConnectionServiceStub getStub()
public final ConnectionProto.Connection createConnection(LocationName parent, ConnectionProto.Connection connection, String connectionId)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ConnectionProto.Connection connection = ConnectionProto.Connection.newBuilder().build();
String connectionId = "connectionId1923106969";
ConnectionProto.Connection response =
connectionServiceClient.createConnection(parent, connection, connectionId);
}
parent - Required. Parent resource name. Must be in the format
`projects/{project_id}/locations/{location_id}`connection - Required. Connection to create.connectionId - Optional. Connection id that should be assigned to the created connection.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.Connection createConnection(String parent, ConnectionProto.Connection connection, String connectionId)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
ConnectionProto.Connection connection = ConnectionProto.Connection.newBuilder().build();
String connectionId = "connectionId1923106969";
ConnectionProto.Connection response =
connectionServiceClient.createConnection(parent, connection, connectionId);
}
parent - Required. Parent resource name. Must be in the format
`projects/{project_id}/locations/{location_id}`connection - Required. Connection to create.connectionId - Optional. Connection id that should be assigned to the created connection.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.Connection createConnection(ConnectionProto.CreateConnectionRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.CreateConnectionRequest request =
ConnectionProto.CreateConnectionRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setConnectionId("connectionId1923106969")
.setConnection(ConnectionProto.Connection.newBuilder().build())
.build();
ConnectionProto.Connection response = connectionServiceClient.createConnection(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ConnectionProto.CreateConnectionRequest,ConnectionProto.Connection> createConnectionCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.CreateConnectionRequest request =
ConnectionProto.CreateConnectionRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setConnectionId("connectionId1923106969")
.setConnection(ConnectionProto.Connection.newBuilder().build())
.build();
ApiFuture<ConnectionProto.Connection> future =
connectionServiceClient.createConnectionCallable().futureCall(request);
// Do something.
ConnectionProto.Connection response = future.get();
}
public final ConnectionProto.Connection getConnection(ConnectionName name)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
ConnectionProto.Connection response = connectionServiceClient.getConnection(name);
}
name - Required. Name of the requested connection, for example:
`projects/{project_id}/locations/{location_id}/connections/{connection_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.Connection getConnection(String name)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString();
ConnectionProto.Connection response = connectionServiceClient.getConnection(name);
}
name - Required. Name of the requested connection, for example:
`projects/{project_id}/locations/{location_id}/connections/{connection_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.Connection getConnection(ConnectionProto.GetConnectionRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.GetConnectionRequest request =
ConnectionProto.GetConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.build();
ConnectionProto.Connection response = connectionServiceClient.getConnection(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ConnectionProto.GetConnectionRequest,ConnectionProto.Connection> getConnectionCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.GetConnectionRequest request =
ConnectionProto.GetConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.build();
ApiFuture<ConnectionProto.Connection> future =
connectionServiceClient.getConnectionCallable().futureCall(request);
// Do something.
ConnectionProto.Connection response = future.get();
}
public final ConnectionProto.ListConnectionsResponse listConnections(LocationName parent, com.google.protobuf.UInt32Value maxResults)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
UInt32Value maxResults = UInt32Value.newBuilder().build();
ConnectionProto.ListConnectionsResponse response =
connectionServiceClient.listConnections(parent, maxResults);
}
parent - Required. Parent resource name. Must be in the form:
`projects/{project_id}/locations/{location_id}`maxResults - Required. Maximum number of results per page.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.ListConnectionsResponse listConnections(String parent, com.google.protobuf.UInt32Value maxResults)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
UInt32Value maxResults = UInt32Value.newBuilder().build();
ConnectionProto.ListConnectionsResponse response =
connectionServiceClient.listConnections(parent, maxResults);
}
parent - Required. Parent resource name. Must be in the form:
`projects/{project_id}/locations/{location_id}`maxResults - Required. Maximum number of results per page.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.ListConnectionsResponse listConnections(ConnectionProto.ListConnectionsRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.ListConnectionsRequest request =
ConnectionProto.ListConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setMaxResults(UInt32Value.newBuilder().build())
.setPageToken("pageToken873572522")
.build();
ConnectionProto.ListConnectionsResponse response =
connectionServiceClient.listConnections(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ConnectionProto.ListConnectionsRequest,ConnectionProto.ListConnectionsResponse> listConnectionsCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.ListConnectionsRequest request =
ConnectionProto.ListConnectionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setMaxResults(UInt32Value.newBuilder().build())
.setPageToken("pageToken873572522")
.build();
ApiFuture<ConnectionProto.ListConnectionsResponse> future =
connectionServiceClient.listConnectionsCallable().futureCall(request);
// Do something.
ConnectionProto.ListConnectionsResponse response = future.get();
}
public final ConnectionProto.Connection updateConnection(ConnectionName name, ConnectionProto.Connection connection, com.google.protobuf.FieldMask updateMask)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
ConnectionProto.Connection connection = ConnectionProto.Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
ConnectionProto.Connection response =
connectionServiceClient.updateConnection(name, connection, updateMask);
}
name - Required. Name of the connection to update, for example:
`projects/{project_id}/locations/{location_id}/connections/{connection_id}`connection - Required. Connection containing the updated fields.updateMask - Required. Update mask for the connection fields to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.Connection updateConnection(String name, ConnectionProto.Connection connection, com.google.protobuf.FieldMask updateMask)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString();
ConnectionProto.Connection connection = ConnectionProto.Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
ConnectionProto.Connection response =
connectionServiceClient.updateConnection(name, connection, updateMask);
}
name - Required. Name of the connection to update, for example:
`projects/{project_id}/locations/{location_id}/connections/{connection_id}`connection - Required. Connection containing the updated fields.updateMask - Required. Update mask for the connection fields to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionProto.Connection updateConnection(ConnectionProto.UpdateConnectionRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.UpdateConnectionRequest request =
ConnectionProto.UpdateConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.setConnection(ConnectionProto.Connection.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ConnectionProto.Connection response = connectionServiceClient.updateConnection(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ConnectionProto.UpdateConnectionRequest,ConnectionProto.Connection> updateConnectionCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.UpdateConnectionRequest request =
ConnectionProto.UpdateConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.setConnection(ConnectionProto.Connection.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<ConnectionProto.Connection> future =
connectionServiceClient.updateConnectionCallable().futureCall(request);
// Do something.
ConnectionProto.Connection response = future.get();
}
public final void updateConnectionCredential(String name, ConnectionProto.ConnectionCredential 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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String name = "name3373707";
ConnectionProto.ConnectionCredential credential =
ConnectionProto.ConnectionCredential.newBuilder().build();
connectionServiceClient.updateConnectionCredential(name, credential);
}
name - Required. Name of the connection, for example:
`projects/{project_id}/locations/{location_id}/connections/{connection_id}/credential`credential - Required. Credential to use with the connection.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void updateConnectionCredential(ConnectionProto.UpdateConnectionCredentialRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.UpdateConnectionCredentialRequest request =
ConnectionProto.UpdateConnectionCredentialRequest.newBuilder()
.setName("name3373707")
.setCredential(ConnectionProto.ConnectionCredential.newBuilder().build())
.build();
connectionServiceClient.updateConnectionCredential(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ConnectionProto.UpdateConnectionCredentialRequest,com.google.protobuf.Empty> updateConnectionCredentialCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.UpdateConnectionCredentialRequest request =
ConnectionProto.UpdateConnectionCredentialRequest.newBuilder()
.setName("name3373707")
.setCredential(ConnectionProto.ConnectionCredential.newBuilder().build())
.build();
ApiFuture<Empty> future =
connectionServiceClient.updateConnectionCredentialCallable().futureCall(request);
// Do something.
future.get();
}
public final void deleteConnection(ConnectionName name)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
connectionServiceClient.deleteConnection(name);
}
name - Required. Name of the deleted connection, for example:
`projects/{project_id}/locations/{location_id}/connections/{connection_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteConnection(String name)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString();
connectionServiceClient.deleteConnection(name);
}
name - Required. Name of the deleted connection, for example:
`projects/{project_id}/locations/{location_id}/connections/{connection_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteConnection(ConnectionProto.DeleteConnectionRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.DeleteConnectionRequest request =
ConnectionProto.DeleteConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.build();
connectionServiceClient.deleteConnection(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ConnectionProto.DeleteConnectionRequest,com.google.protobuf.Empty> deleteConnectionCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionProto.DeleteConnectionRequest request =
ConnectionProto.DeleteConnectionRequest.newBuilder()
.setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.build();
ApiFuture<Empty> future =
connectionServiceClient.deleteConnectionCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.api.resourcenames.ResourceName resource,
com.google.iam.v1.GetPolicyOptions options)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
Policy response = connectionServiceClient.getIamPolicy(resource, options);
}
resource - REQUIRED: The resource for which the policy is being requested. See the
operation documentation for the appropriate value for this field.options - OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(String resource, com.google.iam.v1.GetPolicyOptions options)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString();
GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
Policy response = connectionServiceClient.getIamPolicy(resource, options);
}
resource - REQUIRED: The resource for which the policy is being requested. See the
operation documentation for the appropriate value for this field.options - OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = connectionServiceClient.getIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = connectionServiceClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.api.resourcenames.ResourceName resource,
com.google.iam.v1.Policy 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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Policy policy = Policy.newBuilder().build();
Policy response = connectionServiceClient.setIamPolicy(resource, policy);
}
resource - REQUIRED: The resource for which the policy is being specified. See the
operation documentation for the appropriate value for this field.policy - REQUIRED: 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.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(String resource, com.google.iam.v1.Policy 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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString();
Policy policy = Policy.newBuilder().build();
Policy response = connectionServiceClient.setIamPolicy(resource, policy);
}
resource - REQUIRED: The resource for which the policy is being specified. See the
operation documentation for the appropriate value for this field.policy - REQUIRED: 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.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policy response = connectionServiceClient.setIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
SetIamPolicyRequest request =
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.
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.api.resourcenames.ResourceName resource,
List<String> permissions)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response =
connectionServiceClient.testIamPermissions(resource, permissions);
}
resource - REQUIRED: The resource for which the policy detail is being requested. See the
operation documentation for the appropriate value for this field.permissions - 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](https://cloud.google.com/iam/docs/overview#permissions).com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
String resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString();
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response =
connectionServiceClient.testIamPermissions(resource, permissions);
}
resource - REQUIRED: The resource for which the policy detail is being requested. See the
operation documentation for the appropriate value for this field.permissions - 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](https://cloud.google.com/iam/docs/overview#permissions).com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
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 (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
connectionServiceClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponse response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2023 Google LLC. All rights reserved.