-
Notifications
You must be signed in to change notification settings - Fork 3
docs: add code samples #5
Conversation
|
Here is the summary of possible violations 😱 There are 2 possible violations for not having product prefix.
The end of the violation section. All the stuff below is FYI purposes only. Here is the summary of changes. You are about to add 2 region tags.
This comment is generated by snippet-bot.
|
busunkim96
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.
Hi @changsongd! I took a first pass through this PR.
The test environment has a project. You can fetch the id through the google-auth library:
import google.auth
credentials, project_id = google.auth.default()I'll open a CL to enable samples CI on this PR as well. If you haven't already, please review https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md.
|
|
||
| with open(request_file_name, 'r') as f: | ||
| # The request must include the "parent" field with the value set to | ||
| # "projects/{YOUR_GCP_PROJECT_ID}". |
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.
Please avoid commented out variables, as they're prone to breaking without us noticing. Could you make project_id an argument to the function instead?
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.
The project_id is best to be set in resources/sync_request.json. I can make it an argument and let the function inject it into the request, but it might be too cumbersome for our users in real life use case. I can avoid explicitly calling out the variables in the comment. For example, I can change the comment to
Please replace the variables in "resources/sync_request.json" before calling the API.
Please let me know if that sounds good.
|
Why is the snippet-bot complaining about the region tag prefix?
|
|
Hi @busunkim96 , I'm getting a permission denied error from sample checks: I don't have access to the project and can't enable the API. Could you grant me the access or help me enable the API? |
|
@changsongd I've enabled the API. Could you let me know what IAM permissions I should grant to the service account so it can run the samples? |
Hi, you might need to add the role of |
|
@changsongd Hmm I can't find that role in the dropdown (or in https://cloud.google.com/iam/docs/permissions-reference), are the roles fully rolled out? The tests look like they're failing now because the requests include the unresolved env var names: |
|
@dizcology suggested using the generated code samples in the documentation. I will close this PR. Thank you @busunkim96 for all your efforts and helps! |
Add code snippets for sync and async APIs.
The region tags have been created: https://devrel.corp.google.com/snippets/region-tags?region_tag=%25optimization%25