Files
sim/apps/sim/tools/google_groups/add_member.ts
Adam Gough ae7937280e feat(google-groups): added google groups (#2229)
* added google-groups

* added a few more endpoints

* removed comments

* removed named imports, fixed comments

* fixed google groups tool names

---------

Co-authored-by: aadamgough <adam@sim.ai>
Co-authored-by: waleed <walif6@gmail.com>
2025-12-06 17:32:30 -08:00

73 lines
1.9 KiB
TypeScript

import type { ToolConfig } from '@/tools/types'
import type { GoogleGroupsAddMemberParams, GoogleGroupsResponse } from './types'
export const addMemberTool: ToolConfig<GoogleGroupsAddMemberParams, GoogleGroupsResponse> = {
id: 'google_groups_add_member',
name: 'Google Groups Add Member',
description: 'Add a new member to a Google Group',
version: '1.0.0',
oauth: {
required: true,
provider: 'google-groups',
},
params: {
accessToken: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'OAuth access token',
},
groupKey: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Group email address or unique group ID',
},
email: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Email address of the member to add',
},
role: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Role for the member (MEMBER, MANAGER, or OWNER). Defaults to MEMBER.',
},
},
request: {
url: (params) => {
const encodedGroupKey = encodeURIComponent(params.groupKey)
return `https://admin.googleapis.com/admin/directory/v1/groups/${encodedGroupKey}/members`
},
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.accessToken}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, string> = {
email: params.email,
role: params.role || 'MEMBER',
}
return JSON.stringify(body)
},
},
transformResponse: async (response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error?.message || 'Failed to add member to group')
}
return {
success: true,
output: data,
}
},
}