Google Cloud Filestore

1.16.0 · active · verified Tue Apr 14

The `google-cloud-filestore` client library provides Python access to the Google Cloud Filestore API. Google Cloud Filestore offers fully managed NFS file servers that can be integrated with applications running on Compute Engine virtual machines (VMs) or Google Kubernetes Engine (GKE) clusters, providing high-performance, low-latency shared storage. The library is part of the actively developed `google-cloud-python` monorepo, receiving regular updates across its various client components.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `CloudFilestoreManagerClient` and list existing Filestore instances within a specified Google Cloud project and location. Ensure your `GOOGLE_CLOUD_PROJECT` environment variable is set or replace 'your-project-id' and 'us-central1' with your actual project ID and desired region. Authentication is handled automatically via Application Default Credentials (ADC).

import os
from google.cloud.filestore_v1 import CloudFilestoreManagerClient

project_id = os.environ.get('GOOGLE_CLOUD_PROJECT', 'your-project-id') # Replace with your GCP project ID
location = 'us-central1' # Replace with a suitable region, e.g., 'us-central1'

def list_filestore_instances():
    """Lists all Filestore instances in a given project and location."""
    client = CloudFilestoreManagerClient()
    parent = f"projects/{project_id}/locations/{location}"

    print(f"Listing Filestore instances in {parent}:")
    try:
        # The list_instances method returns a PagedAsyncIterator, which can be iterated directly
        for instance in client.list_instances(parent=parent):
            print(f"  Instance: {instance.name.split('/')[-1]} (State: {instance.state.name}, Tier: {instance.tier.name})")
            print(f"    IP Address: {instance.networks[0].ip_addresses[0] if instance.networks else 'N/A'}")
            print(f"    Capacity: {instance.capacity_gb} GB")
    except Exception as e:
        print(f"Error listing instances: {e}")

if __name__ == '__main__':
    list_filestore_instances()

view raw JSON →