use of com.google.cloud.talent.v4.Company 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);
}
}
use of com.google.cloud.talent.v4.Company in project java-talent by googleapis.
the class ITSystemTest method updateCompanyTest.
@Test
public void updateCompanyTest() {
String careerSiteUri = "www.example.com";
Company updateCompany = company.toBuilder().setCareerSiteUri(careerSiteUri).build();
UpdateCompanyRequest request = UpdateCompanyRequest.newBuilder().setCompany(updateCompany).build();
Company actual = companyServiceClient.updateCompany(request);
assertEquals(company.getName(), actual.getName());
assertEquals(company.getDisplayName(), actual.getDisplayName());
assertEquals(careerSiteUri, actual.getCareerSiteUri());
}
use of com.google.cloud.talent.v4.Company 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();
}
use of com.google.cloud.talent.v4.Company 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());
}
}
use of com.google.cloud.talent.v4.Company 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());
}
}
}
Aggregations