시작하기 전에(v3)

설정

데이터 로깅에 Google Cloud Platform 프로젝트(GCP 프로젝트)를 등록하려면 다음 단계를 따르세요.

  1. GCP 콘솔로 이동합니다.
    Google Cloud 프로젝트를 아직 설정하지 않았으면 프로젝트를 만들어야 합니다.
  2. GCP 대시보드에서 Cloud Talent Solution의 프로젝트 설정으로 이동합니다. 왼쪽 상단 모서리에 있는 햄버거 아이콘을 클릭하고 아래로 스크롤하여 인공지능에서 Talent Solution을 선택하여 탐색 메뉴를 표시합니다.

    드롭다운 메뉴에서 프로젝트를 선택합니다.
  3. 이 Google Cloud 프로젝트와 연결된 결제 계정이 없으면 먼저 결제 계정을 설정한 다음 이 Google Cloud 프로젝트로 연결하라는 메시지가 표시됩니다. Google Cloud 프로젝트 소유자이고 결제 계정 소유자인 사용자만 해당 프로젝트에 연결할 수 있습니다.
    1. 결제 사용 설정을 클릭합니다.

      프로젝트의 결제 사용 설정 대화상자가 나타납니다.
    2. 결제 계정 만들기를 클릭합니다. 결제 계정 만들기, 수정 또는 닫기를 참조하세요.
  4. API 사용 설정
    사용 설정을 클릭합니다.

  5. 대시보드 페이지가 나타납니다.
    데이터 로깅 탭을 클릭합니다.

  6. 데이터 로깅 선택 페이지가 표시됩니다. 이 페이지에 나와 있는 약관에 동의하면 다양한 API 기능을 사용할 수 있습니다. 해당 약관에 동의하지 않으면 API 요청 삭제만 사용할 수 있습니다.

    사용 설정을 클릭합니다.

    확인 페이지가 표시됩니다.
  7. 확인 페이지에서 계속을 클릭합니다.


    서비스 계정 연결 뷰가 표시됩니다.

  8. 서비스 계정 연결
    Google Cloud 프로젝트용으로 생성된 서비스 계정이 이미 있으면 여기에 관련 목록이 표시됩니다. 그렇지 않으면 서비스 계정 관리를 클릭합니다. 안내는 서비스 계정 만들기를 참조하세요.



    서비스 계정을 만들 때 새 비공개 키 제공 체크박스도 선택합니다. 새 JSON 사용자 인증 정보 파일이 자동으로 다운로드됩니다. 이 파일을 서버의 특정 위치에 저장하고 안내에 따라 GOOGLE_APPLICATION_CREDENTIALS 환경 변수가 이 파일을 가리키도록 설정합니다. 이 단계는 Cloud Talent Solution에 대한 요청을 인증하는 필수 단계입니다.

  9. 서비스 계정을 만든 후 Cloud Talent Solution 왼쪽에 있는 탐색 탭으로 다시 이동합니다. 이제 생성된 서비스 계정이 표시됩니다. 연결을 클릭하여 이 계정을 Cloud Talent Solution에 연결합니다.

  10. 이제 계정이 연결되었습니다.
    완료를 클릭하여 계속 진행합니다.

  11. 이제 Cloud Talent Solution을 시스템에 통합할 수 있습니다.

  12. 환경에 프로젝트 ID를 설정합니다.

    Linux 또는 macOS

    export GOOGLE_CLOUD_PROJECT="your-project-id"

    Windows

    PowerShell:

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

    명령 프롬프트:

    set GOOGLE_CLOUD_PROJECT="your-project-id"
  13. 그런 다음, 회사 및 채용정보 만들기 빠른 시작으로 이동하여 Cloud Talent Solution 통합을 시작합니다.

클라이언트 라이브러리 설치

Java

Cloud Talent Solution 클라이언트 설치 및 생성에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.

Maven을 사용하는 경우 pom.xml 파일에 다음을 추가합니다.

  <dependency>
      <groupId>com.google.apis</groupId>
      <artifactId>google-api-services-jobs</artifactId>
      <version>LATEST</version>
  </dependency>
  

Python

Cloud Talent Solution 클라이언트 설치 및 생성에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.

pip install --upgrade google-api-python-client

Node.js

Cloud Talent Solution 클라이언트 설치 및 생성에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.

npm install --save googleapis

Go

Cloud Talent Solution 클라이언트 설치 및 생성에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.

go get google.golang.org/api/jobs/v3

요청하기

Java

Cloud Talent Solution 클라이언트 설치 및 생성에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.


private static final JsonFactory JSON_FACTORY = new GsonFactory();
private static final NetHttpTransport NET_HTTP_TRANSPORT = new NetHttpTransport();
private static final String DEFAULT_PROJECT_ID =
    "projects/" + System.getenv("GOOGLE_CLOUD_PROJECT");

private static CloudTalentSolution talentSolutionClient =
    createTalentSolutionClient(generateCredential());

private static CloudTalentSolution createTalentSolutionClient(GoogleCredentials credential) {
  String url = "https://jobs.googleapis.com";

  HttpRequestInitializer requestInitializer =
      request -> {
        new HttpCredentialsAdapter(credential).initialize(request);
        request.setConnectTimeout(60000); // 1 minute connect timeout
        request.setReadTimeout(60000); // 1 minute read timeout
      };

  return new CloudTalentSolution.Builder(NET_HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
      .setApplicationName("JobServiceClientSamples")
      .setRootUrl(url)
      .build();
}

private static GoogleCredentials generateCredential() {
  try {
    // Credentials could be downloaded after creating service account
    // set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, for example:
    // export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/key.json
    return GoogleCredentials.getApplicationDefault()
        .createScoped(Collections.singleton(CloudTalentSolutionScopes.JOBS));
  } catch (Exception e) {
    System.out.println("Error in generating credential");
    throw new RuntimeException(e);
  }
}

public static CloudTalentSolution getTalentSolutionClient() {
  return talentSolutionClient;
}

public static void main(String... args) throws Exception {
  try {
    ListCompaniesResponse listCompaniesResponse =
        talentSolutionClient.projects().companies().list(DEFAULT_PROJECT_ID).execute();
    System.out.println("Request Id is " + listCompaniesResponse.getMetadata().getRequestId());
    if (listCompaniesResponse.getCompanies() != null) {
      for (Company company : listCompaniesResponse.getCompanies()) {
        System.out.println(company.getName());
      }
    }
  } catch (IOException e) {
    System.out.println("Got exception while listing companies");
    throw e;
  }
}

Python

Cloud Talent Solution 클라이언트 설치 및 생성에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.

import os

from googleapiclient.discovery import build
from googleapiclient.errors import Error

client_service = build("jobs", "v3")

def run_sample():
    try:
        project_id = "projects/" + os.environ["GOOGLE_CLOUD_PROJECT"]
        response = (
            client_service.projects().companies().list(parent=project_id).execute()
        )
        print("Request Id: %s" % response.get("metadata").get("requestId"))
        print("Companies:")
        if response.get("companies") is not None:
            for company in response.get("companies"):
                print("%s" % company.get("name"))
        print("")

    except Error as e:
        print("Got exception while listing companies")
        raise e

if __name__ == "__main__":
    run_sample()

Go

Cloud Talent Solution 클라이언트 설치 및 생성에 대한 자세한 내용은 Cloud Talent Solution 클라이언트 라이브러리를 참조하세요.


// Command quickstart is an example of using the Google Cloud Talent Solution API.
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"golang.org/x/oauth2/google"
	talent "google.golang.org/api/jobs/v3"
)

func main() {
	projectID := os.Getenv("GOOGLE_CLOUD_PROJECT")
	parent := fmt.Sprintf("projects/%s", projectID)

	// Authorize the client using Application Default Credentials.
	// See https://g.co/dv/identity/protocols/application-default-credentials
	ctx := context.Background()
	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
	if err != nil {
		log.Fatal(err)
	}

	// Create the jobs service client.
	ctsService, err := talent.New(client)
	if err != nil {
		log.Fatal(err)
	}

	// Make the RPC call.
	response, err := ctsService.Projects.Companies.List(parent).Do()
	if err != nil {
		log.Fatalf("Failed to list Companies: %v", err)
	}

	// Print the request id.
	fmt.Printf("Request ID: %q\n", response.Metadata.RequestId)

	// Print the returned companies.
	for _, company := range response.Companies {
		fmt.Printf("Company: %q\n", company.Name)
	}
}