Skip to content

feat(parametermanager): add templates, tags and checksum samples - #14629

Open
suvidha-malaviya wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
suvidha-malaviya:feat/parametermanager-templates-tags-checksum-python
Open

suvidha-malaviya wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
suvidha-malaviya:feat/parametermanager-templates-tags-checksum-python

Conversation

@suvidha-malaviya

@suvidha-malaviya suvidha-malaviya commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds Python samples and tests for Parameter Manager templates, tags and checksums, for both global and regional parameters.

  • Create a parameter template
  • Create a parameter template version with variable placeholders
  • List all parameter templates
  • View parameter template details
  • List all parameter template versions
  • View parameter template version details
  • Update a parameter template's labels
  • Delete a parameter template
  • Disable / enable a parameter template version
  • Delete a parameter template version
  • Render a parameter template version using a parameter version's values
  • Create a parameter with tags
  • Bind a tag to a parameter (creates the parameter, then binds an existing tag value through Resource Manager)
  • Get the tags of a parameter (read as Resource Manager tag bindings, because Parameter.tags is input-only and is not returned by Parameter Manager)
  • Create a parameter version with a client-computed CRC32C checksum
  • View a parameter version and verify the returned checksum
  • Create a parameter version with a mismatched checksum (negative; covered as a test only)
  • Quick Start - Create Template -> Create Template Version -> Create Parameter + Version with matching values -> Render Template Version

Bumps google-cloud-parametermanager to 0.4.3, adds google-crc32c, and updates the test requirements (protobuf 6 compatible secret-manager/kms, plus resource-manager for tag binding checks).

Checklist

  • I have followed Sample Guidelines from AUTHORING_GUIDE.MD
  • README is updated to include all relevant information
  • Tests pass: nox -s py-3.10 (see Test Environment Setup)
  • Lint pass: nox -s lint (see Test Environment Setup)
  • These samples need a new API enabled in testing projects to pass (Cloud Resource Manager API — cloudresourcemanager.googleapis.com, used to bind tags and verify tag bindings)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
    - PARAMETER_MANAGER_TAG_KEY / PARAMETER_MANAGER_TAG_VALUE — an existing Resource Manager tag key and value (tagKeys/<id>, tagValues/<id>). The tag tests are skipped if they are unset.
    - The test identity needs permission to attach that tag value (e.g. roles/resourcemanager.tagUser).
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners 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

Add global and regional Python samples and tests for Parameter Manager templates (create, get, list, update labels, enable/disable, delete, render, quickstart), creating a parameter with tags, and CRC32C checksum create/verify. Bump google-cloud-parametermanager to 0.4.3.
@product-auto-label product-auto-label Bot added api: parametermanager samples Issues that are directly related to samples. labels Oct 7, 2026

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

Copy link
Copy Markdown
Contributor

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 a comprehensive set of Python snippets and integration tests for Google Cloud Parameter Manager templates, covering both global and regional resource management. The feedback highlights critical runtime bugs in the template rendering snippets and tests where non-existent attributes (payload and parameter_version) are accessed on the RenderTemplateVersionResponse object. Additionally, it suggests optimizing the template label update snippets by removing redundant get_template API calls, as update_template already returns the updated resource.

Comment on lines +80 to +82
# Print the template payload and the rendered payload.
print(f"Template payload: {response.payload.data.decode('utf-8')}")
print(f"Rendered payload: {response.rendered_payload.decode('utf-8')}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The RenderTemplateVersionResponse object returned by render_template_version only contains the rendered_payload field. It does not contain a payload attribute, so attempting to access response.payload will raise an AttributeError at runtime. We should remove the print statement for the template payload.

Suggested change
# Print the template payload and the rendered payload.
print(f"Template payload: {response.payload.data.decode('utf-8')}")
print(f"Rendered payload: {response.rendered_payload.decode('utf-8')}")
# Print the rendered payload.
print(f"Rendered payload: {response.rendered_payload.decode('utf-8')}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have payload field in RenderTemplateVersionResponse

Comment on lines +88 to +90
# Print the template payload and the rendered payload.
print(f"Template payload: {response.payload.data.decode('utf-8')}")
print(f"Rendered regional payload: {response.rendered_payload.decode('utf-8')}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The RenderTemplateVersionResponse object returned by render_template_version only contains the rendered_payload field. It does not contain a payload attribute, so attempting to access response.payload will raise an AttributeError at runtime. We should remove the print statement for the template payload.

Suggested change
# Print the template payload and the rendered payload.
print(f"Template payload: {response.payload.data.decode('utf-8')}")
print(f"Rendered regional payload: {response.rendered_payload.decode('utf-8')}")
# Print the rendered payload.
print(f"Rendered regional payload: {response.rendered_payload.decode('utf-8')}")

Comment on lines +967 to +969
assert response.payload.data == payload
assert param_id in response.parameter_version
assert json.loads(response.rendered_payload.decode("utf-8")) == values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The RenderTemplateVersionResponse object returned by render_param_template_version only contains the rendered_payload field. It does not contain payload or parameter_version attributes, so these assertions will raise an AttributeError at runtime. We should remove them and only assert on the rendered_payload.

Suggested change
assert response.payload.data == payload
assert param_id in response.parameter_version
assert json.loads(response.rendered_payload.decode("utf-8")) == values
assert json.loads(response.rendered_payload.decode("utf-8")) == values

Comment on lines +1025 to +1027
assert response.payload.data == payload
assert param_id in response.parameter_version
assert json.loads(response.rendered_payload.decode("utf-8")) == values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The RenderTemplateVersionResponse object returned by render_regional_param_template_version only contains the rendered_payload field. It does not contain payload or parameter_version attributes, so these assertions will raise an AttributeError at runtime. We should remove them and only assert on the rendered_payload.

Suggested change
assert response.payload.data == payload
assert param_id in response.parameter_version
assert json.loads(response.rendered_payload.decode("utf-8")) == values
assert json.loads(response.rendered_payload.decode("utf-8")) == values

Comment on lines +70 to +74
client.update_template(request=request)

# The update response does not include the labels, so get the template
# again to read the stored labels.
response = client.get_template(request={"name": name})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The update_template method already returns the updated Template object, including its labels. There is no need to make an extra get_template API call to retrieve the updated labels, which saves a network round-trip.

Suggested change
client.update_template(request=request)
# The update response does not include the labels, so get the template
# again to read the stored labels.
response = client.get_template(request={"name": name})
response = client.update_template(request=request)

Comment on lines +75 to +79
client.update_template(request=request)

# The update response does not include the labels, so get the template
# again to read the stored labels.
response = client.get_template(request={"name": name})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The update_template method already returns the updated Template object, including its labels. There is no need to make an extra get_template API call to retrieve the updated labels, which saves a network round-trip.

Suggested change
client.update_template(request=request)
# The update response does not include the labels, so get the template
# again to read the stored labels.
response = client.get_template(request={"name": name})
response = client.update_template(request=request)

Add global and regional samples that bind a tag value to a parameter through Resource Manager and read the tags of a parameter as tag bindings, with tests.
@suvidha-malaviya
suvidha-malaviya marked this pull request as ready for review October 7, 2026 09:50
@suvidha-malaviya
suvidha-malaviya requested review from a team as code owners October 7, 2026 09:50
@snippet-bot

snippet-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

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

@suvidha-malaviya
suvidha-malaviya force-pushed the feat/parametermanager-templates-tags-checksum-python branch from 31fd7ae to 12b5773 Compare October 7, 2026 10:17
@suvidha-malaviya
suvidha-malaviya force-pushed the feat/parametermanager-templates-tags-checksum-python branch from 19a741f to 654a76e Compare October 7, 2026 10:33
@suvidha-malaviya
suvidha-malaviya marked this pull request as draft October 7, 2026 10:33
@suvidha-malaviya
suvidha-malaviya marked this pull request as ready for review October 7, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: parametermanager samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants