Google Cloud App Engine Admin API

1.17.0 · active · verified Sun Apr 12

The `google-cloud-appengine-admin` client library for Python allows developers to programmatically manage their Google App Engine applications, including services, versions, instances, and certificates. It is an actively maintained, stable client, part of the larger `google-cloud-python` monorepo, receiving regular updates. The current version is 1.17.0, and it adheres to Google Cloud's client library release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `AppEngineAdminClient` and list all App Engine applications associated with your Google Cloud project. It relies on standard Google Cloud authentication mechanisms (e.g., `GOOGLE_APPLICATION_CREDENTIALS` environment variable or default credentials). Ensure the App Engine Admin API is enabled in your project and the authenticated principal has the necessary permissions (e.g., `roles/appengine.appAdmin`).

import os
from google.cloud import appengine_admin_v1

# Ensure GOOGLE_CLOUD_PROJECT environment variable is set
# For local development, ensure GOOGLE_APPLICATION_CREDENTIALS is set
# or a service account key is available and has necessary permissions (e.g., App Engine Admin).

project_id = os.environ.get("GOOGLE_CLOUD_PROJECT", "your-gcp-project-id")

def list_app_engine_applications(project_id: str):
    """Lists all App Engine applications in the specified project."""
    if project_id == "your-gcp-project-id":
        print("Please set the GOOGLE_CLOUD_PROJECT environment variable or replace 'your-gcp-project-id' with your actual project ID.")
        return

    try:
        # Create a client
        client = appengine_admin_v1.AppEngineAdminClient()

        # The `list_applications` method lists applications associated with the authenticated project.
        applications = client.list_applications()

        print(f"App Engine Applications in project '{project_id}':")
        found_any = False
        for app in applications:
            print(f"- {app.name} (ID: {app.id}) - Auth Domain: {app.auth_domain})")
            found_any = True
        if not found_any:
            print("No applications found or the App Engine Admin API is not enabled/permissions are insufficient.")

    except Exception as e:
        print(f"An error occurred: {e}")
        print("Ensure the 'App Engine Admin API' is enabled in your GCP project and your credentials have sufficient permissions (e.g., App Engine Admin role).")

if __name__ == "__main__":
    list_app_engine_applications(project_id)

view raw JSON →