2022-08-17 08:50:24 -07:00
|
|
|
import { IExecuteFunctions } from 'n8n-core';
|
2020-04-05 18:06:23 -07:00
|
|
|
|
|
|
|
import {
|
|
|
|
IDataObject,
|
|
|
|
ILoadOptionsFunctions,
|
|
|
|
INodeExecutionData,
|
|
|
|
INodePropertyOptions,
|
2020-04-06 11:07:32 -07:00
|
|
|
INodeType,
|
|
|
|
INodeTypeDescription,
|
2020-04-05 18:06:23 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
import {
|
2020-04-06 11:07:32 -07:00
|
|
|
keysToSnakeCase,
|
2020-04-05 18:06:23 -07:00
|
|
|
pagerDutyApiRequest,
|
|
|
|
pagerDutyApiRequestAllItems,
|
|
|
|
} from './GenericFunctions';
|
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
import { incidentFields, incidentOperations } from './IncidentDescription';
|
2020-04-05 18:06:23 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
import { incidentNoteFields, incidentNoteOperations } from './IncidentNoteDescription';
|
2020-04-05 18:06:23 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
import { logEntryFields, logEntryOperations } from './LogEntryDescription';
|
2020-04-05 18:06:23 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
import { userFields, userOperations } from './UserDescription';
|
2020-04-23 21:38:19 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
import { IIncident } from './IncidentInterface';
|
2020-04-05 18:06:23 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
import { snakeCase } from 'change-case';
|
2020-04-05 18:06:23 -07:00
|
|
|
|
2022-04-08 14:32:08 -07:00
|
|
|
import moment from 'moment-timezone';
|
2020-04-05 18:06:23 -07:00
|
|
|
|
|
|
|
export class PagerDuty implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'PagerDuty',
|
|
|
|
name: 'pagerDuty',
|
2021-06-12 12:00:37 -07:00
|
|
|
icon: 'file:pagerDuty.svg',
|
2020-04-05 18:06:23 -07:00
|
|
|
group: ['output'],
|
|
|
|
version: 1,
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
description: 'Consume PagerDuty API',
|
|
|
|
defaults: {
|
|
|
|
name: 'PagerDuty',
|
|
|
|
},
|
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'pagerDutyApi',
|
|
|
|
required: true,
|
2020-06-08 07:58:32 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
authentication: ['apiToken'],
|
2020-06-08 07:58:32 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'pagerDutyOAuth2Api',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-08-17 08:50:24 -07:00
|
|
|
authentication: ['oAuth2'],
|
2020-06-08 07:58:32 -07:00
|
|
|
},
|
|
|
|
},
|
2020-04-05 18:06:23 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
properties: [
|
2020-06-08 07:58:32 -07:00
|
|
|
{
|
|
|
|
displayName: 'Authentication',
|
|
|
|
name: 'authentication',
|
|
|
|
type: 'options',
|
|
|
|
options: [
|
|
|
|
{
|
2020-06-14 18:39:30 -07:00
|
|
|
name: 'API Token',
|
|
|
|
value: 'apiToken',
|
2020-06-08 07:58:32 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'OAuth2',
|
|
|
|
value: 'oAuth2',
|
|
|
|
},
|
|
|
|
],
|
2020-06-14 18:39:30 -07:00
|
|
|
default: 'apiToken',
|
2020-06-08 07:58:32 -07:00
|
|
|
},
|
2020-04-05 18:06:23 -07:00
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
noDataExpression: true,
|
2020-04-05 18:06:23 -07:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Incident',
|
|
|
|
value: 'incident',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Incident Note',
|
|
|
|
value: 'incidentNote',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Log Entry',
|
|
|
|
value: 'logEntry',
|
|
|
|
},
|
2020-04-23 21:38:19 -07:00
|
|
|
{
|
|
|
|
name: 'User',
|
|
|
|
value: 'user',
|
|
|
|
},
|
2020-04-05 18:06:23 -07:00
|
|
|
],
|
|
|
|
default: 'incident',
|
|
|
|
},
|
|
|
|
// INCIDENT
|
|
|
|
...incidentOperations,
|
|
|
|
...incidentFields,
|
|
|
|
// INCIDENT NOTE
|
|
|
|
...incidentNoteOperations,
|
|
|
|
...incidentNoteFields,
|
|
|
|
// LOG ENTRY
|
|
|
|
...logEntryOperations,
|
|
|
|
...logEntryFields,
|
2020-04-23 21:38:19 -07:00
|
|
|
// USER
|
|
|
|
...userOperations,
|
|
|
|
...userFields,
|
2020-04-05 18:06:23 -07:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
methods = {
|
|
|
|
loadOptions: {
|
|
|
|
// Get all the available escalation policies to display them to user so that he can
|
|
|
|
// select them easily
|
|
|
|
async getEscalationPolicies(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
2022-08-17 08:50:24 -07:00
|
|
|
const escalationPolicies = await pagerDutyApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'escalation_policies',
|
|
|
|
'GET',
|
|
|
|
'/escalation_policies',
|
|
|
|
);
|
2020-04-05 18:06:23 -07:00
|
|
|
for (const escalationPolicy of escalationPolicies) {
|
|
|
|
const escalationPolicyName = escalationPolicy.name;
|
|
|
|
const escalationPolicyId = escalationPolicy.id;
|
|
|
|
returnData.push({
|
|
|
|
name: escalationPolicyName,
|
|
|
|
value: escalationPolicyId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
// Get all the available priorities to display them to user so that he can
|
|
|
|
// select them easily
|
|
|
|
async getPriorities(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
2022-08-17 08:50:24 -07:00
|
|
|
const priorities = await pagerDutyApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'priorities',
|
|
|
|
'GET',
|
|
|
|
'/priorities',
|
|
|
|
);
|
2020-04-05 18:06:23 -07:00
|
|
|
for (const priority of priorities) {
|
|
|
|
const priorityName = priority.name;
|
|
|
|
const priorityId = priority.id;
|
|
|
|
const priorityDescription = priority.description;
|
|
|
|
returnData.push({
|
|
|
|
name: priorityName,
|
|
|
|
value: priorityId,
|
|
|
|
description: priorityDescription,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
// Get all the available services to display them to user so that he can
|
|
|
|
// select them easily
|
|
|
|
async getServices(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
2022-08-17 08:50:24 -07:00
|
|
|
const services = await pagerDutyApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'services',
|
|
|
|
'GET',
|
|
|
|
'/services',
|
|
|
|
);
|
2020-04-05 18:06:23 -07:00
|
|
|
for (const service of services) {
|
|
|
|
const serviceName = service.name;
|
|
|
|
const serviceId = service.id;
|
|
|
|
returnData.push({
|
|
|
|
name: serviceName,
|
|
|
|
value: serviceId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
// Get all the timezones to display them to user so that he can
|
|
|
|
// select them easily
|
|
|
|
async getTimezones(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
|
|
|
for (const timezone of moment.tz.names()) {
|
|
|
|
const timezoneName = timezone;
|
|
|
|
const timezoneId = timezone;
|
|
|
|
returnData.push({
|
|
|
|
name: timezoneName,
|
|
|
|
value: timezoneId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return returnData;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
const items = this.getInputData();
|
2022-08-30 08:55:33 -07:00
|
|
|
const returnData: INodeExecutionData[] = [];
|
2022-04-22 09:29:51 -07:00
|
|
|
const length = items.length;
|
2020-04-05 18:06:23 -07:00
|
|
|
let responseData;
|
|
|
|
const qs: IDataObject = {};
|
|
|
|
const resource = this.getNodeParameter('resource', 0) as string;
|
|
|
|
const operation = this.getNodeParameter('operation', 0) as string;
|
|
|
|
for (let i = 0; i < length; i++) {
|
2021-07-19 23:58:54 -07:00
|
|
|
try {
|
|
|
|
if (resource === 'incident') {
|
|
|
|
//https://api-reference.pagerduty.com/#!/Incidents/post_incidents
|
|
|
|
if (operation === 'create') {
|
|
|
|
const title = this.getNodeParameter('title', i) as string;
|
|
|
|
const serviceId = this.getNodeParameter('serviceId', i) as string;
|
|
|
|
const email = this.getNodeParameter('email', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
2022-08-17 08:50:24 -07:00
|
|
|
const conferenceBridge = (this.getNodeParameter('conferenceBridgeUi', i) as IDataObject)
|
|
|
|
.conferenceBridgeValues as IDataObject;
|
2021-07-19 23:58:54 -07:00
|
|
|
const body: IIncident = {
|
|
|
|
type: 'incident',
|
|
|
|
title,
|
|
|
|
service: {
|
|
|
|
id: serviceId,
|
|
|
|
type: 'service_reference',
|
|
|
|
},
|
2020-04-05 18:06:23 -07:00
|
|
|
};
|
2021-07-19 23:58:54 -07:00
|
|
|
if (additionalFields.details) {
|
|
|
|
body.body = {
|
|
|
|
type: 'incident_body',
|
|
|
|
details: additionalFields.details,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (additionalFields.priorityId) {
|
|
|
|
body.priority = {
|
|
|
|
id: additionalFields.priorityId,
|
|
|
|
type: 'priority_reference',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (additionalFields.escalationPolicyId) {
|
|
|
|
body.escalation_policy = {
|
|
|
|
id: additionalFields.escalationPolicyId,
|
|
|
|
type: 'escalation_policy_reference',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (additionalFields.urgency) {
|
|
|
|
body.urgency = additionalFields.urgency as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.incidentKey) {
|
|
|
|
body.incident_key = additionalFields.incidentKey as string;
|
|
|
|
}
|
|
|
|
if (conferenceBridge) {
|
|
|
|
body.conference_bridge = {
|
|
|
|
conference_number: conferenceBridge.conferenceNumber,
|
|
|
|
conference_url: conferenceBridge.conferenceUrl,
|
|
|
|
};
|
|
|
|
}
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
'/incidents',
|
|
|
|
{ incident: body },
|
|
|
|
{},
|
|
|
|
undefined,
|
|
|
|
{ from: email },
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
responseData = responseData.incident;
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
//https://api-reference.pagerduty.com/#!/Incidents/get_incidents_id
|
|
|
|
if (operation === 'get') {
|
|
|
|
const incidentId = this.getNodeParameter('incidentId', i) as string;
|
|
|
|
responseData = await pagerDutyApiRequest.call(this, 'GET', `/incidents/${incidentId}`);
|
|
|
|
responseData = responseData.incident;
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
//https://api-reference.pagerduty.com/#!/Incidents/get_incidents
|
|
|
|
if (operation === 'getAll') {
|
2022-11-18 05:31:38 -08:00
|
|
|
const returnAll = this.getNodeParameter('returnAll', 0);
|
2021-07-19 23:58:54 -07:00
|
|
|
const options = this.getNodeParameter('options', 0) as IDataObject;
|
|
|
|
if (options.userIds) {
|
|
|
|
options.userIds = (options.userIds as string).split(',') as string[];
|
|
|
|
}
|
|
|
|
if (options.teamIds) {
|
|
|
|
options.teamIds = (options.teamIds as string).split(',') as string[];
|
|
|
|
}
|
|
|
|
if (options.include) {
|
|
|
|
options.include = (options.include as string[]).map((e) => snakeCase(e));
|
|
|
|
}
|
|
|
|
if (options.sortBy) {
|
|
|
|
options.sortBy = options.sortBy as string;
|
|
|
|
}
|
|
|
|
Object.assign(qs, keysToSnakeCase(options)[0]);
|
|
|
|
if (returnAll) {
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'incidents',
|
|
|
|
'GET',
|
|
|
|
'/incidents',
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-11-18 06:26:22 -08:00
|
|
|
qs.limit = this.getNodeParameter('limit', 0);
|
2021-07-19 23:58:54 -07:00
|
|
|
responseData = await pagerDutyApiRequest.call(this, 'GET', '/incidents', {}, qs);
|
|
|
|
responseData = responseData.incidents;
|
|
|
|
}
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
//https://api-reference.pagerduty.com/#!/Incidents/put_incidents_id
|
|
|
|
if (operation === 'update') {
|
|
|
|
const incidentId = this.getNodeParameter('incidentId', i) as string;
|
|
|
|
const email = this.getNodeParameter('email', i) as string;
|
2022-08-17 08:50:24 -07:00
|
|
|
const conferenceBridge = (this.getNodeParameter('conferenceBridgeUi', i) as IDataObject)
|
|
|
|
.conferenceBridgeValues as IDataObject;
|
2022-11-18 07:29:44 -08:00
|
|
|
const updateFields = this.getNodeParameter('updateFields', i);
|
2021-07-19 23:58:54 -07:00
|
|
|
const body: IIncident = {
|
|
|
|
type: 'incident',
|
2020-04-05 18:06:23 -07:00
|
|
|
};
|
2021-07-19 23:58:54 -07:00
|
|
|
if (updateFields.title) {
|
|
|
|
body.title = updateFields.title as string;
|
|
|
|
}
|
|
|
|
if (updateFields.escalationLevel) {
|
|
|
|
body.escalation_level = updateFields.escalationLevel as number;
|
|
|
|
}
|
|
|
|
if (updateFields.details) {
|
|
|
|
body.body = {
|
|
|
|
type: 'incident_body',
|
|
|
|
details: updateFields.details,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (updateFields.priorityId) {
|
|
|
|
body.priority = {
|
|
|
|
id: updateFields.priorityId,
|
|
|
|
type: 'priority_reference',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (updateFields.escalationPolicyId) {
|
|
|
|
body.escalation_policy = {
|
|
|
|
id: updateFields.escalationPolicyId,
|
|
|
|
type: 'escalation_policy_reference',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (updateFields.urgency) {
|
|
|
|
body.urgency = updateFields.urgency as string;
|
|
|
|
}
|
|
|
|
if (updateFields.resolution) {
|
|
|
|
body.resolution = updateFields.resolution as string;
|
|
|
|
}
|
|
|
|
if (updateFields.status) {
|
|
|
|
body.status = updateFields.status as string;
|
|
|
|
}
|
|
|
|
if (conferenceBridge) {
|
|
|
|
body.conference_bridge = {
|
|
|
|
conference_number: conferenceBridge.conferenceNumber,
|
|
|
|
conference_url: conferenceBridge.conferenceUrl,
|
|
|
|
};
|
|
|
|
}
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequest.call(
|
|
|
|
this,
|
|
|
|
'PUT',
|
|
|
|
`/incidents/${incidentId}`,
|
|
|
|
{ incident: body },
|
|
|
|
{},
|
|
|
|
undefined,
|
|
|
|
{ from: email },
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
responseData = responseData.incident;
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
if (resource === 'incidentNote') {
|
|
|
|
//https://api-reference.pagerduty.com/#!/Incidents/post_incidents_id_notes
|
|
|
|
if (operation === 'create') {
|
|
|
|
const incidentId = this.getNodeParameter('incidentId', i) as string;
|
|
|
|
const content = this.getNodeParameter('content', i) as string;
|
|
|
|
const email = this.getNodeParameter('email', i) as string;
|
|
|
|
const body: IDataObject = {
|
|
|
|
content,
|
2020-04-05 18:06:23 -07:00
|
|
|
};
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
`/incidents/${incidentId}/notes`,
|
|
|
|
{ note: body },
|
|
|
|
{},
|
|
|
|
undefined,
|
|
|
|
{ from: email },
|
|
|
|
);
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
//https://api-reference.pagerduty.com/#!/Incidents/get_incidents_id_notes
|
|
|
|
if (operation === 'getAll') {
|
|
|
|
const incidentId = this.getNodeParameter('incidentId', i) as string;
|
2022-11-18 05:31:38 -08:00
|
|
|
const returnAll = this.getNodeParameter('returnAll', 0);
|
2021-07-19 23:58:54 -07:00
|
|
|
if (returnAll) {
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'notes',
|
|
|
|
'GET',
|
|
|
|
`/incidents/${incidentId}/notes`,
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-11-18 06:26:22 -08:00
|
|
|
qs.limit = this.getNodeParameter('limit', 0);
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
`/incidents/${incidentId}/notes`,
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
responseData = responseData.notes;
|
|
|
|
}
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
|
|
|
if (resource === 'logEntry') {
|
|
|
|
//https://api-reference.pagerduty.com/#!/Log_Entries/get_log_entries_id
|
|
|
|
if (operation === 'get') {
|
|
|
|
const logEntryId = this.getNodeParameter('logEntryId', i) as string;
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequest.call(
|
|
|
|
this,
|
|
|
|
'GET',
|
|
|
|
`/log_entries/${logEntryId}`,
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
responseData = responseData.log_entry;
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
//https://api-reference.pagerduty.com/#!/Log_Entries/get_log_entries
|
|
|
|
if (operation === 'getAll') {
|
2022-11-18 07:29:44 -08:00
|
|
|
const options = this.getNodeParameter('options', i);
|
2021-07-19 23:58:54 -07:00
|
|
|
Object.assign(qs, options);
|
|
|
|
keysToSnakeCase(qs);
|
2022-11-18 05:31:38 -08:00
|
|
|
const returnAll = this.getNodeParameter('returnAll', 0);
|
2021-07-19 23:58:54 -07:00
|
|
|
if (returnAll) {
|
2022-08-17 08:50:24 -07:00
|
|
|
responseData = await pagerDutyApiRequestAllItems.call(
|
|
|
|
this,
|
|
|
|
'log_entries',
|
|
|
|
'GET',
|
|
|
|
'/log_entries',
|
|
|
|
{},
|
|
|
|
qs,
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-11-18 06:26:22 -08:00
|
|
|
qs.limit = this.getNodeParameter('limit', 0);
|
2021-07-19 23:58:54 -07:00
|
|
|
responseData = await pagerDutyApiRequest.call(this, 'GET', '/log_entries', {}, qs);
|
|
|
|
responseData = responseData.log_entries;
|
|
|
|
}
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
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;
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 08:55:33 -07:00
|
|
|
|
|
|
|
const executionData = this.helpers.constructExecutionMetaData(
|
|
|
|
this.helpers.returnJsonArray(responseData),
|
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
|
|
|
|
|
|
|
returnData.push(...executionData);
|
2021-07-19 23:58:54 -07:00
|
|
|
} catch (error) {
|
|
|
|
if (this.continueOnFail()) {
|
2022-08-30 08:55:33 -07:00
|
|
|
const executionErrorData = this.helpers.constructExecutionMetaData(
|
|
|
|
this.helpers.returnJsonArray({ error: error.message }),
|
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
|
|
|
returnData.push(...executionErrorData);
|
2021-07-19 23:58:54 -07:00
|
|
|
continue;
|
2020-04-23 21:38:19 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
throw error;
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 08:55:33 -07:00
|
|
|
return this.prepareOutputData(returnData);
|
2020-04-05 18:06:23 -07:00
|
|
|
}
|
|
|
|
}
|