Search in sources :

Example 1 with CompanyServiceClient

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

the class JobSearchCreateCompany method sampleCreateCompany.

/**
 * Create Company
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleCreateCompany(String projectId, String tenantId, String displayName, String externalId) {
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        Company company = Company.newBuilder().setDisplayName(displayName).setExternalId(externalId).build();
        CreateCompanyRequest request = CreateCompanyRequest.newBuilder().setParent(parent.toString()).setCompany(company).build();
        Company response = companyServiceClient.createCompany(request);
        System.out.println("Created Company");
        System.out.printf("Name: %s\n", response.getName());
        System.out.printf("Display Name: %s\n", response.getDisplayName());
        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 : CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) CreateCompanyRequest(com.google.cloud.talent.v4beta1.CreateCompanyRequest) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 2 with CompanyServiceClient

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

the class JobSearchCreateCompany method createCompany.

// Create a company.
public static void createCompany(String projectId, String tenantId, String displayName, String externalId) 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);
        Company company = Company.newBuilder().setDisplayName(displayName).setExternalId(externalId).build();
        CreateCompanyRequest request = CreateCompanyRequest.newBuilder().setParent(parent.toString()).setCompany(company).build();
        Company response = companyServiceClient.createCompany(request);
        System.out.println("Created Company");
        System.out.format("Name: %s%n", response.getName());
        System.out.format("Display Name: %s%n", response.getDisplayName());
        System.out.format("External ID: %s%n", response.getExternalId());
    }
}
Also used : CompanyServiceClient(com.google.cloud.talent.v4.CompanyServiceClient) Company(com.google.cloud.talent.v4.Company) CreateCompanyRequest(com.google.cloud.talent.v4.CreateCompanyRequest) TenantName(com.google.cloud.talent.v4.TenantName)

Example 3 with CompanyServiceClient

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

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

the class JobSearchDeleteCompany method deleteCompany.

// Delete Company.
public static void deleteCompany(String projectId, String tenantId, String companyId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        CompanyName name = CompanyName.ofProjectTenantCompanyName(projectId, tenantId, companyId);
        DeleteCompanyRequest request = DeleteCompanyRequest.newBuilder().setName(name.toString()).build();
        companyServiceClient.deleteCompany(request);
        System.out.println("Deleted company");
    }
}
Also used : DeleteCompanyRequest(com.google.cloud.talent.v4beta1.DeleteCompanyRequest) CompanyName(com.google.cloud.talent.v4beta1.CompanyName) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient)

Example 5 with CompanyServiceClient

use of com.google.cloud.talent.v4.CompanyServiceClient 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)

Aggregations

CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)8 Company (com.google.cloud.talent.v4beta1.Company)6 CompanyServiceClient (com.google.cloud.talent.v4.CompanyServiceClient)4 CompanyName (com.google.cloud.talent.v4beta1.CompanyName)4 Company (com.google.cloud.talent.v4.Company)3 CompanyName (com.google.cloud.talent.v4.CompanyName)2 TenantName (com.google.cloud.talent.v4.TenantName)2 CreateCompanyRequest (com.google.cloud.talent.v4beta1.CreateCompanyRequest)2 DeleteCompanyRequest (com.google.cloud.talent.v4beta1.DeleteCompanyRequest)2 GetCompanyRequest (com.google.cloud.talent.v4beta1.GetCompanyRequest)2 ListCompaniesRequest (com.google.cloud.talent.v4beta1.ListCompaniesRequest)2 TenantName (com.google.cloud.talent.v4beta1.TenantName)2 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)2 CreateCompanyRequest (com.google.cloud.talent.v4.CreateCompanyRequest)1 DeleteCompanyRequest (com.google.cloud.talent.v4.DeleteCompanyRequest)1 GetCompanyRequest (com.google.cloud.talent.v4.GetCompanyRequest)1 ListCompaniesRequest (com.google.cloud.talent.v4.ListCompaniesRequest)1