@Generated(value="by gapic-generator") @BetaApi public class TenantServiceClient extends Object implements 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 (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Tenant tenant = Tenant.newBuilder().build();
Tenant response = tenantServiceClient.createTenant(parent, tenant);
}
Note: close() needs to be called on the tenantServiceClient 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 TenantServiceSettings to create(). For example:
To customize credentials:
TenantServiceSettings tenantServiceSettings =
TenantServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
TenantServiceClient tenantServiceClient =
TenantServiceClient.create(tenantServiceSettings);
To customize the endpoint:
TenantServiceSettings tenantServiceSettings =
TenantServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
TenantServiceClient tenantServiceClient =
TenantServiceClient.create(tenantServiceSettings);
Modifier and Type | Class and Description |
---|---|
static class |
TenantServiceClient.ListTenantsFixedSizeCollection |
static class |
TenantServiceClient.ListTenantsPage |
static class |
TenantServiceClient.ListTenantsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
TenantServiceClient(TenantServiceSettings settings)
Constructs an instance of TenantServiceClient, using the given settings.
|
protected |
TenantServiceClient(TenantServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static TenantServiceClient |
create()
Constructs an instance of TenantServiceClient with default settings.
|
static TenantServiceClient |
create(TenantServiceSettings settings)
Constructs an instance of TenantServiceClient, using the given settings.
|
static TenantServiceClient |
create(TenantServiceStub stub)
Constructs an instance of TenantServiceClient, using the given stub for making calls.
|
com.google.cloud.talent.v4beta1.Tenant |
createTenant(com.google.cloud.talent.v4beta1.CreateTenantRequest request)
Creates a new tenant entity.
|
com.google.cloud.talent.v4beta1.Tenant |
createTenant(com.google.cloud.talent.v4beta1.ProjectName parent,
com.google.cloud.talent.v4beta1.Tenant tenant)
Creates a new tenant entity.
|
com.google.cloud.talent.v4beta1.Tenant |
createTenant(String parent,
com.google.cloud.talent.v4beta1.Tenant tenant)
Creates a new tenant entity.
|
UnaryCallable<com.google.cloud.talent.v4beta1.CreateTenantRequest,com.google.cloud.talent.v4beta1.Tenant> |
createTenantCallable()
Creates a new tenant entity.
|
void |
deleteTenant(com.google.cloud.talent.v4beta1.DeleteTenantRequest request)
Deletes specified tenant.
|
void |
deleteTenant(String name)
Deletes specified tenant.
|
void |
deleteTenant(com.google.cloud.talent.v4beta1.TenantName name)
Deletes specified tenant.
|
UnaryCallable<com.google.cloud.talent.v4beta1.DeleteTenantRequest,Empty> |
deleteTenantCallable()
Deletes specified tenant.
|
TenantServiceSettings |
getSettings() |
TenantServiceStub |
getStub() |
com.google.cloud.talent.v4beta1.Tenant |
getTenant(com.google.cloud.talent.v4beta1.GetTenantRequest request)
Retrieves specified tenant.
|
com.google.cloud.talent.v4beta1.Tenant |
getTenant(String name)
Retrieves specified tenant.
|
com.google.cloud.talent.v4beta1.Tenant |
getTenant(com.google.cloud.talent.v4beta1.TenantName name)
Retrieves specified tenant.
|
UnaryCallable<com.google.cloud.talent.v4beta1.GetTenantRequest,com.google.cloud.talent.v4beta1.Tenant> |
getTenantCallable()
Retrieves specified tenant.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
TenantServiceClient.ListTenantsPagedResponse |
listTenants(com.google.cloud.talent.v4beta1.ListTenantsRequest request)
Lists all tenants associated with the project.
|
TenantServiceClient.ListTenantsPagedResponse |
listTenants(com.google.cloud.talent.v4beta1.ProjectName parent)
Lists all tenants associated with the project.
|
TenantServiceClient.ListTenantsPagedResponse |
listTenants(String parent)
Lists all tenants associated with the project.
|
UnaryCallable<com.google.cloud.talent.v4beta1.ListTenantsRequest,com.google.cloud.talent.v4beta1.ListTenantsResponse> |
listTenantsCallable()
Lists all tenants associated with the project.
|
UnaryCallable<com.google.cloud.talent.v4beta1.ListTenantsRequest,TenantServiceClient.ListTenantsPagedResponse> |
listTenantsPagedCallable()
Lists all tenants associated with the project.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.cloud.talent.v4beta1.Tenant |
updateTenant(com.google.cloud.talent.v4beta1.Tenant tenant)
Updates specified tenant.
|
com.google.cloud.talent.v4beta1.Tenant |
updateTenant(com.google.cloud.talent.v4beta1.UpdateTenantRequest request)
Updates specified tenant.
|
UnaryCallable<com.google.cloud.talent.v4beta1.UpdateTenantRequest,com.google.cloud.talent.v4beta1.Tenant> |
updateTenantCallable()
Updates specified tenant.
|
protected TenantServiceClient(TenantServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected TenantServiceClient(TenantServiceStub stub)
public static final TenantServiceClient create() throws IOException
IOException
public static final TenantServiceClient create(TenantServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final TenantServiceClient create(TenantServiceStub stub)
public final TenantServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public TenantServiceStub getStub()
public final com.google.cloud.talent.v4beta1.Tenant createTenant(com.google.cloud.talent.v4beta1.ProjectName parent, com.google.cloud.talent.v4beta1.Tenant tenant)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Tenant tenant = Tenant.newBuilder().build();
Tenant response = tenantServiceClient.createTenant(parent, tenant);
}
parent
- Required.
Resource name of the project under which the tenant is created.
The format is "projects/{project_id}", for example, "projects/api-test-project".
tenant
- Required.
The tenant to be created.
ApiException
- if the remote call failspublic final com.google.cloud.talent.v4beta1.Tenant createTenant(String parent, com.google.cloud.talent.v4beta1.Tenant tenant)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Tenant tenant = Tenant.newBuilder().build();
Tenant response = tenantServiceClient.createTenant(parent.toString(), tenant);
}
parent
- Required.
Resource name of the project under which the tenant is created.
The format is "projects/{project_id}", for example, "projects/api-test-project".
tenant
- Required.
The tenant to be created.
ApiException
- if the remote call failspublic final com.google.cloud.talent.v4beta1.Tenant createTenant(com.google.cloud.talent.v4beta1.CreateTenantRequest request)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Tenant tenant = Tenant.newBuilder().build();
CreateTenantRequest request = CreateTenantRequest.newBuilder()
.setParent(parent.toString())
.setTenant(tenant)
.build();
Tenant response = tenantServiceClient.createTenant(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.talent.v4beta1.CreateTenantRequest,com.google.cloud.talent.v4beta1.Tenant> createTenantCallable()
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Tenant tenant = Tenant.newBuilder().build();
CreateTenantRequest request = CreateTenantRequest.newBuilder()
.setParent(parent.toString())
.setTenant(tenant)
.build();
ApiFuture<Tenant> future = tenantServiceClient.createTenantCallable().futureCall(request);
// Do something
Tenant response = future.get();
}
public final com.google.cloud.talent.v4beta1.Tenant getTenant(com.google.cloud.talent.v4beta1.TenantName name)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
Tenant response = tenantServiceClient.getTenant(name);
}
name
- Required.
The resource name of the tenant to be retrieved.
The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/api-test-project/tenants/foo".
ApiException
- if the remote call failspublic final com.google.cloud.talent.v4beta1.Tenant getTenant(String name)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
Tenant response = tenantServiceClient.getTenant(name.toString());
}
name
- Required.
The resource name of the tenant to be retrieved.
The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/api-test-project/tenants/foo".
ApiException
- if the remote call failspublic final com.google.cloud.talent.v4beta1.Tenant getTenant(com.google.cloud.talent.v4beta1.GetTenantRequest request)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
GetTenantRequest request = GetTenantRequest.newBuilder()
.setName(name.toString())
.build();
Tenant response = tenantServiceClient.getTenant(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.talent.v4beta1.GetTenantRequest,com.google.cloud.talent.v4beta1.Tenant> getTenantCallable()
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
GetTenantRequest request = GetTenantRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Tenant> future = tenantServiceClient.getTenantCallable().futureCall(request);
// Do something
Tenant response = future.get();
}
public final com.google.cloud.talent.v4beta1.Tenant updateTenant(com.google.cloud.talent.v4beta1.Tenant tenant)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
Tenant tenant = Tenant.newBuilder().build();
Tenant response = tenantServiceClient.updateTenant(tenant);
}
tenant
- Required.
The tenant resource to replace the current resource in the system.
ApiException
- if the remote call failspublic final com.google.cloud.talent.v4beta1.Tenant updateTenant(com.google.cloud.talent.v4beta1.UpdateTenantRequest request)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
Tenant tenant = Tenant.newBuilder().build();
UpdateTenantRequest request = UpdateTenantRequest.newBuilder()
.setTenant(tenant)
.build();
Tenant response = tenantServiceClient.updateTenant(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.talent.v4beta1.UpdateTenantRequest,com.google.cloud.talent.v4beta1.Tenant> updateTenantCallable()
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
Tenant tenant = Tenant.newBuilder().build();
UpdateTenantRequest request = UpdateTenantRequest.newBuilder()
.setTenant(tenant)
.build();
ApiFuture<Tenant> future = tenantServiceClient.updateTenantCallable().futureCall(request);
// Do something
Tenant response = future.get();
}
public final void deleteTenant(com.google.cloud.talent.v4beta1.TenantName name)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
tenantServiceClient.deleteTenant(name);
}
name
- Required.
The resource name of the tenant to be deleted.
The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/api-test-project/tenants/foo".
ApiException
- if the remote call failspublic final void deleteTenant(String name)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
tenantServiceClient.deleteTenant(name.toString());
}
name
- Required.
The resource name of the tenant to be deleted.
The format is "projects/{project_id}/tenants/{tenant_id}", for example, "projects/api-test-project/tenants/foo".
ApiException
- if the remote call failspublic final void deleteTenant(com.google.cloud.talent.v4beta1.DeleteTenantRequest request)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
DeleteTenantRequest request = DeleteTenantRequest.newBuilder()
.setName(name.toString())
.build();
tenantServiceClient.deleteTenant(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.talent.v4beta1.DeleteTenantRequest,Empty> deleteTenantCallable()
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of("[PROJECT]", "[TENANT]");
DeleteTenantRequest request = DeleteTenantRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = tenantServiceClient.deleteTenantCallable().futureCall(request);
// Do something
future.get();
}
public final TenantServiceClient.ListTenantsPagedResponse listTenants(com.google.cloud.talent.v4beta1.ProjectName parent)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Tenant element : tenantServiceClient.listTenants(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required.
Resource name of the project under which the tenant is created.
The format is "projects/{project_id}", for example, "projects/api-test-project".
ApiException
- if the remote call failspublic final TenantServiceClient.ListTenantsPagedResponse listTenants(String parent)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Tenant element : tenantServiceClient.listTenants(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required.
Resource name of the project under which the tenant is created.
The format is "projects/{project_id}", for example, "projects/api-test-project".
ApiException
- if the remote call failspublic final TenantServiceClient.ListTenantsPagedResponse listTenants(com.google.cloud.talent.v4beta1.ListTenantsRequest request)
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListTenantsRequest request = ListTenantsRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Tenant element : tenantServiceClient.listTenants(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.talent.v4beta1.ListTenantsRequest,TenantServiceClient.ListTenantsPagedResponse> listTenantsPagedCallable()
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListTenantsRequest request = ListTenantsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListTenantsPagedResponse> future = tenantServiceClient.listTenantsPagedCallable().futureCall(request);
// Do something
for (Tenant element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.talent.v4beta1.ListTenantsRequest,com.google.cloud.talent.v4beta1.ListTenantsResponse> listTenantsCallable()
Sample code:
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListTenantsRequest request = ListTenantsRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListTenantsResponse response = tenantServiceClient.listTenantsCallable().call(request);
for (Tenant element : response.getTenantsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.