@itentialopensource/adapter-checkpoint_management 0.10.5 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/adapter.js CHANGED
@@ -32308,6 +32308,1003 @@ class CheckpointManagement extends AdapterBaseCl {
32308
32308
  return callback(null, errorObj);
32309
32309
  }
32310
32310
  }
32311
+
32312
+ /**
32313
+ * @function verifySoftwarePackage
32314
+ * @pronghornType method
32315
+ * @name verifySoftwarePackage
32316
+ * @summary Verifies the software package on target machines.
32317
+ *
32318
+ * @param {object} body - Request body
32319
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
32320
+ * @param {string} sid - session id
32321
+ * @param {getCallback} callback - a callback function to return the result
32322
+ * @return {object} results - An object containing the response of the action
32323
+ *
32324
+ * @route {POST} /verifySoftwarePackage
32325
+ * @roles admin
32326
+ * @task true
32327
+ */
32328
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
32329
+ verifySoftwarePackage(body, iapMetadata, sid, callback) {
32330
+ const meth = 'adapter-verifySoftwarePackage';
32331
+ const origin = `${this.id}-${meth}`;
32332
+ log.trace(origin);
32333
+
32334
+ if (this.suspended && this.suspendMode === 'error') {
32335
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
32336
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32337
+ return callback(null, errorObj);
32338
+ }
32339
+
32340
+ /* HERE IS WHERE YOU VALIDATE DATA */
32341
+ if (body === undefined || body === null || body === '') {
32342
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
32343
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32344
+ return callback(null, errorObj);
32345
+ }
32346
+
32347
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
32348
+ const queryParamsAvailable = {};
32349
+ const queryParams = {};
32350
+ const pathVars = [];
32351
+ const bodyVars = body;
32352
+
32353
+ // loop in template. long callback arg name to avoid identifier conflicts
32354
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
32355
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
32356
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
32357
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
32358
+ }
32359
+ });
32360
+
32361
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
32362
+ // see adapter code documentation for more information on the request object's fields
32363
+ const reqObj = {
32364
+ payload: bodyVars,
32365
+ uriPathVars: pathVars,
32366
+ uriQuery: queryParams
32367
+ };
32368
+
32369
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
32370
+
32371
+ // Merge and add new iapMetadata fields in reqObj
32372
+ if (iapMetadata && typeof iapMetadata === 'object') {
32373
+ Object.keys(iapMetadata).forEach((iapField) => {
32374
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
32375
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
32376
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
32377
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
32378
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
32379
+ } else {
32380
+ // Otherwise, add new iapMetadata fields to reqObj
32381
+ reqObj[iapField] = iapMetadata[iapField];
32382
+ }
32383
+ }
32384
+ });
32385
+ // Add iapMetadata to reqObj for further work
32386
+ reqObj.iapMetadata = iapMetadata;
32387
+ }
32388
+ if (sid) {
32389
+ if (!reqObj.addlHeaders) {
32390
+ reqObj.addlHeaders = {};
32391
+ }
32392
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
32393
+ }
32394
+ try {
32395
+ // Make the call -
32396
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
32397
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'verifySoftwarePackage', reqObj, true, (irReturnData, irReturnError) => {
32398
+ // if we received an error or their is no response on the results
32399
+ // return an error
32400
+ if (irReturnError) {
32401
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
32402
+ return callback(null, irReturnError);
32403
+ }
32404
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
32405
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['verifySoftwarePackage'], null, null, null);
32406
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32407
+ return callback(null, errorObj);
32408
+ }
32409
+
32410
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
32411
+ // return the response
32412
+ return callback(irReturnData, null);
32413
+ });
32414
+ } catch (ex) {
32415
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
32416
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32417
+ return callback(null, errorObj);
32418
+ }
32419
+ }
32420
+
32421
+ /**
32422
+ * @function installSoftwarePackage
32423
+ * @pronghornType method
32424
+ * @name installSoftwarePackage
32425
+ * @summary Installs the software package on target machines.
32426
+ *
32427
+ * @param {object} body - Request body
32428
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
32429
+ * @param {string} sid - session id
32430
+ * @param {getCallback} callback - a callback function to return the result
32431
+ * @return {object} results - An object containing the response of the action
32432
+ *
32433
+ * @route {POST} /installSoftwarePackage
32434
+ * @roles admin
32435
+ * @task true
32436
+ */
32437
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
32438
+ installSoftwarePackage(body, iapMetadata, sid, callback) {
32439
+ const meth = 'adapter-installSoftwarePackage';
32440
+ const origin = `${this.id}-${meth}`;
32441
+ log.trace(origin);
32442
+
32443
+ if (this.suspended && this.suspendMode === 'error') {
32444
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
32445
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32446
+ return callback(null, errorObj);
32447
+ }
32448
+
32449
+ /* HERE IS WHERE YOU VALIDATE DATA */
32450
+ if (body === undefined || body === null || body === '') {
32451
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
32452
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32453
+ return callback(null, errorObj);
32454
+ }
32455
+
32456
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
32457
+ const queryParamsAvailable = {};
32458
+ const queryParams = {};
32459
+ const pathVars = [];
32460
+ const bodyVars = body;
32461
+
32462
+ // loop in template. long callback arg name to avoid identifier conflicts
32463
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
32464
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
32465
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
32466
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
32467
+ }
32468
+ });
32469
+
32470
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
32471
+ // see adapter code documentation for more information on the request object's fields
32472
+ const reqObj = {
32473
+ payload: bodyVars,
32474
+ uriPathVars: pathVars,
32475
+ uriQuery: queryParams
32476
+ };
32477
+
32478
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
32479
+
32480
+ // Merge and add new iapMetadata fields in reqObj
32481
+ if (iapMetadata && typeof iapMetadata === 'object') {
32482
+ Object.keys(iapMetadata).forEach((iapField) => {
32483
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
32484
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
32485
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
32486
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
32487
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
32488
+ } else {
32489
+ // Otherwise, add new iapMetadata fields to reqObj
32490
+ reqObj[iapField] = iapMetadata[iapField];
32491
+ }
32492
+ }
32493
+ });
32494
+ // Add iapMetadata to reqObj for further work
32495
+ reqObj.iapMetadata = iapMetadata;
32496
+ }
32497
+
32498
+ if (sid) {
32499
+ if (!reqObj.addlHeaders) {
32500
+ reqObj.addlHeaders = {};
32501
+ }
32502
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
32503
+ }
32504
+
32505
+ try {
32506
+ // Make the call -
32507
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
32508
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'installSoftwarePackage', reqObj, true, (irReturnData, irReturnError) => {
32509
+ // if we received an error or their is no response on the results
32510
+ // return an error
32511
+ if (irReturnError) {
32512
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
32513
+ return callback(null, irReturnError);
32514
+ }
32515
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
32516
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['installSoftwarePackage'], null, null, null);
32517
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32518
+ return callback(null, errorObj);
32519
+ }
32520
+
32521
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
32522
+ // return the response
32523
+ return callback(irReturnData, null);
32524
+ });
32525
+ } catch (ex) {
32526
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
32527
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32528
+ return callback(null, errorObj);
32529
+ }
32530
+ }
32531
+
32532
+ /**
32533
+ * @function uninstallSoftwarePackage
32534
+ * @pronghornType method
32535
+ * @name uninstallSoftwarePackage
32536
+ * @summary Uninstalls the software package from target machines.
32537
+ *
32538
+ * @param {object} body - Request body
32539
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
32540
+ * @param {string} sid - session id
32541
+ * @param {getCallback} callback - a callback function to return the result
32542
+ * @return {object} results - An object containing the response of the action
32543
+ *
32544
+ * @route {POST} /uninstallSoftwarePackage
32545
+ * @roles admin
32546
+ * @task true
32547
+ */
32548
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
32549
+ uninstallSoftwarePackage(body, iapMetadata, sid, callback) {
32550
+ const meth = 'adapter-uninstallSoftwarePackage';
32551
+ const origin = `${this.id}-${meth}`;
32552
+ log.trace(origin);
32553
+
32554
+ if (this.suspended && this.suspendMode === 'error') {
32555
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
32556
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32557
+ return callback(null, errorObj);
32558
+ }
32559
+
32560
+ /* HERE IS WHERE YOU VALIDATE DATA */
32561
+ if (body === undefined || body === null || body === '') {
32562
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
32563
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32564
+ return callback(null, errorObj);
32565
+ }
32566
+
32567
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
32568
+ const queryParamsAvailable = {};
32569
+ const queryParams = {};
32570
+ const pathVars = [];
32571
+ const bodyVars = body;
32572
+
32573
+ // loop in template. long callback arg name to avoid identifier conflicts
32574
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
32575
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
32576
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
32577
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
32578
+ }
32579
+ });
32580
+
32581
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
32582
+ // see adapter code documentation for more information on the request object's fields
32583
+ const reqObj = {
32584
+ payload: bodyVars,
32585
+ uriPathVars: pathVars,
32586
+ uriQuery: queryParams
32587
+ };
32588
+
32589
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
32590
+
32591
+ // Merge and add new iapMetadata fields in reqObj
32592
+ if (iapMetadata && typeof iapMetadata === 'object') {
32593
+ Object.keys(iapMetadata).forEach((iapField) => {
32594
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
32595
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
32596
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
32597
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
32598
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
32599
+ } else {
32600
+ // Otherwise, add new iapMetadata fields to reqObj
32601
+ reqObj[iapField] = iapMetadata[iapField];
32602
+ }
32603
+ }
32604
+ });
32605
+ // Add iapMetadata to reqObj for further work
32606
+ reqObj.iapMetadata = iapMetadata;
32607
+ }
32608
+
32609
+ if (sid) {
32610
+ if (!reqObj.addlHeaders) {
32611
+ reqObj.addlHeaders = {};
32612
+ }
32613
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
32614
+ }
32615
+
32616
+ try {
32617
+ // Make the call -
32618
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
32619
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'uninstallSoftwarePackage', reqObj, true, (irReturnData, irReturnError) => {
32620
+ // if we received an error or their is no response on the results
32621
+ // return an error
32622
+ if (irReturnError) {
32623
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
32624
+ return callback(null, irReturnError);
32625
+ }
32626
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
32627
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['uninstallSoftwarePackage'], null, null, null);
32628
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32629
+ return callback(null, errorObj);
32630
+ }
32631
+
32632
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
32633
+ // return the response
32634
+ return callback(irReturnData, null);
32635
+ });
32636
+ } catch (ex) {
32637
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
32638
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32639
+ return callback(null, errorObj);
32640
+ }
32641
+ }
32642
+
32643
+ /**
32644
+ * @function addRepositoryPackage
32645
+ * @pronghornType method
32646
+ * @name addRepositoryPackage
32647
+ * @summary Add the software package to the central repository.
32648
+ *
32649
+ * @param {object} body - Request body
32650
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
32651
+ * @param {string} sid - session id
32652
+ * @param {getCallback} callback - a callback function to return the result
32653
+ * @return {object} results - An object containing the response of the action
32654
+ *
32655
+ * @route {POST} /addRepositoryPackage
32656
+ * @roles admin
32657
+ * @task true
32658
+ */
32659
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
32660
+ addRepositoryPackage(body, iapMetadata, sid, callback) {
32661
+ const meth = 'adapter-addRepositoryPackage';
32662
+ const origin = `${this.id}-${meth}`;
32663
+ log.trace(origin);
32664
+
32665
+ if (this.suspended && this.suspendMode === 'error') {
32666
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
32667
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32668
+ return callback(null, errorObj);
32669
+ }
32670
+
32671
+ /* HERE IS WHERE YOU VALIDATE DATA */
32672
+ if (body === undefined || body === null || body === '') {
32673
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
32674
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32675
+ return callback(null, errorObj);
32676
+ }
32677
+
32678
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
32679
+ const queryParamsAvailable = {};
32680
+ const queryParams = {};
32681
+ const pathVars = [];
32682
+ const bodyVars = body;
32683
+
32684
+ // loop in template. long callback arg name to avoid identifier conflicts
32685
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
32686
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
32687
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
32688
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
32689
+ }
32690
+ });
32691
+
32692
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
32693
+ // see adapter code documentation for more information on the request object's fields
32694
+ const reqObj = {
32695
+ payload: bodyVars,
32696
+ uriPathVars: pathVars,
32697
+ uriQuery: queryParams
32698
+ };
32699
+
32700
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
32701
+
32702
+ // Merge and add new iapMetadata fields in reqObj
32703
+ if (iapMetadata && typeof iapMetadata === 'object') {
32704
+ Object.keys(iapMetadata).forEach((iapField) => {
32705
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
32706
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
32707
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
32708
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
32709
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
32710
+ } else {
32711
+ // Otherwise, add new iapMetadata fields to reqObj
32712
+ reqObj[iapField] = iapMetadata[iapField];
32713
+ }
32714
+ }
32715
+ });
32716
+ // Add iapMetadata to reqObj for further work
32717
+ reqObj.iapMetadata = iapMetadata;
32718
+ }
32719
+
32720
+ if (sid) {
32721
+ if (!reqObj.addlHeaders) {
32722
+ reqObj.addlHeaders = {};
32723
+ }
32724
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
32725
+ }
32726
+
32727
+ try {
32728
+ // Make the call -
32729
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
32730
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'addRepositoryPackage', reqObj, true, (irReturnData, irReturnError) => {
32731
+ // if we received an error or their is no response on the results
32732
+ // return an error
32733
+ if (irReturnError) {
32734
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
32735
+ return callback(null, irReturnError);
32736
+ }
32737
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
32738
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['addRepositoryPackage'], null, null, null);
32739
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32740
+ return callback(null, errorObj);
32741
+ }
32742
+
32743
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
32744
+ // return the response
32745
+ return callback(irReturnData, null);
32746
+ });
32747
+ } catch (ex) {
32748
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
32749
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32750
+ return callback(null, errorObj);
32751
+ }
32752
+ }
32753
+
32754
+ /**
32755
+ * @function showRepositoryPackage
32756
+ * @pronghornType method
32757
+ * @name showRepositoryPackage
32758
+ * @summary Gets repository software packages information.
32759
+ *
32760
+ * @param {object} body - Request body
32761
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
32762
+ * @param {string} sid - session id
32763
+ * @param {getCallback} callback - a callback function to return the result
32764
+ * @return {object} results - An object containing the response of the action
32765
+ *
32766
+ * @route {POST} /showRepositoryPackage
32767
+ * @roles admin
32768
+ * @task true
32769
+ */
32770
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
32771
+ showRepositoryPackage(body, iapMetadata, sid, callback) {
32772
+ const meth = 'adapter-showRepositoryPackage';
32773
+ const origin = `${this.id}-${meth}`;
32774
+ log.trace(origin);
32775
+
32776
+ if (this.suspended && this.suspendMode === 'error') {
32777
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
32778
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32779
+ return callback(null, errorObj);
32780
+ }
32781
+
32782
+ /* HERE IS WHERE YOU VALIDATE DATA */
32783
+ if (body === undefined || body === null || body === '') {
32784
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
32785
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32786
+ return callback(null, errorObj);
32787
+ }
32788
+
32789
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
32790
+ const queryParamsAvailable = {};
32791
+ const queryParams = {};
32792
+ const pathVars = [];
32793
+ const bodyVars = body;
32794
+
32795
+ // loop in template. long callback arg name to avoid identifier conflicts
32796
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
32797
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
32798
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
32799
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
32800
+ }
32801
+ });
32802
+
32803
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
32804
+ // see adapter code documentation for more information on the request object's fields
32805
+ const reqObj = {
32806
+ payload: bodyVars,
32807
+ uriPathVars: pathVars,
32808
+ uriQuery: queryParams
32809
+ };
32810
+
32811
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
32812
+
32813
+ // Merge and add new iapMetadata fields in reqObj
32814
+ if (iapMetadata && typeof iapMetadata === 'object') {
32815
+ Object.keys(iapMetadata).forEach((iapField) => {
32816
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
32817
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
32818
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
32819
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
32820
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
32821
+ } else {
32822
+ // Otherwise, add new iapMetadata fields to reqObj
32823
+ reqObj[iapField] = iapMetadata[iapField];
32824
+ }
32825
+ }
32826
+ });
32827
+ // Add iapMetadata to reqObj for further work
32828
+ reqObj.iapMetadata = iapMetadata;
32829
+ }
32830
+
32831
+ if (sid) {
32832
+ if (!reqObj.addlHeaders) {
32833
+ reqObj.addlHeaders = {};
32834
+ }
32835
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
32836
+ }
32837
+
32838
+ try {
32839
+ // Make the call -
32840
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
32841
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'showRepositoryPackage', reqObj, true, (irReturnData, irReturnError) => {
32842
+ // if we received an error or their is no response on the results
32843
+ // return an error
32844
+ if (irReturnError) {
32845
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
32846
+ return callback(null, irReturnError);
32847
+ }
32848
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
32849
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['showRepositoryPackage'], null, null, null);
32850
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32851
+ return callback(null, errorObj);
32852
+ }
32853
+
32854
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
32855
+ // return the response
32856
+ return callback(irReturnData, null);
32857
+ });
32858
+ } catch (ex) {
32859
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
32860
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32861
+ return callback(null, errorObj);
32862
+ }
32863
+ }
32864
+
32865
+ /**
32866
+ * @function showSoftwarePackageDetails
32867
+ * @pronghornType method
32868
+ * @name showSoftwarePackageDetails
32869
+ * @summary Gets the software package information from the cloud.
32870
+ *
32871
+ * @param {object} body - Request body
32872
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
32873
+ * @param {string} sid - session id
32874
+ * @param {getCallback} callback - a callback function to return the result
32875
+ * @return {object} results - An object containing the response of the action
32876
+ *
32877
+ * @route {POST} /showSoftwarePackageDetails
32878
+ * @roles admin
32879
+ * @task true
32880
+ */
32881
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
32882
+ showSoftwarePackageDetails(body, iapMetadata, sid, callback) {
32883
+ const meth = 'adapter-showSoftwarePackageDetails';
32884
+ const origin = `${this.id}-${meth}`;
32885
+ log.trace(origin);
32886
+
32887
+ if (this.suspended && this.suspendMode === 'error') {
32888
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
32889
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32890
+ return callback(null, errorObj);
32891
+ }
32892
+
32893
+ /* HERE IS WHERE YOU VALIDATE DATA */
32894
+ if (body === undefined || body === null || body === '') {
32895
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
32896
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32897
+ return callback(null, errorObj);
32898
+ }
32899
+
32900
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
32901
+ const queryParamsAvailable = {};
32902
+ const queryParams = {};
32903
+ const pathVars = [];
32904
+ const bodyVars = body;
32905
+
32906
+ // loop in template. long callback arg name to avoid identifier conflicts
32907
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
32908
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
32909
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
32910
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
32911
+ }
32912
+ });
32913
+
32914
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
32915
+ // see adapter code documentation for more information on the request object's fields
32916
+ const reqObj = {
32917
+ payload: bodyVars,
32918
+ uriPathVars: pathVars,
32919
+ uriQuery: queryParams
32920
+ };
32921
+
32922
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
32923
+
32924
+ // Merge and add new iapMetadata fields in reqObj
32925
+ if (iapMetadata && typeof iapMetadata === 'object') {
32926
+ Object.keys(iapMetadata).forEach((iapField) => {
32927
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
32928
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
32929
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
32930
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
32931
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
32932
+ } else {
32933
+ // Otherwise, add new iapMetadata fields to reqObj
32934
+ reqObj[iapField] = iapMetadata[iapField];
32935
+ }
32936
+ }
32937
+ });
32938
+ // Add iapMetadata to reqObj for further work
32939
+ reqObj.iapMetadata = iapMetadata;
32940
+ }
32941
+
32942
+ if (sid) {
32943
+ if (!reqObj.addlHeaders) {
32944
+ reqObj.addlHeaders = {};
32945
+ }
32946
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
32947
+ }
32948
+
32949
+ try {
32950
+ // Make the call -
32951
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
32952
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'showSoftwarePackageDetails', reqObj, true, (irReturnData, irReturnError) => {
32953
+ // if we received an error or their is no response on the results
32954
+ // return an error
32955
+ if (irReturnError) {
32956
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
32957
+ return callback(null, irReturnError);
32958
+ }
32959
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
32960
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['showSoftwarePackageDetails'], null, null, null);
32961
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32962
+ return callback(null, errorObj);
32963
+ }
32964
+
32965
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
32966
+ // return the response
32967
+ return callback(irReturnData, null);
32968
+ });
32969
+ } catch (ex) {
32970
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
32971
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32972
+ return callback(null, errorObj);
32973
+ }
32974
+ }
32975
+
32976
+ /**
32977
+ * @function showSoftwarePackagesPerTargets
32978
+ * @pronghornType method
32979
+ * @name showSoftwarePackagesPerTargets
32980
+ * @summary Shows software packages on targets.
32981
+ *
32982
+ * @param {object} body - Request body
32983
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
32984
+ * @param {string} sid - session id
32985
+ * @param {getCallback} callback - a callback function to return the result
32986
+ * @return {object} results - An object containing the response of the action
32987
+ *
32988
+ * @route {POST} /showSoftwarePackagesPerTargets
32989
+ * @roles admin
32990
+ * @task true
32991
+ */
32992
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
32993
+ showSoftwarePackagesPerTargets(body, iapMetadata, sid, callback) {
32994
+ const meth = 'adapter-showSoftwarePackagesPerTargets';
32995
+ const origin = `${this.id}-${meth}`;
32996
+ log.trace(origin);
32997
+
32998
+ if (this.suspended && this.suspendMode === 'error') {
32999
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
33000
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33001
+ return callback(null, errorObj);
33002
+ }
33003
+
33004
+ /* HERE IS WHERE YOU VALIDATE DATA */
33005
+ if (body === undefined || body === null || body === '') {
33006
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
33007
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33008
+ return callback(null, errorObj);
33009
+ }
33010
+
33011
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
33012
+ const queryParamsAvailable = {};
33013
+ const queryParams = {};
33014
+ const pathVars = [];
33015
+ const bodyVars = body;
33016
+
33017
+ // loop in template. long callback arg name to avoid identifier conflicts
33018
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
33019
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
33020
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
33021
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
33022
+ }
33023
+ });
33024
+
33025
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
33026
+ // see adapter code documentation for more information on the request object's fields
33027
+ const reqObj = {
33028
+ payload: bodyVars,
33029
+ uriPathVars: pathVars,
33030
+ uriQuery: queryParams
33031
+ };
33032
+
33033
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
33034
+
33035
+ // Merge and add new iapMetadata fields in reqObj
33036
+ if (iapMetadata && typeof iapMetadata === 'object') {
33037
+ Object.keys(iapMetadata).forEach((iapField) => {
33038
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
33039
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
33040
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
33041
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
33042
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
33043
+ } else {
33044
+ // Otherwise, add new iapMetadata fields to reqObj
33045
+ reqObj[iapField] = iapMetadata[iapField];
33046
+ }
33047
+ }
33048
+ });
33049
+ // Add iapMetadata to reqObj for further work
33050
+ reqObj.iapMetadata = iapMetadata;
33051
+ }
33052
+
33053
+ if (sid) {
33054
+ if (!reqObj.addlHeaders) {
33055
+ reqObj.addlHeaders = {};
33056
+ }
33057
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
33058
+ }
33059
+
33060
+ try {
33061
+ // Make the call -
33062
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
33063
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'showSoftwarePackagesPerTargets', reqObj, true, (irReturnData, irReturnError) => {
33064
+ // if we received an error or their is no response on the results
33065
+ // return an error
33066
+ if (irReturnError) {
33067
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
33068
+ return callback(null, irReturnError);
33069
+ }
33070
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
33071
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['showSoftwarePackagesPerTargets'], null, null, null);
33072
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33073
+ return callback(null, errorObj);
33074
+ }
33075
+
33076
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
33077
+ // return the response
33078
+ return callback(irReturnData, null);
33079
+ });
33080
+ } catch (ex) {
33081
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
33082
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33083
+ return callback(null, errorObj);
33084
+ }
33085
+ }
33086
+
33087
+ /**
33088
+ * @function deleteRepositoryPackage
33089
+ * @pronghornType method
33090
+ * @name deleteRepositoryPackage
33091
+ * @summary Delete the repository software package from the central repository.
33092
+ *
33093
+ * @param {object} body - Request body
33094
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
33095
+ * @param {string} sid - session id
33096
+ * @param {getCallback} callback - a callback function to return the result
33097
+ * @return {object} results - An object containing the response of the action
33098
+ *
33099
+ * @route {POST} /deleteRepositoryPackage
33100
+ * @roles admin
33101
+ * @task true
33102
+ */
33103
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
33104
+ deleteRepositoryPackage(body, iapMetadata, sid, callback) {
33105
+ const meth = 'adapter-deleteRepositoryPackage';
33106
+ const origin = `${this.id}-${meth}`;
33107
+ log.trace(origin);
33108
+
33109
+ if (this.suspended && this.suspendMode === 'error') {
33110
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
33111
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33112
+ return callback(null, errorObj);
33113
+ }
33114
+
33115
+ /* HERE IS WHERE YOU VALIDATE DATA */
33116
+ if (body === undefined || body === null || body === '') {
33117
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
33118
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33119
+ return callback(null, errorObj);
33120
+ }
33121
+
33122
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
33123
+ const queryParamsAvailable = {};
33124
+ const queryParams = {};
33125
+ const pathVars = [];
33126
+ const bodyVars = body;
33127
+
33128
+ // loop in template. long callback arg name to avoid identifier conflicts
33129
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
33130
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
33131
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
33132
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
33133
+ }
33134
+ });
33135
+
33136
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
33137
+ // see adapter code documentation for more information on the request object's fields
33138
+ const reqObj = {
33139
+ payload: bodyVars,
33140
+ uriPathVars: pathVars,
33141
+ uriQuery: queryParams
33142
+ };
33143
+
33144
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
33145
+
33146
+ // Merge and add new iapMetadata fields in reqObj
33147
+ if (iapMetadata && typeof iapMetadata === 'object') {
33148
+ Object.keys(iapMetadata).forEach((iapField) => {
33149
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
33150
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
33151
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
33152
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
33153
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
33154
+ } else {
33155
+ // Otherwise, add new iapMetadata fields to reqObj
33156
+ reqObj[iapField] = iapMetadata[iapField];
33157
+ }
33158
+ }
33159
+ });
33160
+ // Add iapMetadata to reqObj for further work
33161
+ reqObj.iapMetadata = iapMetadata;
33162
+ }
33163
+
33164
+ if (sid) {
33165
+ if (!reqObj.addlHeaders) {
33166
+ reqObj.addlHeaders = {};
33167
+ }
33168
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
33169
+ }
33170
+
33171
+ try {
33172
+ // Make the call -
33173
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
33174
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'deleteRepositoryPackage', reqObj, true, (irReturnData, irReturnError) => {
33175
+ // if we received an error or their is no response on the results
33176
+ // return an error
33177
+ if (irReturnError) {
33178
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
33179
+ return callback(null, irReturnError);
33180
+ }
33181
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
33182
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteRepositoryPackage'], null, null, null);
33183
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33184
+ return callback(null, errorObj);
33185
+ }
33186
+
33187
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
33188
+ // return the response
33189
+ return callback(irReturnData, null);
33190
+ });
33191
+ } catch (ex) {
33192
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
33193
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33194
+ return callback(null, errorObj);
33195
+ }
33196
+ }
33197
+
33198
+ /**
33199
+ * @function showRepositoryPackages
33200
+ * @pronghornType method
33201
+ * @name showRepositoryPackages
33202
+ * @summary Gets all repository software packages information.
33203
+ *
33204
+ * @param {object} body - Request body
33205
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
33206
+ * @param {string} sid - session id
33207
+ * @param {getCallback} callback - a callback function to return the result
33208
+ * @return {object} results - An object containing the response of the action
33209
+ *
33210
+ * @route {POST} /showRepositoryPackages
33211
+ * @roles admin
33212
+ * @task true
33213
+ */
33214
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
33215
+ showRepositoryPackages(body, iapMetadata, sid, callback) {
33216
+ const meth = 'adapter-showRepositoryPackages';
33217
+ const origin = `${this.id}-${meth}`;
33218
+ log.trace(origin);
33219
+
33220
+ if (this.suspended && this.suspendMode === 'error') {
33221
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
33222
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33223
+ return callback(null, errorObj);
33224
+ }
33225
+
33226
+ /* HERE IS WHERE YOU VALIDATE DATA */
33227
+ if (body === undefined || body === null || body === '') {
33228
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
33229
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33230
+ return callback(null, errorObj);
33231
+ }
33232
+
33233
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
33234
+ const queryParamsAvailable = {};
33235
+ const queryParams = {};
33236
+ const pathVars = [];
33237
+ const bodyVars = body;
33238
+
33239
+ // loop in template. long callback arg name to avoid identifier conflicts
33240
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
33241
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
33242
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
33243
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
33244
+ }
33245
+ });
33246
+
33247
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
33248
+ // see adapter code documentation for more information on the request object's fields
33249
+ const reqObj = {
33250
+ payload: bodyVars,
33251
+ uriPathVars: pathVars,
33252
+ uriQuery: queryParams
33253
+ };
33254
+
33255
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
33256
+
33257
+ // Merge and add new iapMetadata fields in reqObj
33258
+ if (iapMetadata && typeof iapMetadata === 'object') {
33259
+ Object.keys(iapMetadata).forEach((iapField) => {
33260
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
33261
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
33262
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
33263
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
33264
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
33265
+ } else {
33266
+ // Otherwise, add new iapMetadata fields to reqObj
33267
+ reqObj[iapField] = iapMetadata[iapField];
33268
+ }
33269
+ }
33270
+ });
33271
+ // Add iapMetadata to reqObj for further work
33272
+ reqObj.iapMetadata = iapMetadata;
33273
+ }
33274
+
33275
+ if (sid) {
33276
+ if (!reqObj.addlHeaders) {
33277
+ reqObj.addlHeaders = {};
33278
+ }
33279
+ reqObj.addlHeaders['X-chkp-sid'] = sid;
33280
+ }
33281
+
33282
+ try {
33283
+ // Make the call -
33284
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
33285
+ return this.requestHandlerInst.identifyRequest('PackageDeployment', 'showRepositoryPackages', reqObj, true, (irReturnData, irReturnError) => {
33286
+ // if we received an error or their is no response on the results
33287
+ // return an error
33288
+ if (irReturnError) {
33289
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
33290
+ return callback(null, irReturnError);
33291
+ }
33292
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
33293
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['showRepositoryPackages'], null, null, null);
33294
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33295
+ return callback(null, errorObj);
33296
+ }
33297
+
33298
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
33299
+ // return the response
33300
+ return callback(irReturnData, null);
33301
+ });
33302
+ } catch (ex) {
33303
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
33304
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
33305
+ return callback(null, errorObj);
33306
+ }
33307
+ }
32311
33308
  }
32312
33309
 
32313
33310
  module.exports = CheckpointManagement;