@itentialopensource/adapter-netbox_v210 0.1.1 → 0.2.1

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.
@@ -4,7 +4,7 @@
4
4
  "name": "getGenerics",
5
5
  "protocol": "REST",
6
6
  "method": "GET",
7
- "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
7
+ "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
8
8
  "requestSchema": "schema.json",
9
9
  "responseSchema": "schema.json",
10
10
  "timeout": 0,
@@ -25,7 +25,7 @@
25
25
  "name": "createGeneric",
26
26
  "protocol": "REST",
27
27
  "method": "POST",
28
- "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
28
+ "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
29
29
  "requestSchema": "schema.json",
30
30
  "responseSchema": "schema.json",
31
31
  "timeout": 0,
@@ -46,7 +46,7 @@
46
46
  "name": "updateGeneric",
47
47
  "protocol": "REST",
48
48
  "method": "PUT",
49
- "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
49
+ "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
50
50
  "requestSchema": "schema.json",
51
51
  "responseSchema": "schema.json",
52
52
  "timeout": 0,
@@ -67,7 +67,7 @@
67
67
  "name": "patchGeneric",
68
68
  "protocol": "REST",
69
69
  "method": "PATCH",
70
- "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
70
+ "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
71
71
  "requestSchema": "schema.json",
72
72
  "responseSchema": "schema.json",
73
73
  "timeout": 0,
@@ -88,7 +88,7 @@
88
88
  "name": "deleteGeneric",
89
89
  "protocol": "REST",
90
90
  "method": "DELETE",
91
- "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
91
+ "entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
92
92
  "requestSchema": "schema.json",
93
93
  "responseSchema": "schema.json",
94
94
  "timeout": 0,
@@ -0,0 +1,25 @@
1
+ {
2
+ "actions": [
3
+ {
4
+ "name": "getGraphql",
5
+ "protocol": "REST",
6
+ "method": "GET",
7
+ "entitypath": "/graphql/?{query}",
8
+ "requestSchema": "schema.json",
9
+ "responseSchema": "schema.json",
10
+ "timeout": 0,
11
+ "sendEmpty": false,
12
+ "sendGetBody": true,
13
+ "requestDatatype": "JSON",
14
+ "responseDatatype": "JSON",
15
+ "headers": {},
16
+ "responseObjects": [
17
+ {
18
+ "type": "default",
19
+ "key": "",
20
+ "mockFile": ""
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$id": "schema.json",
3
+ "type": "object",
4
+ "schema": "http://json-schema.org/draft-07/schema#",
5
+ "translate": false,
6
+ "dynamicfields": true,
7
+ "properties": {
8
+ "ph_request_type": {
9
+ "type": "string",
10
+ "description": "type of request (internal to adapter)",
11
+ "default": "getGraphql",
12
+ "enum": [
13
+ "getGraphql"
14
+ ],
15
+ "external_name": "ph_request_type"
16
+ }
17
+ },
18
+ "definitions": {}
19
+ }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-netbox_v210",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "This adapter integrates with system described as: Netbox v2.10",
5
5
  "main": "adapter.js",
6
- "wizardVersion": "2.44.5",
7
- "engineVersion": "1.59.28",
6
+ "wizardVersion": "2.44.7",
7
+ "engineVersion": "1.59.55",
8
8
  "adapterType": "http",
9
9
  "scripts": {
10
10
  "artifactize": "npm i && node utils/packModificationScript.js",
11
- "preinstall": "node utils/setup.js",
11
+ "preinstall": "node utils/setup.js && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
12
12
  "lint": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js",
13
13
  "lint:errors": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet",
14
14
  "test:baseunit": "mocha test/unit/adapterBaseTestUnit.js --LOG=error",
@@ -16,7 +16,7 @@
16
16
  "test:integration": "mocha test/integration/adapterTestIntegration.js --LOG=error",
17
17
  "test:cover": "nyc --reporter html --reporter text mocha --reporter dot test/*",
18
18
  "test": "npm run test:baseunit && npm run test:unit && npm run test:integration",
19
- "adapter:install": "node utils/tbScript.js install",
19
+ "adapter:install": "npm i && node utils/tbScript.js install",
20
20
  "adapter:checkMigrate": "node utils/checkMigrate.js",
21
21
  "adapter:findPath": "node utils/findPath.js",
22
22
  "adapter:migrate": "node utils/modify.js -m",
@@ -26,7 +26,7 @@
26
26
  "healthcheck": "node utils/tbScript.js healthcheck",
27
27
  "basicget": "node utils/tbScript.js basicget",
28
28
  "connectivity": "node utils/tbScript.js connectivity",
29
- "deploy": "npm publish --registry=http://registry.npmjs.org --access=public",
29
+ "deploy": "npm publish --registry=https://registry.npmjs.org --access=public",
30
30
  "build": "npm run deploy"
31
31
  },
32
32
  "keywords": [
@@ -53,13 +53,14 @@
53
53
  "author": "Itential",
54
54
  "homepage": "https://gitlab.com/itentialopensource/adapters/inventory/adapter-netbox_v210#readme",
55
55
  "dependencies": {
56
- "@itentialopensource/adapter-utils": "^4.44.0",
56
+ "@itentialopensource/adapter-utils": "^4.44.11",
57
57
  "ajv": "^6.12.0",
58
58
  "axios": "^0.21.0",
59
59
  "commander": "^2.20.0",
60
60
  "fs-extra": "^8.1.0",
61
61
  "mocha": "^9.0.1",
62
62
  "mocha-param": "^2.0.1",
63
+ "mongodb": "^4.1.0",
63
64
  "network-diagnostics": "^0.5.3",
64
65
  "nyc": "^15.1.0",
65
66
  "readline-sync": "^1.4.10",
@@ -75,5 +76,8 @@
75
76
  "package-json-validator": "^0.6.3",
76
77
  "testdouble": "^3.16.1"
77
78
  },
79
+ "resolutions": {
80
+ "minimist": "^1.2.5"
81
+ },
78
82
  "private": false
79
83
  }
package/pronghorn.json CHANGED
@@ -386,6 +386,198 @@
386
386
  },
387
387
  "task": true
388
388
  },
389
+ {
390
+ "name": "moveEntitiesToDB",
391
+ "summary": "Moves entities from an adapter into the IAP database",
392
+ "description": "Moves entities from an adapter into the IAP database",
393
+ "input": [],
394
+ "output": {
395
+ "name": "res",
396
+ "type": "object",
397
+ "description": "A JSON Object containing status, code and the response from the mongo transaction",
398
+ "schema": {
399
+ "title": "res",
400
+ "type": "object"
401
+ }
402
+ },
403
+ "roles": [
404
+ "admin"
405
+ ],
406
+ "route": {
407
+ "verb": "POST",
408
+ "path": "/moveEntitiesToDB"
409
+ },
410
+ "task": true
411
+ },
412
+ {
413
+ "name": "getDevice",
414
+ "summary": "Get the Appliance",
415
+ "description": "Get the Appliance",
416
+ "input": [
417
+ {
418
+ "name": "deviceName",
419
+ "type": "string",
420
+ "info": "An Appliance Device Name",
421
+ "required": true,
422
+ "schema": {
423
+ "title": "deviceName",
424
+ "type": "string"
425
+ }
426
+ }
427
+ ],
428
+ "output": {
429
+ "name": "result",
430
+ "type": "object",
431
+ "description": "A JSON Object containing status, code and the result",
432
+ "schema": {
433
+ "title": "result",
434
+ "type": "object"
435
+ }
436
+ },
437
+ "roles": [
438
+ "admin"
439
+ ],
440
+ "route": {
441
+ "verb": "POST",
442
+ "path": "/getDevice"
443
+ },
444
+ "task": false
445
+ },
446
+ {
447
+ "name": "getDevicesFiltered",
448
+ "summary": "Get Appliances that match the filter",
449
+ "description": "Get Appliances that match the filter",
450
+ "input": [
451
+ {
452
+ "name": "options",
453
+ "type": "object",
454
+ "info": "options - e.g. { 'start': 1, 'limit': 20, 'filter': { 'name': 'abc123' } }",
455
+ "required": true,
456
+ "schema": {
457
+ "title": "options",
458
+ "type": "object"
459
+ }
460
+ }
461
+ ],
462
+ "output": {
463
+ "name": "result",
464
+ "type": "array",
465
+ "description": "A JSON Object containing status, code and the result",
466
+ "schema": {
467
+ "title": "result",
468
+ "type": "array"
469
+ }
470
+ },
471
+ "roles": [
472
+ "admin"
473
+ ],
474
+ "route": {
475
+ "verb": "POST",
476
+ "path": "/getDevicesFiltered"
477
+ },
478
+ "task": false
479
+ },
480
+ {
481
+ "name": "isAlive",
482
+ "summary": "Checks the status for the provided Appliance",
483
+ "description": "Checks the status for the provided Appliance",
484
+ "input": [
485
+ {
486
+ "name": "deviceName",
487
+ "type": "string",
488
+ "info": "An Appliance Device Name",
489
+ "required": true,
490
+ "schema": {
491
+ "title": "deviceName",
492
+ "type": "string"
493
+ }
494
+ }
495
+ ],
496
+ "output": {
497
+ "name": "result",
498
+ "type": "boolean",
499
+ "description": "A JSON Object containing status, code and the result",
500
+ "schema": {
501
+ "title": "result",
502
+ "type": "boolean"
503
+ }
504
+ },
505
+ "roles": [
506
+ "admin"
507
+ ],
508
+ "route": {
509
+ "verb": "POST",
510
+ "path": "/isAlive"
511
+ },
512
+ "task": false
513
+ },
514
+ {
515
+ "name": "getConfig",
516
+ "summary": "Gets a config for the provided Appliance",
517
+ "description": "Gets a config for the provided Appliance",
518
+ "input": [
519
+ {
520
+ "name": "deviceName",
521
+ "type": "string",
522
+ "info": "An Appliance Device Name",
523
+ "required": true,
524
+ "schema": {
525
+ "title": "deviceName",
526
+ "type": "string"
527
+ }
528
+ },
529
+ {
530
+ "name": "format",
531
+ "type": "string",
532
+ "info": "The format to be returned - this is ignored as we always return json",
533
+ "required": false,
534
+ "schema": {
535
+ "title": "format",
536
+ "type": "string"
537
+ }
538
+ }
539
+ ],
540
+ "output": {
541
+ "name": "result",
542
+ "type": "object",
543
+ "description": "A JSON Object containing status, code and the result",
544
+ "schema": {
545
+ "title": "result",
546
+ "type": "object"
547
+ }
548
+ },
549
+ "roles": [
550
+ "admin"
551
+ ],
552
+ "route": {
553
+ "verb": "POST",
554
+ "path": "/getConfig"
555
+ },
556
+ "task": false
557
+ },
558
+ {
559
+ "name": "getCount",
560
+ "summary": "Gets a device count from the system",
561
+ "description": "Gets a device count from the system",
562
+ "input": [],
563
+ "output": {
564
+ "name": "result",
565
+ "type": "object",
566
+ "description": "A JSON Object containing status, code and the result",
567
+ "schema": {
568
+ "title": "result",
569
+ "type": "object"
570
+ }
571
+ },
572
+ "roles": [
573
+ "admin"
574
+ ],
575
+ "route": {
576
+ "verb": "POST",
577
+ "path": "/getCount"
578
+ },
579
+ "task": false
580
+ },
389
581
  {
390
582
  "name": "getCircuitsCircuitTerminations",
391
583
  "summary": "circuits_circuit-terminations_list",
@@ -150156,6 +150348,40 @@
150156
150348
  },
150157
150349
  "task": true
150158
150350
  },
150351
+ {
150352
+ "name": "getGraphql",
150353
+ "summary": "A lightweight read-only endpoint for conveying querying using graphql.",
150354
+ "description": "A lightweight read-only endpoint for conveying querying using graphql.",
150355
+ "input": [
150356
+ {
150357
+ "name": "body",
150358
+ "type": "object",
150359
+ "info": "JSON object containing the graphql query",
150360
+ "required": true,
150361
+ "schema": {
150362
+ "title": "body",
150363
+ "type": "object"
150364
+ }
150365
+ }
150366
+ ],
150367
+ "output": {
150368
+ "name": "result",
150369
+ "type": "object",
150370
+ "description": "A JSON Object containing status, code and the result",
150371
+ "schema": {
150372
+ "title": "result",
150373
+ "type": "object"
150374
+ }
150375
+ },
150376
+ "roles": [
150377
+ "admin"
150378
+ ],
150379
+ "route": {
150380
+ "verb": "GET",
150381
+ "path": "/getGraphql"
150382
+ },
150383
+ "task": true
150384
+ },
150159
150385
  {
150160
150386
  "name": "getTenancyTenantGroups",
150161
150387
  "summary": "tenancy_tenant-groups_list",
@@ -837,4 +837,4 @@
837
837
  }
838
838
  }
839
839
  }
840
- }
840
+ }
Binary file
@@ -0,0 +1,95 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 0
8
+ },
9
+ {
10
+ "owner": "errorJson",
11
+ "description": "Adapter errors no longer available for use",
12
+ "value": 0
13
+ },
14
+ {
15
+ "owner": "errorJson",
16
+ "description": "Adapter errors that have been updated (e.g. recommendation changes)",
17
+ "value": 30
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 13
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 7
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 23
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.44.11"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 64
43
+ },
44
+ {
45
+ "owner": "readmeMd",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 688
48
+ },
49
+ {
50
+ "owner": "unitTestJS",
51
+ "description": "Number of lines of code in unit tests",
52
+ "value": 18675
53
+ },
54
+ {
55
+ "owner": "unitTestJS",
56
+ "description": "Number of unit tests",
57
+ "value": 1250
58
+ },
59
+ {
60
+ "owner": "integrationTestJS",
61
+ "description": "Number of lines of code in integration tests",
62
+ "value": 18771
63
+ },
64
+ {
65
+ "owner": "integrationTestJS",
66
+ "description": "Number of integration tests",
67
+ "value": 607
68
+ },
69
+ {
70
+ "owner": "staticFile",
71
+ "description": "Number of lines of code in adapterBase.js",
72
+ "value": 1029
73
+ },
74
+ {
75
+ "owner": "staticFile",
76
+ "description": "Number of static files added",
77
+ "value": 34
78
+ },
79
+ {
80
+ "owner": "Overall",
81
+ "description": "Total lines of Code",
82
+ "value": 38475
83
+ },
84
+ {
85
+ "owner": "Overall",
86
+ "description": "Total Tests",
87
+ "value": 1857
88
+ },
89
+ {
90
+ "owner": "Overall",
91
+ "description": "Total Files",
92
+ "value": 6
93
+ }
94
+ ]
95
+ }
@@ -14,7 +14,10 @@ const winston = require('winston');
14
14
  const { expect } = require('chai');
15
15
  const { use } = require('chai');
16
16
  const td = require('testdouble');
17
+ const util = require('util');
18
+ const pronghorn = require('../../pronghorn.json');
17
19
 
20
+ pronghorn.methodsByName = pronghorn.methods.reduce((result, meth) => ({ ...result, [meth.name]: meth }), {});
18
21
  const anything = td.matchers.anything();
19
22
 
20
23
  // stub and attemptTimeout are used throughout the code so set them here
@@ -13351,6 +13354,31 @@ describe('[integration] Netbox_v210 Adapter Test', () => {
13351
13354
  }).timeout(attemptTimeout);
13352
13355
  });
13353
13356
 
13357
+ describe('#getGraphql - errors', () => {
13358
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
13359
+ try {
13360
+ a.getGraphql({ query: 'fakeq' }, (data, error) => {
13361
+ try {
13362
+ if (stub) {
13363
+ const displayE = 'Error 400 received on request';
13364
+ runErrorAsserts(data, error, 'AD.500', 'Test-netbox_v210-connectorRest-handleEndResponse', displayE);
13365
+ } else {
13366
+ runCommonAsserts(data, error);
13367
+ }
13368
+ saveMockData('Status', 'getGraphql', 'default', data);
13369
+ done();
13370
+ } catch (err) {
13371
+ log.error(`Test Failure: ${err}`);
13372
+ done(err);
13373
+ }
13374
+ });
13375
+ } catch (error) {
13376
+ log.error(`Adapter Exception: ${error}`);
13377
+ done(error);
13378
+ }
13379
+ }).timeout(attemptTimeout);
13380
+ });
13381
+
13354
13382
  let tenancyId = 'fakedata';
13355
13383
  const tenancyPostTenancyTenantGroupsBodyParam = {
13356
13384
  name: 'string',
@@ -317,7 +317,7 @@ describe('[unit] Adapter Base Test', () => {
317
317
  });
318
318
  it('should return a list of functions', (done) => {
319
319
  const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
320
- 'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck',
320
+ 'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck', 'moveEntitiesToDB',
321
321
  'refreshProperties', 'runBasicGet', 'runConnectivity', 'runHealthcheck', 'suspend', 'troubleshoot', 'unsuspend', 'updateAdapterConfiguration', 'addListener',
322
322
  'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
323
323
  'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];