Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Conversation

@FrodoTheTrue
Copy link
Contributor

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added api: security-privateca Issues related to the googleapis/python-security-private-ca API. samples Issues that are directly related to samples. labels Jan 26, 2022
@snippet-bot
Copy link

snippet-bot bot commented Jan 26, 2022

Here is the summary of changes.

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

@leahecole
Copy link

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.

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.

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

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.

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.

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.

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.

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

Copy link
Member

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.

Copy link
Contributor Author

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)

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?

Copy link
Contributor Author

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),
)

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?

Copy link
Contributor Author

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

@parthea parthea changed the title samples(security): add template/monitoring samples docs(samples): add template/monitoring samples Feb 3, 2022
@FrodoTheTrue FrodoTheTrue requested a review from a team as a code owner February 11, 2022 12:46
Copy link

@savijatv savijatv left a 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.

@FrodoTheTrue FrodoTheTrue merged commit 9fbd3e1 into main Feb 14, 2022
@FrodoTheTrue FrodoTheTrue deleted the ca-templates-samples branch February 14, 2022 13:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: security-privateca Issues related to the googleapis/python-security-private-ca API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants