Criar um cliente com transporte HTTP/JSON

Inicialize um cliente de administrador configurado para usar o protocolo de transporte HTTP/JSON em vez do gRPC padrão. Isso é útil para ambientes em que o gRPC não é compatível ou está bloqueado, como alguns proxies da Web ou firewalls.

Exemplo de código

Java

Para autenticar no AlloyDB, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.

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

A seguir

Para pesquisar e filtrar exemplos de código de outros Google Cloud produtos, consulte a Google Cloud pesquisa de exemplos de código.