n8n-nodes-netbox
Version:
n8n community node for NetBox API integration with comprehensive DCIM, IPAM, and data center management operations
59 lines (58 loc) • 2.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.listJournalEntries = listJournalEntries;
exports.getJournalEntry = getJournalEntry;
exports.createJournalEntry = createJournalEntry;
exports.updateJournalEntry = updateJournalEntry;
exports.deleteJournalEntry = deleteJournalEntry;
const apiRequest_1 = require("../../../helpers/apiRequest");
const responseFormatter_1 = require("../../../helpers/responseFormatter");
async function listJournalEntries() {
const filters = this.getNodeParameter('filter', 0, {});
const endpoint = '/api/extras/journal-entries/';
const response = await apiRequest_1.apiRequestAllItems.call(this, 'GET', endpoint, {}, filters);
return responseFormatter_1.formatResponse.call(this, response);
}
async function getJournalEntry() {
const journalEntryId = this.getNodeParameter('journalEntryId', 0);
const endpoint = `/api/extras/journal-entries/${journalEntryId}/`;
const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint);
return responseFormatter_1.formatResponse.call(this, response);
}
async function createJournalEntry() {
const assignedObjectType = this.getNodeParameter('assigned_object_type', 0);
const assignedObjectId = this.getNodeParameter('assigned_object_id', 0);
const kind = this.getNodeParameter('kind', 0);
const comments = this.getNodeParameter('comments', 0);
const body = {
assigned_object_type: assignedObjectType,
assigned_object_id: assignedObjectId,
kind,
comments,
};
const endpoint = '/api/extras/journal-entries/';
const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, body);
return responseFormatter_1.formatResponse.call(this, response);
}
async function updateJournalEntry() {
const journalEntryId = this.getNodeParameter('journalEntryId', 0);
const assignedObjectType = this.getNodeParameter('assigned_object_type', 0);
const assignedObjectId = this.getNodeParameter('assigned_object_id', 0);
const kind = this.getNodeParameter('kind', 0);
const comments = this.getNodeParameter('comments', 0);
const body = {
assigned_object_type: assignedObjectType,
assigned_object_id: assignedObjectId,
kind,
comments,
};
const endpoint = `/api/extras/journal-entries/${journalEntryId}/`;
const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, body);
return responseFormatter_1.formatResponse.call(this, response);
}
async function deleteJournalEntry() {
const journalEntryId = this.getNodeParameter('journalEntryId', 0);
const endpoint = `/api/extras/journal-entries/${journalEntryId}/`;
await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint);
return [{ json: { success: true } }];
}