@Generated(value="by gapic-generator") @BetaApi public class TenantServiceClient 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 (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.
|
Tenant |
createTenant(CreateTenantRequest request)
Creates a new tenant entity.
|
Tenant |
createTenant(ProjectName parent,
Tenant tenant)
Creates a new tenant entity.
|
Tenant |
createTenant(String parent,
Tenant tenant)
Creates a new tenant entity.
|
com.google.api.gax.rpc.UnaryCallable<CreateTenantRequest,Tenant> |
createTenantCallable()
Creates a new tenant entity.
|
void |
deleteTenant(DeleteTenantRequest request)
Deletes specified tenant.
|
void |
deleteTenant(String name)
Deletes specified tenant.
|
void |
deleteTenant(TenantName name)
Deletes specified tenant.
|
com.google.api.gax.rpc.UnaryCallable<DeleteTenantRequest,Empty> |
deleteTenantCallable()
Deletes specified tenant.
|
TenantServiceSettings |
getSettings() |
TenantServiceStub |
getStub() |
Tenant |
getTenant(GetTenantRequest request)
Retrieves specified tenant.
|
Tenant |
getTenant(String name)
Retrieves specified tenant.
|
Tenant |
getTenant(TenantName name)
Retrieves specified tenant.
|
com.google.api.gax.rpc.UnaryCallable<GetTenantRequest,Tenant> |
getTenantCallable()
Retrieves specified tenant.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
TenantServiceClient.ListTenantsPagedResponse |
listTenants(ListTenantsRequest request)
Lists all tenants associated with the project.
|
TenantServiceClient.ListTenantsPagedResponse |
listTenants(ProjectName parent)
Lists all tenants associated with the project.
|
TenantServiceClient.ListTenantsPagedResponse |
listTenants(String parent)
Lists all tenants associated with the project.
|
com.google.api.gax.rpc.UnaryCallable<ListTenantsRequest,ListTenantsResponse> |
listTenantsCallable()
Lists all tenants associated with the project.
|
com.google.api.gax.rpc.UnaryCallable<ListTenantsRequest,TenantServiceClient.ListTenantsPagedResponse> |
listTenantsPagedCallable()
Lists all tenants associated with the project.
|
void |
shutdown() |
void |
shutdownNow() |
Tenant |
updateTenant(Tenant tenant)
Updates specified tenant.
|
Tenant |
updateTenant(UpdateTenantRequest request)
Updates specified tenant.
|
com.google.api.gax.rpc.UnaryCallable<UpdateTenantRequest,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 Tenant createTenant(ProjectName parent, 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/foo".
tenant
- Required. The tenant to be created.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Tenant createTenant(String parent, 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/foo".
tenant
- Required. The tenant to be created.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Tenant createTenant(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateTenantRequest,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 Tenant getTenant(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/foo/tenants/bar".
com.google.api.gax.rpc.ApiException
- if the remote call failspublic final 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/foo/tenants/bar".
com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Tenant getTenant(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetTenantRequest,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 Tenant updateTenant(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Tenant updateTenant(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateTenantRequest,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(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/foo/tenants/bar".
com.google.api.gax.rpc.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/foo/tenants/bar".
com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteTenant(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<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(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/foo".
com.google.api.gax.rpc.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/foo".
com.google.api.gax.rpc.ApiException
- if the remote call failspublic final TenantServiceClient.ListTenantsPagedResponse listTenants(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<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 com.google.api.gax.rpc.UnaryCallable<ListTenantsRequest,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 com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.