View resource maintenances by using the API

You can use the Unified Maintenance API to return information about maintenance on your resources.

This document describes how to use Cloud Shell to call the Unified Maintenance API to return resource maintenance.

To view upcoming and historical maintenance activities in Cloud Hub, see View maintenance activities.

Before you begin

Before you view maintenance on your resources using Unified Maintenance, verify that Unified Maintenance supports your resource types.

Filters

You can filter which maintenance activities are returned by several parameters:

  • State (SUCCEEDED, or STARTED, for example)
  • Resource name
  • Resource location
  • Resource type
  • Maintenance name
  • Maintenance start time
  • Maintenance end time

For more information, see Unified Maintenance API documentation.

View resource maintenances

You can use the Unified Maintenance API to return maintenance activity information for a Google Cloud project.

To list all maintenance activities:

  1. Go to Cloud Shell.

    Go to Cloud Shell

  2. Run the command:

    curl \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type:
    application/json" \
    https://maintenance.googleapis.com/v1beta/projects/PROJECT_ID/locations/LOCATION/resourceMaintenances
    

    Replace:

    • PROJECT_ID: The project ID of your project.
    • LOCATION: Region or zone containing your project. Set to global, region, or - (to match all locations).
  3. Unified Maintenance returns information about resource maintenances for your specified project.

View maintenances for a resource

You can use the Unified Maintenance API to return maintenances for a specified resource.

To filter and print maintenances for a specified resource:

  1. Go to Cloud Shell.

    Go to Cloud Shell

  2. Run the command:

    curl \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type:
    application/json" \
    https://maintenance.googleapis.com/v1beta/projects/PROJECT_ID/locations/LOCATION/resourceMaintenances?filter=FILTER=%22RESOURCE_NAME%22
    

    Replace:

    • PROJECT_ID: The project ID of your project.
    • LOCATION: Region or zone containing your project. Set to global, region, or - (to match all locations).
    • RESOURCE_NAME: The full resource name of your resource.

What's next