From 518d762fb001e230e5fbd2638bbaa45f77858c2d Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Wed, 2 May 2018 15:45:14 -0400 Subject: [PATCH] Fix Readme.md in /samples Delete tests for sendgrid and mailjet. Add vms_api to the list of samples. Add descriptions, fix sample code, and fix broken links --- .cloud-repo-tools.json | 12 +- CONTRIBUTORS | 1 + README.md | 3 +- package.json | 1 + samples/README.md | 22 ++- samples/mailjet.js | 48 ------ samples/package-lock.json | 283 +++++----------------------------- samples/package.json | 5 +- samples/sendgrid.js | 51 ------ samples/test/.eslintrc.yml | 5 - samples/test/mailjet.test.js | 59 ------- samples/test/sendgrid.test.js | 58 ------- samples/vms_api.js | 5 +- 13 files changed, 77 insertions(+), 476 deletions(-) delete mode 100644 samples/mailjet.js delete mode 100644 samples/sendgrid.js delete mode 100644 samples/test/.eslintrc.yml delete mode 100644 samples/test/mailjet.test.js delete mode 100644 samples/test/sendgrid.test.js diff --git a/.cloud-repo-tools.json b/.cloud-repo-tools.json index ee57e17c..1cb9455a 100644 --- a/.cloud-repo-tools.json +++ b/.cloud-repo-tools.json @@ -7,9 +7,17 @@ "samples": [ { "id": "vms", - "name": "Virtual Machines", + "name": "List Virtual Machines", "file": "vms.js", - "docs_link": "https://cloud.google.com/compute/docs" + "docs_link": "https://cloud.google.com/compute/docs", + "description": "Get a list of virtual machine instances and log the first result.\n\n" + }, + { + "id": "vms_api", + "name": "Use Google Auth and list Virtual Machines", + "file": "vms_api.js", + "docs_link": "https://cloud.google.com/compute/docs", + "description": "After explicit authentication, get a list of virtual machine instances and log the first result.\n\n" } ] } diff --git a/CONTRIBUTORS b/CONTRIBUTORS index d9acfa92..82dfc98c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -12,6 +12,7 @@ CRoed Dave Gramlich Eric Uldall F. Hinkelmann +Franziska Hinkelmann Jason Dobry Jason Dobry Kevin Leung diff --git a/README.md b/README.md index 0a0b9afd..fff31c06 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,8 @@ has instructions for running the samples. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | -| Virtual Machines | [source code](https://github.com/googleapis/nodejs-compute/blob/master/samples/vms.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms.js,samples/README.md) | +| List Virtual Machines | [source code](https://github.com/googleapis/nodejs-compute/blob/master/samples/vms.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms.js,samples/README.md) | +| Use Google Auth and list Virtual Machines | [source code](https://github.com/googleapis/nodejs-compute/blob/master/samples/vms_api.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms_api.js,samples/README.md) | The [Compute Engine Node.js Client API Reference][client-docs] documentation also contains samples. diff --git a/package.json b/package.json index 04c595f5..e36d2a34 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "Dave Gramlich ", "Eric Uldall ", "F. Hinkelmann ", + "Franziska Hinkelmann ", "Jason Dobry ", "Jason Dobry ", "Kevin Leung ", diff --git a/samples/README.md b/samples/README.md index 9be4a160..2a73352b 100644 --- a/samples/README.md +++ b/samples/README.md @@ -12,7 +12,8 @@ * [Before you begin](#before-you-begin) * [Samples](#samples) - * [Virtual Machines](#virtual-machines) + * [List Virtual Machines](#list-virtual-machines) + * [Use Google Auth and list Virtual Machines](#use-google-auth-and-list-virtual-machines) ## Before you begin @@ -22,12 +23,27 @@ library's README. ## Samples -### Virtual Machines +### List Virtual Machines View the [source code][vms_0_code]. -[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms.js,samples/README.md)[vms_0_docs]: https://cloud.google.com/compute/docs +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms.js,samples/README.md) + +Get a list of virtual machine instances and log the first result. + +[vms_0_docs]: https://cloud.google.com/compute/docs [vms_0_code]: vms.js +### Use Google Auth and list Virtual Machines + +View the [source code][vms_api_1_code]. + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/vms_api.js,samples/README.md) + +After explicit authentication, get a list of virtual machine instances and log the first result. + +[vms_api_1_docs]: https://cloud.google.com/compute/docs +[vms_api_1_code]: vms_api.js + [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-compute&page=editor&open_in_editor=samples/README.md diff --git a/samples/mailjet.js b/samples/mailjet.js deleted file mode 100644 index ab368694..00000000 --- a/samples/mailjet.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2017, Google, Inc. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -// [START send] -var mailer = require('nodemailer'); -var smtp = require('nodemailer-smtp-transport'); - -var transport = mailer.createTransport( - smtp({ - host: 'in.mailjet.com', - port: 2525, - auth: { - user: process.env.MAILJET_API_KEY || '', - }, - }) -); - -transport.sendMail( - { - from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM', // From address - to: 'EMAIL@EXAMPLE.COM', // To address - subject: 'test email from Node.js on Google Cloud Platform', // Subject - text: 'Hello!\n\nThis a test email from Node.js.', // Content - }, - function(err, json) { - if (err) { - console.log(err); - } else { - console.log(json); - } - } -); -// [END send] diff --git a/samples/package-lock.json b/samples/package-lock.json index 31f98c74..c94d48ff 100644 --- a/samples/package-lock.json +++ b/samples/package-lock.json @@ -250,6 +250,21 @@ "requires": { "ms": "2.0.0" } + }, + "sinon": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.3.0.tgz", + "integrity": "sha512-pmf05hFgEZUS52AGJcsVjOjqAyJW2yo14cOwVYvzCyw7+inv06YXkLyW75WG6X6p951lzkoKh51L2sNbR9CDvw==", + "dev": true, + "requires": { + "@sinonjs/formatio": "2.0.0", + "diff": "3.5.0", + "lodash.get": "4.4.2", + "lolex": "2.3.2", + "nise": "1.3.3", + "supports-color": "5.3.0", + "type-detect": "4.0.8" + } } } }, @@ -309,16 +324,10 @@ "version": "2.0.0", "resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", "integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==", - "dev": true, "requires": { "samsam": "1.3.0" } }, - "addressparser": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/addressparser/-/addressparser-1.0.1.tgz", - "integrity": "sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y=" - }, "ajv": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", @@ -478,79 +487,6 @@ "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", "dev": true }, - "async.ensureasync": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.ensureasync/-/async.ensureasync-0.5.2.tgz", - "integrity": "sha1-w8fkpOmzHZaHXVa4UEWYRG4eMF0=", - "requires": { - "async.util.ensureasync": "0.5.2" - } - }, - "async.queue": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.queue/-/async.queue-0.5.2.tgz", - "integrity": "sha1-jV2QgS4UgQZrwJBOjMFxKxfDvXw=", - "requires": { - "async.util.queue": "0.5.2" - } - }, - "async.util.arrayeach": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.arrayeach/-/async.util.arrayeach-0.5.2.tgz", - "integrity": "sha1-WMTpgCjVXWm/sFrrOvROClVagpw=" - }, - "async.util.ensureasync": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.ensureasync/-/async.util.ensureasync-0.5.2.tgz", - "integrity": "sha1-EJB/LL0GegYfma5tIuCM7TDbDWg=", - "requires": { - "async.util.restparam": "0.5.2", - "async.util.setimmediate": "0.5.2" - } - }, - "async.util.isarray": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.isarray/-/async.util.isarray-0.5.2.tgz", - "integrity": "sha1-5i2sjyY29lh13PdSHC0k0N+yu98=" - }, - "async.util.map": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.map/-/async.util.map-0.5.2.tgz", - "integrity": "sha1-5YjvhuCzq18CfZevTWg10FXKadY=" - }, - "async.util.noop": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.noop/-/async.util.noop-0.5.2.tgz", - "integrity": "sha1-vdYrl8sKo/YLWGrRSEaGmJdeWLk=" - }, - "async.util.onlyonce": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.onlyonce/-/async.util.onlyonce-0.5.2.tgz", - "integrity": "sha1-uOb8AErckjFk154y8oE+5GXCT/I=" - }, - "async.util.queue": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.queue/-/async.util.queue-0.5.2.tgz", - "integrity": "sha1-V/Zavho83yc9MavSirlUJfgiLuU=", - "requires": { - "async.util.arrayeach": "0.5.2", - "async.util.isarray": "0.5.2", - "async.util.map": "0.5.2", - "async.util.noop": "0.5.2", - "async.util.onlyonce": "0.5.2", - "async.util.setimmediate": "0.5.2" - } - }, - "async.util.restparam": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.restparam/-/async.util.restparam-0.5.2.tgz", - "integrity": "sha1-A+/r88Ane5ciDlJaunUPXgT8gM0=" - }, - "async.util.setimmediate": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/async.util.setimmediate/-/async.util.setimmediate-0.5.2.tgz", - "integrity": "sha1-KBLrq/KlgCd1jUvHeT0cz68QJV8=" - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -1221,11 +1157,6 @@ "hoek": "4.2.1" } }, - "bottleneck": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-1.16.0.tgz", - "integrity": "sha1-1s4TgIUnr8gLaQkvFWBmVeWyHxo=" - }, "boxen": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz", @@ -1748,6 +1679,7 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, "requires": { "ms": "2.0.0" } @@ -1802,8 +1734,7 @@ "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" }, "dot-prop": { "version": "4.2.0", @@ -1859,14 +1790,6 @@ "core-js": "2.5.3" } }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "0.4.21" - } - }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", @@ -1903,7 +1826,8 @@ "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true }, "espower-location-detector": { "version": "1.0.0", @@ -3191,20 +3115,6 @@ "sshpk": "1.14.1" } }, - "httpntlm": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz", - "integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=", - "requires": { - "httpreq": "0.4.24", - "underscore": "1.7.0" - } - }, - "httpreq": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", - "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=" - }, "hullabaloo-config-manager": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/hullabaloo-config-manager/-/hullabaloo-config-manager-1.1.1.tgz", @@ -3227,14 +3137,6 @@ "safe-buffer": "5.1.1" } }, - "iconv-lite": { - "version": "0.4.21", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.21.tgz", - "integrity": "sha512-En5V9za5mBt2oUA03WGD3TwDv0MKAruqsuxstbMUZaj9W9k/m1CV/9py3l0L5kw9Bln8fdHQmzHSYtvpvTLpKw==", - "requires": { - "safer-buffer": "2.1.2" - } - }, "ignore-by-default": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", @@ -3667,8 +3569,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", - "dev": true + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==" }, "jwa": { "version": "1.1.5", @@ -3770,11 +3671,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" }, - "lodash.chunk": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz", - "integrity": "sha1-ZuXOH3btJ7QwPYxlEujRIW6BBrw=" - }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -3814,8 +3710,7 @@ "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", - "dev": true + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" }, "lodash.isequal": { "version": "4.5.0", @@ -3847,8 +3742,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", - "dev": true + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==" }, "longest": { "version": "1.0.1", @@ -3889,17 +3783,6 @@ "yallist": "2.1.2" } }, - "mailparser": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/mailparser/-/mailparser-0.6.2.tgz", - "integrity": "sha1-A8SGA5vfTfbNO2rcqqxBB9/bwGg=", - "requires": { - "encoding": "0.1.12", - "mime": "1.6.0", - "mimelib": "0.3.1", - "uue": "3.1.2" - } - }, "make-dir": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.2.0.tgz", @@ -4126,15 +4009,6 @@ "mime-db": "1.33.0" } }, - "mimelib": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/mimelib/-/mimelib-0.3.1.tgz", - "integrity": "sha1-eHrdJBXYJ6yzr27EvKHqlZZBiFM=", - "requires": { - "addressparser": "1.0.1", - "encoding": "0.1.12" - } - }, "mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", @@ -4207,10 +4081,9 @@ "optional": true }, "nise": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.3.2.tgz", - "integrity": "sha512-KPKb+wvETBiwb4eTwtR/OsA2+iijXP+VnlSFYJo3EHjm2yjek1NWxHOUQat3i7xNLm1Bm18UA5j5Wor0yO2GtA==", - "dev": true, + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.3.3.tgz", + "integrity": "sha512-v1J/FLUB9PfGqZLGDBhQqODkbLotP0WtLo9R4EJY2PPu5f5Xg4o0rA8FDlmrjFSv9vBBKcfnOSpfYYuu5RTHqg==", "requires": { "@sinonjs/formatio": "2.0.0", "just-extend": "1.1.27", @@ -4229,39 +4102,6 @@ "resolved": "https://registry.npmjs.org/node-status-codes/-/node-status-codes-1.0.0.tgz", "integrity": "sha1-WuVUHQJGRdMqWPzdyc7s6nrjrC8=" }, - "nodemailer": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-4.3.1.tgz", - "integrity": "sha512-ngyDzou/Rbppn9WUOpWNoe25mRrW5wMwRokWanBNLt+3YaxOLmUtrc0ZtHMOgHGFPAYNgKA9H70ELlV3qSHL7Q==" - }, - "nodemailer-fetch": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz", - "integrity": "sha1-ecSQihwPXzdbc/6IjamCj23JY6Q=" - }, - "nodemailer-shared": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz", - "integrity": "sha1-z1mU4v0mjQD1zw+nZ6CBae2wfsA=", - "requires": { - "nodemailer-fetch": "1.6.0" - } - }, - "nodemailer-smtp-transport": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/nodemailer-smtp-transport/-/nodemailer-smtp-transport-2.7.4.tgz", - "integrity": "sha1-DYmvAZoUSkgP2OzJmZfZ+DjxNoU=", - "requires": { - "nodemailer-shared": "1.1.0", - "nodemailer-wellknown": "0.1.10", - "smtp-connection": "2.12.0" - } - }, - "nodemailer-wellknown": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz", - "integrity": "sha1-WG24EB2zDLRDjrVGc3pBqtDPE9U=" - }, "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", @@ -6374,7 +6214,6 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, "requires": { "isarray": "0.0.1" }, @@ -6382,8 +6221,7 @@ "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" } } }, @@ -6934,8 +6772,7 @@ "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", - "dev": true + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==" }, "semver": { "version": "5.5.0", @@ -6952,25 +6789,6 @@ "semver": "5.5.0" } }, - "sendgrid": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/sendgrid/-/sendgrid-5.2.3.tgz", - "integrity": "sha512-FD7oR9TbJFUew1p0Vw9JX0wBetDyq634LzylSXz4n9+hwaf+6a9dNloZl8CcjpsX4NuEc3HJanTN4GjDwNyi4A==", - "requires": { - "async.ensureasync": "0.5.2", - "async.queue": "0.5.2", - "bottleneck": "1.16.0", - "debug": "2.6.9", - "lodash.chunk": "4.2.0", - "mailparser": "0.6.2", - "sendgrid-rest": "2.4.0" - } - }, - "sendgrid-rest": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/sendgrid-rest/-/sendgrid-rest-2.4.0.tgz", - "integrity": "sha512-3VRHhTnln17jPQNzBjEHO6u2Y7kLlhVnOvX0aGjr7yRVZpq5LXo0ilAFMsaHUfKVH+jFdCrHMAVLOAdtu6wLJA==" - }, "serialize-error": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-2.1.0.tgz", @@ -7011,16 +6829,15 @@ "dev": true }, "sinon": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.3.0.tgz", - "integrity": "sha512-pmf05hFgEZUS52AGJcsVjOjqAyJW2yo14cOwVYvzCyw7+inv06YXkLyW75WG6X6p951lzkoKh51L2sNbR9CDvw==", - "dev": true, + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-5.0.3.tgz", + "integrity": "sha512-kzBkET1Hf0r0J4uVnlicuAEiq9nnhPrEHZWS0mds+5EaB9rA0XoliIkLaqkBNU9lwPuJACo/velUQQOmTRJtUw==", "requires": { "@sinonjs/formatio": "2.0.0", "diff": "3.5.0", "lodash.get": "4.4.2", "lolex": "2.3.2", - "nise": "1.3.2", + "nise": "1.3.3", "supports-color": "5.3.0", "type-detect": "4.0.8" } @@ -7046,15 +6863,6 @@ "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=", "dev": true }, - "smtp-connection": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/smtp-connection/-/smtp-connection-2.12.0.tgz", - "integrity": "sha1-1275EnyyPCJZ7bHoNJwujV4tdME=", - "requires": { - "httpntlm": "1.6.1", - "nodemailer-shared": "1.1.0" - } - }, "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", @@ -7345,7 +7153,6 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", - "dev": true, "requires": { "has-flag": "3.0.0" }, @@ -7353,8 +7160,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" } } }, @@ -7376,8 +7182,7 @@ "text-encoding": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", - "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=", - "dev": true + "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=" }, "text-table": { "version": "0.2.0", @@ -7501,8 +7306,12 @@ "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "typedarray": { "version": "0.0.6", @@ -7556,11 +7365,6 @@ "integrity": "sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I=", "dev": true }, - "underscore": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", - "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" - }, "unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", @@ -7630,15 +7434,6 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, - "uue": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/uue/-/uue-3.1.2.tgz", - "integrity": "sha512-axKLXVqwtdI/czrjG0X8hyV1KLgeWx8F4KvSbvVCnS+RUvsQMGRjx0kfuZDXXqj0LYvVJmx3B9kWlKtEdRrJLg==", - "requires": { - "escape-string-regexp": "1.0.5", - "extend": "3.0.1" - } - }, "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", diff --git a/samples/package.json b/samples/package.json index 1503a72c..65bba78f 100644 --- a/samples/package.json +++ b/samples/package.json @@ -16,10 +16,7 @@ }, "dependencies": { "@google-cloud/compute": "0.10.0", - "googleapis": "22.2.0", - "nodemailer": "4.3.1", - "nodemailer-smtp-transport": "2.7.4", - "sendgrid": "5.2.3" + "googleapis": "22.2.0" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "2.2.3", diff --git a/samples/sendgrid.js b/samples/sendgrid.js deleted file mode 100644 index 95f87370..00000000 --- a/samples/sendgrid.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015-2016, Google, Inc. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -// [START send] -// This sample is based off of https://www.npmjs.com/package/sendgrid#without-mail-helper-class -var Sendgrid = require('sendgrid')( - process.env.SENDGRID_API_KEY || '' -); - -var request = Sendgrid.emptyRequest({ - method: 'POST', - path: '/v3/mail/send', - body: { - personalizations: [ - { - to: [{email: 'to_email@example.com'}], - subject: 'Sendgrid test email from Node.js on Google Cloud Platform', - }, - ], - from: {email: 'from_email@example.com'}, - content: [ - { - type: 'text/plain', - value: - 'Hello!\n\nThis a Sendgrid test email from Node.js on Google Cloud Platform.', - }, - ], - }, -}); - -Sendgrid.API(request, function(error, response) { - if (error) { - console.log('Mail not sent; see error message below.'); - } else { - console.log('Mail sent successfully!'); - } - console.log(response); -}); -// [END send] diff --git a/samples/test/.eslintrc.yml b/samples/test/.eslintrc.yml deleted file mode 100644 index c0289282..00000000 --- a/samples/test/.eslintrc.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -rules: - node/no-unpublished-require: off - node/no-unsupported-features: off - no-empty: off diff --git a/samples/test/mailjet.test.js b/samples/test/mailjet.test.js deleted file mode 100644 index 38df8086..00000000 --- a/samples/test/mailjet.test.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright 2017, Google, Inc. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const proxyquire = require(`proxyquire`).noPreserveCache(); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); - -process.env.MAILJET_API_KEY = `foo`; -process.env.MAILJET_API_SECRET = `bar`; - -test.beforeEach(tools.stubConsole); -test.afterEach.always(tools.restoreConsole); - -test.cb(`should send an email`, t => { - proxyquire(`../mailjet`, { - nodemailer: { - createTransport: arg => { - t.is(arg, `test`); - return { - sendMail: (payload, cb) => { - t.deepEqual(payload, { - from: `ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM`, - to: `EMAIL@EXAMPLE.COM`, - subject: `test email from Node.js on Google Cloud Platform`, - text: `Hello!\n\nThis a test email from Node.js.`, - }); - cb(null, `done`); - t.end(); - }, - }; - }, - }, - 'nodemailer-smtp-transport': options => { - t.deepEqual(options, { - host: `in.mailjet.com`, - port: 2525, - auth: { - user: `foo`, - pass: `bar`, - }, - }); - return `test`; - }, - }); -}); diff --git a/samples/test/sendgrid.test.js b/samples/test/sendgrid.test.js deleted file mode 100644 index a0162036..00000000 --- a/samples/test/sendgrid.test.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2017, Google, Inc. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const proxyquire = require(`proxyquire`).noPreserveCache(); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); - -process.env.SENDGRID_API_KEY = `foo`; - -test.beforeEach(tools.stubConsole); -test.afterEach.always(tools.restoreConsole); - -test.cb(`should send an email`, t => { - proxyquire(`../sendgrid`, { - sendgrid: key => { - t.is(key, `foo`); - return { - emptyRequest: x => x, - API: request => { - t.deepEqual(request, { - method: `POST`, - path: `/v3/mail/send`, - body: { - personalizations: [ - { - to: [{email: `to_email@example.com`}], - subject: `Sendgrid test email from Node.js on Google Cloud Platform`, - }, - ], - from: {email: `from_email@example.com`}, - content: [ - { - type: `text/plain`, - value: `Hello!\n\nThis a Sendgrid test email from Node.js on Google Cloud Platform.`, - }, - ], - }, - }); - t.end(); - }, - }; - }, - }); -}); diff --git a/samples/vms_api.js b/samples/vms_api.js index 15643a18..f9e70ed1 100644 --- a/samples/vms_api.js +++ b/samples/vms_api.js @@ -28,6 +28,8 @@ function auth(callback) { return callback(err); } + const projectId = authClient.projectId; + // The createScopedRequired method returns true when running on GAE or a // local developer machine. In that case, the desired scopes must be passed // in manually. When the code is running in GCE or GAE Flexible, the scopes @@ -42,6 +44,7 @@ function auth(callback) { 'https://www.googleapis.com/auth/compute', 'https://www.googleapis.com/auth/compute.readonly', ]); + authClient.projectId = projectId; } callback(null, authClient); }); @@ -61,7 +64,7 @@ function getVmsExample(callback) { compute.instances.aggregatedList( { auth: authClient, - project: process.env.GCLOUD_PROJECT, + project: authClient.projectId, // In this example we only want one VM per page maxResults: 1, },