Search in sources :

Example 6 with TenantServiceClient

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

Example 7 with TenantServiceClient

use of com.google.cloud.talent.v4.TenantServiceClient in project java-talent by googleapis.

the class JobSearchDeleteTenant method sampleDeleteTenant.

/**
 * Delete Tenant
 */
public static void sampleDeleteTenant(String projectId, String tenantId) {
    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.");
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) TenantName(com.google.cloud.talent.v4beta1.TenantName) DeleteTenantRequest(com.google.cloud.talent.v4beta1.DeleteTenantRequest)

Example 8 with TenantServiceClient

use of com.google.cloud.talent.v4.TenantServiceClient in project java-talent by googleapis.

the class JobSearchGetTenant method sampleGetTenant.

/**
 * Get Tenant by name
 */
public static void sampleGetTenant(String projectId, String tenantId) {
    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.printf("Name: %s\n", response.getName());
        System.out.printf("External ID: %s\n", response.getExternalId());
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) Tenant(com.google.cloud.talent.v4beta1.Tenant) TenantName(com.google.cloud.talent.v4beta1.TenantName) GetTenantRequest(com.google.cloud.talent.v4beta1.GetTenantRequest)

Example 9 with TenantServiceClient

use of com.google.cloud.talent.v4.TenantServiceClient in project java-talent by googleapis.

the class JobSearchListTenants method sampleListTenants.

/**
 * List Tenants
 */
public static void sampleListTenants(String projectId) {
    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.printf("Tenant Name: %s\n", responseItem.getName());
            System.out.printf("External ID: %s\n", responseItem.getExternalId());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) Tenant(com.google.cloud.talent.v4beta1.Tenant) ProjectName(com.google.cloud.talent.v4beta1.ProjectName) ListTenantsRequest(com.google.cloud.talent.v4beta1.ListTenantsRequest)

Example 10 with TenantServiceClient

use of com.google.cloud.talent.v4.TenantServiceClient in project java-talent by googleapis.

the class JobSearchCreateTenant method sampleCreateTenant.

/**
 * Create Tenant for scoping resources, e.g. companies and jobs
 */
public static void sampleCreateTenant(String projectId, String externalId) {
    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.printf("Name: %s\n", response.getName());
        System.out.printf("External ID: %s\n", response.getExternalId());
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
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

TenantServiceClient (com.google.cloud.talent.v4beta1.TenantServiceClient)8 Tenant (com.google.cloud.talent.v4beta1.Tenant)6 TenantServiceClient (com.google.cloud.talent.v4.TenantServiceClient)4 ProjectName (com.google.cloud.talent.v4beta1.ProjectName)4 TenantName (com.google.cloud.talent.v4beta1.TenantName)4 Tenant (com.google.cloud.talent.v4.Tenant)3 ProjectName (com.google.cloud.talent.v4.ProjectName)2 TenantName (com.google.cloud.talent.v4.TenantName)2 CreateTenantRequest (com.google.cloud.talent.v4beta1.CreateTenantRequest)2 DeleteTenantRequest (com.google.cloud.talent.v4beta1.DeleteTenantRequest)2 GetTenantRequest (com.google.cloud.talent.v4beta1.GetTenantRequest)2 ListTenantsRequest (com.google.cloud.talent.v4beta1.ListTenantsRequest)2 CreateTenantRequest (com.google.cloud.talent.v4.CreateTenantRequest)1 DeleteTenantRequest (com.google.cloud.talent.v4.DeleteTenantRequest)1 GetTenantRequest (com.google.cloud.talent.v4.GetTenantRequest)1 ListTenantsRequest (com.google.cloud.talent.v4.ListTenantsRequest)1