Lakehouse client libraries

This page shows how to get started with the Cloud Client Libraries for the Lakehouse API. Client libraries make it easier to access Google Cloud APIs from a supported language. Although you can use Google Cloud APIs directly by making raw requests to the server, client libraries provide simplifications that significantly reduce the amount of code you need to write.

Read more about the Cloud Client Libraries and the older Google API Client Libraries in Client libraries explained.

Install the client library

Go

go get cloud.google.com/go/biglake/apiv1

For more information, see Setting Up a Go Development Environment.

Java

If you're using Maven, add the following to your pom.xml file:

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-biglake</artifactId>
  <version>VERSION</version>
</dependency>

If you're using Gradle, add the following to your dependencies:

implementation 'com.google.cloud:google-cloud-biglake:VERSION'

For more information, see Setting Up a Java Development Environment.

Python

pip install --upgrade google-cloud-biglake

For more information, see Setting Up a Python Development Environment.

Rust

cargo add google-cloud-biglake-v1

For more information, see Get started with Rust.

Set up authentication

To authenticate calls to Google Cloud APIs, client libraries support Application Default Credentials (ADC); the libraries look for credentials in a set of defined locations and use those credentials to authenticate requests to the API. With ADC, you can make credentials available to your application in a variety of environments, such as local development or production, without needing to modify your application code.

For production environments, the way you set up ADC depends on the service and context. For more information, see Set up Application Default Credentials.

For a local development environment, you can set up ADC with the credentials that are associated with your Google Account:

  1. Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:

    gcloud init

    If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  2. If you're using a local shell, then create local authentication credentials for your user account:

    gcloud auth application-default login

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

    A sign-in screen appears. After you sign in, your credentials are stored in the local credential file used by ADC.

Use the client library

The following example shows how to use the client library.

Go


func ExampleIcebergCatalogClient_ListIcebergCatalogs() {
	ctx := context.Background()
	// 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := biglake.NewIcebergCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &biglakepb.ListIcebergCatalogsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/biglake/apiv1/biglakepb#ListIcebergCatalogsRequest.
	}
	it := c.ListIcebergCatalogs(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp

		// If you need to access the underlying RPC response,
		// you can do so by casting the `Response` as below.
		// Otherwise, remove this line. Only populated after
		// first call to Next(). Not safe for concurrent access.
		_ = it.Response.(*biglakepb.ListIcebergCatalogsResponse)
	}
}

Java

import com.google.cloud.biglake.v1.IcebergCatalog;
import com.google.cloud.biglake.v1.IcebergCatalogServiceClient;
import com.google.cloud.biglake.v1.ListIcebergCatalogsRequest;
import com.google.cloud.biglake.v1.ProjectName;

public class SyncListIcebergCatalogs {

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

  public static void syncListIcebergCatalogs() 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
    try (IcebergCatalogServiceClient icebergCatalogServiceClient =
        IcebergCatalogServiceClient.create()) {
      ListIcebergCatalogsRequest request =
          ListIcebergCatalogsRequest.newBuilder()
              .setParent(ProjectName.of("[PROJECT]").toString())
              .setPageSize(883849137)
              .setPageToken("pageToken873572522")
              .setFilter("filter-1274492040")
              .build();
      for (IcebergCatalog element :
          icebergCatalogServiceClient.listIcebergCatalogs(request).iterateAll()) {
        // doThingsWith(element);
      }
    }
  }
}

Python

# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import biglake_v1


def sample_list_iceberg_catalogs():
    # Create a client
    client = biglake_v1.IcebergCatalogServiceClient()

    # Initialize request argument(s)
    request = biglake_v1.ListIcebergCatalogsRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_iceberg_catalogs(request=request)

    # Handle the response
    for response in page_result:
        print(response)

Additional resources

Go

The following list contains links to more resources related to the client libraries for Go:

Java

The following list contains links to more resources related to the client libraries for Java:

Python

The following list contains links to more resources related to the client libraries for Python:

Rust

The following list contains links to more resources related to the client libraries for Rust: