Search in sources :

Example 1 with ListCompaniesRequest

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

the class JobSearchListCompanies method listCompanies.

// List Companies.
public static void listCompanies(String projectId, String tenantId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();
        for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
            System.out.format("Company Name: %s%n", responseItem.getName());
            System.out.format("Display Name: %s%n", responseItem.getDisplayName());
            System.out.format("External ID: %s%n", responseItem.getExternalId());
        }
    }
}
Also used : ListCompaniesRequest(com.google.cloud.talent.v4.ListCompaniesRequest) CompanyServiceClient(com.google.cloud.talent.v4.CompanyServiceClient) Company(com.google.cloud.talent.v4.Company) TenantName(com.google.cloud.talent.v4.TenantName)

Example 2 with ListCompaniesRequest

use of com.google.cloud.talent.v4.ListCompaniesRequest in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchListCompanies method listCompanies.

// List Companies.
public static void listCompanies(String projectId, String tenantId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();
        for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
            System.out.format("Company Name: %s%n", responseItem.getName());
            System.out.format("Display Name: %s%n", responseItem.getDisplayName());
            System.out.format("External ID: %s%n", responseItem.getExternalId());
        }
    }
}
Also used : ListCompaniesRequest(com.google.cloud.talent.v4beta1.ListCompaniesRequest) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) TenantName(com.google.cloud.talent.v4beta1.TenantName)

Example 3 with ListCompaniesRequest

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

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

the class CompanyServiceClientTest method listCompaniesTest2.

@Test
public void listCompaniesTest2() throws Exception {
    Company responsesElement = Company.newBuilder().build();
    ListCompaniesResponse expectedResponse = ListCompaniesResponse.newBuilder().setNextPageToken("").addAllCompanies(Arrays.asList(responsesElement)).build();
    mockCompanyService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    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, 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 5 with ListCompaniesRequest

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

the class JobSearchListCompanies method sampleListCompanies.

/**
 * List Companies
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleListCompanies(String projectId, String tenantId) {
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();
        for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
            System.out.printf("Company Name: %s\n", responseItem.getName());
            System.out.printf("Display Name: %s\n", responseItem.getDisplayName());
            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 : ListCompaniesRequest(com.google.cloud.talent.v4beta1.ListCompaniesRequest) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Aggregations

Company (com.google.cloud.talent.v4beta1.Company)3 ListCompaniesRequest (com.google.cloud.talent.v4beta1.ListCompaniesRequest)3 Test (org.junit.Test)3 ListCompaniesPagedResponse (com.google.cloud.talent.v4.CompanyServiceClient.ListCompaniesPagedResponse)2 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Company (com.google.cloud.talent.v4.Company)1 CompanyServiceClient (com.google.cloud.talent.v4.CompanyServiceClient)1 ListCompaniesRequest (com.google.cloud.talent.v4.ListCompaniesRequest)1 TenantName (com.google.cloud.talent.v4.TenantName)1 TenantName (com.google.cloud.talent.v4beta1.TenantName)1 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)1