本页面将介绍如何开始使用 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 身份验证文档。
通过设置环境变量 GOOGLE_APPLICATION_CREDENTIALS
向应用代码提供身份验证凭据。此变量仅适用于当前的 Shell 会话。如果您希望变量应用于未来的 Shell 会话,请在 shell 启动文件中设置变量,例如在 ~/.bashrc
或 ~/.profile
文件中。
Linux 或 macOS
export GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH
"
将 KEY_PATH
替换为包含凭据的 JSON 文件的路径。
例如:
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json"
Windows
对于 PowerShell:
$env:GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH
"
将 KEY_PATH
替换为包含凭据的 JSON 文件的路径。
例如:
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\service-account-file.json"
对于命令提示符:
set GOOGLE_APPLICATION_CREDENTIALS=KEY_PATH
将 KEY_PATH
替换为包含凭据的 JSON 文件的路径。
使用客户端库
以下示例展示了如何使用客户端库。
C#
Go
Java
Node.js
PHP
Python
Ruby