-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Add cap billing walkthrough tutorial #4494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cap billing walkthrough tutorial #4494
Conversation
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.
Some questions:
1a) Are we planning to implement this in other languages? If we're implementing it in both Node and Python, that implies (to me) that we should also support Java and Go.
1b) I'm not sure this sample is complex enough to justify implementing in four languages (unless someone other than my Serverless team is responsible for maintaining them). @grant WDYT? (@tod-hilton: is there customer feedback requesting this?)
2) Maybe this content would be better created as a codelab or Qwiklab than in GitHub, since that's typically where interactive walkthroughs/tutorials reside? (@tod-hilton thoughts?)
@@ -0,0 +1,154 @@ | |||
# Automating cost controls by capping billing |
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.
Nit: can we name this file tutorial.md
? (A one-word name is probably cleaner.)
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.
Thanks for the questions, @ace-n.
1a) No, this will only be in Python.
1b) No, there aren't requests for multiple languages (at least now). If that changes when it goes public, we'll address it then.
2) I can see where that might seem reasonable, but we chose Neos and GitHub because @hujessica is interning with us this summer.
Regarding @grant's suggestion, I agree that it can live in a billing/
folder in this repo. We anticipate/hope to create more Neos-style tutorials in the future. And if we're using a billing/
folder, then I think the name should be something descriptive, like capbillingtutorial.md.
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.
Got it - thanks for the clarification!
A few further questions:
- I'm fine with longer names, but can we break them up a bit (e.g. hyphenate them)?
- Is this repo the best place to put Neos tutorials? (i.e. would it be better to create a separate GitHub repo dedicated to them, assuming they're supposed to live on a public GitHub a la our community tutorials site?)
- I like @grant's suggestion of using a
billing
folder. If we merge these samples into this repo, we should identify an owner and document that in the repo-rootCODEOWNERS
file.
(Note to self: if we move this to a separate folder, we'll have to do the same for Node.)
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.
Also - N.B: the Node implementation is here.
(I presume the reason for not reusing that code is that external developers are more familiar with Python.)
Thanks for the PR @hujessica. Looks like a useful same for the Cloud Billing API. Is there a GitHub issue for this sample? Or a Google Doc planning it? I would recommend that this sample lives in a new |
@grant - Jessica created a doc plan (go/pban-doc-plan) and tutorial draft (go/pban-tut-draft). |
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.
Thanks Tod! Personally excited to see this API sample.
Looking at the design doc, this looks like primary sample shows the Cloud Billing API. It uses Pub/Sub as the event channel and Functions Pub/Sub trigger (Could be Cloud Run, or a different Pub/Sub sink).
Let's move the code to a billing
folder.
I'd imagine the code would be in a billing/tutorial/
folder.
billing/tutorial/README.md
billing/tutorial/main.py
walkthroughtutorial.md- put in README.md- The tutorial is short enough where we can put the instructions in the main README, which is the default markdown file for the folder (it renders nicely on GitHub).
functions/billing/README.md
Outdated
## Contributing | ||
|
||
Contributions to this library are always welcome and highly encouraged. | ||
|
||
See [CONTRIBUTING](CONTRIBUTING) for more information on how to get started. | ||
|
||
## License | ||
|
||
Apache 2.0 - See [LICENSE](LICENSE) for more information. |
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.
We can leave this out.
We have common contributing and license files in this repo already.
Thanks for the help and feedback, @ace-n and @grant! To make sure I'm clear on your suggestions, here's what we should do:
How's that all sound? Any other thoughts, @NimishC? |
Those 5 things all sound good 👍 |
All that sounds good to me too 👍 |
LGTM to me too. 🙂 Thanks for putting this together @hujessica! |
Great, thanks all! @hujessica has made all of the changes and it's ready for review. |
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.
LGTM
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.
To be clear, this sample should live in a new folder, billing/
:
https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/billing
@grant Got it! Created a new folder called billing, let me know how it looks now. |
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.
Folder structure looks good 👍 I didn't review the PR contents in detail.
billing/cap-billing-walkthrough.md
Outdated
This function will remove the billing account associated with the project if the cost amount is higher than the budget amount. | ||
```sh | ||
gcloud functions deploy ${FUNCTION_NAME} \ | ||
--runtime=python37 --source=./sample_code \ |
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.
split up the flags?
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.
Good catch, just fixed that.
@busunkim96 - I see this PR is assigned to you. Please take a look at your earliest convenience. Thanks! |
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.
Hiya!
(1) I don't see region tags in the file. Is this going to be used as snippets in cloud.google.com? Never mind. I didn't see the explanation above. :)
(2) Please add tests. You can reference the other directories for examples.
billing/CODEOWNERS
Outdated
@@ -0,0 +1,5 @@ | |||
# These owners will be the default owners for everything in |
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.
import base64 | ||
import json | ||
import os | ||
from googleapiclient import discovery |
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.
Can the GAPIC libraries be used instead? https://github.com/googleapis/python-billing and https://github.com/googleapis/python-billingbudgets? (not sure which is applicable here).
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'm not familiar with the GAPIC libraries. What is the benefit or reason for using them versus the one currently being used?
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.
Among other things, they're generally cleaner/easier to use from a syntactical perspective.
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.
This page explains the main differences. (GAPIC == Google Cloud Client Library)
billing/cap-billing-walkthrough.md
Outdated
<walkthrough-project-setup></walkthrough-project-setup> | ||
|
||
```sh | ||
export GCP_PROJECT={{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 use GOOGLE_CLOUD_PROJECT
- this is the env var that's used by the auth library https://googleapis.dev/python/google-auth/latest/reference/google.auth.environment_vars.html?highlight=google_cloud_project It's also automatically populated in our test setup.
Thanks for the review, @busunkim96! I'm not familiar with which tests we would use for this scenario. The previous tutorial our team implemented didn't have any tests associated with it: https://github.com/GoogleCloudPlatform/deploymentmanager-samples/pull/493/files. Can you direct us to specific examples we should implement, assuming we do need to before merging? |
@ace-n - I see that you enabled automerge, but the PR doesn't seem to have been merged yet. Can you help? Thanks! ~tod |
@busunkim96 - Thanks for looking at this this morning! Is there anything we need to do to help you and @ace-n merge this? |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@tod-hilton Nothing in particular! I'm just trying to get the branch up to date with master before merging. 😁 @googlebot Overriding CLA as the author was an intern with a valid CLA at the time this PR was created. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@busunkim96, @ace-n, & @grant - Thanks for all of your help getting this merged!!! @NimishC and I will start on the remaining action items soon. |
Description
Fixes #
Note: It's a good idea to open an issue first for discussion.
Checklist
nox -s py-3.6
(see Test Environment Setup)nox -s lint
(see Test Environment Setup)