Before You Begin

Set up

To enroll your Google Cloud Platform project (GCP Project) in data logging, follow these steps:

  1. Go to the GCP Console.
    If you don’t already have a Google Cloud Project set up, you must create a project.
  2. Go to your project settings for Cloud Talent Solution in the GCP Dashboard. To view navigation, click the hamburger icon in the upper left-hand corner and scroll down to select Talent Solution under Artificial Intelligence.

    Select your project from the drop down.
  3. If you don't already have a billing account associated with this Google Cloud Project, you are prompted to first set up a billing account and then link it to this Google Cloud Project. Note that only a person who is the owner of the Google Cloud Project and the owner of the billing account can link them.
    1. Click Enable billing.

      The Enable billing for project dialog box appears.
    2. Click CREATE BILLING ACCOUNT. See Create, Modify, or Close Your Billing Account.
  4. Enable API
    Click ENABLE.

  5. The dashboard page appears.
    Click the DATA LOGGING tab.

  6. The data logging opt-in page appears. Accepting the terms outlined on this page allows you to use the various API features. By not accepting these terms, you'll only be able to use deletion API requests.

    Click ENABLE.

    The confirmation page appears.
  7. Click CONTINUE on the confirmation page.


    The Connect service accounts view appears.

  8. Connect service accounts
    If you already have service accounts created for your Google Cloud project, you’ll see a list of them here, otherwise, click MANAGE SERVICE ACCOUNTS. See Creating a service account for instructions.



    When creating the service account, also check the box Furnish a new private key. A new JSON credential file is automatically downloaded. Store this file in a specific location on the server, and follow the instructions to set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to this file. This is an essential step for authenticating requests to Cloud Talent Solution.

  9. After creating the service account, navigate back to the Cloud Talent Solution left-nav tab. The service account you’ve created now appears. Click CONNECT to link this account to Cloud Talent Solution.

  10. The account is now connected.
    Click DONE to proceed.

  11. You’re now ready to begin integrating Cloud Talent Solution into your system.

  12. Set your project id to environment.

    LINUX OR MACOS

    export GOOGLE_CLOUD_PROJECT="your-project-id"

    WINDOWS

    With PowerShell:

    $env:GOOGLE_CLOUD_PROJECT="your-project-id"

    With command prompt:

    set GOOGLE_CLOUD_PROJECT="your-project-id"
  13. Next, go to the Create companies and jobs quickstart, to start integrating Cloud Talent Solution.

Installing the client library

Go

go get -u google.golang.org/api/jobs/v4

Java

For more information, see Setting Up a Java Development Environment. If you are using Maven, add the following to your pom.xml file:
<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-talent</artifactId>
  <version>0.13.0-beta</version>
</dependency>
If you are using Gradle, add the following to your dependencies:
compile 'com.google.cloud:google-cloud-talent:0.13.0-beta'
If you are using SBT, add the following to your dependencies:
libraryDependencies += "com.google.cloud" % "google-cloud-talent" % "0.13.0-beta"

If you're using IntelliJ or Eclipse, you can add client libraries to your project using the following IDE plugins:

The plugins provide additional functionality, such as key management for service accounts. Refer to each plugin's documentation for details.

Node.js

For more information, see Setting Up a Node.js Development Environment.
npm install --save google-cloud

PHP

composer require google/cloud

Python

For more information, see Setting Up a Python Development Environment.
pip install --upgrade google-cloud

Ruby

For more information, see Setting Up a Ruby Development Environment.
gem install google-cloud

Make a request

Go

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	talentpb "google.golang.org/genproto/googleapis/cloud/talent/v4beta1"
)

// createCompany creates a company as given.
func createCompany(w io.Writer, projectID, externalID, displayName string) (*talentpb.Company, error) {
	ctx := context.Background()

	// Initializes a companyService client.
	c, err := talent.NewCompanyClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewCompanyClient: %v", err)
	}

	// Construct a createCompany request.
	req := &talentpb.CreateCompanyRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		Company: &talentpb.Company{
			ExternalId:  externalID,
			DisplayName: displayName,
		},
	}

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

	fmt.Fprintf(w, "Created company: %q\n", resp.GetName())

	return resp, nil
}

Java

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.talent.v4beta1.Company;
 * import com.google.cloud.talent.v4beta1.CompanyServiceClient;
 * import com.google.cloud.talent.v4beta1.CreateCompanyRequest;
 * import com.google.cloud.talent.v4beta1.TenantName;
 * import com.google.cloud.talent.v4beta1.TenantOrProjectName;
 */

/**
 * 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()) {
    // projectId = "Your Google Cloud Project ID";
    // tenantId = "Your Tenant ID (using tenancy is optional)";
    // displayName = "My Company Name";
    // externalId = "Identifier of this company in my system";
    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);
  }
}

Node.js

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

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

/**
 * Create Company
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenant
 */
function sampleCreateCompany(projectId, tenantId, displayName, externalId) {
  const client = new talent.CompanyServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const displayName = 'My Company Name';
  // const externalId = 'Identifier of this company in my system';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const company = {
    displayName: displayName,
    externalId: externalId,
  };
  const request = {
    parent: formattedParent,
    company: company,
  };
  client.createCompany(request)
    .then(responses => {
      const response = responses[0];
      console.log(`Created Company`);
      console.log(`Name: ${response.name}`);
      console.log(`Display Name: ${response.displayName}`);
      console.log(`External ID: ${response.externalId}`);
    })
    .catch(err => {
      console.error(err);
    });
}

PHP

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Talent\V4beta1\CompanyServiceClient;
use Google\Cloud\Talent\V4beta1\Company;

/**
 * Create Company.
 *
 * @param string $projectId Your Google Cloud Project ID
 * @param string $tenantId  Identifier of the Tenant
 */
function sampleCreateCompany($projectId, $tenantId, $displayName, $externalId)
{

    $companyServiceClient = new CompanyServiceClient();

    // $projectId = 'Your Google Cloud Project ID';
    // $tenantId = 'Your Tenant ID (using tenancy is optional)';
    // $displayName = 'My Company Name';
    // $externalId = 'Identifier of this company in my system';
    $formattedParent = $companyServiceClient->tenantName($projectId, $tenantId);
    $company = new Company();
    $company->setDisplayName($displayName);
    $company->setExternalId($externalId);

    try {
        $response = $companyServiceClient->createCompany($formattedParent, $company);
        printf('Created Company'.PHP_EOL);
        printf('Name: %s'.PHP_EOL, $response->getName());
        printf('Display Name: %s'.PHP_EOL, $response->getDisplayName());
        printf('External ID: %s'.PHP_EOL, $response->getExternalId());
    } finally {
        $companyServiceClient->close();
    }

}

Python

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

from google.cloud import talent_v4beta1
import six


def sample_create_company(project_id, tenant_id, display_name, external_id):
    """Create Company"""

    client = talent_v4beta1.CompanyServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # display_name = 'My Company Name'
    # external_id = 'Identifier of this company in my system'

    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(display_name, six.binary_type):
        display_name = display_name.decode('utf-8')
    if isinstance(external_id, six.binary_type):
        external_id = external_id.decode('utf-8')
    parent = client.tenant_path(project_id, tenant_id)
    company = {'display_name': display_name, 'external_id': external_id}

    response = client.create_company(parent, company)
    print('Created Company')
    print('Name: {}'.format(response.name))
    print('Display Name: {}'.format(response.display_name))
    print('External ID: {}'.format(response.external_id))


Ruby

For more on installing and creating a Cloud Talent Solution client, see Cloud Talent Solution Client Libraries.

 # Create Company
 #
 # @param project_id {String} Your Google Cloud Project ID
 # @param tenant_id {String} Identifier of the Tenant
def sample_create_company(project_id, tenant_id, display_name, external_id)
  # Instantiate a client
  company_client = Google::Cloud::Talent::CompanyService.new version: :v4beta1

  # project_id = "Your Google Cloud Project ID"
  # tenant_id = "Your Tenant ID (using tenancy is optional)"
  # display_name = "My Company Name"
  # external_id = "Identifier of this company in my system"
  formatted_parent = company_client.class.tenant_path(project_id, tenant_id)
  company = { display_name: display_name, external_id: external_id }

  response = company_client.create_company(formatted_parent, company)
  puts "Created Company"
  puts "Name: #{response.name}"
  puts "Display Name: #{response.display_name}"
  puts "External ID: #{response.external_id}"

end

Var denne siden nyttig? Si fra hva du synes:

Send tilbakemelding om ...

Job search documentation