Set a custom API endpoint

This snippet shows how to initialize the client library with a custom API endpoint. You can use this to direct requests to a specific regional endpoint or for testing against a local mock server.

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.AlloyDBAdminClient;
import com.google.cloud.alloydb.v1.AlloyDBAdminSettings;
import com.google.cloud.alloydb.v1.myEndpoint;

public class SyncCreateSetEndpoint {

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

  public static void syncCreateSetEndpoint() 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
    AlloyDBAdminSettings alloyDBAdminSettings =
        AlloyDBAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
    AlloyDBAdminClient alloyDBAdminClient = AlloyDBAdminClient.create(alloyDBAdminSettings);
  }
}

What's next

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