Skip to content

feat(parametermanager): Added samples for global & regional parameter manager #2079

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

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

Conversation

durgesh-ninave-crest
Copy link

Description

Created samples for Global and Regional Parameter Manager API

Samples (Global, Regional)

  1. quickstart
  2. parameter-structured-data
  3. parameter-unstructured-data
  4. add-parameter-version (structured, unstructured)
  5. create-parameter-secret-reference
  6. list-all-parameters
  7. view-parameter-details
  8. delete-parameter
  9. list-all-parameters-versions
  10. view-parameter-version-details
  11. render-secret-parameter-version
  12. disable-parameters-version
  13. enable-disabled-parameters-version
  14. delete-parameter-version

Checklist

  • I have followed guidelines from the CONTRIBUTING.MD
  • Appropriate changes to README are included in PR
  • Test passed: ../testing/vendor/bin/phpunit test/ -v
  • Lint passed: php-cs-fixer fix . --config .php-cs-fixer.dist.php
  • 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

Please merge this PR for me once it is approved

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Apr 8, 2025
Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

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

see my comments on #2071 (review)

Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

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

this is really well done! I was able to run the tests locally and they all passed.

I made some minor suggestions for how to construct the JSON payload - it's more idiomatic to call json_encode on a PHP array than hardcode a string. But this is minor, so, approved!

$parent = $client->parameterName($projectId, 'global', $parameterId);

// Build payload.
$payload = sprintf('{"username": "test-user", "password": "__REF__(//secretmanager.googleapis.com/%s)"}', $secretId);
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be better off using json_encode:

Suggested change
$payload = sprintf('{"username": "test-user", "password": "__REF__(//secretmanager.googleapis.com/%s)"}', $secretId);
$payload = json_encode([
'username' => 'test-user',
'password' => sprintf('__REF__(//secretmanager.googleapis.com/%s)', $secretId)
]);

Choose a reason for hiding this comment

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

I've updated payload using json_encode.

$parent = $client->parameterName($projectId, $locationId, $parameterId);

// Build payload.
$payload = sprintf('{"username": "test-user", "password": "__REF__(//secretmanager.googleapis.com/%s)"}', $secretId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with this one - better to use json_encode

Choose a reason for hiding this comment

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

I've updated payload using json_encode.

printf('Created parameter %s with format %s' . PHP_EOL, $newParameter->getName(), ParameterFormat::name($newParameter->getFormat()));

// Create a new ParameterVersionPayload object and set the json data.
$payload = '{"username": "test-user", "host": "localhost"}';
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with this one - better to use json_encode

Suggested change
$payload = '{"username": "test-user", "host": "localhost"}';
$payload = json_encode(['username' => 'test-user', 'host' => 'localhost']);

Choose a reason for hiding this comment

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

I've updated payload using json_encode.

printf('Created regional parameter %s with format %s' . PHP_EOL, $newParameter->getName(), ParameterFormat::name($newParameter->getFormat()));

// Create a new ParameterVersionPayload object and set the json data.
$payload = '{"username": "test-user", "host": "localhost"}';
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with this one - better to use json_encode

Suggested change
$payload = '{"username": "test-user", "host": "localhost"}';
$payload = json_encode(['username' => 'test-user', 'host' => 'localhost']);

Choose a reason for hiding this comment

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

I've updated payload using json_encode.

@durgesh-ninave-crest durgesh-ninave-crest marked this pull request as ready for review April 30, 2025 17:39
@durgesh-ninave-crest durgesh-ninave-crest requested review from a team as code owners April 30, 2025 17:39
Copy link

snippet-bot bot commented Apr 30, 2025

Here is the summary of changes.

You are about to add 30 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

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

Successfully merging this pull request may close these issues.

2 participants