🔀 Merge pull request #510 from RicardoE105/feature/pagerduty

 Added get user by id
This commit is contained in:
Jan 2020-04-24 08:23:34 +02:00 committed by GitHub
commit c18742e69e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 0 deletions

View file

@ -32,6 +32,11 @@ import {
logEntryOperations, logEntryOperations,
} from './LogEntryDescription'; } from './LogEntryDescription';
import {
userFields,
userOperations,
} from './UserDescription';
import { import {
IIncident, IIncident,
} from './IncidentInterface'; } from './IncidentInterface';
@ -81,6 +86,10 @@ export class PagerDuty implements INodeType {
name: 'Log Entry', name: 'Log Entry',
value: 'logEntry', value: 'logEntry',
}, },
{
name: 'User',
value: 'user',
},
], ],
default: 'incident', default: 'incident',
description: 'Resource to consume.', description: 'Resource to consume.',
@ -94,6 +103,9 @@ export class PagerDuty implements INodeType {
// LOG ENTRY // LOG ENTRY
...logEntryOperations, ...logEntryOperations,
...logEntryFields, ...logEntryFields,
// USER
...userOperations,
...userFields,
], ],
}; };
@ -350,6 +362,14 @@ export class PagerDuty implements INodeType {
} }
} }
} }
if (resource === 'user') {
//https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1users~1%7Bid%7D/get
if (operation === 'get') {
const userId = this.getNodeParameter('userId', i) as string;
responseData = await pagerDutyApiRequest.call(this, 'GET', `/users/${userId}`);
responseData = responseData.user;
}
}
if (Array.isArray(responseData)) { if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]); returnData.push.apply(returnData, responseData as IDataObject[]);
} else { } else {

View file

@ -0,0 +1,51 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const userOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'user',
],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get a user',
},
],
default: 'get',
description: 'The operation to perform.',
},
] as INodeProperties[];
export const userFields = [
/* -------------------------------------------------------------------------- */
/* user:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'User ID',
name: 'userId',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'get',
]
},
},
description: 'Unique identifier for the user.',
},
] as INodeProperties[];