Delete parameter versions

This page describes how to delete a parameter version.

Consider deleting a parameter version in the following scenarios:

  • The version is obsolete and is no longer needed.
  • The version contains sensitive information that needs to be permanently removed.
  • You want to simplify the management of parameter versions by deleting old and unused versions.

Required roles

To get the permissions that you need to delete a parameter version, ask your administrator to grant you the Parameter Manager Parameter Version Manager ( roles/parametermanager.parameterVersionManager ) IAM role on the 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 .

Delete a parameter version

To delete a parameter version, 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 access its versions. The parameter details page opens. You can see all the versions belonging to the selected parameter in the Versions tab.

  4. Select the parameter version that you want to delete.

  5. Click the Actions menu associated with that version, and then click Delete .

  6. In the confirmation dialog that appears, enter the parameter ID to confirm, and then click click Delete .

gcloud

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

  • PARAMETER_VERSION_ID : the ID of the parameter version
  • PARAMETER_ID : the name of the parameter

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud  
parametermanager  
parameters  
versions  
delete  
 PARAMETER_VERSION_ID 
  
--parameter = 
 PARAMETER_ID 
  
--location = 
global

Windows (PowerShell)

gcloud  
parametermanager  
parameters  
versions  
delete  
 PARAMETER_VERSION_ID 
  
--parameter = 
 PARAMETER_ID 
  
--location = 
global

Windows (cmd.exe)

gcloud  
parametermanager  
parameters  
versions  
delete  
 PARAMETER_VERSION_ID 
  
--parameter = 
 PARAMETER_ID 
  
--location = 
global

You should receive a response similar to the following:

You are about to delete parameterVersion [appconfigv1]

Do you want to continue (Y/n)?  y

Deleted parameterVersion [appconfigv1].

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
  • PARAMETER_VERSION_ID : the ID of the parameter version

HTTP method and URL:

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

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 DELETE \
-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/ PARAMETER_VERSION_ID "

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 DELETE `
-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/ PARAMETER_VERSION_ID " | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{}

C#

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

  using 
  
  Google.Cloud.ParameterManager.V1 
 
 ; 
 public 
  
 class 
  
 DeleteParameterVersionSample 
 { 
  
 /// <summary> 
  
 /// This function deletes a 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 deleted.</param> 
  
 /// <param name="versionId">The ID of the version to be deleted.</param> 
  
 public 
  
 void 
  
 DeleteParameterVersion 
 ( 
  
 string 
  
 projectId 
 , 
  
 string 
  
 parameterId 
 , 
  
 string 
  
 versionId 
 ) 
  
 { 
  
 // Create the client. 
  
  ParameterManagerClient 
 
  
 client 
  
 = 
  
  ParameterManagerClient 
 
 . 
  Create 
 
 (); 
  
 // Build the resource name for the parameter version. 
  
  ParameterVersionName 
 
  
 parameterVersionName 
  
 = 
  
 new 
  
  ParameterVersionName 
 
 ( 
 projectId 
 , 
  
 "global" 
 , 
  
 parameterId 
 , 
  
 versionId 
 ); 
  
 // Call the API to delete the parameter version. 
  
 client 
 . 
  DeleteParameterVersion 
 
 ( 
 parameterVersionName 
 ); 
  
 // Print a confirmation message. 
  
 Console 
 . 
 WriteLine 
 ( 
 $"Deleted parameter version: {parameterVersionName}" 
 ); 
  
 } 
 } 
 

Go

To run this code, first set up a Go development environment and install the Parameter 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" 
 ) 
 // deleteParamVersion deletes a parameter version 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 version is to be deleted. 
 // versionID: The ID of the version to be deleted. 
 // 
 //	The function returns an error if the parameter version deletion fails. 
 func 
  
 deleteParamVersion 
 ( 
 w 
  
 io 
 . 
 Writer 
 , 
  
 projectID 
 , 
  
 parameterID 
 , 
  
 versionID 
  
 string 
 ) 
  
 error 
  
 { 
  
 // Create a new context. 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // Initialize a Parameter Manager client. 
  
 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 parameter version to delete. 
  
 name 
  
 := 
  
 fmt 
 . 
 Sprintf 
 ( 
 "projects/%s/locations/global/parameters/%s/versions/%s" 
 , 
  
 projectID 
 , 
  
 parameterID 
 , 
  
 versionID 
 ) 
  
 // Build the request to delete the parameter version. 
  
 req 
  
 := 
  
& parametermanagerpb 
 . 
 DeleteParameterVersionRequest 
 { 
  
 Name 
 : 
  
 name 
 , 
  
 } 
  
 // Call the API to delete the parameter version. 
  
 if 
  
 err 
  
 := 
  
 client 
 . 
 DeleteParameterVersion 
 ( 
 ctx 
 , 
  
 req 
 ); 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 return 
  
 fmt 
 . 
 Errorf 
 ( 
 "failed to delete parameter version: %w" 
 , 
  
 err 
 ) 
  
 } 
  
 fmt 
 . 
 Fprintf 
 ( 
 w 
 , 
  
 "Deleted parameter version: %s\n" 
 , 
  
 name 
 ) 
  
 return 
  
 nil 
 } 
 

Java

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

  import 
  
 com.google.cloud.parametermanager.v1. ParameterManagerClient 
 
 ; 
 import 
  
 com.google.cloud.parametermanager.v1. ParameterVersionName 
 
 ; 
 import 
  
 java.io.IOException 
 ; 
 /** 
 * This class demonstrates how to delete a parameter version using the Parameter Manager SDK for 
 * GCP. 
 */ 
 public 
  
 class 
 DeleteParamVersion 
  
 { 
  
 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" 
 ; 
  
 String 
  
 versionId 
  
 = 
  
 "your-version-id" 
 ; 
  
 // Call the method to delete a parameter version. 
  
 deleteParamVersion 
 ( 
 projectId 
 , 
  
 parameterId 
 , 
  
 versionId 
 ); 
  
 } 
  
 // This is an example snippet for deleting a parameter version. 
  
 public 
  
 static 
  
 void 
  
 deleteParamVersion 
 ( 
 String 
  
 projectId 
 , 
  
 String 
  
 parameterId 
 , 
  
 String 
  
 versionId 
 ) 
  
 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 version name. 
  
  ParameterVersionName 
 
  
 parameterVersionName 
  
 = 
  
  ParameterVersionName 
 
 . 
 of 
 ( 
 projectId 
 , 
  
 locationId 
 , 
  
 parameterId 
 , 
  
 versionId 
 ); 
  
 // Delete the parameter version. 
  
 client 
 . 
 deleteParameterVersion 
 ( 
 parameterVersionName 
 ); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Deleted parameter version: %s\n" 
 , 
  
 parameterVersionName 
 . 
  toString 
 
 ()); 
  
 } 
  
 } 
 } 
 

Node.js

To run this code, first set up a Node.js development environment and install the Parameter 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'; 
 // const versionId = 'v1'; 
 // Imports the Parameter Manager library 
 const 
  
 { 
 ParameterManagerClient 
 } 
  
 = 
  
 require 
 ( 
 ' @google-cloud/parametermanager 
' 
 ); 
 // Instantiates a client 
 const 
  
 client 
  
 = 
  
 new 
  
  ParameterManagerClient 
 
 (); 
 async 
  
 function 
  
 deleteParamVersion 
 () 
  
 { 
  
 // Construct the fully qualified parameter version name 
  
 const 
  
 name 
  
 = 
  
 client 
 . 
  parameterVersionPath 
 
 ( 
  
 projectId 
 , 
  
 'global' 
 , 
  
 parameterId 
 , 
  
 versionId 
  
 ); 
  
 // Delete the parameter version 
  
 await 
  
 client 
 . 
 deleteParameterVersion 
 ({ 
  
 name 
 : 
  
 name 
 , 
  
 }); 
  
 console 
 . 
 log 
 ( 
 `Deleted parameter version: 
 ${ 
 name 
 } 
 ` 
 ); 
  
 return 
  
 name 
 ; 
 } 
 return 
  
 await 
  
 deleteParamVersion 
 (); 
 

PHP

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

  // Import necessary classes for delete a parameter version. 
 use Google\Cloud\ParameterManager\V1\Client\ParameterManagerClient; 
 use Google\Cloud\ParameterManager\V1\DeleteParameterVersionRequest; 
 /** 
 * Deletes a parameter version 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') 
 * @param string $versionId The Version ID (e.g. 'my-param-version') 
 */ 
 function delete_param_version(string $projectId, string $parameterId, string $versionId): void 
 { 
 // Create a client for the Parameter Manager service. 
 $client = new ParameterManagerClient(); 
 // Build the resource name of the parameter version. 
 $parameterVersionName = $client->parameterVersionName($projectId, 'global', $parameterId, $versionId); 
 // Prepare the request to delete the parameter version. 
 $request = (new DeleteParameterVersionRequest()) 
 ->setName($parameterVersionName); 
 // Delete the parameter version using the client. 
 $client->deleteParameterVersion($request); 
 printf('Deleted parameter version: %s' . PHP_EOL, $versionId); 
 } 
 

Python

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

  def 
  
 delete_param_version 
 ( 
 project_id 
 : 
 str 
 , 
 parameter_id 
 : 
 str 
 , 
 version_id 
 : 
 str 
 ) 
 - 
> None 
 : 
  
 """ 
 Deletes a specific version 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 the version is to be deleted. 
 version_id (str): The ID of the version to be deleted. 
 Returns: 
 None 
 Example: 
 delete_param_version( 
 "my-project", 
 "my-global-parameter", 
 "v1" 
 ) 
 """ 
 # 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 version. 
 name 
 = 
 client 
 . 
  parameter_version_path 
 
 ( 
 project_id 
 , 
 "global" 
 , 
 parameter_id 
 , 
 version_id 
 ) 
 # Define the request to delete the parameter version. 
 request 
 = 
  parametermanager_v1 
 
 . 
  DeleteParameterVersionRequest 
 
 ( 
 name 
 = 
 name 
 ) 
 # Delete the parameter version. 
 client 
 . 
  delete_parameter_version 
 
 ( 
 request 
 = 
 request 
 ) 
 # Print a confirmation message. 
 print 
 ( 
 f 
 "Deleted parameter version: 
 { 
 name 
 } 
 " 
 ) 
 

Ruby

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

  require 
  
 "google/cloud/parameter_manager" 
 ## 
 # Delete a parameter version 
 # 
 # @param project_id [String] The Google Cloud project (e.g. "my-project") 
 # @param parameter_id [String] The parameter name (e.g. "my-parameter") 
 # @param version_id [String] The version name (e.g. "my-version") 
 # 
 def 
  
 delete_param_version 
  
 project_id 
 :, 
  
 parameter_id 
 :, 
  
 version_id 
 : 
  
 # Create a Parameter Manager client. 
  
 client 
  
 = 
  
 Google 
 :: 
 Cloud 
 :: 
  ParameterManager 
 
 . 
  parameter_manager 
 
  
 # Build the resource name of the parent project. 
  
 name 
  
 = 
  
 client 
 . 
  parameter_version_path 
 
  
 project 
 : 
  
 project_id 
 , 
  
 location 
 : 
  
 "global" 
 , 
  
 parameter 
 : 
  
 parameter_id 
 , 
  
 parameter_version 
 : 
  
 version_id 
  
 # Create the parameter version. 
  
 param_version 
  
 = 
  
 client 
 . 
 delete_parameter_version 
  
 name 
 : 
  
 name 
  
 # Print the parameter version name. 
  
 puts 
  
 "Deleted parameter version 
 #{ 
 name 
 } 
 " 
 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 access its versions. The parameter details page opens. You can see all the versions belonging to the selected parameter in the Versions tab.

  4. Select the parameter version that you want to delete.

  5. Click the Actions menu associated with that version, and then click Delete .

  6. In the confirmation dialog that appears, enter the parameter ID to confirm, and then click click Delete .

gcloud

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

  • PARAMETER_VERSION_ID : the ID of the parameter version
  • 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  
delete  
 PARAMETER_VERSION_ID 
  
--parameter = 
 PARAMETER_ID 
  
--location = 
 LOCATION 

Windows (PowerShell)

gcloud  
parametermanager  
parameters  
versions  
delete  
 PARAMETER_VERSION_ID 
  
--parameter = 
 PARAMETER_ID 
  
--location = 
 LOCATION 

Windows (cmd.exe)

gcloud  
parametermanager  
parameters  
versions  
delete  
 PARAMETER_VERSION_ID 
  
--parameter = 
 PARAMETER_ID 
  
--location = 
 LOCATION 

You should receive a response similar to the following:

You are about to delete parameterVersion [appconfigv1]

Do you want to continue (Y/n)?  y

Deleted parameterVersion [appconfigv1].

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
  • PARAMETER_VERSION_ID : the ID of the parameter version

HTTP method and URL:

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

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 DELETE \
-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/ PARAMETER_VERSION_ID "

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 DELETE `
-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/ PARAMETER_VERSION_ID " | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{}

C#

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

  using 
  
  Google.Cloud.ParameterManager.V1 
 
 ; 
 public 
  
 class 
  
 DeleteRegionalParameterVersionSample 
 { 
  
 /// <summary> 
  
 /// This function deletes a regional 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="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 deleted.</param> 
  
 /// <param name="versionId">The ID of the version to be deleted.</param> 
  
 public 
  
 void 
  
 DeleteRegionalParameterVersion 
 ( 
  
 string 
  
 projectId 
 , 
  
 string 
  
 locationId 
 , 
  
 string 
  
 parameterId 
 , 
  
 string 
  
 versionId 
 ) 
  
 { 
  
 // 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 resource name for the parameter version in the specified regional locationId 
  
  ParameterVersionName 
 
  
 parameterVersionName 
  
 = 
  
 new 
  
  ParameterVersionName 
 
 ( 
 projectId 
 , 
  
 locationId 
 , 
  
 parameterId 
 , 
  
 versionId 
 ); 
  
 // Call the API to delete the parameter version 
  
 client 
 . 
  DeleteParameterVersion 
 
 ( 
 parameterVersionName 
 ); 
  
 Console 
 . 
 WriteLine 
 ( 
 $"Deleted regional parameter version: {parameterVersionName}" 
 ); 
  
 } 
 } 
 

Go

To run this code, first set up a Go development environment and install the Parameter 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/option" 
 ) 
 // deleteRegionalParamVersion deletes a regional parameter version 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 deleted. 
 // versionID: The ID of the version to be deleted. 
 // 
 // The function returns an error if the parameter version deletion fails. 
 func 
  
 deleteRegionalParamVersion 
 ( 
 w 
  
 io 
 . 
 Writer 
 , 
  
 projectID 
 , 
  
 locationID 
 , 
  
 parameterID 
 , 
  
 versionID 
  
 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 version to delete. 
  
 name 
  
 := 
  
 fmt 
 . 
 Sprintf 
 ( 
 "projects/%s/locations/%s/parameters/%s/versions/%s" 
 , 
  
 projectID 
 , 
  
 locationID 
 , 
  
 parameterID 
 , 
  
 versionID 
 ) 
  
 // Build the request to delete the parameter version. 
  
 req 
  
 := 
  
& parametermanagerpb 
 . 
 DeleteParameterVersionRequest 
 { 
  
 Name 
 : 
  
 name 
 , 
  
 } 
  
 // Call the API to delete the parameter version. 
  
 if 
  
 err 
  
 := 
  
 client 
 . 
 DeleteParameterVersion 
 ( 
 ctx 
 , 
  
 req 
 ); 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 return 
  
 fmt 
 . 
 Errorf 
 ( 
 "failed to delete parameter version: %w" 
 , 
  
 err 
 ) 
  
 } 
  
 fmt 
 . 
 Fprintf 
 ( 
 w 
 , 
  
 "Deleted regional parameter version: %s\n" 
 , 
  
 name 
 ) 
  
 return 
  
 nil 
 } 
 

Java

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

  import 
  
 com.google.cloud.parametermanager.v1. ParameterManagerClient 
 
 ; 
 import 
  
 com.google.cloud.parametermanager.v1. ParameterManagerSettings 
 
 ; 
 import 
  
 com.google.cloud.parametermanager.v1. ParameterVersionName 
 
 ; 
 import 
  
 java.io.IOException 
 ; 
 /** 
 * This class demonstrates how to delete a regional parameter version using the Parameter Manager 
 * SDK for GCP. 
 */ 
 public 
  
 class 
 DeleteRegionalParamVersion 
  
 { 
  
 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" 
 ; 
  
 String 
  
 versionId 
  
 = 
  
 "your-version-id" 
 ; 
  
 // Call the method to delete a regional parameter version. 
  
 deleteRegionalParamVersion 
 ( 
 projectId 
 , 
  
 locationId 
 , 
  
 parameterId 
 , 
  
 versionId 
 ); 
  
 } 
  
 // This is an example snippet that deletes a regional parameter version. 
  
 public 
  
 static 
  
 void 
  
 deleteRegionalParamVersion 
 ( 
  
 String 
  
 projectId 
 , 
  
 String 
  
 locationId 
 , 
  
 String 
  
 parameterId 
 , 
  
 String 
  
 versionId 
 ) 
  
 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 version name. 
  
  ParameterVersionName 
 
  
 parameterVersionName 
  
 = 
  
  ParameterVersionName 
 
 . 
 of 
 ( 
 projectId 
 , 
  
 locationId 
 , 
  
 parameterId 
 , 
  
 versionId 
 ); 
  
 // Delete the parameter version. 
  
 client 
 . 
 deleteParameterVersion 
 ( 
 parameterVersionName 
 . 
  toString 
 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
  
 "Deleted regional parameter version: %s\n" 
 , 
  
 parameterVersionName 
 . 
  toString 
 
 ()); 
  
 } 
  
 } 
 } 
 

Node.js

To run this code, first set up a Node.js development environment and install the Parameter 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'; 
 // const versionId = 'v1'; 
 // 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 
  
 deleteRegionalParamVersion 
 () 
  
 { 
  
 // Construct the fully qualified parameter version name 
  
 const 
  
 name 
  
 = 
  
 client 
 . 
  parameterVersionPath 
 
 ( 
  
 projectId 
 , 
  
 locationId 
 , 
  
 parameterId 
 , 
  
 versionId 
  
 ); 
  
 // Delete the parameter version 
  
 await 
  
 client 
 . 
 deleteParameterVersion 
 ({ 
  
 name 
 : 
  
 name 
 , 
  
 }); 
  
 console 
 . 
 log 
 ( 
 `Deleted regional parameter version: 
 ${ 
 name 
 } 
 ` 
 ); 
  
 return 
  
 name 
 ; 
 } 
 return 
  
 await 
  
 deleteRegionalParamVersion 
 (); 
 

PHP

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

  // Import necessary classes for delete a parameter version. 
 use Google\Cloud\ParameterManager\V1\Client\ParameterManagerClient; 
 use Google\Cloud\ParameterManager\V1\DeleteParameterVersionRequest; 
 /** 
 * Deletes a regional parameter version 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') 
 * @param string $versionId The Version ID (e.g. 'my-param-version') 
 */ 
 function delete_regional_param_version(string $projectId, string $locationId, string $parameterId, string $versionId): 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 version. 
 $parameterVersionName = $client->parameterVersionName($projectId, $locationId, $parameterId, $versionId); 
 // Prepare the request to delete the parameter version. 
 $request = (new DeleteParameterVersionRequest()) 
 ->setName($parameterVersionName); 
 // Delete the parameter version using the client. 
 $client->deleteParameterVersion($request); 
 printf('Deleted regional parameter version: %s' . PHP_EOL, $versionId); 
 } 
 

Python

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

  def 
  
 delete_regional_param_version 
 ( 
 project_id 
 : 
 str 
 , 
 location_id 
 : 
 str 
 , 
 parameter_id 
 : 
 str 
 , 
 version_id 
 : 
 str 
 ) 
 - 
> None 
 : 
  
 """ 
 Deletes a specific version 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 the version is to be deleted. 
 version_id (str): The ID of the version to be deleted. 
 Returns: 
 None 
 Example: 
 delete_regional_param_version( 
 "my-project", 
 "us-central1", 
 "my-regional-parameter", 
 "v1" 
 ) 
 """ 
 # 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 version. 
 name 
 = 
 client 
 . 
  parameter_version_path 
 
 ( 
 project_id 
 , 
 location_id 
 , 
 parameter_id 
 , 
 version_id 
 ) 
 # Define the request to delete the parameter version. 
 request 
 = 
  parametermanager_v1 
 
 . 
  DeleteParameterVersionRequest 
 
 ( 
 name 
 = 
 name 
 ) 
 # Delete the parameter version. 
 client 
 . 
  delete_parameter_version 
 
 ( 
 request 
 = 
 request 
 ) 
 # Print a confirmation message. 
 print 
 ( 
 f 
 "Deleted regional parameter version: 
 { 
 name 
 } 
 " 
 ) 
 

Ruby

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

  require 
  
 "google/cloud/parameter_manager" 
 ## 
 # Delete a regional parameter version 
 # 
 # @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 name (e.g. "my-parameter") 
 # @param version_id [String] The version name (e.g. "my-version") 
 # 
 def 
  
 delete_regional_param_version 
  
 project_id 
 :, 
  
 location_id 
 :, 
  
 parameter_id 
 :, 
  
 version_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. 
  
 name 
  
 = 
  
 client 
 . 
  parameter_version_path 
 
  
 project 
 : 
  
 project_id 
 , 
  
 location 
 : 
  
 location_id 
 , 
  
 parameter 
 : 
  
 parameter_id 
 , 
  
 parameter_version 
 : 
  
 version_id 
  
 # Create the parameter version. 
  
 param_version 
  
 = 
  
 client 
 . 
 delete_parameter_version 
  
 name 
 : 
  
 name 
  
 # Print the parameter version name. 
  
 puts 
  
 "Deleted regional parameter version 
 #{ 
 name 
 } 
 " 
 end 
 

What's next

Create a Mobile Website
View Site in Mobile | Classic
Share by: