mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-29 21:31:07 -08:00
feat(Jira Software Node): Personal Access Token credential type (#11038)
This commit is contained in:
parent
69c2153279
commit
1c7a38f6ba
|
@ -0,0 +1,47 @@
|
|||
import type {
|
||||
IAuthenticateGeneric,
|
||||
ICredentialTestRequest,
|
||||
ICredentialType,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class JiraSoftwareServerPatApi implements ICredentialType {
|
||||
name = 'jiraSoftwareServerPatApi';
|
||||
|
||||
displayName = 'Jira SW Server (PAT) API';
|
||||
|
||||
documentationUrl = 'jira';
|
||||
|
||||
properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Personal Access Token',
|
||||
name: 'personalAccessToken',
|
||||
typeOptions: { password: true },
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Domain',
|
||||
name: 'domain',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'https://example.com',
|
||||
},
|
||||
];
|
||||
|
||||
authenticate: IAuthenticateGeneric = {
|
||||
type: 'generic',
|
||||
properties: {
|
||||
headers: {
|
||||
Authorization: '=Bearer {{$credentials.personalAccessToken}}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test: ICredentialTestRequest = {
|
||||
request: {
|
||||
baseURL: '={{$credentials?.domain}}',
|
||||
url: '/rest/api/2/project',
|
||||
},
|
||||
};
|
||||
}
|
|
@ -28,6 +28,9 @@ export async function jiraSoftwareCloudApiRequest(
|
|||
if (jiraVersion === 'server') {
|
||||
domain = (await this.getCredentials('jiraSoftwareServerApi')).domain as string;
|
||||
credentialType = 'jiraSoftwareServerApi';
|
||||
} else if (jiraVersion === 'serverPat') {
|
||||
domain = (await this.getCredentials('jiraSoftwareServerPatApi')).domain as string;
|
||||
credentialType = 'jiraSoftwareServerPatApi';
|
||||
} else {
|
||||
domain = (await this.getCredentials('jiraSoftwareCloudApi')).domain as string;
|
||||
credentialType = 'jiraSoftwareCloudApi';
|
||||
|
@ -233,7 +236,7 @@ export async function getUsers(this: ILoadOptionsFunctions): Promise<INodeProper
|
|||
const query: IDataObject = { maxResults };
|
||||
let endpoint = '/api/2/users/search';
|
||||
|
||||
if (jiraVersion === 'server') {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat') {
|
||||
endpoint = '/api/2/user/search';
|
||||
query.username = "'";
|
||||
}
|
||||
|
|
|
@ -67,6 +67,15 @@ export class Jira implements INodeType {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'jiraSoftwareServerPatApi',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
jiraVersion: ['serverPat'],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
|
@ -82,6 +91,10 @@ export class Jira implements INodeType {
|
|||
name: 'Server (Self Hosted)',
|
||||
value: 'server',
|
||||
},
|
||||
{
|
||||
name: 'Server Pat (Self Hosted)',
|
||||
value: 'serverPat',
|
||||
},
|
||||
],
|
||||
default: 'cloud',
|
||||
},
|
||||
|
@ -139,7 +152,7 @@ export class Jira implements INodeType {
|
|||
let endpoint = '';
|
||||
let projects;
|
||||
|
||||
if (jiraVersion === 'server') {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat') {
|
||||
endpoint = '/api/2/project';
|
||||
projects = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET');
|
||||
} else {
|
||||
|
@ -502,7 +515,7 @@ export class Jira implements INodeType {
|
|||
};
|
||||
}
|
||||
if (additionalFields.assignee) {
|
||||
if (jiraVersion === 'server') {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat') {
|
||||
fields.assignee = {
|
||||
name: additionalFields.assignee as string,
|
||||
};
|
||||
|
@ -513,7 +526,7 @@ export class Jira implements INodeType {
|
|||
}
|
||||
}
|
||||
if (additionalFields.reporter) {
|
||||
if (jiraVersion === 'server') {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat') {
|
||||
fields.reporter = {
|
||||
name: additionalFields.reporter as string,
|
||||
};
|
||||
|
@ -632,7 +645,7 @@ export class Jira implements INodeType {
|
|||
};
|
||||
}
|
||||
if (updateFields.assignee) {
|
||||
if (jiraVersion === 'server') {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat') {
|
||||
fields.assignee = {
|
||||
name: updateFields.assignee as string,
|
||||
};
|
||||
|
@ -643,7 +656,7 @@ export class Jira implements INodeType {
|
|||
}
|
||||
}
|
||||
if (updateFields.reporter) {
|
||||
if (jiraVersion === 'server') {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat') {
|
||||
fields.reporter = {
|
||||
name: updateFields.reporter as string,
|
||||
};
|
||||
|
@ -1025,7 +1038,8 @@ export class Jira implements INodeType {
|
|||
}
|
||||
}
|
||||
if (resource === 'issueAttachment') {
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string);
|
||||
const apiVersion =
|
||||
jiraVersion === 'server' || jiraVersion === 'serverPat' ? '2' : ('3' as string);
|
||||
|
||||
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post
|
||||
if (operation === 'add') {
|
||||
|
@ -1183,7 +1197,8 @@ export class Jira implements INodeType {
|
|||
}
|
||||
|
||||
if (resource === 'issueComment') {
|
||||
let apiVersion = jiraVersion === 'server' ? '2' : ('3' as string);
|
||||
let apiVersion =
|
||||
jiraVersion === 'server' || jiraVersion === 'serverPat' ? '2' : ('3' as string);
|
||||
|
||||
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post
|
||||
if (operation === 'add') {
|
||||
|
@ -1205,7 +1220,7 @@ export class Jira implements INodeType {
|
|||
Object.assign(body, options);
|
||||
if (!jsonParameters) {
|
||||
const comment = this.getNodeParameter('comment', i) as string;
|
||||
if (jiraVersion === 'server' || options.wikiMarkup) {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat' || options.wikiMarkup) {
|
||||
Object.assign(body, { body: comment });
|
||||
} else {
|
||||
Object.assign(body, {
|
||||
|
@ -1356,7 +1371,7 @@ export class Jira implements INodeType {
|
|||
Object.assign(qs, options);
|
||||
if (!jsonParameters) {
|
||||
const comment = this.getNodeParameter('comment', i) as string;
|
||||
if (jiraVersion === 'server' || options.wikiMarkup) {
|
||||
if (jiraVersion === 'server' || jiraVersion === 'serverPat' || options.wikiMarkup) {
|
||||
Object.assign(body, { body: comment });
|
||||
} else {
|
||||
Object.assign(body, {
|
||||
|
@ -1407,7 +1422,8 @@ export class Jira implements INodeType {
|
|||
}
|
||||
|
||||
if (resource === 'user') {
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string);
|
||||
const apiVersion =
|
||||
jiraVersion === 'server' || jiraVersion === 'serverPat' ? '2' : ('3' as string);
|
||||
|
||||
if (operation === 'create') {
|
||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-post
|
||||
|
|
|
@ -45,6 +45,16 @@ export class JiraTrigger implements INodeType {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Credentials to Connect to Jira',
|
||||
name: 'jiraSoftwareServerPatApi',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
jiraVersion: ['serverPat'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed
|
||||
name: 'httpQueryAuth',
|
||||
|
@ -87,6 +97,10 @@ export class JiraTrigger implements INodeType {
|
|||
name: 'Server (Self Hosted)',
|
||||
value: 'server',
|
||||
},
|
||||
{
|
||||
name: 'Server (Pat) (Self Hosted)',
|
||||
value: 'serverPat',
|
||||
},
|
||||
],
|
||||
default: 'cloud',
|
||||
},
|
||||
|
|
|
@ -181,6 +181,7 @@
|
|||
"dist/credentials/JenkinsApi.credentials.js",
|
||||
"dist/credentials/JiraSoftwareCloudApi.credentials.js",
|
||||
"dist/credentials/JiraSoftwareServerApi.credentials.js",
|
||||
"dist/credentials/JiraSoftwareServerPatApi.credentials.js",
|
||||
"dist/credentials/JotFormApi.credentials.js",
|
||||
"dist/credentials/JwtAuth.credentials.js",
|
||||
"dist/credentials/Kafka.credentials.js",
|
||||
|
|
Loading…
Reference in a new issue