n8n/packages/nodes-base/nodes/Jira/Jira.node.ts

607 lines
20 KiB
TypeScript
Raw Normal View History

2019-11-26 12:38:38 -08:00
import {
IExecuteFunctions,
} from 'n8n-core';
2020-04-23 22:59:19 -07:00
2019-11-26 12:38:38 -08:00
import {
IDataObject,
ILoadOptionsFunctions,
2020-04-23 22:59:19 -07:00
INodeExecutionData,
2019-11-26 12:38:38 -08:00
INodePropertyOptions,
2020-04-23 22:59:19 -07:00
INodeType,
INodeTypeDescription,
2019-11-26 12:38:38 -08:00
} from 'n8n-workflow';
2020-04-23 22:59:19 -07:00
2019-11-26 12:38:38 -08:00
import {
jiraSoftwareCloudApiRequest,
jiraSoftwareCloudApiRequestAllItems,
2019-11-26 12:38:38 -08:00
validateJSON,
} from './GenericFunctions';
2020-04-23 22:59:19 -07:00
2019-11-27 14:42:28 -08:00
import {
issueFields,
issueOperations,
2019-11-27 14:42:28 -08:00
} from './IssueDescription';
2020-04-23 22:59:19 -07:00
import {
IFields,
2020-04-23 22:59:19 -07:00
IIssue,
2019-11-29 14:30:00 -08:00
INotificationRecipients,
2020-04-23 22:59:19 -07:00
INotify,
2019-11-29 14:30:00 -08:00
NotificationRecipientsRestrictions,
} from './IssueInterface';
2019-11-26 12:38:38 -08:00
2020-05-12 06:08:19 -07:00
export class Jira implements INodeType {
2019-11-26 12:38:38 -08:00
description: INodeTypeDescription = {
2020-02-01 15:15:56 -08:00
displayName: 'Jira Software',
2020-05-12 06:08:19 -07:00
name: 'jira',
2019-11-26 12:38:38 -08:00
icon: 'file:jira.png',
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
2020-02-01 15:15:56 -08:00
description: 'Consume Jira Software API',
2019-11-26 12:38:38 -08:00
defaults: {
2020-05-12 06:08:19 -07:00
name: 'Jira',
2020-04-23 22:59:19 -07:00
color: '#4185f7',
2019-11-26 12:38:38 -08:00
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'jiraSoftwareCloudApi',
2019-11-26 12:38:38 -08:00
required: true,
2020-02-02 07:01:56 -08:00
displayOptions: {
show: {
jiraVersion: [
'cloud',
],
},
},
},
{
name: 'jiraSoftwareServerApi',
required: true,
displayOptions: {
show: {
jiraVersion: [
'server',
],
},
},
2020-02-01 15:15:56 -08:00
},
2019-11-26 12:38:38 -08:00
],
properties: [
2020-02-02 07:01:56 -08:00
{
displayName: 'Jira Version',
name: 'jiraVersion',
type: 'options',
options: [
{
name: 'Cloud',
value: 'cloud',
},
{
name: 'Server (Self Hosted)',
value: 'server',
},
],
default: 'cloud',
},
2019-11-26 12:38:38 -08:00
{
displayName: 'Resource',
name: 'resource',
type: 'options',
options: [
{
name: 'Issue',
value: 'issue',
description: 'Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask',
},
],
default: 'issue',
description: 'Resource to consume.',
},
2020-02-01 15:15:56 -08:00
...issueOperations,
2019-11-27 14:42:28 -08:00
...issueFields,
2019-11-26 12:38:38 -08:00
],
};
2019-11-27 14:42:28 -08:00
methods = {
loadOptions: {
// Get all the projects to display them to user so that he can
// select them easily
async getProjects(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
let endpoint = '';
let projects;
if (jiraVersion === 'server') {
endpoint = '/api/2/project';
projects = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET');
} else {
endpoint = '/api/2/project/search';
projects = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values', endpoint, 'GET');
2020-02-01 15:15:56 -08:00
}
2020-04-23 22:59:19 -07:00
2020-02-01 15:15:56 -08:00
if (projects.values && Array.isArray(projects.values)) {
projects = projects.values;
}
for (const project of projects) {
2019-11-27 14:42:28 -08:00
const projectName = project.name;
const projectId = project.id;
returnData.push({
name: projectName,
value: projectId,
});
}
return returnData;
},
// Get all the issue types to display them to user so that he can
// select them easily
async getIssueTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
2020-04-23 22:59:19 -07:00
const projectId = this.getCurrentNodeParameter('project');
2019-11-27 14:42:28 -08:00
const returnData: INodePropertyOptions[] = [];
2020-04-23 22:59:19 -07:00
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET');
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
2020-05-05 13:56:24 -07:00
if (jiraVersion === 'server') {
for (const issueType of issueTypes) {
2020-04-23 22:59:19 -07:00
const issueTypeName = issueType.name;
const issueTypeId = issueType.id;
2020-05-05 13:56:24 -07:00
2020-04-23 22:59:19 -07:00
returnData.push({
name: issueTypeName,
value: issueTypeId,
});
}
} else {
for (const issueType of issueTypes) {
if (issueType.scope === undefined || issueType.scope.project.id === projectId) {
const issueTypeName = issueType.name;
const issueTypeId = issueType.id;
2020-05-05 13:56:24 -07:00
returnData.push({
name: issueTypeName,
value: issueTypeId,
});
}
}
2019-11-27 14:42:28 -08:00
}
2020-05-05 13:56:24 -07:00
2019-11-27 14:42:28 -08:00
return returnData;
},
// Get all the labels to display them to user so that he can
// select them easily
async getLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-04-23 22:59:19 -07:00
const labels = await jiraSoftwareCloudApiRequest.call(this, '/api/2/label', 'GET');
2020-04-23 22:59:19 -07:00
2019-11-27 14:42:28 -08:00
for (const label of labels.values) {
const labelName = label;
const labelId = label;
returnData.push({
name: labelName,
value: labelId,
});
}
return returnData;
},
// Get all the priorities to display them to user so that he can
// select them easily
async getPriorities(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-04-23 22:59:19 -07:00
const priorities = await jiraSoftwareCloudApiRequest.call(this, '/api/2/priority', 'GET');
2020-04-23 22:59:19 -07:00
2019-11-27 14:42:28 -08:00
for (const priority of priorities) {
const priorityName = priority.name;
const priorityId = priority.id;
returnData.push({
name: priorityName,
value: priorityId,
});
}
return returnData;
},
// Get all the users to display them to user so that he can
// select them easily
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-05-05 13:56:24 -07:00
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
if (jiraVersion === 'server') {
// the interface call must bring username
const users = await jiraSoftwareCloudApiRequest.call(this, '/api/2/user/search', 'GET', {},
{
username: "'",
2020-10-22 09:00:28 -07:00
},
);
for (const user of users) {
const userName = user.displayName;
const userId = user.name;
2020-05-05 13:56:24 -07:00
returnData.push({
name: userName,
value: userId,
});
}
} else {
const users = await jiraSoftwareCloudApiRequest.call(this, '/api/2/users/search', 'GET');
2020-04-23 22:59:19 -07:00
for (const user of users) {
const userName = user.displayName;
const userId = user.accountId;
2019-11-27 14:42:28 -08:00
returnData.push({
name: userName,
value: userId,
});
}
2019-11-27 14:42:28 -08:00
}
2020-05-05 13:56:24 -07:00
2019-11-27 14:42:28 -08:00
return returnData;
},
2019-11-29 14:30:00 -08:00
// Get all the groups to display them to user so that he can
// select them easily
async getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-04-23 22:59:19 -07:00
const groups = await jiraSoftwareCloudApiRequest.call(this, '/api/2/groups/picker', 'GET');
2020-04-23 22:59:19 -07:00
2019-11-29 14:30:00 -08:00
for (const group of groups.groups) {
const groupName = group.name;
const groupId = group.name;
returnData.push({
name: groupName,
value: groupId,
});
}
return returnData;
2020-04-24 00:50:56 -07:00
},
// Get all the groups to display them to user so that he can
// select them easily
async getTransitions(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const issueKey = this.getCurrentNodeParameter('issueKey');
const transitions = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET');
2020-04-24 00:50:56 -07:00
for (const transition of transitions.transitions) {
returnData.push({
name: transition.name,
value: transition.id,
});
}
return returnData;
},
2020-10-22 06:46:03 -07:00
},
2019-11-27 14:42:28 -08:00
};
2019-11-26 12:38:38 -08:00
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
2019-11-27 14:42:28 -08:00
const items = this.getInputData();
const returnData: IDataObject[] = [];
const length = items.length as unknown as number;
let responseData;
2019-11-29 14:30:00 -08:00
const qs: IDataObject = {};
2019-12-02 13:40:24 -08:00
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
const jiraVersion = this.getNodeParameter('jiraVersion', 0) as string;
2019-12-02 13:40:24 -08:00
2019-11-27 14:42:28 -08:00
for (let i = 0; i < length; i++) {
if (resource === 'issue') {
2019-11-29 14:36:07 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-post
2019-11-27 14:42:28 -08:00
if (operation === 'create') {
const summary = this.getNodeParameter('summary', i) as string;
const projectId = this.getNodeParameter('project', i) as string;
const issueTypeId = this.getNodeParameter('issueType', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const body: IIssue = {};
const fields: IFields = {
summary,
project: {
id: projectId,
},
issuetype: {
id: issueTypeId,
},
2019-11-27 14:42:28 -08:00
};
if (additionalFields.labels) {
fields.labels = additionalFields.labels as string[];
2019-11-27 14:42:28 -08:00
}
if (additionalFields.serverLabels) {
fields.labels = additionalFields.serverLabels as string[];
}
2019-11-27 14:42:28 -08:00
if (additionalFields.priority) {
fields.priority = {
2019-11-27 14:42:28 -08:00
id: additionalFields.priority as string,
};
}
if (additionalFields.assignee) {
2020-05-05 13:56:24 -07:00
if (jiraVersion === 'server') {
fields.assignee = {
name: additionalFields.assignee as string,
};
} else {
fields.assignee = {
id: additionalFields.assignee as string,
};
}
2019-11-27 14:42:28 -08:00
}
if (additionalFields.description) {
fields.description = additionalFields.description as string;
}
2019-11-29 14:30:00 -08:00
if (additionalFields.updateHistory) {
qs.updateHistory = additionalFields.updateHistory as boolean;
}
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET', body, qs);
2019-11-29 14:30:00 -08:00
const subtaskIssues = [];
for (const issueType of issueTypes) {
if (issueType.subtask) {
subtaskIssues.push(issueType.id);
2019-11-27 14:42:28 -08:00
}
}
2019-12-01 13:47:53 -08:00
if (!additionalFields.parentIssueKey
&& subtaskIssues.includes(issueTypeId)) {
2019-11-29 14:30:00 -08:00
throw new Error('You must define a Parent Issue Key when Issue type is sub-task');
2019-12-01 13:47:53 -08:00
} else if (additionalFields.parentIssueKey
&& subtaskIssues.includes(issueTypeId)) {
2019-11-29 14:30:00 -08:00
fields.parent = {
2019-12-01 13:47:53 -08:00
key: (additionalFields.parentIssueKey as string).toUpperCase(),
2019-11-29 14:30:00 -08:00
};
}
body.fields = fields;
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issue', 'POST', body);
2019-11-27 14:42:28 -08:00
}
2019-11-29 14:36:07 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-put
2019-11-29 14:30:00 -08:00
if (operation === 'update') {
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
2019-11-29 14:30:00 -08:00
const body: IIssue = {};
2019-12-01 13:47:53 -08:00
const fields: IFields = {};
if (updateFields.summary) {
fields.summary = updateFields.summary as string;
2019-11-29 14:30:00 -08:00
}
2019-12-01 13:47:53 -08:00
if (updateFields.issueType) {
fields.issuetype = {
id: updateFields.issueType as string,
};
}
if (updateFields.labels) {
fields.labels = updateFields.labels as string[];
}
if (updateFields.serverLabels) {
fields.labels = updateFields.serverLabels as string[];
}
2019-12-01 13:47:53 -08:00
if (updateFields.priority) {
2019-11-29 14:30:00 -08:00
fields.priority = {
2019-12-01 13:47:53 -08:00
id: updateFields.priority as string,
2019-11-29 14:30:00 -08:00
};
}
2019-12-01 13:47:53 -08:00
if (updateFields.assignee) {
2020-05-05 13:56:24 -07:00
if (jiraVersion === 'server') {
fields.assignee = {
name: updateFields.assignee as string,
};
} else {
fields.assignee = {
id: updateFields.assignee as string,
};
}
2019-11-29 14:30:00 -08:00
}
2019-12-01 13:47:53 -08:00
if (updateFields.description) {
fields.description = updateFields.description as string;
2019-11-29 14:30:00 -08:00
}
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET', body);
2019-11-29 14:30:00 -08:00
const subtaskIssues = [];
for (const issueType of issueTypes) {
if (issueType.subtask) {
subtaskIssues.push(issueType.id);
}
}
2019-12-01 13:47:53 -08:00
if (!updateFields.parentIssueKey
&& subtaskIssues.includes(updateFields.issueType)) {
2019-11-29 14:30:00 -08:00
throw new Error('You must define a Parent Issue Key when Issue type is sub-task');
2019-12-01 13:47:53 -08:00
} else if (updateFields.parentIssueKey
&& subtaskIssues.includes(updateFields.issueType)) {
2019-11-29 14:30:00 -08:00
fields.parent = {
2019-12-01 13:47:53 -08:00
key: (updateFields.parentIssueKey as string).toUpperCase(),
2019-11-29 14:30:00 -08:00
};
}
body.fields = fields;
2020-04-23 22:59:19 -07:00
if (updateFields.statusId) {
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'POST', { transition: { id: updateFields.statusId } });
2019-11-29 14:30:00 -08:00
}
2020-04-23 22:59:19 -07:00
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'PUT', body);
2020-04-23 22:59:19 -07:00
responseData = { success: true };
2019-11-29 14:30:00 -08:00
}
2019-11-29 14:36:07 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-get
2019-11-29 14:30:00 -08:00
if (operation === 'get') {
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.fields) {
qs.fields = additionalFields.fields as string;
}
if (additionalFields.fieldsByKey) {
qs.fieldsByKey = additionalFields.fieldsByKey as boolean;
}
if (additionalFields.expand) {
qs.expand = additionalFields.expand as string;
}
if (additionalFields.properties) {
qs.properties = additionalFields.properties as string;
}
if (additionalFields.updateHistory) {
qs.updateHistory = additionalFields.updateHistory as string;
}
2020-04-23 22:59:19 -07:00
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, qs);
2020-04-23 22:59:19 -07:00
2019-11-29 14:30:00 -08:00
}
2020-02-02 07:01:56 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-search-post
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const options = this.getNodeParameter('options', i) as IDataObject;
const body: IDataObject = {};
if (options.fields) {
body.fields = (options.fields as string).split(',') as string[];
}
if (options.jql) {
body.jql = options.jql as string;
}
if (options.expand) {
body.expand = options.expand as string;
}
if (returnAll) {
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'issues', `/api/2/search`, 'POST', body);
2020-02-02 07:01:56 -08:00
} else {
const limit = this.getNodeParameter('limit', i) as number;
body.maxResults = limit;
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/search`, 'POST', body);
2020-02-02 07:01:56 -08:00
responseData = responseData.issues;
}
}
2019-11-29 14:36:07 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-changelog-get
2019-11-29 14:30:00 -08:00
if (operation === 'changelog') {
const issueKey = this.getNodeParameter('issueKey', i) as string;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
2020-04-23 22:59:19 -07:00
if (returnAll) {
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values',`/api/2/issue/${issueKey}/changelog`, 'GET');
2020-04-23 22:59:19 -07:00
} else {
qs.maxResults = this.getNodeParameter('limit', i) as number;
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/changelog`, 'GET', {}, qs);
2020-04-23 22:59:19 -07:00
responseData = responseData.values;
2019-11-29 14:30:00 -08:00
}
}
2019-11-29 14:36:07 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-notify-post
2019-11-29 14:30:00 -08:00
if (operation === 'notify') {
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
2019-11-29 14:30:00 -08:00
const jsonActive = this.getNodeParameter('jsonParameters', 0) as boolean;
const body: INotify = {};
2019-12-01 13:47:53 -08:00
if (additionalFields.textBody) {
body.textBody = additionalFields.textBody as string;
}
if (additionalFields.htmlBody) {
body.htmlBody = additionalFields.htmlBody as string;
}
2019-11-29 14:30:00 -08:00
if (!jsonActive) {
const notificationRecipientsValues = (this.getNodeParameter('notificationRecipientsUi', i) as IDataObject).notificationRecipientsValues as IDataObject[];
const notificationRecipients: INotificationRecipients = {};
if (notificationRecipientsValues) {
// @ts-ignore
if (notificationRecipientsValues.reporter) {
// @ts-ignore
notificationRecipients.reporter = notificationRecipientsValues.reporter as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.assignee) {
// @ts-ignore
notificationRecipients.assignee = notificationRecipientsValues.assignee as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.assignee) {
// @ts-ignore
notificationRecipients.watchers = notificationRecipientsValues.watchers as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.voters) {
// @ts-ignore
notificationRecipients.watchers = notificationRecipientsValues.voters as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.users.length > 0) {
// @ts-ignore
notificationRecipients.users = notificationRecipientsValues.users.map(user => {
return {
2020-10-22 06:46:03 -07:00
accountId: user,
2019-11-29 14:30:00 -08:00
};
});
}
// @ts-ignore
if (notificationRecipientsValues.groups.length > 0) {
// @ts-ignore
notificationRecipients.groups = notificationRecipientsValues.groups.map(group => {
return {
2020-10-22 06:46:03 -07:00
name: group,
2019-11-29 14:30:00 -08:00
};
});
}
}
body.to = notificationRecipients;
const notificationRecipientsRestrictionsValues = (this.getNodeParameter('notificationRecipientsRestrictionsUi', i) as IDataObject).notificationRecipientsRestrictionsValues as IDataObject[];
const notificationRecipientsRestrictions: NotificationRecipientsRestrictions = {};
if (notificationRecipientsRestrictionsValues) {
// @ts-ignore
if (notificationRecipientsRestrictionsValues.groups. length > 0) {
// @ts-ignore
notificationRecipientsRestrictions.groups = notificationRecipientsRestrictionsValues.groups.map(group => {
return {
2020-10-22 06:46:03 -07:00
name: group,
2019-11-29 14:30:00 -08:00
};
});
}
}
body.restrict = notificationRecipientsRestrictions;
} else {
const notificationRecipientsJson = validateJSON(this.getNodeParameter('notificationRecipientsJson', i) as string);
if (notificationRecipientsJson) {
body.to = notificationRecipientsJson;
}
const notificationRecipientsRestrictionsJson = validateJSON(this.getNodeParameter('notificationRecipientsRestrictionsJson', i) as string);
if (notificationRecipientsRestrictionsJson) {
body.restrict = notificationRecipientsRestrictionsJson;
}
}
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/notify`, 'POST', body, qs);
2020-04-23 22:59:19 -07:00
2019-11-29 14:30:00 -08:00
}
2019-12-01 13:47:53 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-transitions-get
2019-11-29 14:30:00 -08:00
if (operation === 'transitions') {
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.transitionId) {
qs.transitionId = additionalFields.transitionId as string;
2019-11-29 14:30:00 -08:00
}
2019-12-01 13:47:53 -08:00
if (additionalFields.expand) {
qs.expand = additionalFields.expand as string;
}
if (additionalFields.skipRemoteOnlyCondition) {
qs.skipRemoteOnlyCondition = additionalFields.skipRemoteOnlyCondition as boolean;
2019-11-29 14:30:00 -08:00
}
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET', {}, qs);
2020-04-23 22:59:19 -07:00
responseData = responseData.transitions;
2019-11-29 14:30:00 -08:00
}
2019-11-29 14:36:07 -08:00
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-delete
2019-11-29 14:30:00 -08:00
if (operation === 'delete') {
const issueKey = this.getNodeParameter('issueKey', i) as string;
const deleteSubtasks = this.getNodeParameter('deleteSubtasks', i) as boolean;
qs.deleteSubtasks = deleteSubtasks;
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'DELETE', {}, qs);
2019-11-29 14:30:00 -08:00
}
2019-11-27 14:42:28 -08:00
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
returnData.push(responseData as IDataObject);
}
}
return [this.helpers.returnJsonArray(returnData)];
2019-11-26 12:38:38 -08:00
}
}