Search in sources :

Example 11 with Tenant

use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.

the class JobSearchListJobs method sampleListJobs.

/**
 * List Jobs
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleListJobs(String projectId, String tenantId, String filter) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
            System.out.printf("Job name: %s\n", responseItem.getName());
            System.out.printf("Job requisition ID: %s\n", responseItem.getRequisitionId());
            System.out.printf("Job title: %s\n", responseItem.getTitle());
            System.out.printf("Job description: %s\n", responseItem.getDescription());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : ListJobsRequest(com.google.cloud.talent.v4beta1.ListJobsRequest) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job)

Example 12 with Tenant

use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.

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.v4.CreateTenantRequest) TenantServiceClient(com.google.cloud.talent.v4.TenantServiceClient) Tenant(com.google.cloud.talent.v4.Tenant) ProjectName(com.google.cloud.talent.v4.ProjectName)

Example 13 with Tenant

use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.

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.v4.TenantServiceClient) Tenant(com.google.cloud.talent.v4.Tenant) TenantName(com.google.cloud.talent.v4.TenantName) GetTenantRequest(com.google.cloud.talent.v4.GetTenantRequest)

Example 14 with Tenant

use of com.google.cloud.talent.v4beta1.Tenant in project openstack4j by ContainX.

the class KeystoneTests method testAuthorizationFailure.

public void testAuthorizationFailure() throws IOException {
    // First we simulate a 401 Authorization error
    respondWith(401);
    // The retry logic should re-authenticate and would be expecting the
    // Access object
    respondWith(JSON_ACCESS);
    // The retry logic would then run the user lists expecting the proper
    // result
    respondWith(JSON_USERS);
    assertEquals(osv2.identity().users().list().size(), 8);
    // Positive test to make sure we are back in sync
    respondWith(JSON_TENANT);
    Tenant t = osv2.identity().tenants().get("b80f8d4e28b74188858b654cb1fccf7d");
    assertEquals(t.getName(), "admin");
}
Also used : Tenant(org.openstack4j.model.identity.v2.Tenant)

Example 15 with Tenant

use of com.google.cloud.talent.v4beta1.Tenant in project openstack4j by ContainX.

the class KeystoneTests method testTenants.

/**
 * Tests tenant based operations
 *
 * @throws Exception
 */
public void testTenants() throws Exception {
    respondWith(JSON_TENANTS);
    List<? extends Tenant> tenants = osv2().identity().tenants().list();
    assertEquals(tenants.size(), 3);
    respondWith(JSON_TENANT);
    Tenant t = osv2().identity().tenants().get("b80f8d4e28b74188858b654cb1fccf7d");
    assertEquals(t.getName(), "admin");
}
Also used : Tenant(org.openstack4j.model.identity.v2.Tenant)

Aggregations

Test (org.junit.Test)12 Tenant (com.google.cloud.talent.v4beta1.Tenant)10 AbstractMessage (com.google.protobuf.AbstractMessage)9 TenantServiceClient (com.google.cloud.talent.v4beta1.TenantServiceClient)8 Job (com.google.cloud.talent.v4beta1.Job)5 TenantName (com.google.cloud.talent.v4beta1.TenantName)5 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)5 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)4 ProjectName (com.google.cloud.talent.v4beta1.ProjectName)4 Tenant (com.google.cloud.talent.v4.Tenant)3 TenantServiceClient (com.google.cloud.talent.v4.TenantServiceClient)3 Company (com.google.cloud.talent.v4beta1.Company)3 CreateTenantRequest (com.google.cloud.talent.v4beta1.CreateTenantRequest)3 DeleteTenantRequest (com.google.cloud.talent.v4beta1.DeleteTenantRequest)3 GetTenantRequest (com.google.cloud.talent.v4beta1.GetTenantRequest)3 ListTenantsRequest (com.google.cloud.talent.v4beta1.ListTenantsRequest)3 ProjectName (com.google.cloud.talent.v4.ProjectName)2 BatchOperationMetadata (com.google.cloud.talent.v4beta1.BatchOperationMetadata)2 ClientEvent (com.google.cloud.talent.v4beta1.ClientEvent)2 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)2