Skip to content
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 billing samples (Node 8 ONLY) #748

Merged
merged 5 commits into from
Sep 25, 2018
Merged

Add billing samples (Node 8 ONLY) #748

merged 5 commits into from
Sep 25, 2018

Conversation

ace-n
Copy link
Contributor

@ace-n ace-n commented Sep 24, 2018

@labtopia FYI

@ace-n ace-n requested a review from fhinkel September 24, 2018 20:44
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 24, 2018
const {google} = require('googleapis');
const {auth} = require('google-auth-library');

const PROJECT_ID = process.env.GCP_PROJECT;
Copy link
Contributor

@fhinkel fhinkel Sep 24, 2018

Choose a reason for hiding this comment

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

I think GCP_PROJECT is not a variable we usually set. Can we use the standard mechanism instead?

Copy link
Contributor Author

@ace-n ace-n Sep 25, 2018

Choose a reason for hiding this comment

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

It is defined (and named) by GCF itself.

functions/billing/index.js Outdated Show resolved Hide resolved

exports.stopBilling = async (data, context) => {
const pubsubData = JSON.parse(Buffer.from(data.data, 'base64').toString());
if (pubsubData.costAmount <= pubsubData.budgetAmount) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to assure that costAmount is a number and not a string? Want to avoid cases like '100' < '2' = true

Copy link
Contributor Author

@ace-n ace-n Sep 25, 2018

Choose a reason for hiding this comment

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

Probably not - the Billing API itself outputs a number, not a string.

FWIW this is how the code is currently structured.

Copy link
Contributor

@fhinkel fhinkel left a comment

Choose a reason for hiding this comment

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

Can you add it to the internal CI?

@ace-n
Copy link
Contributor Author

ace-n commented Sep 25, 2018

CI (config) has been added - PTAL?

@ace-n ace-n merged commit b81ec57 into master Sep 25, 2018
@ace-n ace-n deleted the slack-billing branch September 25, 2018 21:49
ace-n pushed a commit that referenced this pull request Nov 16, 2022
* chore(main): release 4.1.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
ace-n pushed a commit that referenced this pull request Nov 17, 2022
* chore(main): release 4.1.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
ahrarmonsur pushed a commit that referenced this pull request Nov 17, 2022
* chore(main): release 4.1.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants