Job mit Client abrufen (v4beta1)

Job mit Client abrufen.

Dokumentationsseiten mit diesem Codebeispiel

Das Codebeispiel im Kontext finden Sie in der folgenden Dokumentation:



import (

	talent ""
	talentpb ""

// getJob gets an existing job by its resource name.
func getJob(w io.Writer, projectID, jobID string) (*talentpb.Job, error) {
	ctx := context.Background()

	// Initialize a jobService client.
	c, err := talent.NewJobClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewJobClient: %v", err)
	defer c.Close()

	// Construct a getJob request.
	jobName := fmt.Sprintf("projects/%s/jobs/%s", projectID, jobID)
	req := &talentpb.GetJobRequest{
		// The resource name of the job to retrieve.
		// The format is "projects/{project_id}/jobs/{job_id}".
		Name: jobName,

	resp, err := c.GetJob(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("GetJob: %v", err)

	fmt.Fprintf(w, "Job: %q\n", resp.GetName())
	fmt.Fprintf(w, "Job title: %v\n", resp.GetTitle())

	return resp, err


 * Please include the following imports to run this sample.
 * import;
 * import;
 * import;
 * import;
 * import;

public static void sampleGetJob() {
  // TODO(developer): Replace these variables before running the sample.
  String projectId = "Your Google Cloud Project ID";
  String tenantId = "Your Tenant ID (using tenancy is optional)";
  String jobId = "Job ID";
  sampleGetJob(projectId, tenantId, jobId);

/** Get Job */
public static void sampleGetJob(String projectId, String tenantId, String jobId) {
  try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
    JobName name = JobWithTenantName.of(projectId, tenantId, jobId);
    GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();
    Job response = jobServiceClient.getJob(request);
    System.out.printf("Job name: %s\n", response.getName());
    System.out.printf("Requisition ID: %s\n", response.getRequisitionId());
    System.out.printf("Title: %s\n", response.getTitle());
    System.out.printf("Description: %s\n", response.getDescription());
    System.out.printf("Posting language: %s\n", response.getLanguageCode());
    for (String address : response.getAddressesList()) {
      System.out.printf("Address: %s\n", address);
    for (String email : response.getApplicationInfo().getEmailsList()) {
      System.out.printf("Email: %s\n", email);
    for (String websiteUri : response.getApplicationInfo().getUrisList()) {
      System.out.printf("Website: %s\n", websiteUri);
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);


const talent = require('@google-cloud/talent').v4;

/** Get Job */
function sampleGetJob(projectId, tenantId, jobId) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const jobId = 'Job ID';
  const formattedName = client.jobPath(projectId, tenantId, jobId);
    .getJob({name: formattedName})
    .then(responses => {
      const response = responses[0];
      console.log(`Job name: ${}`);
      console.log(`Requisition ID: ${response.requisitionId}`);
      console.log(`Title: ${response.title}`);
      console.log(`Description: ${response.description}`);
      console.log(`Posting language: ${response.languageCode}`);
      for (const address of response.addresses) {
        console.log(`Address: ${address}`);
      for (const email of response.applicationInfo.emails) {
        console.log(`Email: ${email}`);
      for (const websiteUri of response.applicationInfo.uris) {
        console.log(`Website: ${websiteUri}`);
    .catch(err => {


from import talent
import six

def get_job(project_id, tenant_id, job_id):
    """Get Job"""

    client = talent.JobServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # job_id = 'Job ID'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(job_id, six.binary_type):
        job_id = job_id.decode("utf-8")
    name = client.job_path(project_id, tenant_id, job_id)

    response = client.get_job(name=name)
    print(f"Job name: {}")
    print(f"Requisition ID: {response.requisition_id}")
    print(f"Title: {response.title}")
    print(f"Description: {response.description}")
    print(f"Posting language: {response.language_code}")
    for address in response.addresses:
        print(f"Address: {address}")
    for email in response.application_info.emails:
        print(f"Email: {email}")
    for website_uri in response.application_info.uris:
        print(f"Website: {website_uri}")

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.