diff --git a/apps-script/execute/index.js b/apps-script/execute/index.js index 7fb5fb3a..60e0a451 100644 --- a/apps-script/execute/index.js +++ b/apps-script/execute/index.js @@ -45,8 +45,8 @@ async function callAppsScript() { // The API executed, but the script returned an error. // Extract the first (and only) set of error details. The values of this - // object are the script's 'errorMessage' and 'errorType', and an array - // of stack trace elements. + // object are the script's 'errorMessage' and 'errorType', and an array of + // stack trace elements. const error = resp.data.error.details[0]; console.log(`Script error message: ${error.errorMessage}`); @@ -60,10 +60,9 @@ async function callAppsScript() { } } } else { - // The structure of the result will depend upon what the Apps Script - // function returns. Here, the function returns an Apps Script Object - // with String keys and values, and so the result is treated as a - // Node.js object (folderSet). + // The structure of the result depends on the Apps Script function's return value. + // Here, the function returns an object with string keys and values, which is + // treated as a Node.js object (folderSet). const folderSet = resp.data.response ?? {}; if (Object.keys(folderSet).length === 0) { console.log('No folders returned!'); diff --git a/chat/client-libraries/cloud/authentication-utils.js b/chat/client-libraries/cloud/authentication-utils.js index bb37deee..8eb02571 100644 --- a/chat/client-libraries/cloud/authentication-utils.js +++ b/chat/client-libraries/cloud/authentication-utils.js @@ -84,7 +84,7 @@ function getAuthenticatedUserOAuth2Client(scopes) { scope: scopes, }); - // Open an HTTP server to accept the OAuth2 callback + // Creates and starts an HTTP server to accept the OAuth2 callback. const server = http .createServer(async (request, response) => { try { @@ -108,7 +108,7 @@ function getAuthenticatedUserOAuth2Client(scopes) { } }) .listen(3000, () => { - // Open default browser and start the flow + // Opens the default browser to start the OAuth2 flow. open(authorizeUrl, {wait: false}).then((cp) => cp.unref()); }); destroyer(server); diff --git a/chat/client-libraries/cloud/create-custom-emoji-user-cred.js b/chat/client-libraries/cloud/create-custom-emoji-user-cred.js index 4ee74302..1b5e57e0 100644 --- a/chat/client-libraries/cloud/create-custom-emoji-user-cred.js +++ b/chat/client-libraries/cloud/create-custom-emoji-user-cred.js @@ -32,7 +32,7 @@ async function main() { // TODO(developer) Replace FILENAME here. const filename = 'FILENAME'; - // Read Custom emoji file content into base64 encoded string + // Read custom emoji file content into a base64 encoded string. const fileContent = fs.readFileSync(filename, {encoding: 'base64'}); // Initialize request argument(s) diff --git a/chat/client-libraries/cloud/create-membership-user-cred-for-app.js b/chat/client-libraries/cloud/create-membership-user-cred-for-app.js index 0c4d17c3..56788d47 100644 --- a/chat/client-libraries/cloud/create-membership-user-cred-for-app.js +++ b/chat/client-libraries/cloud/create-membership-user-cred-for-app.js @@ -23,7 +23,7 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.memberships.app', ]; -// This sample shows how to create membership with app credential for an app +// This sample shows how to create an app membership. async function main() { // Create a client const chatClient = await createClientWithUserCredentials( diff --git a/chat/client-libraries/cloud/create-membership-user-cred.js b/chat/client-libraries/cloud/create-membership-user-cred.js index e05a593a..2409b451 100644 --- a/chat/client-libraries/cloud/create-membership-user-cred.js +++ b/chat/client-libraries/cloud/create-membership-user-cred.js @@ -23,7 +23,8 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.memberships', ]; -// This sample shows how to create membership with user credential for a human user +// This sample shows how to create membership with user credential for a human +// user async function main() { // Create a client const chatClient = await createClientWithUserCredentials( diff --git a/chat/client-libraries/cloud/create-message-user-cred-at-mention.js b/chat/client-libraries/cloud/create-message-user-cred-at-mention.js index 8bd44d10..ad6f1a3a 100644 --- a/chat/client-libraries/cloud/create-message-user-cred-at-mention.js +++ b/chat/client-libraries/cloud/create-message-user-cred-at-mention.js @@ -23,7 +23,8 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.messages.create', ]; -// This sample shows how to create message with user credential with a user mention +// This sample shows how to create message with user credential with a user +// mention async function main() { // Create a client const chatClient = await createClientWithUserCredentials( diff --git a/chat/client-libraries/cloud/create-message-user-cred-message-id.js b/chat/client-libraries/cloud/create-message-user-cred-message-id.js index 76bc0eb3..be3886c9 100644 --- a/chat/client-libraries/cloud/create-message-user-cred-message-id.js +++ b/chat/client-libraries/cloud/create-message-user-cred-message-id.js @@ -23,7 +23,8 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.messages.create', ]; -// This sample shows how to create message with user credential with message id +// This sample shows how to create a message with user credentials and a custom +// message id async function main() { // Create a client const chatClient = await createClientWithUserCredentials( diff --git a/chat/client-libraries/cloud/create-message-user-cred-thread-name.js b/chat/client-libraries/cloud/create-message-user-cred-thread-name.js index 877ab8aa..53e4ca03 100644 --- a/chat/client-libraries/cloud/create-message-user-cred-thread-name.js +++ b/chat/client-libraries/cloud/create-message-user-cred-thread-name.js @@ -24,7 +24,8 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.messages.create', ]; -// This sample shows how to create message with user credential with thread name +// This sample shows how to create a message with user credentials in a named +// thread async function main() { // Create a client const chatClient = await createClientWithUserCredentials( @@ -35,8 +36,8 @@ async function main() { const request = { // Replace SPACE_NAME here. parent: 'spaces/SPACE_NAME', - // Creates the message as a reply to the thread specified by thread.name - // If it fails, the message starts a new thread instead + // Creates the message as a reply to the thread specified by thread.name. + // If it fails, the message starts a new thread instead. messageReplyOption: protos.google.chat.v1.CreateMessageRequest.MessageReplyOption .REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD, diff --git a/chat/client-libraries/cloud/delete-membership-user-cred.js b/chat/client-libraries/cloud/delete-membership-user-cred.js index 670c92ef..5fcc9c15 100644 --- a/chat/client-libraries/cloud/delete-membership-user-cred.js +++ b/chat/client-libraries/cloud/delete-membership-user-cred.js @@ -23,7 +23,8 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.memberships', ]; -// This sample shows how to delete a membership of type HUMAN with user credential +// This sample shows how to delete a membership of type HUMAN with user +// credential async function main() { // Create a client const chatClient = await createClientWithUserCredentials( diff --git a/chat/client-libraries/cloud/get-attachment-app-cred.js b/chat/client-libraries/cloud/get-attachment-app-cred.js index cc23d7bf..a7748fe6 100644 --- a/chat/client-libraries/cloud/get-attachment-app-cred.js +++ b/chat/client-libraries/cloud/get-attachment-app-cred.js @@ -19,7 +19,8 @@ import {createClientWithAppCredentials} from './authentication-utils.js'; -// This sample shows how to get attachment metadata with app credential +// This sample shows how to get attachment metadata with app +// credential async function main() { // Create a client const chatClient = createClientWithAppCredentials(); diff --git a/chat/client-libraries/cloud/get-space-notification-setting-user-cred.js b/chat/client-libraries/cloud/get-space-notification-setting-user-cred.js index 4615e152..1e069760 100644 --- a/chat/client-libraries/cloud/get-space-notification-setting-user-cred.js +++ b/chat/client-libraries/cloud/get-space-notification-setting-user-cred.js @@ -23,14 +23,16 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.users.spacesettings', ]; -// This sample shows how to get the space notification setting for the calling user +// This sample shows how to get the space notification setting for the calling +// user async function main() { // Create a client const chatClient = await createClientWithUserCredentials( USER_AUTH_OAUTH_SCOPES, ); - // Initialize request argument(s), replace the SPACE_NAME with an actual space name. + // Initialize request argument(s), replace the SPACE_NAME with an actual space + // name. const request = { name: 'users/me/spaces/SPACE_NAME/spaceNotificationSetting', }; diff --git a/chat/client-libraries/cloud/get-thread-read-state-user-cred.js b/chat/client-libraries/cloud/get-thread-read-state-user-cred.js index dd1f82ca..61500eb0 100644 --- a/chat/client-libraries/cloud/get-thread-read-state-user-cred.js +++ b/chat/client-libraries/cloud/get-thread-read-state-user-cred.js @@ -23,7 +23,8 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.users.readstate.readonly', ]; -// This sample shows how to get the thread read state for a space and calling user +// This sample shows how to get the thread read state for a space and calling +// user async function main() { // Create a client const chatClient = await createClientWithUserCredentials( diff --git a/chat/client-libraries/cloud/list-messages-user-cred.js b/chat/client-libraries/cloud/list-messages-user-cred.js index 9b684f8a..1e32b832 100644 --- a/chat/client-libraries/cloud/list-messages-user-cred.js +++ b/chat/client-libraries/cloud/list-messages-user-cred.js @@ -39,8 +39,8 @@ async function main() { // Make the request const pageResult = chatClient.listMessagesAsync(request); - // Handle the response. Iterating over pageResult will yield results and - // resolve additional pages automatically. + // Handle the response. Iterating over pageResult will yield results + // and resolve additional pages automatically. for await (const response of pageResult) { console.log(response); } diff --git a/chat/client-libraries/cloud/list-reactions-user-cred.js b/chat/client-libraries/cloud/list-reactions-user-cred.js index 65bad11e..22b754ea 100644 --- a/chat/client-libraries/cloud/list-reactions-user-cred.js +++ b/chat/client-libraries/cloud/list-reactions-user-cred.js @@ -39,8 +39,8 @@ async function main() { // Make the request const pageResult = chatClient.listReactionsAsync(request); - // Handle the response. Iterating over pageResult will yield results and - // resolve additional pages automatically. + // Handle the response. Iterating over pageResult will yield results + // and resolve additional pages automatically. for await (const response of pageResult) { console.log(response); } diff --git a/chat/client-libraries/cloud/list-space-events-user-cred.js b/chat/client-libraries/cloud/list-space-events-user-cred.js index a63a8e0a..2f90e796 100644 --- a/chat/client-libraries/cloud/list-space-events-user-cred.js +++ b/chat/client-libraries/cloud/list-space-events-user-cred.js @@ -36,7 +36,7 @@ async function main() { const request = { // Replace SPACE_NAME here parent: 'spaces/SPACE_NAME', - // A required filter. Filters events about new memberships and messages + // A required filter. Filters events about new memberships and messages. filter: 'eventTypes:"google.workspace.chat.membership.v1.created" OR eventTypes:"google.workspace.chat.message.v1.created"', }; diff --git a/chat/client-libraries/cloud/list-spaces-app-cred.js b/chat/client-libraries/cloud/list-spaces-app-cred.js index e4c66984..dd5a4d98 100644 --- a/chat/client-libraries/cloud/list-spaces-app-cred.js +++ b/chat/client-libraries/cloud/list-spaces-app-cred.js @@ -33,8 +33,8 @@ async function main() { // Make the request const pageResult = chatClient.listSpacesAsync(request); - // Handle the response. Iterating over pageResult will yield results and - // resolve additional pages automatically. + // Handle the response. Iterating over pageResult will yield results + // and resolve additional pages automatically. for await (const response of pageResult) { console.log(response); } diff --git a/chat/client-libraries/cloud/list-spaces-user-cred.js b/chat/client-libraries/cloud/list-spaces-user-cred.js index 205f305a..3a961c15 100644 --- a/chat/client-libraries/cloud/list-spaces-user-cred.js +++ b/chat/client-libraries/cloud/list-spaces-user-cred.js @@ -39,8 +39,8 @@ async function main() { // Make the request const pageResult = chatClient.listSpacesAsync(request); - // Handle the response. Iterating over pageResult will yield results and - // resolve additional pages automatically. + // Handle the response. Iterating over pageResult will yield results + // and resolve additional pages automatically. for await (const response of pageResult) { console.log(response); } diff --git a/chat/client-libraries/cloud/update-message-app-cred.js b/chat/client-libraries/cloud/update-message-app-cred.js index 189595a4..08404958 100644 --- a/chat/client-libraries/cloud/update-message-app-cred.js +++ b/chat/client-libraries/cloud/update-message-app-cred.js @@ -42,8 +42,8 @@ async function main() { }, ], }, - // The field paths to update. Separate multiple values with commas or use - // `*` to update all field paths. + // The field paths to update. Separate multiple values with commas or use `*` + // to update all field paths. updateMask: { // The field paths to update. paths: ['text', 'cards_v2'], diff --git a/chat/client-libraries/cloud/update-message-user-cred.js b/chat/client-libraries/cloud/update-message-user-cred.js index 41c99186..656e4729 100644 --- a/chat/client-libraries/cloud/update-message-user-cred.js +++ b/chat/client-libraries/cloud/update-message-user-cred.js @@ -37,8 +37,8 @@ async function main() { name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME', text: 'Updated with user credential!', }, - // The field paths to update. Separate multiple values with commas or use - // `*` to update all field paths. + // The field paths to update. Separate multiple values with commas or use `*` + // to update all field paths. updateMask: { // The field paths to update. paths: ['text'], diff --git a/chat/client-libraries/cloud/update-space-notification-setting-user-cred.js b/chat/client-libraries/cloud/update-space-notification-setting-user-cred.js index 7889cf9c..825ab2e5 100644 --- a/chat/client-libraries/cloud/update-space-notification-setting-user-cred.js +++ b/chat/client-libraries/cloud/update-space-notification-setting-user-cred.js @@ -23,14 +23,16 @@ const USER_AUTH_OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/chat.users.spacesettings', ]; -// This sample shows how to update the space notification setting for the calling user +// This sample shows how to update the space notification setting for the +// calling user async function main() { // Create a client const chatClient = await createClientWithUserCredentials( USER_AUTH_OAUTH_SCOPES, ); - // Initialize request argument(s), replace the SPACE_NAME with an actual space name. + // Initialize request argument(s), replace the SPACE_NAME with an actual space + // name. const request = { spaceNotificationSetting: { name: 'users/me/spaces/SPACE_NAME/spaceNotificationSetting', diff --git a/chat/client-libraries/cloud/update-space-user-cred.js b/chat/client-libraries/cloud/update-space-user-cred.js index 6e3c2df1..7db2d16f 100644 --- a/chat/client-libraries/cloud/update-space-user-cred.js +++ b/chat/client-libraries/cloud/update-space-user-cred.js @@ -35,8 +35,8 @@ async function main() { name: 'spaces/SPACE_NAME', displayName: 'New space display name', }, - // The field paths to update. Separate multiple values with commas or use - // `*` to update all field paths. + // The field paths to update. Separate multiple values with commas or use `*` + // to update all field paths. updateMask: { // The field paths to update. paths: ['display_name'], diff --git a/chat/quickstart/index.js b/chat/quickstart/index.js index 34ff6142..6e11911a 100644 --- a/chat/quickstart/index.js +++ b/chat/quickstart/index.js @@ -48,8 +48,8 @@ async function listSpaces() { // Make the request const pageResult = chatClient.listSpacesAsync(request); - // Handle the response. Iterating over pageResult will yield results and - // resolve additional pages automatically. + // Handle the response. Iterating over pageResult will yield results + // and resolve additional pages automatically. for await (const response of pageResult) { console.log(response); } diff --git a/drive/snippets/drive_v2/drive_snippets/recover_drives.js b/drive/snippets/drive_v2/drive_snippets/recover_drives.js index 0e495893..b744f97c 100644 --- a/drive/snippets/drive_v2/drive_snippets/recover_drives.js +++ b/drive/snippets/drive_v2/drive_snippets/recover_drives.js @@ -21,7 +21,7 @@ import {google} from 'googleapis'; /** * Find all shared drives without an organizer and add one. - * @param{string} userEmail user ID + * @param{string} userEmail The email of the user to transfer ownership to. */ async function recoverDrives(userEmail) { // Get credentials and build service diff --git a/drive/snippets/drive_v2/file snippets/move_file_to_folder.js b/drive/snippets/drive_v2/file snippets/move_file_to_folder.js index a5f0fc6e..a1c83c17 100644 --- a/drive/snippets/drive_v2/file snippets/move_file_to_folder.js +++ b/drive/snippets/drive_v2/file snippets/move_file_to_folder.js @@ -20,7 +20,7 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Change the file's modification timestamp. + * Moves a file to a folder. * @param{string} fileId Id of the file to move * @param{string} folderId Id of the folder to move * @return{Promise} file status diff --git a/drive/snippets/drive_v2/file snippets/search_file.js b/drive/snippets/drive_v2/file snippets/search_file.js index cba6b18a..fcfb1fcc 100644 --- a/drive/snippets/drive_v2/file snippets/search_file.js +++ b/drive/snippets/drive_v2/file snippets/search_file.js @@ -20,7 +20,7 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Search file in drive location + * Searches for files in Google Drive. */ async function searchFile() { // Get credentials and build service diff --git a/drive/snippets/drive_v2/file snippets/share_file.js b/drive/snippets/drive_v2/file snippets/share_file.js index 3ecb26db..467324fa 100644 --- a/drive/snippets/drive_v2/file snippets/share_file.js +++ b/drive/snippets/drive_v2/file snippets/share_file.js @@ -20,10 +20,10 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Download a Document file in PDF format - * @param{string} fileId file ID - * @param{string} targetUser username - * @param{string} targetDomain domain + * Share a file with a user and a domain. + * @param{string} fileId The ID of the file to share. + * @param{string} targetUser The email address of the user to share with. + * @param{string} targetDomain The domain to share with. */ async function shareFile(fileId, targetUser, targetDomain) { // Get credentials and build service @@ -48,10 +48,9 @@ async function shareFile(fileId, targetUser, targetDomain) { }, ]; - // Note: Client library does not currently support HTTP batch - // requests. When possible, use batched requests when inserting - // multiple permissions on the same item. For this sample, - // permissions are inserted serially. + // Note: Client library does not currently support HTTP batch requests. When + // possible, use batched requests when inserting multiple permissions on the + // same item. For this sample, permissions are inserted serially. for (const permission of permissions) { try { const result = await service.permissions.insert({ diff --git a/drive/snippets/drive_v2/file snippets/touch_file.js b/drive/snippets/drive_v2/file snippets/touch_file.js index 90862fa9..61a039f7 100644 --- a/drive/snippets/drive_v2/file snippets/touch_file.js +++ b/drive/snippets/drive_v2/file snippets/touch_file.js @@ -21,9 +21,9 @@ import {google} from 'googleapis'; /** * Change the file's modification timestamp. - * @param{string} fileId ID of the file to change modified time - * @param{string} timestamp Timestamp to override Modified date time of the file - * @return{Promise} modified timestamp + * @param{string} fileId ID of the file to change modified time. + * @param{string} timestamp Timestamp to override the modification timestamp of the file. + * @return{Promise} The modified timestamp. */ async function touchFile(fileId, timestamp) { // Get credentials and build service diff --git a/drive/snippets/drive_v3/change_snippets/fetch_changes.js b/drive/snippets/drive_v3/change_snippets/fetch_changes.js index ffe025b3..b4cb2afd 100644 --- a/drive/snippets/drive_v3/change_snippets/fetch_changes.js +++ b/drive/snippets/drive_v3/change_snippets/fetch_changes.js @@ -21,7 +21,8 @@ import {google} from 'googleapis'; /** * Retrieve the list of changes for the currently authenticated user. - * @param {string} savedStartPageToken page token got after executing fetch_start_page_token.js file + * @param {string} savedStartPageToken page token got after executing + * fetch_start_page_token.js file **/ async function fetchChanges(savedStartPageToken) { // Get credentials and build service diff --git a/drive/snippets/drive_v3/file_snippets/create_folder.js b/drive/snippets/drive_v3/file_snippets/create_folder.js index 6864d640..b28e494d 100644 --- a/drive/snippets/drive_v3/file_snippets/create_folder.js +++ b/drive/snippets/drive_v3/file_snippets/create_folder.js @@ -20,8 +20,8 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Create a folder and prints the folder ID - * @return{Promise} folder Id + * Create a folder and return the folder ID. + * @return{Promise} The folder ID. */ async function createFolder() { // Get credentials and build service diff --git a/drive/snippets/drive_v3/file_snippets/create_shortcut.js b/drive/snippets/drive_v3/file_snippets/create_shortcut.js index 340ff631..d438aa9d 100644 --- a/drive/snippets/drive_v3/file_snippets/create_shortcut.js +++ b/drive/snippets/drive_v3/file_snippets/create_shortcut.js @@ -20,8 +20,8 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Create a third party shortcut - * @return{Promise} shortcut Id + * Create a shortcut. + * @return{Promise} The shortcut ID. */ async function createShortcut() { // Get credentials and build service diff --git a/drive/snippets/drive_v3/file_snippets/download_file.js b/drive/snippets/drive_v3/file_snippets/download_file.js index a81c58ab..94eb62c9 100644 --- a/drive/snippets/drive_v3/file_snippets/download_file.js +++ b/drive/snippets/drive_v3/file_snippets/download_file.js @@ -21,10 +21,10 @@ import {google} from 'googleapis'; /** * Downloads a file - * @param{string} realFileId file ID + * @param{string} fileId file ID * @return{Promise} file status */ -async function downloadFile(realFileId) { +async function downloadFile(fileId) { // Get credentials and build service // TODO (developer) - Use appropriate auth mechanism for your app @@ -33,7 +33,6 @@ async function downloadFile(realFileId) { }); const service = google.drive({version: 'v3', auth}); - const fileId = realFileId; const file = await service.files.get({ fileId, alt: 'media', diff --git a/drive/snippets/drive_v3/file_snippets/export_pdf.js b/drive/snippets/drive_v3/file_snippets/export_pdf.js index 89939e1b..e8027e93 100644 --- a/drive/snippets/drive_v3/file_snippets/export_pdf.js +++ b/drive/snippets/drive_v3/file_snippets/export_pdf.js @@ -22,7 +22,7 @@ import {google} from 'googleapis'; /** * Download a Document file in PDF format * @param{string} fileId file ID - * @return{Promise} file status + * @return{Promise} The status of the export request. */ async function exportPdf(fileId) { // Get credentials and build service diff --git a/drive/snippets/drive_v3/file_snippets/search_file.js b/drive/snippets/drive_v3/file_snippets/search_file.js index 2ab7eeb1..56935a87 100644 --- a/drive/snippets/drive_v3/file_snippets/search_file.js +++ b/drive/snippets/drive_v3/file_snippets/search_file.js @@ -20,7 +20,7 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Search file in drive location + * Searches for files in Google Drive. */ async function searchFile() { // Get credentials and build service diff --git a/drive/snippets/drive_v3/file_snippets/share_file.js b/drive/snippets/drive_v3/file_snippets/share_file.js index 5216547e..53695a25 100644 --- a/drive/snippets/drive_v3/file_snippets/share_file.js +++ b/drive/snippets/drive_v3/file_snippets/share_file.js @@ -20,12 +20,11 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Batch permission modification - * - * @param{string} fileId file ID - * @param{string} targetUserEmail username - * @param{string} targetDomainName domain - * @return{Promise>} permission id + * Share a file with a user and a domain. + * @param{string} fileId The ID of the file to share. + * @param{string} targetUserEmail The email address of the user to share with. + * @param{string} targetDomainName The domain to share with. + * @return{Promise>} A promise that resolves to an array of permission IDs. */ async function shareFile(fileId, targetUserEmail, targetDomainName) { // Get credentials and build service diff --git a/drive/snippets/drive_v3/file_snippets/touch_file.js b/drive/snippets/drive_v3/file_snippets/touch_file.js index 0567bc81..bc2850e3 100644 --- a/drive/snippets/drive_v3/file_snippets/touch_file.js +++ b/drive/snippets/drive_v3/file_snippets/touch_file.js @@ -21,11 +21,11 @@ import {google} from 'googleapis'; /** * Change the file's modification timestamp. - * @param{string} fileId ID of the file to change modified time - * @param{string} Timestamp Timestamp to override Modified date time of the file - * @return{Promise} modified Timestamp + * @param{string} fileId ID of the file to change modified time. + * @param{string} timestamp Timestamp to override the modification timestamp of the file. + * @return{Promise} The modified timestamp. **/ -async function touchFile(fileId, Timestamp) { +async function touchFile(fileId, timestamp) { // Get credentials and build service // TODO (developer) - Use appropriate auth mechanism for your app const auth = new GoogleAuth({ @@ -35,7 +35,7 @@ async function touchFile(fileId, Timestamp) { const fileMetadata = { modifiedTime: new Date().toISOString(), }; - fileMetadata.modifiedTime = Timestamp; + fileMetadata.modifiedTime = timestamp; const file = await service.files.update({ fileId, requestBody: fileMetadata, diff --git a/drive/snippets/test/test_drive_v2_create_drive.js b/drive/snippets/test/test_drive_v2_create_drive.js index 3675965b..83d6c686 100644 --- a/drive/snippets/test/test_drive_v2_create_drive.js +++ b/drive/snippets/test/test_drive_v2_create_drive.js @@ -25,9 +25,9 @@ describe('Drive snippets', () => { return helpers.cleanup(); }); - // Note, you must enable creating Team Drives for your service account. + // Note, you must enable creating shared drives for your service account. // https://support.google.com/a/answer/7337635?hl=en - it('should create a team drive', async () => { + it('should create a shared drive', async () => { const id = await createDrive(); expect(id).toBeDefined(); await helpers.service.teamdrives.delete({teamDriveId: id}); diff --git a/drive/snippets/test/test_drive_v2_recover_drives.js b/drive/snippets/test/test_drive_v2_recover_drives.js index f0f56b53..c940c086 100644 --- a/drive/snippets/test/test_drive_v2_recover_drives.js +++ b/drive/snippets/test/test_drive_v2_recover_drives.js @@ -26,7 +26,7 @@ describe('Drive snippets', () => { return helpers.cleanup(); }); - // Note, you must enable creating Team Drives for your service account. + // Note, you must enable creating shared drives for your service account. // https://support.google.com/a/answer/7337635?hl=en it('should recover team drives', async () => { await createOrphanedTeamDrive(); @@ -35,8 +35,8 @@ describe('Drive snippets', () => { }); /** - * Creates a standalone Team Drive. - * @return {fileId} The id of the new Team Drive. + * Creates a standalone shared drive. + * @return {fileId} The id of the new shared drive. */ async function createOrphanedTeamDrive() { const fileId = await createDrive(); diff --git a/drive/snippets/test/test_drive_v3_create_drive.js b/drive/snippets/test/test_drive_v3_create_drive.js index d2fcb184..cba0f06e 100644 --- a/drive/snippets/test/test_drive_v3_create_drive.js +++ b/drive/snippets/test/test_drive_v3_create_drive.js @@ -21,9 +21,9 @@ import {Helpers} from './helpers.js'; describe('Drive snippets', () => { const helpers = new Helpers(); - // Note, you must enable creating Team Drives for your service account. + // Note, you must enable creating shared drives for your service account. // https://support.google.com/a/answer/7337635?hl=en - it('should create a team drive', async () => { + it('should create a shared drive', async () => { const id = await createDrive(); expect(id).toBeDefined(); await helpers.service.teamdrives.delete({teamDriveId: id}); diff --git a/drive/snippets/test/test_drive_v3_recover_drives.js b/drive/snippets/test/test_drive_v3_recover_drives.js index 32942c1d..2ccef7fa 100644 --- a/drive/snippets/test/test_drive_v3_recover_drives.js +++ b/drive/snippets/test/test_drive_v3_recover_drives.js @@ -26,7 +26,7 @@ describe('Drive snippets', () => { return helpers.cleanup(); }); - // Note, you must enable creating Team Drives for your service account. + // Note, you must enable creating shared drives for your service account. // https://support.google.com/a/answer/7337635?hl=en it('should recover team drives', async () => { await createOrphanedTeamDrive(); @@ -35,8 +35,8 @@ describe('Drive snippets', () => { }); /** - * Creates a standalone Team Drive. - * @return {fileId} The id of the new Team Drive. + * Creates a standalone shared drive. + * @return {fileId} The id of the new shared drive. */ async function createOrphanedTeamDrive() { const fileId = await createDrive(); diff --git a/forms/snippets/anyone_with_link_responder.js b/forms/snippets/anyone_with_link_responder.js index 9942c0ff..03c5d2f1 100644 --- a/forms/snippets/anyone_with_link_responder.js +++ b/forms/snippets/anyone_with_link_responder.js @@ -99,7 +99,8 @@ async function setAnyoneWithLinkResponder(formId) { fields: 'id', // Request only needed fields }); console.log( - `'Anyone with the link can respond' permission set for form '${formId}'. Permission ID: ${result.data.id}`, + `'Anyone with the link can respond' permission set for form '${formId}'.` + + ` Permission ID: ${result.data.id}`, ); } catch (e) { console.error(`Error setting "anyone with link" permission: ${e}`); @@ -147,12 +148,11 @@ async function removeAnyoneWithLinkResponder(formId) { permissionId: permissionIdToDelete, }); console.log( - `Successfully removed 'Anyone with the link' permission (ID: ${permissionIdToDelete}) from form '${formId}'.`, + `Successfully removed permission (ID: ${permissionIdToDelete})` + + ` from form '${formId}'.`, ); } else { - console.log( - `'Anyone with the link can respond' permission not found for form '${formId}'. Nothing to remove.`, - ); + console.log(`Permission not found for form '${formId}'.`); } } catch (e) { console.error(`Error removing "anyone with link" permission: ${e}`); diff --git a/sheets/snippets/sheets_batch_update.js b/sheets/snippets/sheets_batch_update.js index 21a32588..3f1bec9d 100644 --- a/sheets/snippets/sheets_batch_update.js +++ b/sheets/snippets/sheets_batch_update.js @@ -24,7 +24,7 @@ import {google} from 'googleapis'; * @param {string} title The new Spreadsheet title * @param {string} find The text to find * @param {string} replacement The text to replace - * @return {obj} holding the information regarding the replacement of strings + * @return {Promise} A promise that resolves to the response from the batch update. */ async function batchUpdate(spreadsheetId, title, find, replacement) { const auth = new GoogleAuth({ diff --git a/sheets/snippets/sheets_create.js b/sheets/snippets/sheets_create.js index 834a94bd..14ea3695 100644 --- a/sheets/snippets/sheets_create.js +++ b/sheets/snippets/sheets_create.js @@ -19,9 +19,9 @@ import {GoogleAuth} from 'google-auth-library'; import {google} from 'googleapis'; /** - * Create a google spreadsheet - * @param {string} title Spreadsheets title - * @return {string} Created spreadsheets ID + * Creates a Google Spreadsheet. + * @param {string} title The spreadsheet's title. + * @return {string} The ID of the created spreadsheet. */ async function create(title) { const auth = new GoogleAuth({ diff --git a/sheets/snippets/sheets_get_values.js b/sheets/snippets/sheets_get_values.js index f1f08510..2539afc7 100644 --- a/sheets/snippets/sheets_get_values.js +++ b/sheets/snippets/sheets_get_values.js @@ -22,7 +22,7 @@ import {google} from 'googleapis'; * Gets cell values from a Spreadsheet. * @param {string} spreadsheetId The spreadsheet ID. * @param {string} range The sheet range. - * @return {obj} spreadsheet information + * @return {Promise} A promise that resolves to the response from the get. */ async function getValues(spreadsheetId, range) { const auth = new GoogleAuth({ diff --git a/sheets/snippets/sheets_pivot_table.js b/sheets/snippets/sheets_pivot_table.js index b896f842..6b3da1d9 100644 --- a/sheets/snippets/sheets_pivot_table.js +++ b/sheets/snippets/sheets_pivot_table.js @@ -21,7 +21,7 @@ import {google} from 'googleapis'; /** * Adds a pivot table to a spreadsheet. * @param {string} spreadsheetId The Spreadsheet to add the pivot table to. - * @return {obj} spreadsheet information + * @return {Promise} A promise that resolves to the response from the batch update. */ async function pivotTable(spreadsheetId) { const auth = new GoogleAuth({ diff --git a/slides/snippets/slides_create_image.js b/slides/snippets/slides_create_image.js index a8335133..355a1bc9 100644 --- a/slides/snippets/slides_create_image.js +++ b/slides/snippets/slides_create_image.js @@ -32,7 +32,8 @@ async function createImage(presentationId, pageId) { const imageUrl = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'; - // Create a new image, using the supplied object ID, with content downloaded from imageUrl. + // Create a new image, using the supplied object ID, with content + // downloaded from imageUrl. const imageId = 'MyImage_01'; const emu4M = { magnitude: 4000000, diff --git a/slides/snippets/slides_create_sheets_chart.js b/slides/snippets/slides_create_sheets_chart.js index 85277429..daa42841 100644 --- a/slides/snippets/slides_create_sheets_chart.js +++ b/slides/snippets/slides_create_sheets_chart.js @@ -37,9 +37,9 @@ async function createSheetsChart( const service = google.slides({version: 'v1', auth}); - // Embed a Sheets chart (indicated by the spreadsheetId and sheetChartId) onto - // a page in the presentation. Setting the linking mode as "LINKED" allows the - // chart to be refreshed if the Sheets version is updated. + // Embed a Sheets chart (indicated by the spreadsheetId and sheetChartId) + // onto a page in the presentation. Setting the linking mode as "LINKED" + // allows the chart to be refreshed if the Sheets version is updated. const emu4M = { magnitude: 4000000, unit: 'EMU', diff --git a/slides/snippets/slides_create_slide.js b/slides/snippets/slides_create_slide.js index d49f26c9..fc3e2d21 100644 --- a/slides/snippets/slides_create_slide.js +++ b/slides/snippets/slides_create_slide.js @@ -49,7 +49,7 @@ async function createSlide(presentationId, pageId) { console.log( `Created slide with ID: ${result.data.replies[0].createSlide.objectId}`, ); - return res; + return result; } // [END slides_create_slide] diff --git a/slides/snippets/test/test_slides_refresh_sheets_chart.js b/slides/snippets/test/test_slides_refresh_sheets_chart.js index cf0bd6af..773c33e6 100644 --- a/slides/snippets/test/test_slides_refresh_sheets_chart.js +++ b/slides/snippets/test/test_slides_refresh_sheets_chart.js @@ -1,18 +1,18 @@ -// /** -// * Copyright 2022 Google LLC -// * -// * 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 -// * -// * https://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. -// */ +/** + * Copyright 2022 Google LLC + * + * 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 + * + * https://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. + */ import {expect} from 'expect'; import {refreshSheetsChart} from '../slides_refresh_sheets_chart.js'; import {Helpers} from './helpers.js';