From 75168e3dca99b57b6993ff56fd0252af51a20bec Mon Sep 17 00:00:00 2001 From: Gianfranco Manganiello Date: Mon, 15 Jan 2018 10:27:43 -0400 Subject: [PATCH] feat(GlpiRestClient): create basic restclient --- lib/GlpiRestClient.js | 2 +- src/index.js | 2 ++ src/prepareRequest.js | 35 ++++++++++++++++++++++++++++++ src/restclient.js | 50 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/prepareRequest.js create mode 100644 src/restclient.js diff --git a/lib/GlpiRestClient.js b/lib/GlpiRestClient.js index c33beb6..1bf2c31 100644 --- a/lib/GlpiRestClient.js +++ b/lib/GlpiRestClient.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.GlpiRestClient=n():e.GlpiRestClient=n()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function t(o){if(n[o])return n[o].exports;var a=n[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,t),a.l=!0,a.exports}return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.itemtype=void 0;var o,a=t(1),i=(o=a)&&o.__esModule?o:{default:o};n.itemtype=i.default},function(e,n){e.exports={Alert:{name:"Alert"},AuthLDAP:{name:"AuthLDAP"},Computer:{name:"Computer"},Config:{name:"Config"},ConsumableItem:{name:"ConsumableItem"},Contact:{name:"Contact"},Contract:{name:"Contract"},CronTask:{name:"CronTask"},CronTaskLog:{name:"CronTaskLog"},DBConnection:{name:"DBConnection"},DisplayPreference:{name:"DisplayPreference"},Document:{name:"Document"},AuthLdapReplicate:{name:"AuthLdapReplicate"},Event:{name:"Event"},KnowbaseItem:{name:"KnowbaseItem"},Link:{name:"Link"},Log:{name:"Log"},MailCollector:{name:"MailCollector"},Monitor:{name:"Monitor"},NetworkEquipment:{name:"NetworkEquipment"},Notification:{name:"Notification"},NotificationEvent:{name:"NotificationEvent"},NotificationMailSetting:{name:"NotificationMailSetting"},AuthMail:{name:"AuthMail"},NotificationTemplate:{name:"NotificationTemplate"},NotImportedEmail:{name:"NotImportedEmail"},Peripheral:{name:"Peripheral"},Phone:{name:"Phone"},Plugin:{name:"Plugin"},Printer:{name:"Printer"},Profile:{name:"Profile"},Project:{name:"Project"},QueuedMail:{name:"QueuedMail"},Reminder:{name:"Reminder"},Bookmark:{name:"Bookmark"},RSSFeed:{name:"RSSFeed"},Rule:{name:"Rule"},RuleCollection:{name:"RuleCollection"},SLA:{name:"SLA"},SlaLevel_Ticket:{name:"SlaLevel_Ticket"},Software:{name:"Software"},SoftwareLicense:{name:"SoftwareLicense"},Supplier:{name:"Supplier"},TicketFollowup:{name:"TicketFollowup"},TicketSatisfaction:{name:"TicketSatisfaction"},CartridgeItem:{name:"CartridgeItem"},Transfer:{name:"Transfer"},User:{name:"User"},CommonDBConnexity:{name:"CommonDBConnexity"},CommonDropdown:{name:"CommonDropdown"},CommonITILObject:{name:"CommonITILObject"},CommonITILTask:{name:"CommonITILTask"},AutoUpdateSystem:{name:"AutoUpdateSystem"},Blacklist:{name:"Blacklist"},CartridgeItemType:{name:"CartridgeItemType"},Item_DeviceSoundCard:{name:"Item_DeviceSoundCard"},Item_Problem:{name:"Item_Problem"},Item_Project:{name:"Item_Project"},Item_Ticket:{name:"Item_Ticket"},ITILCategory:{name:"ITILCategory"},KnowbaseItem_Profile:{name:"KnowbaseItem_Profile"},KnowbaseItem_User:{name:"KnowbaseItem_User"},KnowbaseItemCategory:{name:"KnowbaseItemCategory"},KnowbaseItemTranslation:{name:"KnowbaseItemTranslation"},Link_Itemtype:{name:"Link_Itemtype"},Change:{name:"Change"},Location:{name:"Location"},Manufacturer:{name:"Manufacturer"},MonitorModel:{name:"MonitorModel"},MonitorType:{name:"MonitorType"},Netpoint:{name:"Netpoint"},Network:{name:"Network"},NetworkAlias:{name:"NetworkAlias"},NetworkEquipmentFirmware:{name:"NetworkEquipmentFirmware"},NetworkEquipmentModel:{name:"NetworkEquipmentModel"},NetworkEquipmentType:{name:"NetworkEquipmentType"},Change_Group:{name:"Change_Group"},NetworkInterface:{name:"NetworkInterface"},NetworkName:{name:"NetworkName"},NetworkPort:{name:"NetworkPort"},NetworkPort_NetworkPort:{name:"NetworkPort_NetworkPort"},NetworkPort_Vlan:{name:"NetworkPort_Vlan"},NetworkPortAggregate:{name:"NetworkPortAggregate"},NetworkPortAlias:{name:"NetworkPortAlias"},NetworkPortDialup:{name:"NetworkPortDialup"},NetworkPortEthernet:{name:"NetworkPortEthernet"},NetworkPortInstantiation:{name:"NetworkPortInstantiation"},Change_Item:{name:"Change_Item"},NetworkPortLocal:{name:"NetworkPortLocal"},NetworkPortMigration:{name:"NetworkPortMigration"},NetworkPortWifi:{name:"NetworkPortWifi"},Notepad:{name:"Notepad"},NotificationTarget:{name:"NotificationTarget"},NotificationTargetCartridgeItem:{name:"NotificationTargetCartridgeItem"},NotificationTargetChange:{name:"NotificationTargetChange"},NotificationTargetCommonITILObject:{name:"NotificationTargetCommonITILObject"},NotificationTargetConsumableItem:{name:"NotificationTargetConsumableItem"},NotificationTargetContract:{name:"NotificationTargetContract"},Change_Problem:{name:"Change_Problem"},NotificationTargetCrontask:{name:"NotificationTargetCrontask"},NotificationTargetDBConnection:{name:"NotificationTargetDBConnection"},NotificationTargetFieldUnicity:{name:"NotificationTargetFieldUnicity"},NotificationTargetInfocom:{name:"NotificationTargetInfocom"},NotificationTargetMailCollector:{name:"NotificationTargetMailCollector"},NotificationTargetPlanningRecall:{name:"NotificationTargetPlanningRecall"},NotificationTargetProblem:{name:"NotificationTargetProblem"},NotificationTargetProject:{name:"NotificationTargetProject"},NotificationTargetProjectTask:{name:"NotificationTargetProjectTask"},NotificationTargetReservation:{name:"NotificationTargetReservation"},Change_Project:{name:"Change_Project"},NotificationTargetSoftwareLicense:{name:"NotificationTargetSoftwareLicense"},NotificationTargetTicket:{name:"NotificationTargetTicket"},NotificationTargetUser:{name:"NotificationTargetUser"},NotificationTemplateTranslation:{name:"NotificationTemplateTranslation"},OperatingSystem:{name:"OperatingSystem"},OperatingSystemServicePack:{name:"OperatingSystemServicePack"},OperatingSystemVersion:{name:"OperatingSystemVersion"},PeripheralModel:{name:"PeripheralModel"},PeripheralType:{name:"PeripheralType"},PhoneModel:{name:"PhoneModel"},Change_Supplier:{name:"Change_Supplier"},PhonePowerSupply:{name:"PhonePowerSupply"},PhoneType:{name:"PhoneType"},PlanningRecall:{name:"PlanningRecall"},PrinterModel:{name:"PrinterModel"},PrinterType:{name:"PrinterType"},Problem:{name:"Problem"},Problem_Supplier:{name:"Problem_Supplier"},Problem_Ticket:{name:"Problem_Ticket"},Problem_User:{name:"Problem_User"},ProblemCost:{name:"ProblemCost"},Change_Ticket:{name:"Change_Ticket"},ProblemTask:{name:"ProblemTask"},Profile_Reminder:{name:"Profile_Reminder"},Profile_RSSFeed:{name:"Profile_RSSFeed"},Profile_User:{name:"Profile_User"},ProfileRight:{name:"ProfileRight"},ProjectCost:{name:"ProjectCost"},ProjectState:{name:"ProjectState"},ProjectTask:{name:"ProjectTask"},ProjectTask_Ticket:{name:"ProjectTask_Ticket"},ProjectTaskTeam:{name:"ProjectTaskTeam"},Change_User:{name:"Change_User"},ProjectTaskType:{name:"ProjectTaskType"},ProjectTeam:{name:"ProjectTeam"},ProjectType:{name:"ProjectType"},RegisteredID:{name:"RegisteredID"},Reminder_User:{name:"Reminder_User"},RequestType:{name:"RequestType"},Reservation:{name:"Reservation"},ReservationItem:{name:"ReservationItem"},RSSFeed_User:{name:"RSSFeed_User"},RuleAction:{name:"RuleAction"},ChangeCost:{name:"ChangeCost"},RuleCriteria:{name:"RuleCriteria"},RuleDictionnaryComputerModel:{name:"RuleDictionnaryComputerModel"},RuleDictionnaryComputerModelCollection:{name:"RuleDictionnaryComputerModelCollection"},RuleDictionnaryComputerType:{name:"RuleDictionnaryComputerType"},RuleDictionnaryComputerTypeCollection:{name:"RuleDictionnaryComputerTypeCollection"},RuleDictionnaryDropdown:{name:"RuleDictionnaryDropdown"},RuleDictionnaryDropdownCollection:{name:"RuleDictionnaryDropdownCollection"},RuleDictionnaryManufacturer:{name:"RuleDictionnaryManufacturer"},RuleDictionnaryManufacturerCollection:{name:"RuleDictionnaryManufacturerCollection"},RuleDictionnaryMonitorModel:{name:"RuleDictionnaryMonitorModel"},BlacklistedMailContent:{name:"BlacklistedMailContent"},ChangeTask:{name:"ChangeTask"},RuleDictionnaryMonitorModelCollection:{name:"RuleDictionnaryMonitorModelCollection"},RuleDictionnaryMonitorType:{name:"RuleDictionnaryMonitorType"},RuleDictionnaryMonitorTypeCollection:{name:"RuleDictionnaryMonitorTypeCollection"},RuleDictionnaryNetworkEquipmentModel:{name:"RuleDictionnaryNetworkEquipmentModel"},RuleDictionnaryNetworkEquipmentModelCollection:{name:"RuleDictionnaryNetworkEquipmentModelCollection"},RuleDictionnaryNetworkEquipmentType:{name:"RuleDictionnaryNetworkEquipmentType"},RuleDictionnaryNetworkEquipmentTypeCollection:{name:"RuleDictionnaryNetworkEquipmentTypeCollection"},RuleDictionnaryOperatingSystem:{name:"RuleDictionnaryOperatingSystem"},RuleDictionnaryOperatingSystemCollection:{name:"RuleDictionnaryOperatingSystemCollection"},RuleDictionnaryOperatingSystemServicePack:{name:"RuleDictionnaryOperatingSystemServicePack"},ChangeValidation:{name:"ChangeValidation"},RuleDictionnaryOperatingSystemServicePackCollection:{name:"RuleDictionnaryOperatingSystemServicePackCollection"},RuleDictionnaryOperatingSystemVersion:{name:"RuleDictionnaryOperatingSystemVersion"},RuleDictionnaryOperatingSystemVersionCollection:{name:"RuleDictionnaryOperatingSystemVersionCollection"},RuleDictionnaryPeripheralModel:{name:"RuleDictionnaryPeripheralModel"},RuleDictionnaryPeripheralModelCollection:{name:"RuleDictionnaryPeripheralModelCollection"},RuleDictionnaryPeripheralType:{name:"RuleDictionnaryPeripheralType"},RuleDictionnaryPeripheralTypeCollection:{name:"RuleDictionnaryPeripheralTypeCollection"},RuleDictionnaryPhoneModel:{name:"RuleDictionnaryPhoneModel"},RuleDictionnaryPhoneModelCollection:{name:"RuleDictionnaryPhoneModelCollection"},RuleDictionnaryPhoneType:{name:"RuleDictionnaryPhoneType"},CommonDBChild:{name:"CommonDBChild"},RuleDictionnaryPhoneTypeCollection:{name:"RuleDictionnaryPhoneTypeCollection"},RuleDictionnaryPrinter:{name:"RuleDictionnaryPrinter"},RuleDictionnaryPrinterCollection:{name:"RuleDictionnaryPrinterCollection"},RuleDictionnaryPrinterModel:{name:"RuleDictionnaryPrinterModel"},RuleDictionnaryPrinterModelCollection:{name:"RuleDictionnaryPrinterModelCollection"},RuleDictionnaryPrinterType:{name:"RuleDictionnaryPrinterType"},RuleDictionnaryPrinterTypeCollection:{name:"RuleDictionnaryPrinterTypeCollection"},RuleDictionnarySoftware:{name:"RuleDictionnarySoftware"},RuleDictionnarySoftwareCollection:{name:"RuleDictionnarySoftwareCollection"},RuleImportComputer:{name:"RuleImportComputer"},CommonDBRelation:{name:"CommonDBRelation"},RuleImportComputerCollection:{name:"RuleImportComputerCollection"},RuleImportEntity:{name:"RuleImportEntity"},RuleImportEntityCollection:{name:"RuleImportEntityCollection"},RuleMailCollector:{name:"RuleMailCollector"},RuleMailCollectorCollection:{name:"RuleMailCollectorCollection"},RuleRight:{name:"RuleRight"},RuleRightCollection:{name:"RuleRightCollection"},RuleRightParameter:{name:"RuleRightParameter"},RuleSoftwareCategory:{name:"RuleSoftwareCategory"},RuleSoftwareCategoryCollection:{name:"RuleSoftwareCategoryCollection"},CommonDevice:{name:"CommonDevice"},RuleTicket:{name:"RuleTicket"},RuleTicketCollection:{name:"RuleTicketCollection"},SlaLevel:{name:"SlaLevel"},SlaLevelAction:{name:"SlaLevelAction"},SlaLevelCriteria:{name:"SlaLevelCriteria"},SoftwareCategory:{name:"SoftwareCategory"},SoftwareLicenseType:{name:"SoftwareLicenseType"},SoftwareVersion:{name:"SoftwareVersion"},SolutionTemplate:{name:"SolutionTemplate"},SolutionType:{name:"SolutionType"},CommonImplicitTreeDropdown:{name:"CommonImplicitTreeDropdown"},SsoVariable:{name:"SsoVariable"},State:{name:"State"},Supplier_Ticket:{name:"Supplier_Ticket"},SupplierType:{name:"SupplierType"},TaskCategory:{name:"TaskCategory"},Ticket:{name:"Ticket"},Ticket_Ticket:{name:"Ticket_Ticket"},Ticket_User:{name:"Ticket_User"},TicketCost:{name:"TicketCost"},TicketRecurrent:{name:"TicketRecurrent"},CommonITILActor:{name:"CommonITILActor"},TicketTask:{name:"TicketTask"},TicketTemplate:{name:"TicketTemplate"},TicketTemplateHiddenField:{name:"TicketTemplateHiddenField"},TicketTemplateMandatoryField:{name:"TicketTemplateMandatoryField"},TicketTemplatePredefinedField:{name:"TicketTemplatePredefinedField"},TicketValidation:{name:"TicketValidation"},UserCategory:{name:"UserCategory"},UserEmail:{name:"UserEmail"},UserTitle:{name:"UserTitle"},VirtualMachineState:{name:"VirtualMachineState"},CommonITILCost:{name:"CommonITILCost"},VirtualMachineSystem:{name:"VirtualMachineSystem"},VirtualMachineType:{name:"VirtualMachineType"},Vlan:{name:"Vlan"},WifiNetwork:{name:"WifiNetwork"},CommonITILValidation:{name:"CommonITILValidation"},CommonTreeDropdown:{name:"CommonTreeDropdown"},Bookmark_User:{name:"Bookmark_User"},Computer_Item:{name:"Computer_Item"},Computer_SoftwareLicense:{name:"Computer_SoftwareLicense"},Computer_SoftwareVersion:{name:"Computer_SoftwareVersion"},ComputerDisk:{name:"ComputerDisk"},ComputerModel:{name:"ComputerModel"},ComputerType:{name:"ComputerType"},ComputerVirtualMachine:{name:"ComputerVirtualMachine"},Consumable:{name:"Consumable"},ConsumableItemType:{name:"ConsumableItemType"},Contact_Supplier:{name:"Contact_Supplier"},Budget:{name:"Budget"},ContactType:{name:"ContactType"},Contract_Item:{name:"Contract_Item"},Contract_Supplier:{name:"Contract_Supplier"},ContractCost:{name:"ContractCost"},ContractType:{name:"ContractType"},DeviceCase:{name:"DeviceCase"},DeviceCaseType:{name:"DeviceCaseType"},DeviceControl:{name:"DeviceControl"},DeviceDrive:{name:"DeviceDrive"},DeviceGraphicCard:{name:"DeviceGraphicCard"},Calendar:{name:"Calendar"},DeviceHardDrive:{name:"DeviceHardDrive"},DeviceMemory:{name:"DeviceMemory"},DeviceMemoryType:{name:"DeviceMemoryType"},DeviceMotherboard:{name:"DeviceMotherboard"},DeviceNetworkCard:{name:"DeviceNetworkCard"},DevicePci:{name:"DevicePci"},DevicePowerSupply:{name:"DevicePowerSupply"},DeviceProcessor:{name:"DeviceProcessor"},DeviceSoundCard:{name:"DeviceSoundCard"},Document_Item:{name:"Document_Item"},Calendar_Holiday:{name:"Calendar_Holiday"},DocumentCategory:{name:"DocumentCategory"},DocumentType:{name:"DocumentType"},Domain:{name:"Domain"},DropdownTranslation:{name:"DropdownTranslation"},Entity:{name:"Entity"},Entity_KnowbaseItem:{name:"Entity_KnowbaseItem"},Entity_Reminder:{name:"Entity_Reminder"},Entity_RSSFeed:{name:"Entity_RSSFeed"},Fieldblacklist:{name:"Fieldblacklist"},FieldUnicity:{name:"FieldUnicity"},CalendarSegment:{name:"CalendarSegment"},Filesystem:{name:"Filesystem"},FQDN:{name:"FQDN"},FQDNLabel:{name:"FQDNLabel"},Group:{name:"Group"},Group_KnowbaseItem:{name:"Group_KnowbaseItem"},Group_Problem:{name:"Group_Problem"},Group_Reminder:{name:"Group_Reminder"},Group_RSSFeed:{name:"Group_RSSFeed"},Group_Ticket:{name:"Group_Ticket"},Group_User:{name:"Group_User"},Cartridge:{name:"Cartridge"},Holiday:{name:"Holiday"},Infocom:{name:"Infocom"},InterfaceType:{name:"InterfaceType"},IPAddress:{name:"IPAddress"},IPAddress_IPNetwork:{name:"IPAddress_IPNetwork"},IPNetmask:{name:"IPNetmask"},IPNetwork:{name:"IPNetwork"},IPNetwork_Vlan:{name:"IPNetwork_Vlan"},Item_DeviceCase:{name:"Item_DeviceCase"},Item_DeviceControl:{name:"Item_DeviceControl"},CartridgeItem_PrinterModel:{name:"CartridgeItem_PrinterModel"},Item_DeviceDrive:{name:"Item_DeviceDrive"},Item_DeviceGraphicCard:{name:"Item_DeviceGraphicCard"},Item_DeviceHardDrive:{name:"Item_DeviceHardDrive"},Item_DeviceMemory:{name:"Item_DeviceMemory"},Item_DeviceMotherboard:{name:"Item_DeviceMotherboard"},Item_DeviceNetworkCard:{name:"Item_DeviceNetworkCard"},Item_DevicePci:{name:"Item_DevicePci"},Item_DevicePowerSupply:{name:"Item_DevicePowerSupply"},Item_DeviceProcessor:{name:"Item_DeviceProcessor"},Item_Devices:{name:"Item_Devices"}}}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GlpiRestClient=t():e.GlpiRestClient=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.itemtype=void 0;var r=i(n(1)),o=i(n(2));function i(e){return e&&e.__esModule?e:{default:e}}t.default=o.default,t.itemtype=r.default},function(e,t){e.exports={Alert:{name:"Alert"},AuthLDAP:{name:"AuthLDAP"},Computer:{name:"Computer"},Config:{name:"Config"},ConsumableItem:{name:"ConsumableItem"},Contact:{name:"Contact"},Contract:{name:"Contract"},CronTask:{name:"CronTask"},CronTaskLog:{name:"CronTaskLog"},DBConnection:{name:"DBConnection"},DisplayPreference:{name:"DisplayPreference"},Document:{name:"Document"},AuthLdapReplicate:{name:"AuthLdapReplicate"},Event:{name:"Event"},KnowbaseItem:{name:"KnowbaseItem"},Link:{name:"Link"},Log:{name:"Log"},MailCollector:{name:"MailCollector"},Monitor:{name:"Monitor"},NetworkEquipment:{name:"NetworkEquipment"},Notification:{name:"Notification"},NotificationEvent:{name:"NotificationEvent"},NotificationMailSetting:{name:"NotificationMailSetting"},AuthMail:{name:"AuthMail"},NotificationTemplate:{name:"NotificationTemplate"},NotImportedEmail:{name:"NotImportedEmail"},Peripheral:{name:"Peripheral"},Phone:{name:"Phone"},Plugin:{name:"Plugin"},Printer:{name:"Printer"},Profile:{name:"Profile"},Project:{name:"Project"},QueuedMail:{name:"QueuedMail"},Reminder:{name:"Reminder"},Bookmark:{name:"Bookmark"},RSSFeed:{name:"RSSFeed"},Rule:{name:"Rule"},RuleCollection:{name:"RuleCollection"},SLA:{name:"SLA"},SlaLevel_Ticket:{name:"SlaLevel_Ticket"},Software:{name:"Software"},SoftwareLicense:{name:"SoftwareLicense"},Supplier:{name:"Supplier"},TicketFollowup:{name:"TicketFollowup"},TicketSatisfaction:{name:"TicketSatisfaction"},CartridgeItem:{name:"CartridgeItem"},Transfer:{name:"Transfer"},User:{name:"User"},CommonDBConnexity:{name:"CommonDBConnexity"},CommonDropdown:{name:"CommonDropdown"},CommonITILObject:{name:"CommonITILObject"},CommonITILTask:{name:"CommonITILTask"},AutoUpdateSystem:{name:"AutoUpdateSystem"},Blacklist:{name:"Blacklist"},CartridgeItemType:{name:"CartridgeItemType"},Item_DeviceSoundCard:{name:"Item_DeviceSoundCard"},Item_Problem:{name:"Item_Problem"},Item_Project:{name:"Item_Project"},Item_Ticket:{name:"Item_Ticket"},ITILCategory:{name:"ITILCategory"},KnowbaseItem_Profile:{name:"KnowbaseItem_Profile"},KnowbaseItem_User:{name:"KnowbaseItem_User"},KnowbaseItemCategory:{name:"KnowbaseItemCategory"},KnowbaseItemTranslation:{name:"KnowbaseItemTranslation"},Link_Itemtype:{name:"Link_Itemtype"},Change:{name:"Change"},Location:{name:"Location"},Manufacturer:{name:"Manufacturer"},MonitorModel:{name:"MonitorModel"},MonitorType:{name:"MonitorType"},Netpoint:{name:"Netpoint"},Network:{name:"Network"},NetworkAlias:{name:"NetworkAlias"},NetworkEquipmentFirmware:{name:"NetworkEquipmentFirmware"},NetworkEquipmentModel:{name:"NetworkEquipmentModel"},NetworkEquipmentType:{name:"NetworkEquipmentType"},Change_Group:{name:"Change_Group"},NetworkInterface:{name:"NetworkInterface"},NetworkName:{name:"NetworkName"},NetworkPort:{name:"NetworkPort"},NetworkPort_NetworkPort:{name:"NetworkPort_NetworkPort"},NetworkPort_Vlan:{name:"NetworkPort_Vlan"},NetworkPortAggregate:{name:"NetworkPortAggregate"},NetworkPortAlias:{name:"NetworkPortAlias"},NetworkPortDialup:{name:"NetworkPortDialup"},NetworkPortEthernet:{name:"NetworkPortEthernet"},NetworkPortInstantiation:{name:"NetworkPortInstantiation"},Change_Item:{name:"Change_Item"},NetworkPortLocal:{name:"NetworkPortLocal"},NetworkPortMigration:{name:"NetworkPortMigration"},NetworkPortWifi:{name:"NetworkPortWifi"},Notepad:{name:"Notepad"},NotificationTarget:{name:"NotificationTarget"},NotificationTargetCartridgeItem:{name:"NotificationTargetCartridgeItem"},NotificationTargetChange:{name:"NotificationTargetChange"},NotificationTargetCommonITILObject:{name:"NotificationTargetCommonITILObject"},NotificationTargetConsumableItem:{name:"NotificationTargetConsumableItem"},NotificationTargetContract:{name:"NotificationTargetContract"},Change_Problem:{name:"Change_Problem"},NotificationTargetCrontask:{name:"NotificationTargetCrontask"},NotificationTargetDBConnection:{name:"NotificationTargetDBConnection"},NotificationTargetFieldUnicity:{name:"NotificationTargetFieldUnicity"},NotificationTargetInfocom:{name:"NotificationTargetInfocom"},NotificationTargetMailCollector:{name:"NotificationTargetMailCollector"},NotificationTargetPlanningRecall:{name:"NotificationTargetPlanningRecall"},NotificationTargetProblem:{name:"NotificationTargetProblem"},NotificationTargetProject:{name:"NotificationTargetProject"},NotificationTargetProjectTask:{name:"NotificationTargetProjectTask"},NotificationTargetReservation:{name:"NotificationTargetReservation"},Change_Project:{name:"Change_Project"},NotificationTargetSoftwareLicense:{name:"NotificationTargetSoftwareLicense"},NotificationTargetTicket:{name:"NotificationTargetTicket"},NotificationTargetUser:{name:"NotificationTargetUser"},NotificationTemplateTranslation:{name:"NotificationTemplateTranslation"},OperatingSystem:{name:"OperatingSystem"},OperatingSystemServicePack:{name:"OperatingSystemServicePack"},OperatingSystemVersion:{name:"OperatingSystemVersion"},PeripheralModel:{name:"PeripheralModel"},PeripheralType:{name:"PeripheralType"},PhoneModel:{name:"PhoneModel"},Change_Supplier:{name:"Change_Supplier"},PhonePowerSupply:{name:"PhonePowerSupply"},PhoneType:{name:"PhoneType"},PlanningRecall:{name:"PlanningRecall"},PrinterModel:{name:"PrinterModel"},PrinterType:{name:"PrinterType"},Problem:{name:"Problem"},Problem_Supplier:{name:"Problem_Supplier"},Problem_Ticket:{name:"Problem_Ticket"},Problem_User:{name:"Problem_User"},ProblemCost:{name:"ProblemCost"},Change_Ticket:{name:"Change_Ticket"},ProblemTask:{name:"ProblemTask"},Profile_Reminder:{name:"Profile_Reminder"},Profile_RSSFeed:{name:"Profile_RSSFeed"},Profile_User:{name:"Profile_User"},ProfileRight:{name:"ProfileRight"},ProjectCost:{name:"ProjectCost"},ProjectState:{name:"ProjectState"},ProjectTask:{name:"ProjectTask"},ProjectTask_Ticket:{name:"ProjectTask_Ticket"},ProjectTaskTeam:{name:"ProjectTaskTeam"},Change_User:{name:"Change_User"},ProjectTaskType:{name:"ProjectTaskType"},ProjectTeam:{name:"ProjectTeam"},ProjectType:{name:"ProjectType"},RegisteredID:{name:"RegisteredID"},Reminder_User:{name:"Reminder_User"},RequestType:{name:"RequestType"},Reservation:{name:"Reservation"},ReservationItem:{name:"ReservationItem"},RSSFeed_User:{name:"RSSFeed_User"},RuleAction:{name:"RuleAction"},ChangeCost:{name:"ChangeCost"},RuleCriteria:{name:"RuleCriteria"},RuleDictionnaryComputerModel:{name:"RuleDictionnaryComputerModel"},RuleDictionnaryComputerModelCollection:{name:"RuleDictionnaryComputerModelCollection"},RuleDictionnaryComputerType:{name:"RuleDictionnaryComputerType"},RuleDictionnaryComputerTypeCollection:{name:"RuleDictionnaryComputerTypeCollection"},RuleDictionnaryDropdown:{name:"RuleDictionnaryDropdown"},RuleDictionnaryDropdownCollection:{name:"RuleDictionnaryDropdownCollection"},RuleDictionnaryManufacturer:{name:"RuleDictionnaryManufacturer"},RuleDictionnaryManufacturerCollection:{name:"RuleDictionnaryManufacturerCollection"},RuleDictionnaryMonitorModel:{name:"RuleDictionnaryMonitorModel"},BlacklistedMailContent:{name:"BlacklistedMailContent"},ChangeTask:{name:"ChangeTask"},RuleDictionnaryMonitorModelCollection:{name:"RuleDictionnaryMonitorModelCollection"},RuleDictionnaryMonitorType:{name:"RuleDictionnaryMonitorType"},RuleDictionnaryMonitorTypeCollection:{name:"RuleDictionnaryMonitorTypeCollection"},RuleDictionnaryNetworkEquipmentModel:{name:"RuleDictionnaryNetworkEquipmentModel"},RuleDictionnaryNetworkEquipmentModelCollection:{name:"RuleDictionnaryNetworkEquipmentModelCollection"},RuleDictionnaryNetworkEquipmentType:{name:"RuleDictionnaryNetworkEquipmentType"},RuleDictionnaryNetworkEquipmentTypeCollection:{name:"RuleDictionnaryNetworkEquipmentTypeCollection"},RuleDictionnaryOperatingSystem:{name:"RuleDictionnaryOperatingSystem"},RuleDictionnaryOperatingSystemCollection:{name:"RuleDictionnaryOperatingSystemCollection"},RuleDictionnaryOperatingSystemServicePack:{name:"RuleDictionnaryOperatingSystemServicePack"},ChangeValidation:{name:"ChangeValidation"},RuleDictionnaryOperatingSystemServicePackCollection:{name:"RuleDictionnaryOperatingSystemServicePackCollection"},RuleDictionnaryOperatingSystemVersion:{name:"RuleDictionnaryOperatingSystemVersion"},RuleDictionnaryOperatingSystemVersionCollection:{name:"RuleDictionnaryOperatingSystemVersionCollection"},RuleDictionnaryPeripheralModel:{name:"RuleDictionnaryPeripheralModel"},RuleDictionnaryPeripheralModelCollection:{name:"RuleDictionnaryPeripheralModelCollection"},RuleDictionnaryPeripheralType:{name:"RuleDictionnaryPeripheralType"},RuleDictionnaryPeripheralTypeCollection:{name:"RuleDictionnaryPeripheralTypeCollection"},RuleDictionnaryPhoneModel:{name:"RuleDictionnaryPhoneModel"},RuleDictionnaryPhoneModelCollection:{name:"RuleDictionnaryPhoneModelCollection"},RuleDictionnaryPhoneType:{name:"RuleDictionnaryPhoneType"},CommonDBChild:{name:"CommonDBChild"},RuleDictionnaryPhoneTypeCollection:{name:"RuleDictionnaryPhoneTypeCollection"},RuleDictionnaryPrinter:{name:"RuleDictionnaryPrinter"},RuleDictionnaryPrinterCollection:{name:"RuleDictionnaryPrinterCollection"},RuleDictionnaryPrinterModel:{name:"RuleDictionnaryPrinterModel"},RuleDictionnaryPrinterModelCollection:{name:"RuleDictionnaryPrinterModelCollection"},RuleDictionnaryPrinterType:{name:"RuleDictionnaryPrinterType"},RuleDictionnaryPrinterTypeCollection:{name:"RuleDictionnaryPrinterTypeCollection"},RuleDictionnarySoftware:{name:"RuleDictionnarySoftware"},RuleDictionnarySoftwareCollection:{name:"RuleDictionnarySoftwareCollection"},RuleImportComputer:{name:"RuleImportComputer"},CommonDBRelation:{name:"CommonDBRelation"},RuleImportComputerCollection:{name:"RuleImportComputerCollection"},RuleImportEntity:{name:"RuleImportEntity"},RuleImportEntityCollection:{name:"RuleImportEntityCollection"},RuleMailCollector:{name:"RuleMailCollector"},RuleMailCollectorCollection:{name:"RuleMailCollectorCollection"},RuleRight:{name:"RuleRight"},RuleRightCollection:{name:"RuleRightCollection"},RuleRightParameter:{name:"RuleRightParameter"},RuleSoftwareCategory:{name:"RuleSoftwareCategory"},RuleSoftwareCategoryCollection:{name:"RuleSoftwareCategoryCollection"},CommonDevice:{name:"CommonDevice"},RuleTicket:{name:"RuleTicket"},RuleTicketCollection:{name:"RuleTicketCollection"},SlaLevel:{name:"SlaLevel"},SlaLevelAction:{name:"SlaLevelAction"},SlaLevelCriteria:{name:"SlaLevelCriteria"},SoftwareCategory:{name:"SoftwareCategory"},SoftwareLicenseType:{name:"SoftwareLicenseType"},SoftwareVersion:{name:"SoftwareVersion"},SolutionTemplate:{name:"SolutionTemplate"},SolutionType:{name:"SolutionType"},CommonImplicitTreeDropdown:{name:"CommonImplicitTreeDropdown"},SsoVariable:{name:"SsoVariable"},State:{name:"State"},Supplier_Ticket:{name:"Supplier_Ticket"},SupplierType:{name:"SupplierType"},TaskCategory:{name:"TaskCategory"},Ticket:{name:"Ticket"},Ticket_Ticket:{name:"Ticket_Ticket"},Ticket_User:{name:"Ticket_User"},TicketCost:{name:"TicketCost"},TicketRecurrent:{name:"TicketRecurrent"},CommonITILActor:{name:"CommonITILActor"},TicketTask:{name:"TicketTask"},TicketTemplate:{name:"TicketTemplate"},TicketTemplateHiddenField:{name:"TicketTemplateHiddenField"},TicketTemplateMandatoryField:{name:"TicketTemplateMandatoryField"},TicketTemplatePredefinedField:{name:"TicketTemplatePredefinedField"},TicketValidation:{name:"TicketValidation"},UserCategory:{name:"UserCategory"},UserEmail:{name:"UserEmail"},UserTitle:{name:"UserTitle"},VirtualMachineState:{name:"VirtualMachineState"},CommonITILCost:{name:"CommonITILCost"},VirtualMachineSystem:{name:"VirtualMachineSystem"},VirtualMachineType:{name:"VirtualMachineType"},Vlan:{name:"Vlan"},WifiNetwork:{name:"WifiNetwork"},CommonITILValidation:{name:"CommonITILValidation"},CommonTreeDropdown:{name:"CommonTreeDropdown"},Bookmark_User:{name:"Bookmark_User"},Computer_Item:{name:"Computer_Item"},Computer_SoftwareLicense:{name:"Computer_SoftwareLicense"},Computer_SoftwareVersion:{name:"Computer_SoftwareVersion"},ComputerDisk:{name:"ComputerDisk"},ComputerModel:{name:"ComputerModel"},ComputerType:{name:"ComputerType"},ComputerVirtualMachine:{name:"ComputerVirtualMachine"},Consumable:{name:"Consumable"},ConsumableItemType:{name:"ConsumableItemType"},Contact_Supplier:{name:"Contact_Supplier"},Budget:{name:"Budget"},ContactType:{name:"ContactType"},Contract_Item:{name:"Contract_Item"},Contract_Supplier:{name:"Contract_Supplier"},ContractCost:{name:"ContractCost"},ContractType:{name:"ContractType"},DeviceCase:{name:"DeviceCase"},DeviceCaseType:{name:"DeviceCaseType"},DeviceControl:{name:"DeviceControl"},DeviceDrive:{name:"DeviceDrive"},DeviceGraphicCard:{name:"DeviceGraphicCard"},Calendar:{name:"Calendar"},DeviceHardDrive:{name:"DeviceHardDrive"},DeviceMemory:{name:"DeviceMemory"},DeviceMemoryType:{name:"DeviceMemoryType"},DeviceMotherboard:{name:"DeviceMotherboard"},DeviceNetworkCard:{name:"DeviceNetworkCard"},DevicePci:{name:"DevicePci"},DevicePowerSupply:{name:"DevicePowerSupply"},DeviceProcessor:{name:"DeviceProcessor"},DeviceSoundCard:{name:"DeviceSoundCard"},Document_Item:{name:"Document_Item"},Calendar_Holiday:{name:"Calendar_Holiday"},DocumentCategory:{name:"DocumentCategory"},DocumentType:{name:"DocumentType"},Domain:{name:"Domain"},DropdownTranslation:{name:"DropdownTranslation"},Entity:{name:"Entity"},Entity_KnowbaseItem:{name:"Entity_KnowbaseItem"},Entity_Reminder:{name:"Entity_Reminder"},Entity_RSSFeed:{name:"Entity_RSSFeed"},Fieldblacklist:{name:"Fieldblacklist"},FieldUnicity:{name:"FieldUnicity"},CalendarSegment:{name:"CalendarSegment"},Filesystem:{name:"Filesystem"},FQDN:{name:"FQDN"},FQDNLabel:{name:"FQDNLabel"},Group:{name:"Group"},Group_KnowbaseItem:{name:"Group_KnowbaseItem"},Group_Problem:{name:"Group_Problem"},Group_Reminder:{name:"Group_Reminder"},Group_RSSFeed:{name:"Group_RSSFeed"},Group_Ticket:{name:"Group_Ticket"},Group_User:{name:"Group_User"},Cartridge:{name:"Cartridge"},Holiday:{name:"Holiday"},Infocom:{name:"Infocom"},InterfaceType:{name:"InterfaceType"},IPAddress:{name:"IPAddress"},IPAddress_IPNetwork:{name:"IPAddress_IPNetwork"},IPNetmask:{name:"IPNetmask"},IPNetwork:{name:"IPNetwork"},IPNetwork_Vlan:{name:"IPNetwork_Vlan"},Item_DeviceCase:{name:"Item_DeviceCase"},Item_DeviceControl:{name:"Item_DeviceControl"},CartridgeItem_PrinterModel:{name:"CartridgeItem_PrinterModel"},Item_DeviceDrive:{name:"Item_DeviceDrive"},Item_DeviceGraphicCard:{name:"Item_DeviceGraphicCard"},Item_DeviceHardDrive:{name:"Item_DeviceHardDrive"},Item_DeviceMemory:{name:"Item_DeviceMemory"},Item_DeviceMotherboard:{name:"Item_DeviceMotherboard"},Item_DeviceNetworkCard:{name:"Item_DeviceNetworkCard"},Item_DevicePci:{name:"Item_DevicePci"},Item_DevicePowerSupply:{name:"Item_DevicePowerSupply"},Item_DeviceProcessor:{name:"Item_DeviceProcessor"},Item_Devices:{name:"Item_Devices"}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._url=t,this._sessionToken="",this._appToken=n}return o(e,[{key:"_makeRequest",value:function(e,t){fetch(e).then(function(e){e.headers.get("Content-Type").indexOf("application/json")>=0?t(e.json()):t(e.text())}).catch(function(e){t(e)})}},{key:"initSessionByCredentials",value:function(e,t){var n=this;return new Promise(function(r,o){try{var i={function:"initSessionByCredentials",endpoint:"initSession",method:"GET",url:n._url,appToken:n._appToken,userName:e,userPassword:t},u=(0,a.default)(i);n._makeRequest(u,function(e){r(e)})}catch(e){o(e)}})}},{key:"url",get:function(){return this._url},set:function(e){this._url=e}},{key:"sessionToken",get:function(){return this._sessionToken},set:function(e){e&&(this._sessionToken=e)}},{key:"appToken",get:function(){return this._appToken},set:function(e){e&&(this._appToken=e)}}]),e}();t.default=u},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function h(e,t){if(l.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return O(e).length;default:if(r)return L(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:d(e,t,n,r,o);if("number"==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):d(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function d(e,t,n,r,o){var i,a=1,u=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,u/=2,l/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var s=-1;for(i=n;iu&&(n=u-l),i=n;i>=0;i--){for(var m=!0,f=0;fo&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a239?4:c>223?3:c>191?2:1;if(o+m<=n)switch(m){case 1:c<128&&(s=c);break;case 2:128==(192&(i=e[o+1]))&&(l=(31&c)<<6|63&i)>127&&(s=l);break;case 3:i=e[o+1],a=e[o+2],128==(192&i)&&128==(192&a)&&(l=(15&c)<<12|(63&i)<<6|63&a)>2047&&(l<55296||l>57343)&&(s=l);break;case 4:i=e[o+1],a=e[o+2],u=e[o+3],128==(192&i)&&128==(192&a)&&128==(192&u)&&(l=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&u)>65535&&l<1114112&&(s=l)}null===s?(s=65533,m=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),o+=m}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);var n="",r=0;for(;rthis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return D(this,t,n);case"utf8":case"utf-8":return P(this,t,n);case"ascii":return _(this,t,n);case"latin1":case"binary":return v(this,t,n);case"base64":return w(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},l.prototype.compare=function(e,t,n,r,o){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,o>>>=0,this===e)return 0;for(var i=o-r,a=n-t,u=Math.min(i,a),c=this.slice(r,o),s=e.slice(t,n),m=0;mo)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i,a,u,l,c,s,m,f,p,h=!1;;)switch(r){case"hex":return T(this,e,t,n);case"utf8":case"utf-8":return f=t,p=n,j(L(e,(m=this).length-f),m,f,p);case"ascii":return C(this,e,t,n);case"latin1":case"binary":return C(this,e,t,n);case"base64":return l=this,c=t,s=n,j(O(e),l,c,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=t,u=n,j(function(e,t){for(var n,r,o,i=[],a=0;a>8,o=n%256,i.push(o),i.push(r);return i}(e,(i=this).length-a),i,a,u);default:if(h)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),h=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function _(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;or)&&(n=r);for(var o="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,n,r,o,i){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function b(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function E(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function N(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function A(e,t,n,r,i){return i||N(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function M(e,t,n,r,i){return i||N(e,0,n,8),o.write(e,t,n,r,52,8),n+8}l.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)r+=this[e+--t]*o;return r},l.prototype.readUInt8=function(e,t){return t||S(e,1,this.length),this[e]},l.prototype.readUInt16LE=function(e,t){return t||S(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUInt16BE=function(e,t){return t||S(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUInt32LE=function(e,t){return t||S(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUInt32BE=function(e,t){return t||S(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||S(e,t,this.length);for(var r=this[e],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*t)),r},l.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||S(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},l.prototype.readInt8=function(e,t){return t||S(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){t||S(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){t||S(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(e,t){return t||S(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return t||S(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return t||S(e,4,this.length),o.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return t||S(e,4,this.length),o.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return t||S(e,8,this.length),o.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return t||S(e,8,this.length),o.read(this,e,!1,52,8)},l.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||I(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+n},l.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):b(this,e,t,!0),t+2},l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):b(this,e,t,!1),t+2},l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):E(this,e,t,!0),t+4},l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):E(this,e,t,!1),t+4},l.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);I(this,e,t,n,o-1,-o)}var i=0,a=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+n},l.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);I(this,e,t,n,o-1,-o)}var i=n-1,a=1,u=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/a>>0)-u&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):b(this,e,t,!0),t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):b(this,e,t,!1),t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):E(this,e,t,!0),t+4},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):E(this,e,t,!1),t+4},l.prototype.writeFloatLE=function(e,t,n){return A(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return A(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return M(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return M(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3||!l.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function O(e){return r.toByteArray(function(e){var t;if((e=(t=e,t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function j(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(t,n(5))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";t.byteLength=function(e){return 3*e.length/4-c(e)},t.toByteArray=function(e){var t,n,r,a,u,l=e.length;a=c(e),u=new i(3*l/4-a),n=a>0?l-4:l;var s=0;for(t=0;t>16&255,u[s++]=r>>8&255,u[s++]=255&r;2===a?(r=o[e.charCodeAt(t)]<<2|o[e.charCodeAt(t+1)]>>4,u[s++]=255&r):1===a&&(r=o[e.charCodeAt(t)]<<10|o[e.charCodeAt(t+1)]<<4|o[e.charCodeAt(t+2)]>>2,u[s++]=r>>8&255,u[s++]=255&r);return u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i="",a=[],u=0,l=n-o;ul?l:u+16383));1===o?(t=e[n-1],i+=r[t>>2],i+=r[t<<4&63],i+="=="):2===o&&(t=(e[n-2]<<8)+e[n-1],i+=r[t>>10],i+=r[t>>4&63],i+=r[t<<2&63],i+="=");return a.push(i),a.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,l=a.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function s(e,t,n){for(var o,i,a=[],u=t;u>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,o){var i,a,u=8*o-r-1,l=(1<>1,s=-7,m=n?o-1:0,f=n?-1:1,p=e[t+m];for(m+=f,i=p&(1<<-s)-1,p>>=-s,s+=u;s>0;i=256*i+e[t+m],m+=f,s-=8);for(a=i&(1<<-s)-1,i>>=-s,s+=r;s>0;a=256*a+e[t+m],m+=f,s-=8);if(0===i)i=1-c;else{if(i===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),i-=c}return(p?-1:1)*a*Math.pow(2,i-r)},t.write=function(e,t,n,r,o,i){var a,u,l,c=8*i-o-1,s=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,h=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,a=s):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+m>=1?f/l:f*Math.pow(2,1-m))*l>=2&&(a++,l/=2),a+m>=s?(u=0,a=s):a+m>=1?(u=(t*l-1)*Math.pow(2,o),a+=m):(u=t*Math.pow(2,m-1)*Math.pow(2,o),a=0));o>=8;e[n+p]=255&u,p+=h,u/=256,o-=8);for(a=a<0;e[n+p]=255&a,p+=h,a/=256,c-=8);e[n+p-h]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}}])}); \ No newline at end of file diff --git a/src/index.js b/src/index.js index 195a9db..552aa38 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,7 @@ import itemtype from './itemtype.json' +import restclient from './restclient' +export default restclient export { itemtype } \ No newline at end of file diff --git a/src/prepareRequest.js b/src/prepareRequest.js new file mode 100644 index 0000000..104eba8 --- /dev/null +++ b/src/prepareRequest.js @@ -0,0 +1,35 @@ + + +function prepareRequest (data) { + + let myHeaders = new Headers() + let myInit = { method: data.method } + let url = `${data.url}/${data.endpoint}` + + myHeaders.append('Content-Type', 'application/json') + + if (data.appToken) { + myHeaders.append('App-Token', data.appToken) + } + + if (data.sessionToken) { + myHeaders.append('Authorization', `user_token ${data.sessionToken}`) + } + + switch (data.function) { + case 'initSessionByCredentials': + myHeaders.append('Authorization', `Basic ${Buffer.from(`${data.userName}:${data.userPassword}`).toString('base64')}`) + break + default: + break + } + + myInit = { + ...myInit, + headers: myHeaders + } + + return new Request(url, myInit) +} + +export default prepareRequest diff --git a/src/restclient.js b/src/restclient.js new file mode 100644 index 0000000..72df08d --- /dev/null +++ b/src/restclient.js @@ -0,0 +1,50 @@ +import prepareRequest from './prepareRequest' + +class GlpiRestClient { + constructor (url, appToken = '') { + this._url = url + this._sessionToken = '' + this._appToken = appToken + } + + get url () { + return this._url + } + + set url (url) { + this._url = url + } + + get sessionToken () { + return this._sessionToken + } + + set sessionToken (sessionToken) { + if (sessionToken) this._sessionToken = sessionToken + } + + get appToken () { + return this._appToken + } + + set appToken (appToken) { + if (appToken) this._appToken = appToken + } + + _makeRequest (myRequest, responseHandler) { + fetch (myRequest) + .then((resp) => { + if (resp.headers.get('Content-Type').indexOf("application/json") >= 0) { + responseHandler(resp.json()) + } else { + responseHandler(resp.text()) + } + }) + .catch((err) => { + responseHandler(err) + }) + } + +} + +export default GlpiRestClient