使用客户端获取职位。
包含此代码示例的文档页面
如需查看上下文中使用的代码示例,请参阅以下文档:
代码示例
C#
public static object GetJob(string projectId, string tenantId, string jobId)
{
JobServiceClient jobServiceClient = JobServiceClient.Create();
JobName jobName = JobName.FromProjectTenantJob(projectId, tenantId, jobId);
GetJobRequest request = new GetJobRequest
{
JobName = jobName
};
var response = jobServiceClient.GetJob(request);
Console.WriteLine($"Job name: {response.Name}");
Console.WriteLine($"Requisition ID: {response.RequisitionId}");
Console.WriteLine($"Title: {response.Title}");
Console.WriteLine($"Description: {response.Description}");
Console.WriteLine($"Posting language: {response.LanguageCode}");
foreach (string address in response.Addresses)
{
Console.WriteLine($"Address: {address}");
}
foreach (string email in response.ApplicationInfo.Emails)
{
Console.WriteLine($"Email: {email}");
}
foreach (string websiteUri in response.ApplicationInfo.Uris)
{
Console.WriteLine($"Website: {websiteUri}");
}
return 0;
}
Java
import com.google.cloud.talent.v4beta1.GetJobRequest;
import com.google.cloud.talent.v4beta1.Job;
import com.google.cloud.talent.v4beta1.JobName;
import com.google.cloud.talent.v4beta1.JobServiceClient;
import java.io.IOException;
public class JobSearchGetJob {
public static void getJob() throws IOException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "your-project-id";
String tenantId = "your-tenant-id";
String jobId = "your-job-id";
getJob(projectId, tenantId, jobId);
}
// Get Job.
public static void getJob(String projectId, String tenantId, String jobId) throws IOException {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId);
GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();
Job response = jobServiceClient.getJob(request);
System.out.format("Job name: %s%n", response.getName());
System.out.format("Requisition ID: %s%n", response.getRequisitionId());
System.out.format("Title: %s%n", response.getTitle());
System.out.format("Description: %s%n", response.getDescription());
System.out.format("Posting language: %s%n", response.getLanguageCode());
for (String address : response.getAddressesList()) {
System.out.format("Address: %s%n", address);
}
for (String email : response.getApplicationInfo().getEmailsList()) {
System.out.format("Email: %s%n", email);
}
for (String websiteUri : response.getApplicationInfo().getUrisList()) {
System.out.format("Website: %s%n", websiteUri);
}
}
}
}