Cloud Deploy 클라이언트 라이브러리

이 페이지에서는 Cloud Deploy API용 Cloud 클라이언트 라이브러리를 시작하는 방법을 설명합니다. 하지만 Google App Engine 표준 환경에서 실행 중인 경우 이전 Google API 클라이언트 라이브러리를 사용하는 것이 좋습니다. 클라이언트 라이브러리 설명에서 Cloud API용 클라이언트 라이브러리에 대해 자세히 알아보세요.

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

C++

이 클라이언트 라이브러리 요구사항 및 설치 종속 항목에 대한 자세한 내용은 C++ 개발 환경 설정을 참조하세요.

C#

자세한 내용은 C# 개발 환경 설정을 참조하세요.

Install-Package Google.Cloud.Deploy.V1 -Pre

Go

자세한 내용은 Go 개발 환경 설정을 참조하세요.

go get cloud.google.com/go/storage

Java

자세한 내용은 자바 개발 환경 설정을 참조하세요.

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

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-deploy</artifactId>
    <version></version>
</dependency>

Gradle을 사용하는 경우 종속 항목에 다음을 추가합니다.

compile group: 'com.google.cloud', name: 'google-cloud-deploy', version: ''

Node.js

자세한 내용은 Node.js 개발 환경 설정을 참조하세요.

npm install --save @google-cloud/deploy

PHP

자세한 내용은 Google Cloud에서 PHP 사용을 참조하세요.

composer require google/cloud-deploy

Python

자세한 내용은 Python 개발 환경 설정을 참조하세요.

pip install --upgrade google-cloud-deploy

Ruby

자세한 내용은 Ruby 개발 환경 설정을 참조하세요.

gem install google-cloud-deploy

인증 설정

클라이언트 라이브러리를 사용할 때는 애플리케이션 기본 사용자 인증 정보(ADC)를 사용하여 인증합니다. ADC 설정은 애플리케이션 기본 사용자 인증 정보에 대한 사용자 인증 정보 제공을 참조하세요. 클라이언트 라이브러리에서 ADC를 사용하는 방법은 클라이언트 라이브러리를 사용하여 인증을 참조하세요.

클라이언트 라이브러리 사용

다음 예시에서는 클라이언트 라이브러리를 사용하는 방법을 보여줍니다.

C++

Cloud Deploy에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


#include "google/cloud/deploy/v1/cloud_deploy_client.h"
#include "google/cloud/location.h"
#include <iostream>

int main(int argc, char* argv[]) try {
  if (argc != 3) {
    std::cerr << "Usage: " << argv[0] << " project-id location-id\n";
    return 1;
  }

  auto const location = google::cloud::Location(argv[1], argv[2]);

  namespace deploy = ::google::cloud::deploy_v1;
  auto client = deploy::CloudDeployClient(deploy::MakeCloudDeployConnection());

  for (auto dp : client.ListDeliveryPipelines(location.FullName())) {
    if (!dp) throw std::move(dp).status();
    std::cout << dp->DebugString() << "\n";
  }

  return 0;
} catch (google::cloud::Status const& status) {
  std::cerr << "google::cloud::Status thrown: " << status << "\n";
  return 1;
}

Node.js

Cloud Deploy에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The parent, which owns this collection of pipelines. Format must be
 *  projects/{project_id}/locations/{location_name}.
 */
// const parent = 'abc123'
/**
 *  The maximum number of pipelines to return. The service may return
 *  fewer than this value. If unspecified, at most 50 pipelines will
 *  be returned. The maximum value is 1000; values above 1000 will be set
 *  to 1000.
 */
// const pageSize = 1234
/**
 *  A page token, received from a previous `ListDeliveryPipelines` call.
 *  Provide this to retrieve the subsequent page.
 *  When paginating, all other provided parameters match
 *  the call that provided the page token.
 */
// const pageToken = 'abc123'
/**
 *  Filter builds to be returned. See https://google.aip.dev/160 for more
 *  details.
 */
// const filter = 'abc123'
/**
 *  Field to sort by. See https://google.aip.dev/132#ordering for more details.
 */
// const orderBy = 'abc123'

// Imports the Deploy library
const {CloudDeployClient} = require('@google-cloud/deploy').v1;

// Instantiates a client
const deployClient = new CloudDeployClient();

async function listDeliveryPipelines() {
  // Construct request
  const request = {
    parent,
  };

  // Run request
  const iterable = await deployClient.listDeliveryPipelinesAsync(request);
  for await (const response of iterable) {
    console.log(response);
  }
}

listDeliveryPipelines();

추가 리소스