Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions apps-script/execute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand All @@ -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!');
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/authentication-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion chat/client-libraries/cloud/create-membership-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion chat/client-libraries/cloud/delete-membership-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion chat/client-libraries/cloud/get-attachment-app-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/list-messages-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/list-reactions-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion chat/client-libraries/cloud/list-space-events-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"',
};
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/list-spaces-app-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/list-spaces-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/update-message-app-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/update-message-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions chat/client-libraries/cloud/update-space-user-cred.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions chat/quickstart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/drive_snippets/recover_drives.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>} file status
Expand Down
2 changes: 1 addition & 1 deletion drive/snippets/drive_v2/file snippets/search_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions drive/snippets/drive_v2/file snippets/share_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions drive/snippets/drive_v2/file snippets/touch_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string|null|undefined>} 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<string|null|undefined>} The modified timestamp.
*/
async function touchFile(fileId, timestamp) {
// Get credentials and build service
Expand Down
3 changes: 2 additions & 1 deletion drive/snippets/drive_v3/change_snippets/fetch_changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions drive/snippets/drive_v3/file_snippets/create_folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';

/**
* Create a folder and prints the folder ID
* @return{Promise<string|null|undefined>} folder Id
* Create a folder and return the folder ID.
* @return{Promise<string|null|undefined>} The folder ID.
*/
async function createFolder() {
// Get credentials and build service
Expand Down
4 changes: 2 additions & 2 deletions drive/snippets/drive_v3/file_snippets/create_shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';

/**
* Create a third party shortcut
* @return{Promise<string|null|undefined>} shortcut Id
* Create a shortcut.
* @return{Promise<string|null|undefined>} The shortcut ID.
*/
async function createShortcut() {
// Get credentials and build service
Expand Down
5 changes: 2 additions & 3 deletions drive/snippets/drive_v3/file_snippets/download_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {google} from 'googleapis';

/**
* Downloads a file
* @param{string} realFileId file ID
* @param{string} fileId file ID
* @return{Promise<number>} file status
*/
async function downloadFile(realFileId) {
async function downloadFile(fileId) {
// Get credentials and build service
// TODO (developer) - Use appropriate auth mechanism for your app

Expand All @@ -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',
Expand Down
Loading
Loading