Skip to content

feat(parametermanager): Added global and regional samples for parameter manager #2071

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

Conversation

vatsal-vora-crestdata
Copy link

Description

Created samples for Global and Regional Parameter Manager API

Samples (Global, Regional)
quickstart
parameter-structured-data
parameter-unstructured-data
add-parameter-version (structured, unstructured)
create-parameter-secret-reference
list-all-parameters
view-parameter-details
delete-parameter
list-all-parameters-versions
view-parameter-version-details
render-secret-parameter-version
disable-parameters-version
enable-disabled-parameters-version
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

@vatsal-vora-crestdata vatsal-vora-crestdata requested a review from a team as a code owner February 28, 2025 09:31
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Feb 28, 2025
Copy link

snippet-bot bot commented Feb 28, 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

@vatsal-vora-crestdata vatsal-vora-crestdata marked this pull request as draft February 28, 2025 10:01
@durgesh-ninave-crest
Copy link

Raised a duplicate of this PR #2079 because Vatsal's CLA has expired, which is blocking the merge. Once the new PR is merged, will close the original one.

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)
]);

$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 - might be better to use 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.

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

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 here

@bshaffer
Copy link
Contributor

Closing as duplicate of #2079

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.

3 participants