Skip to content

New Components - ninjaone #16755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/heylibby/heylibby.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/neetocal/neetocal.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/neetodesk/neetodesk.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
180 changes: 180 additions & 0 deletions components/ninjaone/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
import { ConfigurationError } from "@pipedream/platform";
import {
PRIORITY_OPTIONS,
SEVERITY_OPTIONS,
TYPE_OPTIONS,
} from "../../common/constants.mjs";
import {
normalCase,
parseObject,
} from "../../common/utils.mjs";
import ninjaone from "../../ninjaone.app.mjs";

export default {
key: "ninjaone-create-ticket",
name: "Create Support Ticket",
description: "Creates a new support ticket in NinjaOne. [See the documentation](https://app.ninjarmm.com/apidocs/?links.active=core#/ticketing/create)",
version: "0.0.1",
type: "action",
props: {
ninjaone,
clientId: {
propDefinition: [
ninjaone,
"clientId",
],
},
ticketFormId: {
propDefinition: [
ninjaone,
"ticketFormId",
],
},
organizationId: {
propDefinition: [
ninjaone,
"organizationId",
],
optional: true,
},
locationId: {
propDefinition: [
ninjaone,
"locationId",
({ organizationId }) => ({
organizationId,
}),
],
optional: true,
},
nodeId: {
propDefinition: [
ninjaone,
"deviceId",
({ organizationId }) => ({
organizationId,
}),
],
optional: true,
},
subject: {
type: "string",
label: "Subject",
description: "The subject of the ticket",
},
descriptionPublic: {
type: "boolean",
label: "Public Description",
description: "Whether the ticket's description is public or not",
},
descriptionBody: {
type: "string",
label: "Description Body",
description: "The description of the ticket",
optional: true,
},
descriptionHTML: {
type: "string",
label: "Description HTML",
description: "The description HTML of the ticket",
optional: true,
},
descriptiontimeTracked: {
type: "integer",
label: "Time Tracked",
description: "Time in seconds",
optional: true,
},
descriptionDuplicateInIncidents: {
type: "boolean",
label: "Duplicate In Incidents",
description: "Whether the ticket will duplicate in the same incident",
optional: true,
},
status: {
propDefinition: [
ninjaone,
"status",
],
},
type: {
type: "string",
label: "Type",
description: "The type of the ticket",
options: TYPE_OPTIONS,
optional: true,
},
cc: {
type: "string[]",
label: "CC",
description: "A list of emails to be copied in the notification email",
optional: true,
},
assignedAppUserId: {
propDefinition: [
ninjaone,
"assignedAppUserId",
],
optional: true,
},
severity: {
type: "string",
label: "Severity",
description: "The severity's level of the ticket",
options: SEVERITY_OPTIONS,
optional: true,
},
priority: {
type: "string",
label: "Priority",
description: "The priority's level of the ticket",
options: PRIORITY_OPTIONS,
optional: true,
},
tags: {
propDefinition: [
ninjaone,
"tags",
],
optional: true,
},
},
async run({ $ }) {
try {
const {
ninjaone,
descriptionPublic,
descriptionBody,
descriptionHTML,
descriptiontimeTracked,
descriptionDuplicateInIncidents,
cc,
tags,
...data
} = this;

const response = await ninjaone.createSupportTicket({
$,
data: {
...data,
description: {
public: descriptionPublic,
body: descriptionBody,
htmlBody: descriptionHTML,
timeTracked: descriptiontimeTracked,
duplicateInIncidents: descriptionDuplicateInIncidents,
},
cc: {
emails: parseObject(cc),
},
tags: parseObject(tags),
},
});

$.export("$summary", `Ticket created successfully with ID: ${response.id}`);
return response;
} catch ({ response }) {
throw new ConfigurationError(normalCase(response.data.resultCode) || response.data);
}
},
};
72 changes: 72 additions & 0 deletions components/ninjaone/actions/update-device/update-device.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import ninjaone from "../../ninjaone.app.mjs";

export default {
key: "ninjaone-update-device",
name: "Update Device",
description: "Update details for a specific device in NinjaOne. [See the documentation](https://app.ninjarmm.com/apidocs/?links.active=core)",
version: "0.0.1",
type: "action",
props: {
ninjaone,
deviceId: {
propDefinition: [
ninjaone,
"deviceId",
],
description: "The Id of the device to update ",
},
displayName: {
type: "string",
label: "Display Name",
description: "The name of the device",
optional: true,
},
nodeRoleId: {
propDefinition: [
ninjaone,
"nodeRoleId",
],
optional: true,
},
policyId: {
propDefinition: [
ninjaone,
"policyId",
],
optional: true,
},
organizationId: {
propDefinition: [
ninjaone,
"organizationId",
],
optional: true,
},
locationId: {
propDefinition: [
ninjaone,
"locationId",
({ organizationId }) => ({
organizationId,
}),
],
optional: true,
},
},
async run({ $ }) {
const {
ninjaone,
deviceId,
...data
} = this;

const response = await ninjaone.updateDevice({
$,
deviceId,
data,
});

$.export("$summary", `Successfully updated device with ID ${deviceId}`);
return response;
},
};
23 changes: 23 additions & 0 deletions components/ninjaone/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const LIMIT = 100;

export const TYPE_OPTIONS = [
"PROBLEM",
"QUESTION",
"INCIDENT",
"TASK",
];

export const SEVERITY_OPTIONS = [
"NONE",
"MINOR",
"MODERATE",
"MAJOR",
"CRITICAL",
];

export const PRIORITY_OPTIONS = [
"NONE",
"LOW",
"MEDIUM",
"HIGH",
];
28 changes: 28 additions & 0 deletions components/ninjaone/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};

export const normalCase = (s) =>
s?.replace (/^[-_]*(.)/, (_, c) => c.toUpperCase())
.replace (/[-_]+(.)/g, (_, c) => " " + c);
Loading
Loading