From 0221d8573797c713b0c644dd9363b8bdef559ea1 Mon Sep 17 00:00:00 2001 From: Grant Timmerman Date: Thu, 7 Mar 2019 13:04:02 -0800 Subject: [PATCH 1/2] feat: Export quickstarts. Fixes #65 --- .eslintrc.js | 1 + adminSDK/directory/index.js | 9 +++++++-- adminSDK/reports/index.js | 9 +++++++-- adminSDK/reseller/index.js | 7 ++++++- apps-script/quickstart/index.js | 5 +++++ calendar/quickstart/index.js | 5 +++++ classroom/quickstart/index.js | 5 +++++ docs/quickstart/index.js | 5 +++++ drive/activity-v2/index.js | 5 +++++ drive/activity/index.js | 5 +++++ drive/quickstart/index.js | 5 +++++ gmail/quickstart/index.js | 5 +++++ people/quickstart/index.js | 5 +++++ sheets/quickstart/index.js | 5 +++++ slides/quickstart/index.js | 5 +++++ tasks/quickstart/index.js | 5 +++++ 16 files changed, 81 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ff57c8cf..fd147ff8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,6 +2,7 @@ module.exports = { "extends": "google", "parserOptions": { "ecmaVersion": 8, + "sourceType": "module" }, "env": { "node": true, diff --git a/adminSDK/directory/index.js b/adminSDK/directory/index.js index 69967c57..963ef408 100644 --- a/adminSDK/directory/index.js +++ b/adminSDK/directory/index.js @@ -20,7 +20,7 @@ const readline = require('readline'); const {google} = require('googleapis'); // If modifying these scopes, delete token.json. -const SCOPES = ['https://www.googleapis.com/auth/admin.directory.user']; +export const SCOPES = ['https://www.googleapis.com/auth/admin.directory.user']; // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time. @@ -101,7 +101,7 @@ function storeToken(token) { * * @param {google.auth.OAuth2} auth An authorized OAuth2 client. */ -function listUsers(auth) { +export function listUsers(auth) { const service = google.admin({version: 'directory_v1', auth}); service.users.list({ customer: 'my_customer', @@ -122,3 +122,8 @@ function listUsers(auth) { }); } // [END admin_sdk_directory_quickstart] + +module.exports = { + SCOPES, + listUsers, +}; diff --git a/adminSDK/reports/index.js b/adminSDK/reports/index.js index 5bc4bfab..fe394a31 100644 --- a/adminSDK/reports/index.js +++ b/adminSDK/reports/index.js @@ -20,7 +20,7 @@ const readline = require('readline'); const {google} = require('googleapis'); // If modifying these scopes, delete token.json. -const SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']; +export const SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']; // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time. @@ -101,7 +101,7 @@ function storeToken(token) { * * @param {google.auth.OAuth2} auth An authorized OAuth2 client. */ -function listLoginEvents(auth) { +export function listLoginEvents(auth) { const service = google.admin({version: 'reports_v1', auth}); service.activities.list({ userKey: 'all', @@ -122,3 +122,8 @@ function listLoginEvents(auth) { }); } // [END admin_sdk_reports_quickstart] + +module.exports = { + SCOPES, + listLoginEvents, +}; diff --git a/adminSDK/reseller/index.js b/adminSDK/reseller/index.js index ff50df1c..10343536 100644 --- a/adminSDK/reseller/index.js +++ b/adminSDK/reseller/index.js @@ -20,7 +20,7 @@ const readline = require('readline'); const {google} = require('googleapis'); // If modifying these scopes, delete token.json. -const SCOPES = ['https://www.googleapis.com/auth/apps.order']; +export const SCOPES = ['https://www.googleapis.com/auth/apps.order']; // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time. @@ -120,3 +120,8 @@ function listSubscriptions(auth) { }); } // [END admin_sdk_reseller_quickstart] + +module.exports = { + SCOPES, + listSubscriptions, +}; diff --git a/apps-script/quickstart/index.js b/apps-script/quickstart/index.js index 8cce772d..8a8f3322 100644 --- a/apps-script/quickstart/index.js +++ b/apps-script/quickstart/index.js @@ -117,3 +117,8 @@ function callAppsScript(auth) { }); } // [END apps_script_api_quickstart] + +module.exports = { + SCOPES, + callAppsScript, +}; diff --git a/calendar/quickstart/index.js b/calendar/quickstart/index.js index dc4b0473..139eb92a 100644 --- a/calendar/quickstart/index.js +++ b/calendar/quickstart/index.js @@ -110,3 +110,8 @@ function listEvents(auth) { }); } // [END calendar_quickstart] + +module.exports = { + SCOPES, + listEvents, +}; diff --git a/classroom/quickstart/index.js b/classroom/quickstart/index.js index e889f971..99892e47 100644 --- a/classroom/quickstart/index.js +++ b/classroom/quickstart/index.js @@ -106,3 +106,8 @@ function listCourses(auth) { }); } // [END classroom_quickstart] + +module.exports = { + SCOPES, + listCourses, +}; diff --git a/docs/quickstart/index.js b/docs/quickstart/index.js index 027f34bd..0de59489 100644 --- a/docs/quickstart/index.js +++ b/docs/quickstart/index.js @@ -98,3 +98,8 @@ function printDocTitle(auth) { }); } // [END docs_quickstart] + +module.exports = { + SCOPES, + printDocTitle, +}; diff --git a/drive/activity-v2/index.js b/drive/activity-v2/index.js index 25e5be3a..27eab22c 100644 --- a/drive/activity-v2/index.js +++ b/drive/activity-v2/index.js @@ -218,3 +218,8 @@ function getTargetInfo(target) { return `${getOneOf(target)}:unknown`; } // [END drive_activity_v2_quickstart] + +module.exports = { + SCOPES, + listDriveActivity, +}; diff --git a/drive/activity/index.js b/drive/activity/index.js index db54d6a2..ddee8705 100644 --- a/drive/activity/index.js +++ b/drive/activity/index.js @@ -115,3 +115,8 @@ function listActivity(auth) { }); } // [END drive_activity_quickstart] + +module.exports = { + SCOPES, + listActivity, +}; diff --git a/drive/quickstart/index.js b/drive/quickstart/index.js index dcce6326..a3b8802c 100644 --- a/drive/quickstart/index.js +++ b/drive/quickstart/index.js @@ -106,3 +106,8 @@ function listFiles(auth) { }); } // [END drive_quickstart] + +module.exports = { + SCOPES, + listFiles, +}; diff --git a/gmail/quickstart/index.js b/gmail/quickstart/index.js index a30e5b81..99e0fc1b 100644 --- a/gmail/quickstart/index.js +++ b/gmail/quickstart/index.js @@ -106,3 +106,8 @@ function listLabels(auth) { }); } // [END gmail_quickstart] + +module.exports = { + SCOPES, + listLabels, +}; diff --git a/people/quickstart/index.js b/people/quickstart/index.js index b94afcd9..6a106cc1 100644 --- a/people/quickstart/index.js +++ b/people/quickstart/index.js @@ -112,3 +112,8 @@ function listConnectionNames(auth) { }); } // [END people_quickstart] + +module.exports = { + SCOPES, + listConnectionNames, +}; diff --git a/sheets/quickstart/index.js b/sheets/quickstart/index.js index 172ce420..d0541e5b 100644 --- a/sheets/quickstart/index.js +++ b/sheets/quickstart/index.js @@ -108,3 +108,8 @@ function listMajors(auth) { }); } // [END sheets_quickstart] + +module.exports = { + SCOPES, + listMajors, +}; diff --git a/slides/quickstart/index.js b/slides/quickstart/index.js index a7c3c5a8..e22896a2 100644 --- a/slides/quickstart/index.js +++ b/slides/quickstart/index.js @@ -102,3 +102,8 @@ function listSlides(auth) { }); } // [END slides_quickstart] + +module.exports = { + SCOPES, + listSlides, +}; diff --git a/tasks/quickstart/index.js b/tasks/quickstart/index.js index 80fd5962..4eeb266e 100644 --- a/tasks/quickstart/index.js +++ b/tasks/quickstart/index.js @@ -106,3 +106,8 @@ function listTaskLists(auth) { }); } // [END tasks_quickstart] + +module.exports = { + SCOPES, + listTaskLists, +}; From 1c0b841d50c943ea9e30409df1050a54a0ed86dd Mon Sep 17 00:00:00 2001 From: Grant Timmerman Date: Thu, 7 Mar 2019 13:06:07 -0800 Subject: [PATCH 2/2] fix: Remove `export` keyword from quickstart body --- adminSDK/directory/index.js | 4 ++-- adminSDK/reports/index.js | 4 ++-- adminSDK/reseller/index.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/adminSDK/directory/index.js b/adminSDK/directory/index.js index 963ef408..0324f2c4 100644 --- a/adminSDK/directory/index.js +++ b/adminSDK/directory/index.js @@ -20,7 +20,7 @@ const readline = require('readline'); const {google} = require('googleapis'); // If modifying these scopes, delete token.json. -export const SCOPES = ['https://www.googleapis.com/auth/admin.directory.user']; +const SCOPES = ['https://www.googleapis.com/auth/admin.directory.user']; // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time. @@ -101,7 +101,7 @@ function storeToken(token) { * * @param {google.auth.OAuth2} auth An authorized OAuth2 client. */ -export function listUsers(auth) { +function listUsers(auth) { const service = google.admin({version: 'directory_v1', auth}); service.users.list({ customer: 'my_customer', diff --git a/adminSDK/reports/index.js b/adminSDK/reports/index.js index fe394a31..06b15228 100644 --- a/adminSDK/reports/index.js +++ b/adminSDK/reports/index.js @@ -20,7 +20,7 @@ const readline = require('readline'); const {google} = require('googleapis'); // If modifying these scopes, delete token.json. -export const SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']; +const SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']; // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time. @@ -101,7 +101,7 @@ function storeToken(token) { * * @param {google.auth.OAuth2} auth An authorized OAuth2 client. */ -export function listLoginEvents(auth) { +function listLoginEvents(auth) { const service = google.admin({version: 'reports_v1', auth}); service.activities.list({ userKey: 'all', diff --git a/adminSDK/reseller/index.js b/adminSDK/reseller/index.js index 10343536..69307e71 100644 --- a/adminSDK/reseller/index.js +++ b/adminSDK/reseller/index.js @@ -20,7 +20,7 @@ const readline = require('readline'); const {google} = require('googleapis'); // If modifying these scopes, delete token.json. -export const SCOPES = ['https://www.googleapis.com/auth/apps.order']; +const SCOPES = ['https://www.googleapis.com/auth/apps.order']; // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time.