import type { INodeProperties } from 'n8n-workflow'; import { handleErrorPostReceive, handlePagination, presendOptions, presendPath, } from '../GenericFunctions'; export const groupOperations: INodeProperties[] = [ { displayName: 'Operation', name: 'operation', type: 'options', noDataExpression: true, default: 'getAll', displayOptions: { show: { resource: ['group'], }, }, options: [ { name: 'Create', value: 'create', description: 'Create a new group', routing: { request: { method: 'POST', headers: { 'X-Amz-Target': 'AWSCognitoIdentityProviderService.CreateGroup', }, ignoreHttpStatusErrors: true, }, output: { postReceive: [handleErrorPostReceive], }, }, action: 'Create group', }, { name: 'Delete', value: 'delete', description: 'Delete an existing group', routing: { request: { method: 'POST', headers: { 'X-Amz-Target': 'AWSCognitoIdentityProviderService.DeleteGroup', }, ignoreHttpStatusErrors: true, }, output: { postReceive: [ handleErrorPostReceive, { type: 'set', properties: { value: '={{ { "success": true } }}', }, }, ], }, }, action: 'Delete group', }, { name: 'Get', value: 'get', description: 'Retrieve details of an existing group', routing: { request: { method: 'POST', headers: { 'X-Amz-Target': 'AWSCognitoIdentityProviderService.GetGroup', }, ignoreHttpStatusErrors: true, }, output: { postReceive: [handleErrorPostReceive], }, }, action: 'Get group', }, { name: 'Get Many', value: 'getAll', description: 'Retrieve a list of groups', routing: { send: { paginate: true }, operations: { pagination: handlePagination }, request: { method: 'POST', headers: { 'X-Amz-Target': 'AWSCognitoIdentityProviderService.ListGroups', }, qs: { pageSize: '={{ $parameter["limit"] ? ($parameter["limit"] < 60 ? $parameter["limit"] : 60) : 60 }}', }, ignoreHttpStatusErrors: true, }, output: { postReceive: [handleErrorPostReceive], }, }, action: 'Get many groups', }, { name: 'Update', value: 'update', description: 'Update an existing group', routing: { send: { preSend: [presendOptions], }, request: { method: 'POST', headers: { 'X-Amz-Target': 'AWSCognitoIdentityProviderService.UpdateGroup', }, ignoreHttpStatusErrors: true, }, output: { postReceive: [ handleErrorPostReceive, { type: 'set', properties: { value: '={{ { "success": true } }}', }, }, ], }, }, action: 'Update group', }, ], }, ]; const createFields: INodeProperties[] = [ { displayName: 'User Pool ID', name: 'userPoolId', required: true, type: 'resourceLocator', default: { mode: 'list', value: '', }, description: 'The user pool ID where the users are managed', displayOptions: { show: { resource: ['group'], operation: ['create'], }, }, routing: { send: { type: 'body', property: 'UserPoolId', }, }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchUserPools', searchable: true, }, }, { displayName: 'By ID', name: 'id', type: 'string', hint: 'Enter the user pool ID', validation: [ { type: 'regex', properties: { regex: '^[\\w-]+_[0-9a-zA-Z]+$', errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx".', }, }, ], placeholder: 'e.g. eu-central-1_ab12cdefgh', }, ], }, { displayName: 'Group Name', name: 'GroupName', default: '', placeholder: 'e.g. My New Group', description: 'The name of the new group to create', displayOptions: { show: { resource: ['group'], operation: ['create'], }, }, required: true, routing: { send: { property: 'GroupName', type: 'body', paginate: true, }, }, type: 'string', validateType: 'string', }, { displayName: 'Options', name: 'options', default: {}, displayOptions: { show: { resource: ['group'], operation: ['create'], }, }, options: [ { displayName: 'Description', name: 'Description', default: '', placeholder: 'e.g. New group description', description: 'A description for the new group', type: 'string', routing: { send: { type: 'body', property: 'Description', }, }, }, { displayName: 'Precedence', name: 'Precedence', default: '', placeholder: 'e.g. 10', description: 'Precedence value for the group. Lower values indicate higher priority.', type: 'number', routing: { send: { type: 'body', property: 'Precedence', }, }, validateType: 'number', }, { displayName: 'Path', name: 'path', type: 'string', default: '', placeholder: 'e.g. /division_abc/engineering/', description: 'The path to the group, if it is not included, it defaults to a slash (/)', routing: { send: { property: 'Path', type: 'body', preSend: [presendPath], }, }, }, { displayName: 'Role ARN', name: 'Arn', default: '', placeholder: 'e.g. arn:aws:iam::123456789012:role/GroupRole', description: 'The role ARN for the group, used for setting claims in tokens', type: 'string', routing: { send: { type: 'body', property: 'Arn', }, }, }, ], placeholder: 'Add Option', type: 'collection', }, ]; const deleteFields: INodeProperties[] = [ { displayName: 'User Pool ID', name: 'userPoolId', required: true, type: 'resourceLocator', default: { mode: 'list', value: '', }, description: 'The user pool ID where the users are managed', displayOptions: { show: { resource: ['group'], operation: ['delete'], }, }, routing: { send: { type: 'body', property: 'UserPoolId', }, }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchUserPools', searchable: true, }, }, { displayName: 'By ID', name: 'id', type: 'string', hint: 'Enter the user pool ID', validation: [ { type: 'regex', properties: { regex: '^[\\w-]+_[0-9a-zA-Z]+$', errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"', }, }, ], placeholder: 'e.g. eu-central-1_ab12cdefgh', }, ], }, { displayName: 'Group', name: 'GroupName', default: { mode: 'list', value: '', }, description: 'Select the group you want to delete', displayOptions: { show: { resource: ['group'], operation: ['delete'], }, }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchGroups', searchable: true, }, }, { displayName: 'By Name', name: 'GroupName', type: 'string', hint: 'Enter the group name', validation: [ { type: 'regex', properties: { regex: '^[\\w+=,.@-]+$', errorMessage: 'The group name must follow the allowed pattern.', }, }, ], placeholder: 'e.g. Admins', }, ], required: true, routing: { send: { type: 'body', property: 'GroupName', }, }, type: 'resourceLocator', }, ]; const getFields: INodeProperties[] = [ { displayName: 'User Pool ID', name: 'userPoolId', required: true, type: 'resourceLocator', default: { mode: 'list', value: '', }, description: 'The user pool ID where the users are managed', displayOptions: { show: { resource: ['group'], operation: ['get'], }, }, routing: { send: { type: 'body', property: 'UserPoolId', }, }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchUserPools', searchable: true, }, }, { displayName: 'By ID', name: 'id', type: 'string', hint: 'Enter the user pool ID', validation: [ { type: 'regex', properties: { regex: '^[\\w-]+_[0-9a-zA-Z]+$', errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"', }, }, ], placeholder: 'e.g. eu-central-1_ab12cdefgh', }, ], }, { displayName: 'Group', name: 'GroupName', required: true, type: 'resourceLocator', default: { mode: 'list', value: '', }, description: 'Select the group you want to retrieve', displayOptions: { show: { resource: ['group'], operation: ['get'], }, }, routing: { send: { type: 'body', property: 'GroupName', }, }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchGroups', searchable: true, }, }, { displayName: 'By Name', name: 'GroupName', type: 'string', hint: 'Enter the group name', validation: [ { type: 'regex', properties: { regex: '^[\\w+=,.@-]+$', errorMessage: 'The group name must follow the allowed pattern.', }, }, ], placeholder: 'e.g. Admins', }, ], }, ]; const getAllFields: INodeProperties[] = [ { displayName: 'User Pool ID', name: 'userPoolId', required: true, type: 'resourceLocator', default: { mode: 'list', value: '' }, description: 'The user pool ID where the users are managed', displayOptions: { show: { resource: ['group'], operation: ['getAll'] } }, routing: { send: { type: 'body', property: 'UserPoolId' } }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchUserPools', searchable: true, }, }, { displayName: 'By ID', name: 'id', type: 'string', hint: 'Enter the user pool ID', validation: [ { type: 'regex', properties: { regex: '^[\\w-]+_[0-9a-zA-Z]+$', errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"', }, }, ], placeholder: 'e.g. eu-central-1_ab12cdefgh', }, ], }, { displayName: 'Return All', name: 'returnAll', default: false, description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { resource: ['group'], operation: ['getAll'] } }, type: 'boolean', }, { displayName: 'Limit', name: 'limit', required: true, type: 'number', typeOptions: { minValue: 1, }, default: 20, description: 'Max number of results to return', displayOptions: { show: { resource: ['group'], operation: ['getAll'], returnAll: [false] } }, routing: { send: { type: 'body', property: 'Limit' } }, }, ]; const updateFields: INodeProperties[] = [ { displayName: 'User Pool ID', name: 'userPoolId', required: true, type: 'resourceLocator', default: { mode: 'list', value: '', }, description: 'The user pool ID where the users are managed', displayOptions: { show: { resource: ['group'], operation: ['update'], }, }, routing: { send: { type: 'body', property: 'UserPoolId', }, }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchUserPools', searchable: true, }, }, { displayName: 'By ID', name: 'id', type: 'string', hint: 'Enter the user pool ID', validation: [ { type: 'regex', properties: { regex: '^[\\w-]+_[0-9a-zA-Z]+$', errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"', }, }, ], placeholder: 'e.g. eu-central-1_ab12cdefgh', }, ], }, { displayName: 'Group', name: 'GroupName', default: { mode: 'list', value: '', }, description: 'Select the group you want to update', displayOptions: { show: { resource: ['group'], operation: ['update'], }, }, routing: { send: { type: 'body', property: 'GroupName', }, }, modes: [ { displayName: 'From list', name: 'list', type: 'list', typeOptions: { searchListMethod: 'searchGroups', searchable: true, }, }, { displayName: 'By Name', name: 'GroupName', type: 'string', hint: 'Enter the group name', validation: [ { type: 'regex', properties: { regex: '^[\\w+=,.@-]+$', errorMessage: 'The group name must follow the allowed pattern.', }, }, ], placeholder: 'e.g. Admins', }, ], required: true, type: 'resourceLocator', }, { displayName: 'Options', name: 'options', default: {}, displayOptions: { show: { resource: ['group'], operation: ['update'], }, }, options: [ { displayName: 'Description', name: 'Description', default: '', placeholder: 'e.g. Updated group description', description: 'A new description for the group', type: 'string', routing: { send: { type: 'body', property: 'Description', }, }, }, { displayName: 'Precedence', name: 'Precedence', default: '', placeholder: 'e.g. 10', description: 'The new precedence value for the group. Lower values indicate higher priority.', type: 'number', routing: { send: { type: 'body', property: 'Precedence', }, }, validateType: 'number', }, { displayName: 'Path', name: 'path', type: 'string', default: '', placeholder: 'e.g. /division_abc/engineering/', description: 'The path to the group, if it is not included, it defaults to a slash (/)', routing: { send: { property: 'Path', type: 'body', preSend: [presendPath], }, }, }, { displayName: 'Role ARN', name: 'Arn', default: '', placeholder: 'e.g. arn:aws:iam::123456789012:role/GroupRole', description: 'A new role Amazon Resource Name (ARN) for the group. Used for setting claims in tokens.', type: 'string', routing: { send: { type: 'body', property: 'Arn', }, }, }, ], placeholder: 'Add Option', type: 'collection', }, ]; export const groupFields: INodeProperties[] = [ ...createFields, ...deleteFields, ...getFields, ...getAllFields, ...updateFields, ];