mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
✨ Add user resource and operations to Jira (#1448)
* Add user resource and operations * Update user resource description * ⚡ Small improvements Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
@@ -43,6 +43,11 @@ import {
|
||||
NotificationRecipientsRestrictions,
|
||||
} from './IssueInterface';
|
||||
|
||||
import {
|
||||
userFields,
|
||||
userOperations,
|
||||
} from './UserDescription';
|
||||
|
||||
export class Jira implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Jira Software',
|
||||
@@ -119,6 +124,11 @@ export class Jira implements INodeType {
|
||||
value: 'issueComment',
|
||||
description: 'Get, create, update, and delete a comment from an issue.',
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
value: 'user',
|
||||
description: 'Get, create and delete a user.',
|
||||
},
|
||||
],
|
||||
default: 'issue',
|
||||
description: 'Resource to consume.',
|
||||
@@ -129,6 +139,8 @@ export class Jira implements INodeType {
|
||||
...issueAttachmentFields,
|
||||
...issueCommentOperations,
|
||||
...issueCommentFields,
|
||||
...userOperations,
|
||||
...userFields,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -952,10 +964,51 @@ export class Jira implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'user') {
|
||||
if (operation === 'create') {
|
||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-post
|
||||
for (let i = 0; i < length; i++) {
|
||||
const body = {
|
||||
name: this.getNodeParameter('username', i),
|
||||
emailAddress: this.getNodeParameter('emailAddress', i),
|
||||
displayName: this.getNodeParameter('displayName', i),
|
||||
};
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/3/user', 'POST', body, {});
|
||||
returnData.push(responseData);
|
||||
}
|
||||
} else if (operation === 'delete') {
|
||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-delete
|
||||
for (let i = 0; i < length; i++) {
|
||||
qs.accountId = this.getNodeParameter('accountId', i);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/3/user', 'DELETE', {}, qs);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
} else if (operation === 'get') {
|
||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-get
|
||||
for (let i = 0; i < length; i++) {
|
||||
qs.accountId = this.getNodeParameter('accountId', i);
|
||||
|
||||
const { expand } = this.getNodeParameter('additionalFields', i) as { expand: string[] };
|
||||
|
||||
if (expand) {
|
||||
qs.expand = expand.join(',');
|
||||
}
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/3/user', 'GET', {}, qs);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'issueAttachment' && (operation === 'getAll' || operation === 'get')) {
|
||||
return this.prepareOutputData(returnData as unknown as INodeExecutionData[]);
|
||||
} else {
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user