빠른 시작: 클라이언트 라이브러리 사용
이 페이지에서는 선호하는 프로그래밍 언어로 Policy Controller API를 시작하는 방법을 보여줍니다.
시작하기 전에
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Policy Controller API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Policy Controller API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.
클라이언트 라이브러리 설치
C#
C# 개발 환경 설정에 관한 자세한 내용은 C# 개발 환경 설정 가이드를 참조하세요.
Install-Package Google.Cloud.PubSub.V1 -Pre
Go
go get cloud.google.com/go/pubsub
Java
자바 개발 환경 설정에 관한 자세한 내용은 자바 개발 환경 설정 가이드를 참조하세요.
If you are using Maven, add
the following to your pom.xml
file. For more information about
BOMs, see The Google Cloud Platform Libraries BOM.
If you are using Gradle, add the following to your dependencies:
If you are using sbt, add the following to your dependencies:
If you're using Visual Studio Code, 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
Node.js 개발 환경 설정에 관한 자세한 내용은 Node.js 개발 환경 설정 가이드를 참조하세요.
npm install --save @google-cloud/pubsub
PHP
composer require google/cloud-pubsub
Python
Python 개발 환경 설정에 관한 자세한 내용은 Python 개발 환경 설정 가이드를 참조하세요.
pip install --upgrade google-cloud-pubsub
Ruby
Ruby 개발 환경 설정에 관한 자세한 내용은 Ruby 개발 환경 설정 가이드를 참조하세요.
gem install google-cloud-pubsub
작업 실행
이제 정책 컨트롤러를 사용하여 작업을 수행할 수 있습니다. 다음 코드를 실행하여 첫 번째 작업을 수행하세요.
C#
자세한 내용은 정책 컨트롤러 C# API 참조 문서를 참조하세요.
정책 컨트롤러에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Go
자세한 내용은 정책 컨트롤러 Go API 참고 문서를 참조하세요.
정책 컨트롤러에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Java
자세한 내용은 정책 컨트롤러 Java API 참고 문서를 참조하세요.
정책 컨트롤러에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Node.js
자세한 내용은 정책 컨트롤러 Node.js API 참고 문서를 참조하세요.
정책 컨트롤러에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
PHP
자세한 내용은 정책 컨트롤러 PHP API 참고 문서를 참조하세요.
정책 컨트롤러에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Python
자세한 내용은 정책 컨트롤러 Python API 참고 문서를 참조하세요.
정책 컨트롤러에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Ruby
자세한 내용은 정책 컨트롤러 Ruby API 참고 문서를 참조하세요.
정책 컨트롤러에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
어땠나요?
삭제
이 빠른 시작에서 사용한 리소스 비용이 Google 계정에 청구되지 않도록 하려면 다음 단계를 따르세요.
- Google Cloud 콘솔에서 필요하지 않은 프로젝트를 삭제합니다.
다음 단계
정책 컨트롤러 API 클라이언트 라이브러리에 대해 자세히 알아보기