use of com.google.cloud.talent.v4beta1.TenantServiceClient in project java-docs-samples by GoogleCloudPlatform.
the class JobSearchGetTenant method getTenant.
// Get Tenant by name.
public static void getTenant(String projectId, String tenantId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of(projectId, tenantId);
GetTenantRequest request = GetTenantRequest.newBuilder().setName(name.toString()).build();
Tenant response = tenantServiceClient.getTenant(request);
System.out.format("Name: %s%n", response.getName());
System.out.format("External ID: %s%n", response.getExternalId());
}
}
use of com.google.cloud.talent.v4beta1.TenantServiceClient in project java-docs-samples by GoogleCloudPlatform.
the class JobSearchDeleteTenant method deleteTenant.
// Delete Tenant.
public static void deleteTenant(String projectId, String tenantId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
TenantName name = TenantName.of(projectId, tenantId);
DeleteTenantRequest request = DeleteTenantRequest.newBuilder().setName(name.toString()).build();
tenantServiceClient.deleteTenant(request);
System.out.println("Deleted Tenant.");
}
}
use of com.google.cloud.talent.v4beta1.TenantServiceClient in project java-docs-samples by GoogleCloudPlatform.
the class JobSearchListTenants method listTenants.
// List Tenants.
public static void listTenants(String projectId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
ListTenantsRequest request = ListTenantsRequest.newBuilder().setParent(parent.toString()).build();
for (Tenant responseItem : tenantServiceClient.listTenants(request).iterateAll()) {
System.out.format("Tenant Name: %s%n", responseItem.getName());
System.out.format("External ID: %s%n", responseItem.getExternalId());
}
}
}
use of com.google.cloud.talent.v4beta1.TenantServiceClient in project java-docs-samples by GoogleCloudPlatform.
the class JobSearchCreateTenant method createTenant.
// Create Tenant for scoping resources, e.g. companies and jobs.
public static void createTenant(String projectId, String externalId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
Tenant tenant = Tenant.newBuilder().setExternalId(externalId).build();
CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(parent.toString()).setTenant(tenant).build();
Tenant response = tenantServiceClient.createTenant(request);
System.out.println("Created Tenant");
System.out.format("Name: %s%n", response.getName());
System.out.format("External ID: %s%n", response.getExternalId());
}
}
Aggregations