Search in sources :

Example 21 with TenantName

use of com.google.cloud.talent.v4.TenantName 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 22 with TenantName

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

the class CompanyServiceClientTest method listCompaniesTest.

@Test
public void listCompaniesTest() throws Exception {
    Company responsesElement = Company.newBuilder().build();
    ListCompaniesResponse expectedResponse = ListCompaniesResponse.newBuilder().setNextPageToken("").addAllCompanies(Arrays.asList(responsesElement)).build();
    mockCompanyService.addResponse(expectedResponse);
    TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
    ListCompaniesPagedResponse pagedListResponse = client.listCompanies(parent);
    List<Company> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getCompaniesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCompanyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListCompaniesRequest actualRequest = ((ListCompaniesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCompaniesPagedResponse(com.google.cloud.talent.v4.CompanyServiceClient.ListCompaniesPagedResponse) Test(org.junit.Test)

Example 23 with TenantName

use of com.google.cloud.talent.v4.TenantName 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 24 with TenantName

use of com.google.cloud.talent.v4.TenantName 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 25 with TenantName

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

the class JobSearchAutoCompleteJobTitle method completeQuery.

// Complete job title given partial text (autocomplete).
public static void completeQuery(String projectId, String tenantId, String query) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompletionClient completionClient = CompletionClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        CompleteQueryRequest request = CompleteQueryRequest.newBuilder().setTenant(parent.toString()).setQuery(query).setPageSize(// limit for number of results
        5).addLanguageCodes(// language code
        "en-US").build();
        CompleteQueryResponse response = completionClient.completeQuery(request);
        for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) {
            System.out.format("Suggested title: %s%n", result.getSuggestion());
            // Suggestion type is JOB_TITLE or COMPANY_TITLE
            System.out.format("Suggestion type: %s%n", result.getType());
        }
    }
}
Also used : CompleteQueryResponse(com.google.cloud.talent.v4.CompleteQueryResponse) TenantName(com.google.cloud.talent.v4.TenantName) CompletionClient(com.google.cloud.talent.v4.CompletionClient) CompleteQueryRequest(com.google.cloud.talent.v4.CompleteQueryRequest)

Aggregations

TenantName (com.google.cloud.talent.v4beta1.TenantName)14 TenantName (com.google.cloud.talent.v4.TenantName)12 Job (com.google.cloud.talent.v4.Job)6 JobServiceClient (com.google.cloud.talent.v4.JobServiceClient)6 Job (com.google.cloud.talent.v4beta1.Job)6 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)6 TenantServiceClient (com.google.cloud.talent.v4beta1.TenantServiceClient)4 RequestMetadata (com.google.cloud.talent.v4.RequestMetadata)3 SearchJobsRequest (com.google.cloud.talent.v4.SearchJobsRequest)3 SearchJobsResponse (com.google.cloud.talent.v4.SearchJobsResponse)3 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)3 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)3 SearchJobsResponse (com.google.cloud.talent.v4beta1.SearchJobsResponse)3 Company (com.google.cloud.talent.v4.Company)2 CompanyServiceClient (com.google.cloud.talent.v4.CompanyServiceClient)2 CreateJobRequest (com.google.cloud.talent.v4.CreateJobRequest)2 TenantServiceClient (com.google.cloud.talent.v4.TenantServiceClient)2 Company (com.google.cloud.talent.v4beta1.Company)2 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)2 CreateJobRequest (com.google.cloud.talent.v4beta1.CreateJobRequest)2