-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
New Components - ninjaone #16755
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8f8b225
ninjaone init
luancazarine d532f7f
[Components] ninjaone #14845
luancazarine 871df82
pnpm update
luancazarine e85aaca
pnpm update
luancazarine 023532b
Merge branch 'master' into issue-14845
luancazarine 1517d45
pnpm update
luancazarine 3ceb95a
Update components/ninjaone/ninjaone.app.mjs
luancazarine 8eeca80
some adjusts
luancazarine 07b7001
Update components/ninjaone/sources/new-device-online/new-device-onlin…
luancazarine 68a4a8e
Update components/ninjaone/ninjaone.app.mjs
luancazarine d4a2592
Update components/ninjaone/ninjaone.app.mjs
luancazarine 3c345b2
Update components/ninjaone/ninjaone.app.mjs
luancazarine 12e1d48
Update components/ninjaone/ninjaone.app.mjs
luancazarine 9d078b9
Update components/ninjaone/ninjaone.app.mjs
luancazarine 1a8c0ca
Update components/ninjaone/actions/update-device/update-device.mjs
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export default { | |
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export default { | |
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export default { | |
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; |
180 changes: 180 additions & 0 deletions
180
components/ninjaone/actions/create-ticket/create-ticket.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
72
components/ninjaone/actions/update-device/update-device.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.