@Generated(value="by gapic-generator") @BetaApi 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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Connection connection = Connection.newBuilder().build();
String connectionId = "";
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:
ConnectionServiceSettings connectionServiceSettings =
ConnectionServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ConnectionServiceClient connectionServiceClient =
ConnectionServiceClient.create(connectionServiceSettings);
To customize the endpoint:
ConnectionServiceSettings connectionServiceSettings =
ConnectionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
ConnectionServiceClient connectionServiceClient =
ConnectionServiceClient.create(connectionServiceSettings);
| Modifier and Type | Class and Description |
|---|---|
static class |
ConnectionServiceClient.ListConnectionsFixedSizeCollection |
static class |
ConnectionServiceClient.ListConnectionsPage |
static class |
ConnectionServiceClient.ListConnectionsPagedResponse |
| 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.
|
Connection |
createConnection(CreateConnectionRequest request)
Creates a new connection.
|
Connection |
createConnection(LocationName parent,
Connection connection,
String connectionId)
Creates a new connection.
|
Connection |
createConnection(String parent,
Connection connection,
String connectionId)
Creates a new connection.
|
com.google.api.gax.rpc.UnaryCallable<CreateConnectionRequest,Connection> |
createConnectionCallable()
Creates a new connection.
|
void |
deleteConnection(ConnectionName name)
Deletes connection and associated credential.
|
void |
deleteConnection(DeleteConnectionRequest request)
Deletes connection and associated credential.
|
void |
deleteConnection(String name)
Deletes connection and associated credential.
|
com.google.api.gax.rpc.UnaryCallable<DeleteConnectionRequest,com.google.protobuf.Empty> |
deleteConnectionCallable()
Deletes connection and associated credential.
|
Connection |
getConnection(ConnectionName name)
Returns specified connection.
|
Connection |
getConnection(GetConnectionRequest request)
Returns specified connection.
|
Connection |
getConnection(String name)
Returns specified connection.
|
com.google.api.gax.rpc.UnaryCallable<GetConnectionRequest,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() |
ConnectionServiceClient.ListConnectionsPagedResponse |
listConnections(ListConnectionsRequest request)
Returns a list of connections in the given project.
|
ConnectionServiceClient.ListConnectionsPagedResponse |
listConnections(LocationName parent)
Returns a list of connections in the given project.
|
ConnectionServiceClient.ListConnectionsPagedResponse |
listConnections(String parent)
Returns a list of connections in the given project.
|
com.google.api.gax.rpc.UnaryCallable<ListConnectionsRequest,ListConnectionsResponse> |
listConnectionsCallable()
Returns a list of connections in the given project.
|
com.google.api.gax.rpc.UnaryCallable<ListConnectionsRequest,ConnectionServiceClient.ListConnectionsPagedResponse> |
listConnectionsPagedCallable()
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.
|
Connection |
updateConnection(ConnectionName name,
Connection connection,
com.google.protobuf.FieldMask updateMask)
Updates the specified connection.
|
Connection |
updateConnection(String name,
Connection connection,
com.google.protobuf.FieldMask updateMask)
Updates the specified connection.
|
Connection |
updateConnection(UpdateConnectionRequest request)
Updates the specified connection.
|
com.google.api.gax.rpc.UnaryCallable<UpdateConnectionRequest,Connection> |
updateConnectionCallable()
Updates the specified connection.
|
protected ConnectionServiceClient(ConnectionServiceSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ConnectionServiceClient(ConnectionServiceStub stub)
public static final ConnectionServiceClient create() throws IOException
IOExceptionpublic static final ConnectionServiceClient create(ConnectionServiceSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ConnectionServiceClient create(ConnectionServiceStub stub)
public final ConnectionServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ConnectionServiceStub getStub()
public final Connection createConnection(LocationName parent, Connection connection, String connectionId)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Connection connection = Connection.newBuilder().build();
String connectionId = "";
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 Connection createConnection(String parent, Connection connection, String connectionId)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Connection connection = Connection.newBuilder().build();
String connectionId = "";
Connection response = connectionServiceClient.createConnection(parent.toString(), 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 Connection createConnection(CreateConnectionRequest request)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Connection connection = Connection.newBuilder().build();
CreateConnectionRequest request = CreateConnectionRequest.newBuilder()
.setParent(parent.toString())
.setConnection(connection)
.build();
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<CreateConnectionRequest,Connection> createConnectionCallable()
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Connection connection = Connection.newBuilder().build();
CreateConnectionRequest request = CreateConnectionRequest.newBuilder()
.setParent(parent.toString())
.setConnection(connection)
.build();
ApiFuture<Connection> future = connectionServiceClient.createConnectionCallable().futureCall(request);
// Do something
Connection response = future.get();
}
public final Connection getConnection(ConnectionName name)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
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 Connection getConnection(String name)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Connection response = connectionServiceClient.getConnection(name.toString());
}
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 Connection getConnection(GetConnectionRequest request)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
GetConnectionRequest request = GetConnectionRequest.newBuilder()
.setName(name.toString())
.build();
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<GetConnectionRequest,Connection> getConnectionCallable()
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
GetConnectionRequest request = GetConnectionRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Connection> future = connectionServiceClient.getConnectionCallable().futureCall(request);
// Do something
Connection response = future.get();
}
public final ConnectionServiceClient.ListConnectionsPagedResponse listConnections(LocationName parent)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Connection element : connectionServiceClient.listConnections(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Parent resource name. Must be in the form:
`projects/{project_id}/locations/{location_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionServiceClient.ListConnectionsPagedResponse listConnections(String parent)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Connection element : connectionServiceClient.listConnections(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Parent resource name. Must be in the form:
`projects/{project_id}/locations/{location_id}`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ConnectionServiceClient.ListConnectionsPagedResponse listConnections(ListConnectionsRequest request)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
int pageSize = 0;
ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
.setParent(parent.toString())
.setPageSize(pageSize)
.build();
for (Connection element : connectionServiceClient.listConnections(request).iterateAll()) {
// doThingsWith(element);
}
}
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<ListConnectionsRequest,ConnectionServiceClient.ListConnectionsPagedResponse> listConnectionsPagedCallable()
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
int pageSize = 0;
ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
.setParent(parent.toString())
.setPageSize(pageSize)
.build();
ApiFuture<ListConnectionsPagedResponse> future = connectionServiceClient.listConnectionsPagedCallable().futureCall(request);
// Do something
for (Connection element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListConnectionsRequest,ListConnectionsResponse> listConnectionsCallable()
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
int pageSize = 0;
ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
.setParent(parent.toString())
.setPageSize(pageSize)
.build();
while (true) {
ListConnectionsResponse response = connectionServiceClient.listConnectionsCallable().call(request);
for (Connection element : response.getConnectionsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Connection updateConnection(ConnectionName name, Connection connection, com.google.protobuf.FieldMask updateMask)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Connection connection = Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
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 Connection updateConnection(String name, Connection connection, com.google.protobuf.FieldMask updateMask)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Connection connection = Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Connection response = connectionServiceClient.updateConnection(name.toString(), 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 Connection updateConnection(UpdateConnectionRequest request)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Connection connection = Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder()
.setName(name.toString())
.setConnection(connection)
.setUpdateMask(updateMask)
.build();
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<UpdateConnectionRequest,Connection> updateConnectionCallable()
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Connection connection = Connection.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder()
.setName(name.toString())
.setConnection(connection)
.setUpdateMask(updateMask)
.build();
ApiFuture<Connection> future = connectionServiceClient.updateConnectionCallable().futureCall(request);
// Do something
Connection response = future.get();
}
public final void deleteConnection(ConnectionName name)
Sample code:
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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
connectionServiceClient.deleteConnection(name.toString());
}
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(DeleteConnectionRequest request)
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder()
.setName(name.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<DeleteConnectionRequest,com.google.protobuf.Empty> deleteConnectionCallable()
Sample code:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> 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:
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`.
This field is only used by Cloud IAM.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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
Policy response = connectionServiceClient.getIamPolicy(resource.toString(), 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`.
This field is only used by Cloud IAM.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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.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:
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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Policy policy = Policy.newBuilder().build();
Policy response = connectionServiceClient.setIamPolicy(resource.toString(), 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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.setPolicy(policy)
.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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(resource.toString())
.setPolicy(policy)
.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:
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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(resource.toString(), 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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(resource.toString())
.addAllPermissions(permissions)
.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:
try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(resource.toString())
.addAllPermissions(permissions)
.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 © 2020 Google LLC. All rights reserved.