HTTP/JSON トランスポートを使用してクライアントを作成する

デフォルトの gRPC ではなく、HTTP/JSON トランスポート プロトコルを使用するように構成された管理クライアントを初期化します。これは、特定のウェブ プロキシやファイアウォールなど、gRPC がサポートされていない環境やブロックされている環境で役立ちます。

コードサンプル

Java

AlloyDB に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

import com.google.cloud.alloydb.v1.AlloyDBCSQLAdminClient;
import com.google.cloud.alloydb.v1.AlloyDBCSQLAdminSettings;

public class SyncCreateUseHttpJsonTransport {

  public static void main(String[] args) throws Exception {
    syncCreateUseHttpJsonTransport();
  }

  public static void syncCreateUseHttpJsonTransport() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    AlloyDBCSQLAdminSettings alloyDBCSQLAdminSettings =
        AlloyDBCSQLAdminSettings.newHttpJsonBuilder().build();
    AlloyDBCSQLAdminClient alloyDBCSQLAdminClient =
        AlloyDBCSQLAdminClient.create(alloyDBCSQLAdminSettings);
  }
}

次のステップ

他の Google Cloud プロダクトのコードサンプルを検索およびフィルタするには、Google Cloud サンプル ブラウザをご覧ください。