Skip to content

Commit 9b02816

Browse files
committed
Delint/reformat
1 parent c14cdb9 commit 9b02816

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+421
-469
lines changed

adminSDK/reports/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function listLoginEvents(auth) {
119119
} else {
120120
console.log('No logins found.');
121121
}
122-
});
122+
});
123123
}
124124
// [END admin_sdk_reports_quickstart]
125125

drive/activity/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const {google} = require('googleapis');
2121

2222
// If modifying these scopes, delete token.json.
2323
const SCOPES = ['https://www.googleapis.com/auth/activity',
24-
'https://www.googleapis.com/auth/drive.metadata.readonly'];
24+
'https://www.googleapis.com/auth/drive.metadata.readonly'];
2525
// The file token.json stores the user's access and refresh tokens, and is
2626
// created automatically when the authorization flow completes for the first
2727
// time.

drive/snippets/drive_v2/appdata_snippets/fetch_appdata_folder.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,29 @@
1818
/**
1919
* List out application data folder and prints folder ID
2020
* */
21-
async function fetch_appdata_folder() {
22-
// Get credentials and build service
23-
// TODO (developer) - Use appropriate auth mechanism for your app
21+
async function fetchAppdataFolder() {
22+
// Get credentials and build service
23+
// TODO (developer) - Use appropriate auth mechanism for your app
2424

25-
const {GoogleAuth} = require('google-auth-library');
26-
const {google} = require('googleapis');
25+
const {GoogleAuth} = require('google-auth-library');
26+
const {google} = require('googleapis');
2727

28-
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
29-
const service = google.drive({version: 'v2', auth});
30-
try {
31-
const file = await service.files.get({
32-
fileId: 'appDataFolder',
33-
fields: 'id',
34-
});
28+
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
29+
const service = google.drive({version: 'v2', auth});
30+
try {
31+
const file = await service.files.get({
32+
fileId: 'appDataFolder',
33+
fields: 'id',
34+
});
3535
console.log('File Id:', file.data.id);
36-
} catch (err) {
37-
// TODO(developer) - Handle error
38-
throw err;
39-
}
36+
} catch (err) {
37+
// TODO(developer) - Handle error
38+
throw err;
39+
}
4040
}
4141
// [END drive_fetch_appdata_folder]
4242

43-
fetch_appdata_folder();
43+
module.exports = fetchAppdataFolder;
44+
if (module === require.main) {
45+
fetchAppdataFolder();
46+
}

drive/snippets/drive_v2/appdata_snippets/list_appdata.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,33 @@
1818
/**
1919
* List all files inserted in the application data folder
2020
* */
21-
async function list_appdata() {
22-
// Get credentials and build service
23-
// TODO (developer) - Use appropriate auth mechanism for your app
21+
async function listAppdata() {
22+
// Get credentials and build service
23+
// TODO (developer) - Use appropriate auth mechanism for your app
2424

25-
const {GoogleAuth} = require('google-auth-library');
26-
const {google} = require('googleapis');
25+
const {GoogleAuth} = require('google-auth-library');
26+
const {google} = require('googleapis');
2727

28-
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
29-
const service = google.drive({version: 'v2', auth});
30-
try {
31-
const res = await service.files.list({
32-
spaces: 'appDataFolder',
33-
fields: 'nextPageToken, items(id, title)',
34-
pageSize: 100,
35-
});
36-
res.data.items.forEach(function(file) {
37-
console.log('Found file:', file.title, file.id);
38-
});
39-
} catch (err) {
40-
// TODO(developer) - Handle error
41-
throw err;
42-
}
28+
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
29+
const service = google.drive({version: 'v2', auth});
30+
try {
31+
const res = await service.files.list({
32+
spaces: 'appDataFolder',
33+
fields: 'nextPageToken, items(id, title)',
34+
pageSize: 100,
35+
});
36+
res.data.items.forEach(function(file) {
37+
console.log('Found file:', file.title, file.id);
38+
});
39+
} catch (err) {
40+
// TODO(developer) - Handle error
41+
throw err;
42+
}
4343
}
4444
// [END drive_list_appdata]
4545

46-
list_appdata();
46+
47+
module.exports = listAppdata;
48+
if (module === require.main) {
49+
listAppdata();
50+
}

drive/snippets/drive_v2/appdata_snippets/upload_appdata.js

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,43 @@
1818
/**
1919
* Insert a file in the application data folder and prints file Id.
2020
* */
21-
async function upload_appdata() {
22-
// Get credentials and build service
23-
// TODO (developer) - Use appropriate auth mechanism for your app
21+
async function uploadAppdata() {
22+
// Get credentials and build service
23+
// TODO (developer) - Use appropriate auth mechanism for your app
2424

25-
const fs = require('fs');
26-
const {GoogleAuth} = require('google-auth-library');
27-
const {google} = require('googleapis');
25+
const fs = require('fs');
26+
const {GoogleAuth} = require('google-auth-library');
27+
const {google} = require('googleapis');
2828

29-
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
30-
const service = google.drive({version: 'v2', auth});
31-
const fileMetadata = {
32-
'title': 'config.json',
33-
'parents': [{
34-
'id': 'appDataFolder',
35-
}],
36-
};
37-
const media = {
38-
mimeType: 'application/json',
39-
body: fs.createReadStream('config.json'),
40-
};
41-
try {
42-
const file = await service.files.insert({
43-
resource: fileMetadata,
44-
media: media,
45-
fields: 'id',
46-
});
47-
console.log('Folder Id:', file.data.id);
48-
} catch (err) {
49-
// TODO(developer) - Handle error
50-
throw err;
51-
}
29+
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
30+
const service = google.drive({version: 'v2', auth});
31+
const fileMetadata = {
32+
'title': 'config.json',
33+
'parents': [{
34+
'id': 'appDataFolder',
35+
}],
36+
};
37+
const media = {
38+
mimeType: 'application/json',
39+
body: fs.createReadStream('config.json'),
40+
};
41+
try {
42+
const file = await service.files.insert({
43+
resource: fileMetadata,
44+
media: media,
45+
fields: 'id',
46+
});
47+
console.log('Folder Id:', file.data.id);
48+
} catch (err) {
49+
// TODO(developer) - Handle error
50+
throw err;
51+
}
5252
}
5353
// [END drive_upload_appdata]
5454

55-
upload_appdata();
55+
56+
module.exports = uploadAppdata;
57+
if (module === require.main) {
58+
uploadAppdata();
59+
}
5660

drive/snippets/drive_v2/change_snippets/fetch_changes.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,34 @@
1818
/**
1919
* Retrieve the list of changes for the currently authenticated user
2020
* */
21-
async function fetch_changes() {
22-
// Get credentials and build service
23-
// TODO (developer) - Use appropriate auth mechanism for your app
21+
async function fetchChanges() {
22+
// Get credentials and build service
23+
// TODO (developer) - Use appropriate auth mechanism for your app
2424

25-
const {GoogleAuth} = require('google-auth-library');
26-
const {google} = require('googleapis');
25+
const {GoogleAuth} = require('google-auth-library');
26+
const {google} = require('googleapis');
2727

28-
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive'});
29-
const service = google.drive({version: 'v2', auth});
30-
let pageToken;
31-
try {
32-
const res = await service.changes.list({
33-
pageToken: pageToken,
34-
fields: '*',
35-
});
36-
// Process changes
37-
res.data.items.forEach(function(change) {
38-
console.log('Change found for file:', change.fileId);
39-
});
40-
} catch (err) {
41-
// TODO(developer) - Handle error
42-
throw err;
43-
}
28+
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive'});
29+
const service = google.drive({version: 'v2', auth});
30+
let pageToken;
31+
try {
32+
const res = await service.changes.list({
33+
pageToken: pageToken,
34+
fields: '*',
35+
});
36+
// Process changes
37+
res.data.items.forEach(function(change) {
38+
console.log('Change found for file:', change.fileId);
39+
});
40+
} catch (err) {
41+
// TODO(developer) - Handle error
42+
throw err;
43+
}
4444
}
4545
// [END drive_fetch_changes]
4646

47-
fetch_changes();
47+
48+
module.exports = fetchChanges;
49+
if (module === require.main) {
50+
fetchChanges();
51+
}

drive/snippets/drive_v2/change_snippets/fetch_start_page_token.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,26 @@
1818
/**
1919
* Retrieve page token for the current state of the account
2020
* */
21-
async function fetch_start_page_token() {
22-
// Get credentials and build service
23-
// TODO (developer) - Use appropriate auth mechanism for your app
21+
async function fetchStartPageToken() {
22+
// Get credentials and build service
23+
// TODO (developer) - Use appropriate auth mechanism for your app
2424

25-
const {GoogleAuth} = require('google-auth-library');
26-
const {google} = require('googleapis');
25+
const {GoogleAuth} = require('google-auth-library');
26+
const {google} = require('googleapis');
2727

28-
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive'});
29-
const service = google.drive({version: 'v2', auth});
30-
try {
31-
const res = await service.changes.getStartPageToken();
32-
console.log('Start token:', res.data.startPageToken);
33-
} catch (err) {
34-
// TODO(developer) - Handle error
35-
throw err;
36-
}
28+
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive'});
29+
const service = google.drive({version: 'v2', auth});
30+
try {
31+
const res = await service.changes.getStartPageToken();
32+
console.log('Start token:', res.data.startPageToken);
33+
} catch (err) {
34+
// TODO(developer) - Handle error
35+
throw err;
36+
}
3737
}
3838
// [END drive_fetch_start_page_token]
3939

40-
fetch_start_page_token();
40+
module.exports = fetchStartPageToken;
41+
if (module === require.main) {
42+
fetchStartPageToken();
43+
}

drive/snippets/drive_v3/change_snippets/fetch_changes.js

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,36 @@
1919
* Retrieve the list of changes for the currently authenticated user.
2020
* @param {string} savedStartPageToken page token got after executing fetch_start_page_token.js file
2121
**/
22-
async function fetch_changes(savedStartPageToken) {
23-
// Get credentials and build service
24-
// TODO (developer) - Use appropriate auth mechanism for your app
22+
async function fetchChanges(savedStartPageToken) {
23+
// Get credentials and build service
24+
// TODO (developer) - Use appropriate auth mechanism for your app
2525

26-
const {GoogleAuth} = require('google-auth-library');
27-
const {google} = require('googleapis');
26+
const {GoogleAuth} = require('google-auth-library');
27+
const {google} = require('googleapis');
2828

29-
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.readonly'});
30-
const service = google.drive({version: 'v3', auth});
31-
try {
32-
let pageToken;
33-
const res = await service.changes.list({
34-
pageToken: savedStartPageToken,
35-
fields: '*',
36-
});
37-
res.data.changes.forEach((change) => {
38-
console.log('change found for file: ', change.fileId);
39-
});
40-
pageToken = res.data.newStartPageToken;
41-
console.log('start token :', pageToken);
29+
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.readonly'});
30+
const service = google.drive({version: 'v3', auth});
31+
try {
32+
let pageToken = savedStartPageToken;
33+
do {
34+
const res = await service.changes.list({
35+
pageToken: savedStartPageToken,
36+
fields: '*',
37+
});
38+
res.data.changes.forEach((change) => {
39+
console.log('change found for file: ', change.fileId);
40+
});
41+
pageToken = res.data.newStartPageToken;
42+
} while (pageToken);
4243
} catch (err) {
43-
// TODO(developer) - Handle error
44-
throw err;
44+
// TODO(developer) - Handle error
45+
throw err;
4546
}
4647
}
4748
// [END drive_fetch_changes]
4849

49-
fetch_changes(284);
50+
51+
module.exports = fetchChanges;
52+
if (module === require.main) {
53+
fetchChanges();
54+
}

drive/snippets/drive_v3/change_snippets/fetch_start_page_token.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,28 @@
1818
/**
1919
* Retrieve page token for the current state of the account.
2020
**/
21-
async function fetch_start_page_token() {
21+
async function fetchStartPageToken() {
2222
// Get credentials and build service
2323
// TODO (developer) - Use appropriate auth mechanism for your app
2424

25-
const {GoogleAuth} = require('google-auth-library');
26-
const {google} = require('googleapis');
25+
const {GoogleAuth} = require('google-auth-library');
26+
const {google} = require('googleapis');
2727

28-
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
29-
const service = google.drive({version: 'v3', auth});
30-
try {
31-
const res = await service.changes.getStartPageToken({});
32-
console.log('start token: ', res.data.startPageToken);
33-
} catch (err) {
34-
// TODO(developer) - Handle error
35-
throw err;
36-
}
28+
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive.appdata'});
29+
const service = google.drive({version: 'v3', auth});
30+
try {
31+
const res = await service.changes.getStartPageToken({});
32+
const token = res.data.startPageToken;
33+
console.log('start token: ', token);
34+
} catch (err) {
35+
// TODO(developer) - Handle error
36+
throw err;
37+
}
3738
}
3839
// [END drive_fetch_start_page_token]
3940

40-
fetch_start_page_token();
41+
42+
module.exports = fetchStartPageToken;
43+
if (module === require.main) {
44+
fetchStartPageToken();
45+
}

0 commit comments

Comments
 (0)