Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parametermanager): Added samples to delete, enable and disable parameter versions in both region and global #4014

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

vatsal-vora-crestdata
Copy link

@vatsal-vora-crestdata vatsal-vora-crestdata commented Mar 5, 2025

Description

Created samples for deleting, enabling and disabling parameter and parameter version in both regional and global. Also added quickstart examples for both global and regional

Added Sample List:

  1. Quick start samples for both regional and global
  2. delete-parameter
  3. disable-parameters-version
  4. enable-disabled-parameters-version
  5. delete-parameter-version

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • These samples need a new API enabled in testing projects to pass (let us know which ones) - This requires Parameter manager API to be enabled
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones) - This requires GCLOUD_LOCATION to be set otherwise it will use us-central1
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@vatsal-vora-crestdata vatsal-vora-crestdata requested review from a team as code owners March 5, 2025 11:58
Copy link

snippet-bot bot commented Mar 5, 2025

Here is the summary of changes.

You are about to add 10 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: workflows Issues related to the Workflows API. labels Mar 5, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @vatsal-vora-crestdata, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request introduces samples for deleting, enabling, and disabling parameter versions in both regional and global contexts using the Google Cloud Parameter Manager. It also includes quickstart examples for both global and regional parameter management. The changes include the addition of new files containing the sample code and a modification to the workflow configuration to include the new samples.

Highlights

  • New Samples: Adds samples for deleting parameters, disabling parameter versions, enabling disabled parameter versions, and deleting parameter versions, covering both global and regional scenarios.
  • Workflow Configuration: Updates the .github/workflows/parametermanager.yaml file to include the new samples in the CI/CD pipeline.
  • Quickstart Examples: Includes quickstart examples demonstrating basic parameter management operations for both global and regional setups.

Changelog

Click here to see the changelog
  • .github/workflows/parametermanager.yaml
    • Added a new workflow configuration file for Parameter Manager to automate testing and flaky bot checks.
  • .github/workflows/utils/workflows.json
    • Added 'parametermanager' to the list of workflows to be executed.
  • parametermanager/deleteParam.js
    • Created a new sample to delete a parameter from the global location of a specified project.
    • Implements the deleteParam function to delete the parameter using the Parameter Manager client library.
  • parametermanager/deleteParamVersion.js
    • Created a new sample to delete a specific version of a parameter in the global location.
    • Implements the deleteParamVersion function to delete the parameter version using the Parameter Manager client library.
  • parametermanager/disableParamVersion.js
    • Created a new sample to disable a specific version of a global parameter.
    • Implements the disableParamVersion function to update the parameter version's disabled field to true.
  • parametermanager/enableParamVersion.js
    • Created a new sample to enable a specific version of a global parameter.
    • Implements the enableParamVersion function to update the parameter version's disabled field to false.
  • parametermanager/package.json
    • Added a new package.json file for the Parameter Manager samples.
    • Includes dependencies such as @google-cloud/parametermanager, @google-cloud/secret-manager, c8, chai, mocha, and uuid.
  • parametermanager/quickstart.js
    • Created a new quickstart sample for global parameter management.
    • Demonstrates creating a parameter, creating a parameter version, viewing the parameter version, and rendering its payload.
  • parametermanager/regional_samples/deleteRegionalParam.js
    • Created a new sample to delete a parameter from a specified region.
    • Implements the deleteRegionalParam function to delete the regional parameter using the Parameter Manager client library.
  • parametermanager/regional_samples/deleteRegionalParamVersion.js
    • Created a new sample to delete a specific version of a parameter in a specified region.
    • Implements the deleteRegionalParamVersion function to delete the regional parameter version using the Parameter Manager client library.
  • parametermanager/regional_samples/disableRegionalParamVersion.js
    • Created a new sample to disable a specific version of a regional parameter.
    • Implements the disableRegionalParamVersion function to update the regional parameter version's disabled field to true.
  • parametermanager/regional_samples/enableRegionalParamVersion.js
    • Created a new sample to enable a specific version of a regional parameter.
    • Implements the enableRegionalParamVersion function to update the regional parameter version's disabled field to false.
  • parametermanager/regional_samples/regionalQuickstart.js
    • Created a new quickstart sample for regional parameter management.
    • Demonstrates creating a regional parameter, creating a parameter version, viewing the parameter version, and rendering its payload.
  • parametermanager/test/.eslintrc.yml
    • Added a new .eslintrc.yml file for the Parameter Manager tests.
    • Configures the environment for Mocha testing.
  • parametermanager/test/parametermanager.test.js
    • Created a new test file for the Parameter Manager samples.
    • Includes tests for the quickstart, regional quickstart, enable/disable parameter versions, and delete parameter/parameter versions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


In the realm of parameters, versions reside,
Managed with care, where code does confide.
Enable, disable, delete with grace,
In cloud's vast space, find your place.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces samples for deleting, enabling, and disabling parameter versions in both regional and global contexts. The addition of quickstart examples for both global and regional configurations enhances the usability of the Parameter Manager. The code is generally well-structured and follows a consistent pattern across the different samples.

Summary of Findings

  • Copyright Year: The copyright year in the files is set to 2025. Please ensure this is the correct and intended year.
  • Missing Error Handling: The samples lack explicit error handling for API calls. Adding error checks would improve the robustness of the samples.
  • Inconsistent Parameter Usage: There are inconsistencies in how parameters are passed and used across different samples, particularly in the regional samples. Standardizing this would improve clarity.

Merge Readiness

The pull request introduces valuable samples for managing parameters and their versions in both global and regional contexts. However, before merging, it's recommended to address the copyright year, incorporate error handling, and standardize parameter usage across the samples. I am unable to approve this pull request, and recommend that others review and approve this code before merging.

@@ -0,0 +1,55 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm this is the correct year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2024 Google LLC

@@ -0,0 +1,67 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm this is the correct year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2024 Google LLC

@@ -0,0 +1,80 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm this is the correct year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2024 Google LLC

@@ -0,0 +1,80 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm this is the correct year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2024 Google LLC

@@ -0,0 +1,97 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm this is the correct year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2024 Google LLC

Comment on lines +62 to +64
await client.deleteParameterVersion({
name: name,
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding error handling to the API call to improve the robustness of the sample.

    try {
      await client.deleteParameterVersion({
        name: name,
      });
    } catch (err) {
      console.error(`Failed to delete regional parameter version: ${err}`);
      throw err;
    }

Comment on lines +75 to +77
// Make the API call to update the parameter version
const [response] = await client.updateParameterVersion(request);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding error handling to the API call to improve the robustness of the sample.

Suggested change
// Make the API call to update the parameter version
const [response] = await client.updateParameterVersion(request);
try {
const [response] = await client.updateParameterVersion(request);
return response;
} catch (err) {
console.error(`Failed to disable regional parameter version: ${err}`);
throw err;
}

Comment on lines +73 to +75
// Make the API call to update the parameter version
const [response] = await client.updateParameterVersion(request);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding error handling to the API call to improve the robustness of the sample.

Suggested change
// Make the API call to update the parameter version
const [response] = await client.updateParameterVersion(request);
try {
const [response] = await client.updateParameterVersion(request);
return response;
} catch (err) {
console.error(`Failed to enable regional parameter version: ${err}`);
throw err;
}

Comment on lines +66 to +68
// Create a new parameter
const [parameter] = await client.createParameter(parameterRequest);
console.log(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding error handling to the API call to improve the robustness of the sample.

    try {
      const [parameter] = await client.createParameter(parameterRequest);
      console.log(
        `Created regional parameter ${parameter.name} with format ${parameter.format}`
      );
    } catch (err) {
      console.error(`Failed to create regional parameter: ${err}`);
      throw err;
    }

Comment on lines +86 to +90
const [response] = await client.getParameterVersion({
name: parameterVersion.name,
});
console.log(`Retrieved regional parameter version: ${response.name}`);
console.log('Payload:', response.payload.data.toString('utf8'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding error handling to the API call to improve the robustness of the sample.

    try {
      const [response] = await client.getParameterVersion({
        name: parameterVersion.name,
      });
      console.log(`Retrieved regional parameter version: ${response.name}`);
      console.log('Payload:', response.payload.data.toString('utf8'));
    } catch (err) {
      console.error(`Failed to get regional parameter version: ${err}`);
      throw err;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: workflows Issues related to the Workflows API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant