-
Notifications
You must be signed in to change notification settings - Fork 12
docs(samples): add template/monitoring samples #174
Conversation
|
Here is the summary of changes. You are about to add 7 region tags.
This comment is generated by snippet-bot.
|
|
Hey @savijatv! Sorry I haven't sent you any reviews recently - can you PTAL at this and let me know when you've reviewed it? |
| Create a monitoring policy that notifies you 30 days before a managed CA expires. | ||
|
|
||
| Args: | ||
| project_id: project ID or project number of the Cloud project you want to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, project ID and project number are different entities. Does this function accept either or these? If not, please specify the correct one, project ID OR project number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch - they are different entities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For python-compute we use the same description: https://github.com/googleapis/python-compute/blob/main/samples/snippets/sample_create_vm.py#L167
Here we accept both entities as an input parameter: project ID and project number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leahecole @savijatv WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think that they're different. The Project ID starts with a letter whereas Project number is all numeric. See https://cloud.google.com/resource-manager/docs/creating-managing-projects.
Does the code accept both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, have just checked, the code accepts both
| List the certificate templates present in the given project and location. | ||
|
|
||
| Args: | ||
| project_id: project ID or project number of the Cloud project you want to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, project ID and project number are different entities. Does this function accept either or these? If not, please specify the correct one, project ID OR project number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch - they are different entities
| Delete the certificate template present in the given project and location. | ||
|
|
||
| Args: | ||
| project_id: project ID or project number of the Cloud project you want to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, project ID and project number are different entities. Does this function accept either or these? If not, please specify the correct one, project ID OR project number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch - they are different entities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have double checked with a gloud projects describe and it seems that both project ID and number work in API calls. See more here: https://cloud.google.com/resource-manager/docs/creating-managing-projects
To be on the safe side we should test this sample with ID and number as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that this is a bit strange behavior
Makes sense to add a test.
| alert_policy=alert_policy, | ||
| ) | ||
|
|
||
| print("Monitoring policy successfully created !", policy.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space before !
Also, in case of any error, does this sample print an error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a good question. But this PR is just a python equivalent of Java samples: https://github.com/googleapis/java-security-private-ca/blob/main/samples/snippets/cloud-client/src/main/java/privateca/MonitorCertificateAuthority.java#L87
We can fix it later I guess
| request = privateca_v1.ListCertificateTemplatesRequest( | ||
| parent=caServiceClient.common_location_path(project_id, location), | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we supposed to print an error message, in case of an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess here we have either exception itself or printed list of templates
savijatv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the code accepts both project ID and project number as the argument, please ignore my comment.
70e0749 to
25d0cb5
Compare
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕