0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[BigQuery API(V2)] Javaでサービスアカウントのメールアドレスを取得する

Posted at

BigQuery API V2(Java)を使用して、
Google Cloud KMSとのやり取りに使用されるプロジェクトのサービスアカウントを
取得する方法についてご紹介します。

APIを利用する環境の準備から始める場合や、コードを実行する際は、
⧉[BigQuery API(V2)] JavaでBigQueryを使う
を参照ください。

No 目次
1 メールアドレスを取得
1 スコープ
2 実行
3 レスポンスの内容

1. メールアドレスを取得

GoogleCloud KMSとのやり取りに使用されるプロジェクトのサービスアカウントを取得します。

1.1. スコープ

このAPIを実行するには、以下のいずれかのスコープを指定してください。

BigqueryScopes.BIGQUERY
BigqueryScopes.CLOUD_PLATFORM
BigqueryScopes.CLOUD_PLATFORM_READ_ONLY
https://www.googleapis.com/auth/bigquery.readonly

権限付与に関しては
⧉[BigQuery API(V2)] JavaでBigQueryを使う(2.権限付与)
を参照ください。

1.2. 実行

public static void main(String[] args) throws Exception{
    Bigquery bigquery = getBigquery();
    Bigquery.Projects projects = bigquery.projects();
    
    Bigquery.Projects.GetServiceAccount account = projects.getServiceAccount("プロジェクトID");
    
    GetServiceAccountResponse res = account.execute();
    System.out.println(res);
}

1.2.1. HTTPリクエスト

GET: https://bigquery.googleapis.com/bigquery/v2/projects/{プロジェクトID}/serviceAccount
が実行されます。

1.2.2. クエリパラメータ

クエリパラメータはありません。

1.3. レスポンスの内容

GetServiceAccountResponse

メソッド 戻り値 説明
getKind String リソースの種類
固定文字列:"bigquery#getServiceAccountResponse"
getEmail String サービスアカウントのメールアドレス


おしまい。。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?