Search in sources :

Example 1 with CreateCompanyRequest

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

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

the class ITSystemTest method beforeTest.

@BeforeClass
public static void beforeTest() throws IOException {
    /* create tenant */
    tenantServiceClient = TenantServiceClient.create();
    Tenant createTenant = Tenant.newBuilder().setName(TENANT_NAME).setExternalId(EXTERNAL_ID).build();
    CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(PROJECT_NAME.toString()).setTenant(createTenant).build();
    tenant = tenantServiceClient.createTenant(request);
    tenantId = getId(tenant.getName());
    tenantName = TenantName.of(PROJECT_ID, tenantId);
    /* create company */
    companyServiceClient = CompanyServiceClient.create();
    Company createCompany = Company.newBuilder().setDisplayName(DISPLAY_NAME).setExternalId(EXTERNAL_ID).build();
    CreateCompanyRequest companyRequest = CreateCompanyRequest.newBuilder().setParent(tenantName.toString()).setCompany(createCompany).build();
    company = companyServiceClient.createCompany(companyRequest);
    companyId = getId(company.getName());
    companyName = CompanyName.ofProjectTenantCompanyName(PROJECT_ID, tenantId, companyId);
    /* create job */
    jobServiceClient = JobServiceClient.create();
    Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(Arrays.asList(JOB_APPLICATION_URL)).build();
    Job createJob = Job.newBuilder().setCompany(companyId).setRequisitionId(REQUISITION_ID).setTitle(TITLE).setDescription(DESCRIPTION).setApplicationInfo(applicationInfo).addAllAddresses(Arrays.asList(ADDRESS_ONE, ADDRESS_TWO)).setLanguageCode(LANGUAGE_CODE).build();
    CreateJobRequest jobRequest = CreateJobRequest.newBuilder().setParent(tenantName.toString()).setJob(createJob).build();
    job = jobServiceClient.createJob(jobRequest);
    jobId = getId(job.getName());
    jobName = JobName.ofProjectTenantJobName(PROJECT_ID, tenantId, jobId);
    /*create event */
    eventServiceClient = EventServiceClient.create();
    // create completion
    completionClient = CompletionClient.create();
}
Also used : CreateTenantRequest(com.google.cloud.talent.v4beta1.CreateTenantRequest) Company(com.google.cloud.talent.v4beta1.Company) Tenant(com.google.cloud.talent.v4beta1.Tenant) CreateCompanyRequest(com.google.cloud.talent.v4beta1.CreateCompanyRequest) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest) BeforeClass(org.junit.BeforeClass)

Example 3 with CreateCompanyRequest

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

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

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.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) CreateCompanyRequest(com.google.cloud.talent.v4beta1.CreateCompanyRequest) TenantName(com.google.cloud.talent.v4beta1.TenantName)

Aggregations

Company (com.google.cloud.talent.v4beta1.Company)3 CreateCompanyRequest (com.google.cloud.talent.v4beta1.CreateCompanyRequest)3 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)2 Company (com.google.cloud.talent.v4.Company)1 CompanyServiceClient (com.google.cloud.talent.v4.CompanyServiceClient)1 CreateCompanyRequest (com.google.cloud.talent.v4.CreateCompanyRequest)1 TenantName (com.google.cloud.talent.v4.TenantName)1 CreateJobRequest (com.google.cloud.talent.v4beta1.CreateJobRequest)1 CreateTenantRequest (com.google.cloud.talent.v4beta1.CreateTenantRequest)1 Job (com.google.cloud.talent.v4beta1.Job)1 Tenant (com.google.cloud.talent.v4beta1.Tenant)1 TenantName (com.google.cloud.talent.v4beta1.TenantName)1 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)1 BeforeClass (org.junit.BeforeClass)1