本页面将介绍如何开始使用 BigQuery Data Transfer API 的 Cloud 客户端库。如需详细了解 Cloud API 的客户端库(包括旧版 Google API 客户端库),请参阅客户端库说明。
安装客户端库
C#
如需了解详情,请参阅设置 C# 开发环境。
Install-Package Google.Cloud.BigQuery.DataTransfer.V1 -Pre
Go
如需了解详情,请参阅设置 Go 开发环境。
go get cloud.google.com/go/bigquery/datatransfer/apiv1
Java
如需了解详情,请参阅设置 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 开发环境。
npm install --save @google-cloud/bigquery-data-transfer
PHP
如需了解详情,请参阅在 Google Cloud 上使用 PHP。
composer require google/cloud-bigquerydatatransfer
Python
如需了解详情,请参阅设置 Python 开发环境。
pip install --upgrade google-cloud-bigquery-datatransfer
Ruby
如需了解详情,请参阅设置 Ruby 开发环境。
gem install google-cloud-bigquery-data_transfer
设置身份验证
要运行客户端库,必须先通过创建服务帐号并设置环境变量来设置身份验证。完成以下步骤即可设置身份验证。如需了解其他身份验证方法,请参阅 GCP 身份验证文档。
Provide authentication credentials to your application code by setting the
environment variable GOOGLE_APPLICATION_CREDENTIALS
. This
variable applies only to your current shell session. If you want the variable
to apply to future shell sessions, set the variable in your shell startup file,
for example in the ~/.bashrc
or ~/.profile
file.
Linux 或 macOS
export GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH
"
Replace KEY_PATH
with the path of the JSON file that contains your credentials.
For example:
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json"
Windows
For PowerShell:
$env:GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH
"
Replace KEY_PATH
with the path of the JSON file that contains your credentials.
For example:
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\service-account-file.json"
For command prompt:
set GOOGLE_APPLICATION_CREDENTIALS=KEY_PATH
Replace KEY_PATH
with the path of the JSON file that contains your credentials.
使用客户端库
以下示例展示了如何使用客户端库。
C#
Go
Java
Node.js
PHP
Python
Ruby