Search in sources :

Example 16 with TenantName

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

the class HistogramSearchJobs method searchJobs.

// Search Jobs with histogram queries.
public static void searchJobs(String projectId, String tenantId, String query) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        String domain = "http://www.jobUrl.com";
        String sessionId = "Hashed session identifier";
        String userId = "Hashed user identifier";
        RequestMetadata requestMetadata = RequestMetadata.newBuilder().setDomain(domain).setSessionId(sessionId).setUserId(userId).build();
        HistogramQuery histogramQueriesElement = HistogramQuery.newBuilder().setHistogramQuery(query).build();
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addHistogramQueries(histogramQueriesElement).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) {
            System.out.format("Job summary: %s%n", responseItem.getJobSummary());
            System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet());
            Job job = responseItem.getJob();
            System.out.format("Job name: %s%n", job.getName());
            System.out.format("Job title: %s%n", job.getTitle());
        }
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4beta1.SearchJobsResponse) TenantName(com.google.cloud.talent.v4beta1.TenantName) HistogramQuery(com.google.cloud.talent.v4beta1.HistogramQuery) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Example 17 with TenantName

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

the class JobSearchCreateClientEvent method createClientEvent.

// Creates a client event.
public static void createClientEvent(String projectId, String tenantId, String requestId, String eventId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (EventServiceClient eventServiceClient = EventServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        // The timestamp of the event as seconds of UTC time since Unix epoch
        // For more information on how to create google.protobuf.Timestamps
        // See:
        // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto
        long seconds = 3L;
        Timestamp createTime = Timestamp.newBuilder().setSeconds(seconds).build();
        // The type of event attributed to the behavior of the end user
        JobEvent.JobEventType type = JobEvent.JobEventType.VIEW;
        // List of job names associated with this event
        String jobsElement = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
        String jobsElement2 = "projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]";
        List<String> jobs = Arrays.asList(jobsElement, jobsElement2);
        JobEvent jobEvent = JobEvent.newBuilder().setType(type).addAllJobs(jobs).build();
        ClientEvent clientEvent = ClientEvent.newBuilder().setRequestId(requestId).setEventId(eventId).setCreateTime(createTime).setJobEvent(jobEvent).build();
        CreateClientEventRequest request = CreateClientEventRequest.newBuilder().setParent(parent.toString()).setClientEvent(clientEvent).build();
        ClientEvent response = eventServiceClient.createClientEvent(request);
        System.out.println("Created client event. ");
        System.out.println(response.toString());
    }
}
Also used : JobEvent(com.google.cloud.talent.v4beta1.JobEvent) CreateClientEventRequest(com.google.cloud.talent.v4beta1.CreateClientEventRequest) TenantName(com.google.cloud.talent.v4beta1.TenantName) Timestamp(com.google.protobuf.Timestamp) EventServiceClient(com.google.cloud.talent.v4beta1.EventServiceClient) ClientEvent(com.google.cloud.talent.v4beta1.ClientEvent)

Example 18 with TenantName

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

Example 19 with TenantName

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

the class JobSearchCreateJob method createJob.

// Create a job.
public static void createJob(String projectId, String tenantId, String companyId, String requisitionId, String jobApplicationUrl) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addUris(jobApplicationUrl).build();
        List<String> addresses = Arrays.asList("1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011");
        // By default, job will expire in 30 days.
        // https://cloud.google.com/talent-solution/job-search/docs/jobs
        Job job = Job.newBuilder().setCompany(companyId).setRequisitionId(requisitionId).setTitle("Software Developer").setDescription("Develop, maintain the software solutions.").setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode("en-US").build();
        CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
        Job response = jobServiceClient.createJob(request);
        System.out.format("Created job: %s%n", response.getName());
    }
}
Also used : TenantName(com.google.cloud.talent.v4beta1.TenantName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest)

Example 20 with TenantName

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

the class JobSearchDeleteTenant method deleteTenant.

// Delete Tenant.
public static void deleteTenant(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);
        DeleteTenantRequest request = DeleteTenantRequest.newBuilder().setName(name.toString()).build();
        tenantServiceClient.deleteTenant(request);
        System.out.println("Deleted Tenant.");
    }
}
Also used : TenantServiceClient(com.google.cloud.talent.v4beta1.TenantServiceClient) TenantName(com.google.cloud.talent.v4beta1.TenantName) DeleteTenantRequest(com.google.cloud.talent.v4beta1.DeleteTenantRequest)

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