@maxim_mazurok/gapi.client.workspaceevents-v1
v0.2.20261124
Published
TypeScript typings for Google Workspace Events API v1
Readme
TypeScript typings for Google Workspace Events API v1
The Google Workspace Events API lets you subscribe to events and manage change notifications across Google Workspace applications. For detailed description please check documentation.
Installing
Install typings for Google Workspace Events API:
npm install @types/gapi.client.workspaceevents-v1 --save-devTypeScript 6.0+
TypeScript 6.0 changed types to default to []. You must now explicitly list type packages in tsconfig.json:
{
"compilerOptions": {
"types": [
"gapi",
"gapi.auth2",
"gapi.client",
"gapi.client.workspaceevents-v1"
]
}
}Usage
You need to initialize Google API client in your code:
gapi.load('client', () => {
// now we can use gapi.client
// ...
});Then load api client wrapper:
gapi.client.load(
'https://workspaceevents.googleapis.com/$discovery/rest?version=v1',
() => {
// now we can use:
// gapi.client.workspaceevents
},
);// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('workspaceevents', 'v1', () => {
// now we can use:
// gapi.client.workspaceevents
});Don't forget to authenticate your client before sending any request to resources:
// declare client_id registered in Google Developers Console
var client_id = '',
scope = [
// On their own behalf, apps in Google Chat can see all members in Google Chat spaces and conversations throughout your Workspace organization, even when the Chat app isn't a member
'https://www.googleapis.com/auth/chat.app.all.memberships.readonly',
// On their own behalf, apps in Google Chat can see all messages and reactions throughout your Workspace organization, even when the Chat app isn't a member of a space or conversation
'https://www.googleapis.com/auth/chat.app.all.messages.readonly',
// On their own behalf, apps in Google Chat can see metadata about all spaces and conversations in Google Chat throughout your Workspace organization, even when the Chat app isn't a member
'https://www.googleapis.com/auth/chat.app.all.spaces.readonly',
// On their own behalf, apps in Google Chat can see the last read time for all users in all spaces and conversations throughout your Workspace organization, even when the Chat app isn't a member.
'https://www.googleapis.com/auth/chat.app.all.users.readstate.readonly',
// On their own behalf, apps in Google Chat can see, add, update, and remove members from conversations and spaces
'https://www.googleapis.com/auth/chat.app.memberships',
// On their own behalf, apps in Google Chat can see members of conversations and spaces
'https://www.googleapis.com/auth/chat.app.memberships.readonly',
// On their own behalf, apps in Google Chat can see all messages and their associated reactions and message content
'https://www.googleapis.com/auth/chat.app.messages.readonly',
// On their own behalf, apps in Google Chat can create conversations and spaces and see or update their metadata (including history settings and access settings)
'https://www.googleapis.com/auth/chat.app.spaces',
// On their own behalf, apps in Google Chat can see conversations and spaces and their metadata (including history settings and access settings)
'https://www.googleapis.com/auth/chat.app.spaces.readonly',
// Private Service: https://www.googleapis.com/auth/chat.bot
'https://www.googleapis.com/auth/chat.bot',
// See, add, update, and remove members from conversations and spaces in Google Chat
'https://www.googleapis.com/auth/chat.memberships',
// View members in Google Chat conversations.
'https://www.googleapis.com/auth/chat.memberships.readonly',
// See, compose, send, update, and delete messages, their content, and attached cards; add, see, and delete reactions to messages.
'https://www.googleapis.com/auth/chat.messages',
// See, add, and delete reactions as well as their reaction content to messages in Google Chat
'https://www.googleapis.com/auth/chat.messages.reactions',
// View reactions as well as their reaction content to messages in Google Chat
'https://www.googleapis.com/auth/chat.messages.reactions.readonly',
// See messages as well as their reactions and message content in Google Chat
'https://www.googleapis.com/auth/chat.messages.readonly',
// Create conversations and spaces and see or update metadata (including history settings and access settings) in Google Chat
'https://www.googleapis.com/auth/chat.spaces',
// View chat and spaces in Google Chat
'https://www.googleapis.com/auth/chat.spaces.readonly',
// See and change your availability status in Google Chat.
'https://www.googleapis.com/auth/chat.users.availability',
// See your availability status in Google Chat.
'https://www.googleapis.com/auth/chat.users.availability.readonly',
// View and modify last read time for Google Chat conversations
'https://www.googleapis.com/auth/chat.users.readstate',
// View last read time for Google Chat conversations
'https://www.googleapis.com/auth/chat.users.readstate.readonly',
// See, edit, create, and delete all of your Google Drive files
'https://www.googleapis.com/auth/drive',
// See, edit, create, and delete only the specific Google Drive files you use with this app
'https://www.googleapis.com/auth/drive.file',
// View and manage metadata of files in your Google Drive
'https://www.googleapis.com/auth/drive.metadata',
// See information about your Google Drive files
'https://www.googleapis.com/auth/drive.metadata.readonly',
// See and download all your Google Drive files
'https://www.googleapis.com/auth/drive.readonly',
// Create, edit, and see information about your Google Meet conferences created by the app.
'https://www.googleapis.com/auth/meetings.space.created',
// Read information about any of your Google Meet conferences
'https://www.googleapis.com/auth/meetings.space.readonly',
],
immediate = true;
// ...
gapi.auth.authorize(
{client_id: client_id, scope: scope, immediate: immediate},
authResult => {
if (authResult && !authResult.error) {
/* handle successful authorization */
} else {
/* handle authorization error */
}
},
);After that you can use Google Workspace Events API resources:
/*
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
*/
await gapi.client.workspaceevents.operations.get({name: 'name'});
/*
Creates a Google Workspace subscription. To learn how to use this method, see [Create a Google Workspace subscription](https://developers.google.com/workspace/events/guides/create-subscription). For a subscription on a [Chat target resource](https://developers.google.com/workspace/events/guides/events-chat), you can create a subscription as: - A Chat app subscribing to space events where the app is a member by specifying an authorization scope that begins with `chat.app` and getting one-time administrator approval. To learn more, see [Authorize as a Chat app with administrator approval](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app). - [Developer Preview](https://developers.google.com/workspace/preview): A Chat app subscribing to all events in a Google Workspace organization by specifying an authorization scope that begins with `chat.app.all` and obtaining one-time administrator approval. To learn more, see [Subscribe to all Google Chat events in a Workspace organization ](https://developers.google.com/workspace/events/guides/create-subscription#customer-subscription). - A user by specifying an authorization scope that doesn't include `app` in its name. To learn more, see [Authorize as a Chat user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*/
await gapi.client.workspaceevents.subscriptions.create({});
/*
Deletes a Google Workspace subscription. To learn how to use this method, see [Delete a Google Workspace subscription](https://developers.google.com/workspace/events/guides/delete-subscription).
*/
await gapi.client.workspaceevents.subscriptions.delete({name: 'name'});
/*
Gets details about a Google Workspace subscription. To learn how to use this method, see [Get details about a Google Workspace subscription](https://developers.google.com/workspace/events/guides/get-subscription).
*/
await gapi.client.workspaceevents.subscriptions.get({name: 'name'});
/*
Lists Google Workspace subscriptions. To learn how to use this method, see [List Google Workspace subscriptions](https://developers.google.com/workspace/events/guides/list-subscriptions).
*/
await gapi.client.workspaceevents.subscriptions.list({});
/*
Updates or renews a Google Workspace subscription. To learn how to use this method, see [Update or renew a Google Workspace subscription](https://developers.google.com/workspace/events/guides/update-subscription). For a subscription on a [Chat target resource](https://developers.google.com/workspace/events/guides/events-chat), you can update a subscription as: - A Chat app subscribing to space events where the app is a member by specifying an authorization scope that begins with `chat.app` and getting one-time administrator approval. To learn more, see [Authorize as a Chat app with administrator approval](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app). - [Developer Preview](https://developers.google.com/workspace/preview): A Chat app subscribing to all events in a Google Workspace organization by specifying an authorization scope that begins with `chat.app.all` and getting one-time administrator approval. To learn more, see [Subscribe to all Google Chat events in a Workspace organization ](https://developers.google.com/workspace/events/guides/create-subscription#customer-subscription). - A user by specifying an authorization scope that doesn't include `app` in its name. To learn more, see [Authorize as a Chat user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*/
await gapi.client.workspaceevents.subscriptions.patch({name: 'name'});
/*
Reactivates a suspended Google Workspace subscription. This method resets your subscription's `State` field to `ACTIVE`. Before you use this method, you must fix the error that suspended the subscription. This method will ignore or reject any subscription that isn't currently in a suspended state. To learn how to use this method, see [Reactivate a Google Workspace subscription](https://developers.google.com/workspace/events/guides/reactivate-subscription). For a subscription on a [Chat target resource](https://developers.google.com/workspace/events/guides/events-chat), you can reactivate a subscription as: - A Chat app subscribing to space events where the app is a member by specifying an authorization scope that begins with `chat.app` and getting one-time administrator approval. To learn more, see [Authorize as a Chat app with administrator approval](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app). - [Developer Preview](https://developers.google.com/workspace/preview): A Chat app subscribing to all events in a Google Workspace organization by specifying an authorization scope that begins with `chat.app.all` and getting one-time administrator approval. To learn more, see [Subscribe to all Google Chat events in a Workspace organization ](https://developers.google.com/workspace/events/guides/create-subscription#customer-subscription). - A user by specifying an authorization scope that doesn't include `app` in its name. To learn more, see [Authorize as a Chat user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*/
await gapi.client.workspaceevents.subscriptions.reactivate({name: 'name'});For provenance information see Provenance section on NPM
