List parameter versions

This page describes how to retrieve a list of all the parameter versions associated with a parameter within a specified Google Cloud project and location.

Versions represent the specific setting or configuration value that the parameter holds at a given point in time. By looking at the list of versions, you can see how a parameter has changed over time and who made the change. This helps with auditing and troubleshooting. For example, if you're experiencing issues with your current configuration, examining disabled versions can help you understand what settings were previously used and potentially identify if a recent change caused the problem.

Required roles

To get the permissions that you need to list parameter versions, ask your administrator to grant you the Parameter Manager Parameter Viewer (roles/parametermanager.parameterViewer) IAM role on the parameter, project, folder, or organization. For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

List all parameters versions

To list all the parameter versions associated with a parameter, use one of the following methods:

Global parameters

Console

  1. In the Google Cloud console, go to the Secret Manager page.

    Go to Secret Manager

  2. Click Parameter Manager to go to the Parameter Manager page. You'll see the list of parameters for that project.

  3. Click the parameter name to view its versions.

    The parameter details page opens with the Versions tab in focus where you can see all the versions of the selected parameter.

gcloud

Before using any of the command data below, make the following replacements:

  • PARAMETER_ID: the name of the parameter

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud parametermanager parameters versions list --parameter=PARAMETER_ID --location=global

Windows (PowerShell)

gcloud parametermanager parameters versions list --parameter=PARAMETER_ID --location=global

Windows (cmd.exe)

gcloud parametermanager parameters versions list --parameter=PARAMETER_ID --location=global

You should receive a response similar to the following:

NAME                                                                                DISABLED  CREATE_TIME                     UPDATE_TIME
projects/production-1/locations/global/parameters/app_config/versions/configv3            2024-11-14T10:07:12.883361876Z  2024-11-14T10:07:13.331806596Z

REST

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the Google Cloud project ID
  • PARAMETER_ID: the name of the parameter

HTTP method and URL:

GET https://parametermanager.googleapis.com/v1/projects/PROJECT_ID/locations/global/parameters/PARAMETER_ID/versions

Request JSON body:

{}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://parametermanager.googleapis.com/v1/projects/PROJECT_ID/locations/global/parameters/PARAMETER_ID/versions"

PowerShell

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://parametermanager.googleapis.com/v1/projects/PROJECT_ID/locations/global/parameters/PARAMETER_ID/versions" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "parameterVersions": [
    {
      "name": "projects/production-1/locations/global/parameters/app_config/versions/configv3",
      "createTime": "2024-11-12T10:22:17.704800878Z",
      "updateTime": "2024-11-12T11:08:24.173199506Z",
      "disabled": true
    },
    {
      "name": "projects/production-1/locations/global/parameters/app_config/versions/configv2",
      "createTime": "2024-11-12T10:26:44.168165094Z",
      "updateTime": "2024-11-12T10:26:44.483145675Z"
    }
  ]
}

C#

To run this code, first set up a C# development environment and install the Secret Manager C# SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.


using Google.Api.Gax;
using Google.Cloud.ParameterManager.V1;

public class ListParameterVersionsSample
{
    /// <summary>
    /// This function lists parameter version using the Parameter Manager SDK for GCP.
    /// </summary>
    /// <param name="projectId">The ID of the project where the parameter is located.</param>
    /// <param name="parameterId">The ID of the parameter for which the version is to be listed.</param>
    /// <returns>A list of ParameterVersion objects.</returns>
    public IEnumerable<ParameterVersion> ListParameterVersions(
        string projectId,
        string parameterId)
    {
        // Create the client.
        ParameterManagerClient client = ParameterManagerClient.Create();

        // Build the parent resource name for the parameter.
        ParameterName parent = new ParameterName(projectId, "global", parameterId);

        // Call the API to list the parameter versions.
        PagedEnumerable<ListParameterVersionsResponse, ParameterVersion> response = client.ListParameterVersions(parent);

        // Print each parameter version name.
        foreach (ParameterVersion parameterVersion in response)
        {
            Console.WriteLine($"Found parameter version: {parameterVersion.Name}");
        }

        // Return the list of parameter versions.
        return response;
    }
}

Go

To run this code, first set up a Go development environment and install the Secret Manager Go SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

import (
	"context"
	"fmt"
	"io"

	parametermanager "cloud.google.com/go/parametermanager/apiv1"
	parametermanagerpb "cloud.google.com/go/parametermanager/apiv1/parametermanagerpb"
	"google.golang.org/api/iterator"
)

// listParamVersions lists parameter versions using the Parameter Manager SDK for GCP.
//
// w: The io.Writer object used to write the output.
// projectID: The ID of the project where the parameter is located.
// parameterID: The ID of the parameter for which the versions are to be listed.
//
// The function returns an error if the parameter version listing fails.
func listParamVersions(w io.Writer, projectID, parameterID string) error {
	// Create a context and a Parameter Manager client.
	ctx := context.Background()
	client, err := parametermanager.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("failed to create Parameter Manager client: %w", err)
	}
	defer client.Close()

	// Construct the name of the list parameter.
	parent := fmt.Sprintf("projects/%s/locations/global/parameters/%s", projectID, parameterID)

	// Build the request to list parameter versions.
	req := &parametermanagerpb.ListParameterVersionsRequest{
		Parent: parent,
	}

	// Call the API to list parameter versions.
	parameterVersions := client.ListParameterVersions(ctx, req)
	for {
		version, err := parameterVersions.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("failed to list parameter versions: %w", err)
		}

		fmt.Fprintf(w, "Found parameter version %s with disabled state in %v\n", version.Name, version.Disabled)
	}

	return nil
}

Java

To run this code, first set up a Java development environment and install the Secret Manager Java SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.


import com.google.cloud.parametermanager.v1.ListParameterVersionsRequest;
import com.google.cloud.parametermanager.v1.ParameterManagerClient;
import com.google.cloud.parametermanager.v1.ParameterManagerClient.ListParameterVersionsPagedResponse;
import com.google.cloud.parametermanager.v1.ParameterName;
import java.io.IOException;

/** Class to list parameter versions using the Parameter Manager SDK for GCP. */
public class ListParamVersions {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String parameterId = "your-parameter-id";

    // Call the method to list parameter versions.
    listParamVersions(projectId, parameterId);
  }

  // This is an example snippet that list all parameter versions
  public static ListParameterVersionsPagedResponse listParamVersions(
      String projectId, String parameterId) throws IOException {
    // Initialize the client that will be used to send requests. This client only needs to be
    // created once,
    // and can be reused for multiple requests.
    try (ParameterManagerClient client = ParameterManagerClient.create()) {
      String locationId = "global";

      // Build the parameter name from the project and parameter ID.
      ParameterName parameterName = ParameterName.of(projectId, locationId, parameterId);

      // Build the request to list parameter versions.
      ListParameterVersionsRequest request =
          ListParameterVersionsRequest.newBuilder().setParent(parameterName.toString()).build();

      // Send the request and get the response.
      ListParameterVersionsPagedResponse response = client.listParameterVersions(request);

      // Iterate through all versions and print their details.
      response
          .iterateAll()
          .forEach(
              version ->
                  System.out.printf(
                      "Found parameter version %s with state %s\n",
                      version.getName(), (version.getDisabled() ? "disabled" : "enabled")));

      return response;
    }
  }
}

Node.js

To run this code, first set up a Node.js development environment and install the Secret Manager Node.js SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'my-project';
// const parameterId = 'my-parameter';

// Imports the Parameter Manager library
const {ParameterManagerClient} = require('@google-cloud/parametermanager');

// Instantiates a client
const client = new ParameterManagerClient();

async function listParamVersions() {
  // Construct the parent string for listing parameter versions globally
  const parent = client.parameterPath(projectId, 'global', parameterId);

  const request = {
    parent: parent,
  };

  // Use listParameterVersionsAsync to handle pagination automatically
  const parameterVersions = await client.listParameterVersionsAsync(request);

  for await (const version of parameterVersions) {
    console.log(
      `Found parameter version ${version.name} with state ${version.disabled ? 'disabled' : 'enabled'}`
    );
  }
  return parameterVersions;
}

return await listParamVersions();

PHP

To run this code, first learn about using PHP on Google Cloud and install the Secret Manager PHP SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

// Import necessary classes for list a parameter versions.
use Google\Cloud\ParameterManager\V1\Client\ParameterManagerClient;
use Google\Cloud\ParameterManager\V1\ListParameterVersionsRequest;

/**
 * Lists a parameter versions using the Parameter Manager SDK for GCP.
 *
 * @param string $projectId The Google Cloud Project ID (e.g. 'my-project')
 * @param string $parameterId The Parameter ID (e.g. 'my-param')
 */
function list_param_versions(string $projectId, string $parameterId): void
{
    // Create a client for the Parameter Manager service.
    $client = new ParameterManagerClient();

    // Build the resource name of the parameter.
    $parent = $client->parameterName($projectId, 'global', $parameterId);

    // Prepare the request to list the parameter versions.
    $request = (new ListParameterVersionsRequest())
        ->setParent($parent);

    // Retrieve the parameter version using the client.
    foreach ($client->listParameterVersions($request) as $parameterVersion) {
        printf('Found parameter version: %s' . PHP_EOL, $parameterVersion->getName());
    }
}

Python

To run this code, first set up a Python development environment and install the Secret Manager Python SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

def list_param_versions(project_id: str, parameter_id: str) -> None:
    """
    Lists all versions of an existing parameter in the global location
    of the specified project using the Google Cloud Parameter Manager SDK.

    Args:
        project_id (str): The ID of the project where the parameter is located.
        parameter_id (str): The ID of the parameter for
        which versions are to be listed.

    Returns:
        None

    Example:
        list_param_versions(
            "my-project",
            "my-global-parameter"
        )
    """
    # Import the necessary library for Google Cloud Parameter Manager.
    from google.cloud import parametermanager_v1

    # Create the Parameter Manager client.
    client = parametermanager_v1.ParameterManagerClient()

    # Build the resource name of the parameter.
    parent = client.parameter_path(project_id, "global", parameter_id)

    # Define the request to list parameter versions.
    request = parametermanager_v1.ListParameterVersionsRequest(parent=parent)

    # List the parameter versions.
    page_result = client.list_parameter_versions(request=request)

    # Print the versions of the parameter.
    for response in page_result:
        print(f"Found parameter version: {response.name}")

Ruby

To run this code, first set up a Ruby development environment and install the Secret Manager Ruby SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

require "google/cloud/parameter_manager"

##
# List a parameter versions
#
# @param project_id [String] The Google Cloud project (e.g. "my-project")
# @param parameter_id [String] The parameter ID (e.g. "my-parameter")
#
def list_param_versions project_id:, parameter_id:
  # Create a Parameter Manager client.
  client = Google::Cloud::ParameterManager.parameter_manager

  # Build the resource name of the parent project.
  parent = client.parameter_path project: project_id, location: "global", parameter: parameter_id

  # List the parameter versions.
  param_version_list = client.list_parameter_versions parent: parent

  # Print out all parameter versions.
  param_version_list.each do |param_version|
    puts "Found parameter version #{param_version.name} with state #{param_version.disabled ? 'disabled' : 'enabled'}"
  end
end

Regional parameters

Console

  1. In the Google Cloud console, go to the Secret Manager page.

    Go to Secret Manager

  2. Click Parameter Manager to go to the Parameter Manager page. You'll see the list of parameters for that project.

  3. Click the parameter name to view its versions.

    The parameter details page opens with the Versions tab in focus where you can see all the versions of the selected parameter.

gcloud

Before using any of the command data below, make the following replacements:

  • PARAMETER_ID: the name of the parameter
  • LOCATION: the Google Cloud location of the parameter

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud parametermanager parameters versions list --parameter=PARAMETER_ID --location=LOCATION

Windows (PowerShell)

gcloud parametermanager parameters versions list --parameter=PARAMETER_ID --location=LOCATION

Windows (cmd.exe)

gcloud parametermanager parameters versions list --parameter=PARAMETER_ID --location=LOCATION

You should receive a response similar to the following:

NAME                                                                                DISABLED  CREATE_TIME                     UPDATE_TIME
projects/production-1/locations/us-central1/parameters/app_config/versions/configv3            2024-11-14T10:07:12.883361876Z  2024-11-14T10:07:13.331806596Z

REST

Before using any of the request data, make the following replacements:

  • LOCATION: the Google Cloud location of the parameter
  • PROJECT_ID: the Google Cloud project ID
  • PARAMETER_ID: the name of the parameter

HTTP method and URL:

GET https://parametermanager.LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/parameters/PARAMETER_ID/versions

Request JSON body:

{}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://parametermanager.LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/parameters/PARAMETER_ID/versions"

PowerShell

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://parametermanager.LOCATION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/parameters/PARAMETER_ID/versions" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "parameterVersions": [
    {
      "name": "projects/production-1/locations/us-central1/parameters/app_config/versions/configv3",
      "createTime": "2024-10-30T05:27:51.206825427Z",
      "updateTime": "2024-10-30T05:27:51.442194863Z"
    }
  ]
}

C#

To run this code, first set up a C# development environment and install the Secret Manager C# SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.


using Google.Api.Gax;
using Google.Cloud.ParameterManager.V1;

public class ListRegionalParameterVersionsSample
{
    /// <summary>
    /// This function lists all versions of a regional parameter using the Parameter Manager SDK for GCP.
    /// </summary>
    /// <param name="projectId">The ID of the project where the parameter is located.</param>
    /// <param name="locationId">The ID of the region where the parameter is located.</param>
    /// <param name="parameterId"> The ID of the parameter for which the version is to be listed.</param>
    /// <returns>A list of ParameterVersion objects.</returns>
    public IEnumerable<ParameterVersion> ListRegionalParameterVersions(
        string projectId,
        string locationId,
        string parameterId)
    {
        // Define the regional endpoint
        string regionalEndpoint = $"parametermanager.{locationId}.rep.googleapis.com";

        // Create the client with the regional endpoint
        ParameterManagerClient client = new ParameterManagerClientBuilder
        {
            Endpoint = regionalEndpoint
        }.Build();

        // Build the parent resource name using ParameterName
        ParameterName parent = new ParameterName(projectId, locationId, parameterId);

        // Call the API to list the parameter versions
        PagedEnumerable<ListParameterVersionsResponse, ParameterVersion> response = client.ListParameterVersions(parent);

        // Print each parameter version name
        foreach (ParameterVersion version in response)
        {
            Console.WriteLine($"Found regional parameter version: {version.Name}");
        }

        // Return the list of parameter versions
        return response;
    }
}

Go

To run this code, first set up a Go development environment and install the Secret Manager Go SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

import (
	"context"
	"fmt"
	"io"

	parametermanager "cloud.google.com/go/parametermanager/apiv1"
	parametermanagerpb "cloud.google.com/go/parametermanager/apiv1/parametermanagerpb"
	"google.golang.org/api/iterator"
	"google.golang.org/api/option"
)

// listRegionalParamVersion lists all parameter versions regional using the Parameter Manager SDK for GCP.
//
// w: The io.Writer object used to write the output.
// projectID: The ID of the project where the parameter is located.
// locationID: The ID of the region where the parameter is located.
// parameterID: The ID of the parameter for which the version is to be listed.
//
// The function returns an error if the parameter version listing fails
func listRegionalParamVersion(w io.Writer, projectID, locationID, parameterID string) error {
	// Create a new context.
	ctx := context.Background()

	// Create a Parameter Manager client.
	endpoint := fmt.Sprintf("parametermanager.%s.rep.googleapis.com:443", locationID)
	client, err := parametermanager.NewClient(ctx, option.WithEndpoint(endpoint))
	if err != nil {
		return fmt.Errorf("failed to create Parameter Manager client: %w", err)
	}
	defer client.Close()

	// Construct the name of the parameter to list versions.
	parent := fmt.Sprintf("projects/%s/locations/%s/parameters/%s", projectID, locationID, parameterID)

	// Build the request to list all parameter versions.
	req := &parametermanagerpb.ListParameterVersionsRequest{
		Parent: parent,
	}

	// Call the API to list all parameter versions.
	parameterVersions := client.ListParameterVersions(ctx, req)
	for {
		version, err := parameterVersions.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("failed to list parameter versions: %w", err)
		}

		fmt.Fprintf(w, "Found regional parameter version %s with disabled state in %v\n", version.Name, version.Disabled)
	}

	return nil
}

Java

To run this code, first set up a Java development environment and install the Secret Manager Java SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.


import com.google.cloud.parametermanager.v1.ListParameterVersionsRequest;
import com.google.cloud.parametermanager.v1.ParameterManagerClient;
import com.google.cloud.parametermanager.v1.ParameterManagerClient.ListParameterVersionsPagedResponse;
import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
import com.google.cloud.parametermanager.v1.ParameterName;
import java.io.IOException;

/**
 * Class to list parameter versions for a specified region using the Parameter Manager SDK
 * for GCP.
 */
public class ListRegionalParamVersions {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String locationId = "your-location-id";
    String parameterId = "your-parameter-id";

    // Call the method to list parameter versions regionally.
    listRegionalParamVersions(projectId, locationId, parameterId);
  }

  // This is an example snippet that list all parameter versions regionally
  public static ListParameterVersionsPagedResponse listRegionalParamVersions(
      String projectId, String locationId, String parameterId) throws IOException {
    // Endpoint to call the regional parameter manager server
    String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
    ParameterManagerSettings parameterManagerSettings =
        ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();

    // Initialize the client that will be used to send requests. This client only needs to be
    // created once,
    // and can be reused for multiple requests.
    try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
      // Build the parameter name from the project and parameter ID.
      ParameterName parameterName = ParameterName.of(projectId, locationId, parameterId);

      // Build the request to list parameter versions.
      ListParameterVersionsRequest request =
          ListParameterVersionsRequest.newBuilder().setParent(parameterName.toString()).build();

      // Send the request and get the response.
      ListParameterVersionsPagedResponse response = client.listParameterVersions(request);

      // Iterate through all versions and print their details.
      response
          .iterateAll()
          .forEach(
              version ->
                  System.out.printf(
                      "Found regional parameter version %s with state %s\n",
                      version.getName(), (version.getDisabled() ? "disabled" : "enabled")));

      return response;
    }
  }
}

Node.js

To run this code, first set up a Node.js development environment and install the Secret Manager Node.js SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'my-project';
// const locationId = 'us-central1';
// const parameterId = 'my-parameter';

// Imports the Parameter Manager library
const {ParameterManagerClient} = require('@google-cloud/parametermanager');

// Adding the endpoint to call the regional parameter manager server
const options = {
  apiEndpoint: `parametermanager.${locationId}.rep.googleapis.com`,
};

// Instantiates a client with regional endpoint
const client = new ParameterManagerClient(options);

async function listRegionalParamVersions() {
  // Construct the parent string for listing parameter versions in a specific region
  const parent = client.parameterPath(projectId, locationId, parameterId);

  const request = {
    parent: parent,
  };

  // Use listParameterVersionsAsync to handle pagination automatically
  const paramVersions = await client.listParameterVersionsAsync(request);

  for await (const version of paramVersions) {
    console.log(
      `Found regional parameter version ${version.name} with state ${version.disabled ? 'disabled' : 'enabled'} `
    );
  }
  return paramVersions;
}

return await listRegionalParamVersions();

PHP

To run this code, first learn about using PHP on Google Cloud and install the Secret Manager PHP SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

// Import necessary classes for list a parameter versions.
use Google\Cloud\ParameterManager\V1\Client\ParameterManagerClient;
use Google\Cloud\ParameterManager\V1\ListParameterVersionsRequest;

/**
 * Lists a regional parameter versions using the Parameter Manager SDK for GCP.
 *
 * @param string $projectId The Google Cloud Project ID (e.g. 'my-project')
 * @param string $locationId The Parameter Location (e.g. 'us-central1')
 * @param string $parameterId The Parameter ID (e.g. 'my-param')
 */
function list_regional_param_versions(string $projectId, string $locationId, string $parameterId): void
{
    // Specify regional endpoint.
    $options = ['apiEndpoint' => "parametermanager.$locationId.rep.googleapis.com"];

    // Create a client for the Parameter Manager service.
    $client = new ParameterManagerClient($options);

    // Build the resource name of the parameter.
    $parent = $client->parameterName($projectId, $locationId, $parameterId);

    // Prepare the request to list the parameter versions.
    $request = (new ListParameterVersionsRequest())
        ->setParent($parent);

    // Retrieve the parameter version using the client.
    foreach ($client->listParameterVersions($request) as $parameterVersion) {
        printf('Found regional parameter version: %s' . PHP_EOL, $parameterVersion->getName());
    }
}

Python

To run this code, first set up a Python development environment and install the Secret Manager Python SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

def list_regional_param_versions(
    project_id: str, location_id: str, parameter_id: str
) -> None:
    """
    List all versions of a regional parameter in Google Cloud Parameter Manager.

    This function lists all versions of an existing
    parameter in the specified region of the specified project
    using the Google Cloud Parameter Manager SDK.

    Args:
        project_id (str): The ID of the project where the parameter is located.
        location_id (str): The ID of the region where the parameter is located.
        parameter_id (str): The ID of the parameter for
        which versions are to be listed.

    Returns:
        None

    Example:
        list_regional_param_versions(
            "my-project",
            "us-central1",
            "my-regional-parameter"
        )
    """
    # Import the necessary library for Google Cloud Parameter Manager.
    from google.cloud import parametermanager_v1

    # Create the Parameter Manager client with the regional endpoint.
    api_endpoint = f"parametermanager.{location_id}.rep.googleapis.com"
    client = parametermanager_v1.ParameterManagerClient(
        client_options={"api_endpoint": api_endpoint}
    )

    # Build the resource name of the parameter.
    parent = client.parameter_path(project_id, location_id, parameter_id)

    # Define the request to list parameter versions.
    request = parametermanager_v1.ListParameterVersionsRequest(parent=parent)

    # List the parameter versions.
    page_result = client.list_parameter_versions(request=request)

    # Print the versions of the parameter.
    for response in page_result:
        print(f"Found regional parameter version: {response.name}")

Ruby

To run this code, first set up a Ruby development environment and install the Secret Manager Ruby SDK. On Compute Engine or GKE, you must authenticate with the cloud-platform scope.

require "google/cloud/parameter_manager"

##
# List a regional parameter versions
#
# @param project_id [String] The Google Cloud project (e.g. "my-project")
# @param location_id [String] The location name (e.g. "us-central1")
# @param parameter_id [String] The parameter ID (e.g. "my-parameter")
#
def list_regional_param_versions project_id:, location_id:, parameter_id:
  # Endpoint for the regional parameter manager service.
  api_endpoint = "parametermanager.#{location_id}.rep.googleapis.com"

  # Create the Parameter Manager client.
  client = Google::Cloud::ParameterManager.parameter_manager do |config|
    config.endpoint = api_endpoint
  end

  # Build the resource name of the parent project.
  parent = client.parameter_path project: project_id, location: location_id, parameter: parameter_id

  # List the parameter versions.
  param_version_list = client.list_parameter_versions parent: parent

  # Print out all parameter versions.
  param_version_list.each do |param_version|
    state = param_version.disabled ? "disabled" : "enabled"
    puts "Found regional parameter version #{param_version.name} with state #{state}"
  end
end

What's next