Create a client with HTTP/JSON transport

Initialize an Admin client configured to use the HTTP/JSON transport protocol instead of the default gRPC. This is useful for environments where gRPC is not supported or is blocked, such as certain web proxies or firewalls.

Code sample

Java

To authenticate to AlloyDB, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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);
  }
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.