Repository navigation
feat(spanner): Add UpdateBackupSchedule cron and retention sample - #14986
Conversation
Adjusting backup schedule frequency or retention window uses DatabaseAdminClient.update_backup_schedule with an update_mask. Add a standalone spanner_update_backup_schedule sample.
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new script and corresponding tests to update a Google Cloud Spanner backup schedule's cron frequency, retention duration, and encryption configuration. The review feedback recommends explicitly constructing the update mask using google.protobuf.field_mask_pb2.FieldMask instead of passing a raw dictionary, which improves type safety and aligns with Google Cloud Python client library best practices.
| import sys | ||
|
|
||
| from google.api_core import exceptions | ||
| from google.cloud import spanner_admin_database_v1 |
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks! Keeping the dictionary form: the update samples in this set all pass the mask as a dictionary, which the client accepts, so this one stays consistent with them.
| update_mask={ | ||
| "paths": [ | ||
| "spec.cron_spec.text", | ||
| "retention_duration", | ||
| "encryption_config", | ||
| ] | ||
| }, |
There was a problem hiding this comment.
Use field_mask_pb2.FieldMask to explicitly construct the update mask instead of passing a raw dictionary. This is more idiomatic, type-safe, and aligns with Google Cloud Python client library best practices.
| update_mask={ | |
| "paths": [ | |
| "spec.cron_spec.text", | |
| "retention_duration", | |
| "encryption_config", | |
| ] | |
| }, | |
| update_mask=field_mask_pb2.FieldMask( | |
| paths=[ | |
| "spec.cron_spec.text", | |
| "retention_duration", | |
| "encryption_config", | |
| ] | |
| ), |
There was a problem hiding this comment.
Thanks! Keeping the dictionary form: the update samples in this set all pass the mask as a dictionary, which the client accepts, so this one stays consistent with them.
Description
Adds
spanner_update_backup_scheduleupdating cron expression and retention duration on a Spanner backup schedule.Checklist
Testing
Compliance & Style
spanner/, which the default repository owners cover.Post-Approval Actions