Search in sources :

Example 1 with CreateTenantRequest

use of com.google.cloud.talent.v4beta1.CreateTenantRequest 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());
    }
}
Also used : CreateTenantRequest(com.google.cloud.talent.v4beta1.CreateTenantRequest) TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) Tenant(com.google.cloud.talent.v4beta1.Tenant) ProjectName(com.google.cloud.talent.v4beta1.ProjectName)

Aggregations

CreateTenantRequest (com.google.cloud.talent.v4beta1.CreateTenantRequest)1 ProjectName (com.google.cloud.talent.v4beta1.ProjectName)1 Tenant (com.google.cloud.talent.v4beta1.Tenant)1 TenantServiceClient (com.google.cloud.talent.v4beta1.TenantServiceClient)1