@itentialopensource/adapter-infoblox 1.11.0 → 1.12.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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,20 @@
1
1
 
2
+ ## 1.12.1 [11-30-2022]
3
+
4
+ * Adapt 2543 Add and Update record calls
5
+
6
+ See merge request itentialopensource/adapters/inventory/adapter-infoblox!25
7
+
8
+ ---
9
+
10
+ ## 1.12.0 [08-24-2022]
11
+
12
+ * Added 2 calls
13
+
14
+ See merge request itentialopensource/adapters/inventory/adapter-infoblox!24
15
+
16
+ ---
17
+
2
18
  ## 1.11.0 [08-08-2022]
3
19
 
4
20
  * Add over 200 DNS Calls
package/adapter.js CHANGED
@@ -4930,8 +4930,8 @@ class Infoblox extends AdapterBaseCl {
4930
4930
  }
4931
4931
 
4932
4932
  /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
4933
- const queryParamsAvailable = { hostName };
4934
- const queryParams = {};
4933
+ const queryParamsAvailable = { name: hostName };
4934
+ const queryParams = { _return_fields: 'extattrs,ipv4addrs,name,view' };
4935
4935
  const pathVars = [];
4936
4936
  const bodyVars = {};
4937
4937
  if (query) {
@@ -5014,7 +5014,7 @@ class Infoblox extends AdapterBaseCl {
5014
5014
 
5015
5015
  /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
5016
5016
  const queryParamsAvailable = { name };
5017
- const queryParams = {};
5017
+ const queryParams = { _return_fields: 'extattrs,ipv4addr,name,view' };
5018
5018
  const pathVars = [];
5019
5019
  const bodyVars = {};
5020
5020
  if (query) {
@@ -10247,6 +10247,170 @@ class Infoblox extends AdapterBaseCl {
10247
10247
  }
10248
10248
  }
10249
10249
 
10250
+ /**
10251
+ * @summary Update a plain text file
10252
+ *
10253
+ * @function uploadFile
10254
+ * @param {string} urlFromUploadInitiation - The URI path of the file to upload. E.g. https://1.1.1.1/http_direct_file_io/req_id-UPLOAD-123/import_records
10255
+ * @param {string} filedata - The plain text file data to upload. Usually the CSV text.
10256
+ * @param {getCallback} callback - a callback function to return the result
10257
+ */
10258
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
10259
+ uploadFile(urlFromUploadInitiation, filedata, callback) {
10260
+ const meth = 'adapter-uploadFile';
10261
+ const origin = `${this.id}-${meth}`;
10262
+ log.trace(origin);
10263
+
10264
+ if (this.suspended && this.suspendMode === 'error') {
10265
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
10266
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10267
+ return callback(null, errorObj);
10268
+ }
10269
+
10270
+ /* HERE IS WHERE YOU VALIDATE DATA */
10271
+ if (!urlFromUploadInitiation) {
10272
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['urlFromUploadInitiation'], null, null, null);
10273
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10274
+ return callback(null, errorObj);
10275
+ }
10276
+
10277
+ if (!filedata) {
10278
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['filedata'], null, null, null);
10279
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10280
+ return callback(null, errorObj);
10281
+ }
10282
+
10283
+ // Grabs the URL Id from the urlFromUploadInitiation variable
10284
+ // The URL Id can then be templated into the URL path in the action.json file using a pathVar
10285
+ // Example urlFromUploadInitiation -- https://1.1.1.1/http_direct_file_io/req_id-UPLOAD-1111111111111111/import_records
10286
+ let uploadId;
10287
+ try {
10288
+ [uploadId] = urlFromUploadInitiation.match(/req_id-UPLOAD-[0-9]{16}/);
10289
+ } catch (ex) {
10290
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Unable to parse urlFromUploadInitiation', ['urlFromUploadInitiation'], null, null, null);
10291
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10292
+ return callback(null, errorObj);
10293
+ }
10294
+
10295
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
10296
+ const queryParams = {};
10297
+ const pathVars = [uploadId];
10298
+ const bodyVars = { filedata };
10299
+
10300
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
10301
+ const reqObj = {
10302
+ payload: bodyVars,
10303
+ uriPathVars: pathVars,
10304
+ uriQuery: queryParams
10305
+ };
10306
+
10307
+ try {
10308
+ // Make the call -
10309
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
10310
+ return this.requestHandlerInst.identifyRequest('FileOps', 'uploadFile', reqObj, true, (irReturnData, irReturnError) => {
10311
+ // if we received an error or their is no response on the results
10312
+ // return an error
10313
+ if (irReturnError) {
10314
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
10315
+ return callback(null, irReturnError);
10316
+ }
10317
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
10318
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['uploadFile'], null, null, null);
10319
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10320
+ return callback(null, errorObj);
10321
+ }
10322
+
10323
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
10324
+ // return the response
10325
+ return callback(irReturnData, null);
10326
+ });
10327
+ } catch (ex) {
10328
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
10329
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10330
+ return callback(null, errorObj);
10331
+ }
10332
+ }
10333
+
10334
+ /**
10335
+ * @summary Update a plain text file
10336
+ *
10337
+ * @function downloadFile
10338
+ * @param {string} urlFromDownloadInitiation - The URI path of the file to upload. E.g. https://1.1.1.1/http_direct_file_io/req_id-DOWNLOAD-111/csv-error.1.csv
10339
+ * @param {getCallback} callback - a callback function to return the result
10340
+ */
10341
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
10342
+ downloadFile(urlFromDownloadInitiation, callback) {
10343
+ const meth = 'adapter-downloadFile';
10344
+ const origin = `${this.id}-${meth}`;
10345
+ log.trace(origin);
10346
+
10347
+ if (this.suspended && this.suspendMode === 'error') {
10348
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
10349
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10350
+ return callback(null, errorObj);
10351
+ }
10352
+
10353
+ /* HERE IS WHERE YOU VALIDATE DATA */
10354
+ if (!urlFromDownloadInitiation) {
10355
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['urlFromDownloadInitiation'], null, null, null);
10356
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10357
+ return callback(null, errorObj);
10358
+ }
10359
+
10360
+ // Grabs the URL Id from the urlFromDownloadInitiation variable
10361
+ // The URL Id can then be templated into the URL path in the action.json file using a pathVar
10362
+ // Example urlFromDownloadInitiation -- https://1.1.1.1/http_direct_file_io/req_id-UPLOAD-1111111111111111/import_records
10363
+ let downloadId;
10364
+ let fileName;
10365
+ try {
10366
+ [downloadId] = urlFromDownloadInitiation.match(/req_id-DOWNLOAD-\d+/);
10367
+ [fileName] = urlFromDownloadInitiation.match(/csv-error\.\d+\.csv/);
10368
+ } catch (ex) {
10369
+ log.info(ex);
10370
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Unable to parse urlFromDownloadInitiation', ['urlFromDownloadInitiation'], null, null, null);
10371
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10372
+ return callback(null, errorObj);
10373
+ }
10374
+
10375
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
10376
+ const queryParams = {};
10377
+ const pathVars = [downloadId, fileName];
10378
+ const bodyVars = {};
10379
+
10380
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
10381
+ const reqObj = {
10382
+ payload: bodyVars,
10383
+ uriPathVars: pathVars,
10384
+ uriQuery: queryParams
10385
+ };
10386
+
10387
+ try {
10388
+ // Make the call -
10389
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
10390
+ return this.requestHandlerInst.identifyRequest('FileOps', 'downloadFile', reqObj, true, (irReturnData, irReturnError) => {
10391
+ // if we received an error or their is no response on the results
10392
+ // return an error
10393
+ if (irReturnError) {
10394
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
10395
+ return callback(null, irReturnError);
10396
+ }
10397
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
10398
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['downloadFile'], null, null, null);
10399
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10400
+ return callback(null, errorObj);
10401
+ }
10402
+
10403
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
10404
+ // return the response
10405
+ return callback(irReturnData, null);
10406
+ });
10407
+ } catch (ex) {
10408
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
10409
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
10410
+ return callback(null, errorObj);
10411
+ }
10412
+ }
10413
+
10250
10414
  /**
10251
10415
  * @summary Delete Extensible Attribute definition
10252
10416
  *
@@ -28212,6 +28376,204 @@ class Infoblox extends AdapterBaseCl {
28212
28376
  return callback(null, errorObj);
28213
28377
  }
28214
28378
  }
28379
+
28380
+ /**
28381
+ * @function getNetworkZoneAssociations
28382
+ * @pronghornType method
28383
+ * @name getNetworkZoneAssociations
28384
+ * @summary getNetworkZoneAssociations
28385
+ *
28386
+ * @param {string} networkId - The id of the network to get zones for
28387
+ * @param {string} networkView - The network view we are getting zones from
28388
+ * @param {object} [query] - The query parameters to include on the request
28389
+ * @return {object} results - An object containing the response of the action
28390
+ *
28391
+ * @route {POST} /getNetworkZoneAssociations
28392
+ * @roles admin
28393
+ * @task true
28394
+ */
28395
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
28396
+ getNetworkZoneAssociations(networkId, networkView, query, callback) {
28397
+ const meth = 'adapter-getNetworkZoneAssociations';
28398
+ const origin = `${this.id}-${meth}`;
28399
+ log.trace(origin);
28400
+
28401
+ if (this.suspended && this.suspendMode === 'error') {
28402
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
28403
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28404
+ return callback(null, errorObj);
28405
+ }
28406
+
28407
+ /* HERE IS WHERE YOU VALIDATE DATA */
28408
+ if (networkId === undefined || networkId === null || networkId === '') {
28409
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['networkId'], null, null, null);
28410
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28411
+ return callback(null, errorObj);
28412
+ }
28413
+ if (networkId.indexOf('/') < 1) {
28414
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['subnet mask in networkId'], null, null, null);
28415
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28416
+ return callback(null, errorObj);
28417
+ }
28418
+ const netParts = networkId.split('/');
28419
+ let netView = 'default';
28420
+ if (networkView) {
28421
+ netView = networkView;
28422
+ }
28423
+
28424
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
28425
+ let queryParamsAvailable = {};
28426
+ if (query) {
28427
+ queryParamsAvailable = query;
28428
+ }
28429
+ const queryParams = {};
28430
+ const pathVars = [netParts[0], netParts[1], netView];
28431
+ const bodyVars = {};
28432
+
28433
+ // loop in template. long callback arg name to avoid identifier conflicts
28434
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
28435
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
28436
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
28437
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
28438
+ }
28439
+ });
28440
+
28441
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
28442
+ // see adapter code documentation for more information on the request object's fields
28443
+ const reqObj = {
28444
+ payload: bodyVars,
28445
+ uriPathVars: pathVars,
28446
+ uriQuery: queryParams
28447
+ };
28448
+
28449
+ try {
28450
+ // Make the call -
28451
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
28452
+ return this.requestHandlerInst.identifyRequest('Networks', 'getNetworkZoneAssociations', reqObj, false, (irReturnData, irReturnError) => {
28453
+ // if we received an error or their is no response on the results
28454
+ // return an error
28455
+ if (irReturnError) {
28456
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
28457
+ return callback(null, irReturnError);
28458
+ }
28459
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
28460
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getNetworkZoneAssociations'], null, null, null);
28461
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28462
+ return callback(null, errorObj);
28463
+ }
28464
+
28465
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
28466
+ // return the response
28467
+ return callback(irReturnData, null);
28468
+ });
28469
+ } catch (ex) {
28470
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
28471
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28472
+ return callback(null, errorObj);
28473
+ }
28474
+ }
28475
+
28476
+ /**
28477
+ * @function addNetworkZoneAssociation
28478
+ * @pronghornType method
28479
+ * @name addNetworkZoneAssociation
28480
+ * @summary addNetworkZoneAssociation
28481
+ *
28482
+ * @param {string} networkId - The id of the network to get zones for
28483
+ * @param {string} networkView - The network view we are getting zones from
28484
+ * @param {object} [query] - The query parameters to include on the request
28485
+ * @param {object} body - The zone information to include on the request
28486
+ * @return {object} results - An object containing the response of the action
28487
+ *
28488
+ * @route {POST} /addNetworkZoneAssociation
28489
+ * @roles admin
28490
+ * @task true
28491
+ */
28492
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
28493
+ addNetworkZoneAssociation(networkId, networkView, query, body, callback) {
28494
+ const meth = 'adapter-addNetworkZoneAssociation';
28495
+ const origin = `${this.id}-${meth}`;
28496
+ log.trace(origin);
28497
+
28498
+ if (this.suspended && this.suspendMode === 'error') {
28499
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
28500
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28501
+ return callback(null, errorObj);
28502
+ }
28503
+
28504
+ /* HERE IS WHERE YOU VALIDATE DATA */
28505
+ if (networkId === undefined || networkId === null || networkId === '') {
28506
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['networkId'], null, null, null);
28507
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28508
+ return callback(null, errorObj);
28509
+ }
28510
+ if (networkId.indexOf('/') < 1) {
28511
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['subnet mask in networkId'], null, null, null);
28512
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28513
+ return callback(null, errorObj);
28514
+ }
28515
+ if (body === undefined || body === null || body === '') {
28516
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
28517
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28518
+ return callback(null, errorObj);
28519
+ }
28520
+ const netParts = networkId.split('/');
28521
+ let netView = 'default';
28522
+ if (networkView) {
28523
+ netView = networkView;
28524
+ }
28525
+
28526
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
28527
+ let queryParamsAvailable = {};
28528
+ if (query) {
28529
+ queryParamsAvailable = query;
28530
+ }
28531
+ const queryParams = {};
28532
+ const pathVars = [netParts[0], netParts[1], netView];
28533
+ const bodyVars = body;
28534
+
28535
+ // loop in template. long callback arg name to avoid identifier conflicts
28536
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
28537
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
28538
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
28539
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
28540
+ }
28541
+ });
28542
+
28543
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
28544
+ // see adapter code documentation for more information on the request object's fields
28545
+ const reqObj = {
28546
+ payload: bodyVars,
28547
+ uriPathVars: pathVars,
28548
+ uriQuery: queryParams
28549
+ };
28550
+
28551
+ try {
28552
+ // Make the call -
28553
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
28554
+ return this.requestHandlerInst.identifyRequest('Networks', 'addNetworkZoneAssociation', reqObj, false, (irReturnData, irReturnError) => {
28555
+ // if we received an error or their is no response on the results
28556
+ // return an error
28557
+ if (irReturnError) {
28558
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
28559
+ return callback(null, irReturnError);
28560
+ }
28561
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
28562
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['addNetworkZoneAssociation'], null, null, null);
28563
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28564
+ return callback(null, errorObj);
28565
+ }
28566
+
28567
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
28568
+ // return the response
28569
+ return callback(irReturnData, null);
28570
+ });
28571
+ } catch (ex) {
28572
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
28573
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
28574
+ return callback(null, errorObj);
28575
+ }
28576
+ }
28215
28577
  }
28216
28578
 
28217
28579
  module.exports = Infoblox;
@@ -0,0 +1,48 @@
1
+ {
2
+ "actions": [
3
+ {
4
+ "name": "uploadFile",
5
+ "protocol": "REST",
6
+ "method": "POST",
7
+ "entitypath": "/http_direct_file_io/{pathv1}/import_records",
8
+ "requestSchema": "requestSchema.json",
9
+ "responseSchema": "schema.json",
10
+ "timeout": 0,
11
+ "sendEmpty": false,
12
+ "sendGetBody": false,
13
+ "requestDatatype": "FORM",
14
+ "responseDatatype": "PLAIN",
15
+ "headers": {},
16
+ "responseObjects": [
17
+ {
18
+ "type": "default",
19
+ "key": "",
20
+ "mockFile": ""
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "name": "downloadFile",
26
+ "protocol": "REST",
27
+ "method": "GET",
28
+ "entitypath": "/http_direct_file_io/{pathv1}/{pathv2}",
29
+ "requestSchema": "schema.json",
30
+ "responseSchema": "schema.json",
31
+ "timeout": 0,
32
+ "sendEmpty": false,
33
+ "sendGetBody": false,
34
+ "requestDatatype": "",
35
+ "responseDatatype": "PLAIN",
36
+ "headers": {
37
+ "Content-Type": "application/force-download"
38
+ },
39
+ "responseObjects": [
40
+ {
41
+ "type": "default",
42
+ "key": "",
43
+ "mockFile": ""
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$id": "fileOps",
3
+ "type": "object",
4
+ "$schema": "http://json-schema.org/draft-07/schema#",
5
+ "translate": true,
6
+ "dynamicfields": true,
7
+ "properties": {
8
+ "ph_request_type": {
9
+ "$id": "/properties/ph_request_type",
10
+ "type": "string",
11
+ "description": "type of request (internal to adapter)",
12
+ "default": "uploadFile",
13
+ "enum": [
14
+ "uploadFile"
15
+ ],
16
+ "external_name": "ph_request_type"
17
+ },
18
+ "filedata": {
19
+ "type": "string",
20
+ "description": "",
21
+ "parse": false,
22
+ "encode": false,
23
+ "encrypt": {
24
+ "type": "AES",
25
+ "key": ""
26
+ },
27
+ "external_name": "filedata"
28
+ }
29
+ },
30
+ "definitions": {}
31
+ }
@@ -0,0 +1,20 @@
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": "uploadFile",
12
+ "enum": [
13
+ "uploadFile",
14
+ "downloadFile"
15
+ ],
16
+ "external_name": "ph_request_type"
17
+ }
18
+ },
19
+ "definitions": {}
20
+ }
@@ -418,6 +418,48 @@
418
418
  "mockFile": ""
419
419
  }
420
420
  ]
421
+ },
422
+ {
423
+ "name": "getNetworkZoneAssociations",
424
+ "protocol": "REST",
425
+ "method": "GET",
426
+ "entitypath": "{base_path}/{version}/network/{pathv1}/{pathv2}/{pathv3}?{query}",
427
+ "requestSchema": "requestSchema.json",
428
+ "responseSchema": "responseSchema.json",
429
+ "timeout": 0,
430
+ "sendEmpty": false,
431
+ "sendGetBody": false,
432
+ "requestDatatype": "JSON",
433
+ "responseDatatype": "JSON",
434
+ "headers": {},
435
+ "responseObjects": [
436
+ {
437
+ "type": "default",
438
+ "key": "",
439
+ "mockFile": ""
440
+ }
441
+ ]
442
+ },
443
+ {
444
+ "name": "addNetworkZoneAssociation",
445
+ "protocol": "REST",
446
+ "method": "PUT",
447
+ "entitypath": "{base_path}/{version}/network/{pathv1}/{pathv2}/{pathv3}?{query}",
448
+ "requestSchema": "requestSchema.json",
449
+ "responseSchema": "responseSchema.json",
450
+ "timeout": 0,
451
+ "sendEmpty": false,
452
+ "sendGetBody": false,
453
+ "requestDatatype": "JSON",
454
+ "responseDatatype": "JSON",
455
+ "headers": {},
456
+ "responseObjects": [
457
+ {
458
+ "type": "default",
459
+ "key": "",
460
+ "mockFile": ""
461
+ }
462
+ ]
421
463
  }
422
464
  ]
423
465
  }
@@ -27,7 +27,9 @@
27
27
  "deleteNetwork",
28
28
  "modifyNetworkBlock",
29
29
  "getNetworkContainerNextNetworkIps",
30
- "getIpv6NetworkContainerNextNetworkIps"
30
+ "getIpv6NetworkContainerNextNetworkIps",
31
+ "getNetworkZoneAssociations",
32
+ "addNetworkZoneAssociation"
31
33
  ],
32
34
  "external_name": "ph_request_type"
33
35
  },
@@ -25,7 +25,9 @@
25
25
  "deleteNetwork",
26
26
  "modifyNetworkBlock",
27
27
  "getNetworkContainerNextNetworkIps",
28
- "getIpv6NetworkContainerNextNetworkIps"
28
+ "getIpv6NetworkContainerNextNetworkIps",
29
+ "getNetworkZoneAssociations",
30
+ "addNetworkZoneAssociation"
29
31
  ],
30
32
  "external_name": "ph_request_type"
31
33
  },
@@ -428,7 +428,7 @@
428
428
  "requestSchema": "schema.json",
429
429
  "responseSchema": "schema.json",
430
430
  "timeout": 0,
431
- "sendEmpty": false,
431
+ "sendEmpty": true,
432
432
  "sendGetBody": false,
433
433
  "requestDatatype": "JSON",
434
434
  "responseDatatype": "JSON",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-infoblox",
3
- "version": "1.11.0",
3
+ "version": "1.12.1",
4
4
  "description": "Itential Infoblox Adapter",
5
5
  "main": "adapter.js",
6
6
  "systemName": "Infoblox",
package/pronghorn.json CHANGED
@@ -6657,6 +6657,84 @@
6657
6657
  },
6658
6658
  "task": true
6659
6659
  },
6660
+ {
6661
+ "name": "uploadFile",
6662
+ "summary": "Uploads a file to infoblox",
6663
+ "description": "Uploads a file to infoblox given a url destination",
6664
+ "input": [
6665
+ {
6666
+ "name": "urlFromUploadInitiation",
6667
+ "type": "string",
6668
+ "info": "The URI path of the file to upload. E.g. https://1.1.1.1/http_direct_file_io/req_id-UPLOAD-123/import_records",
6669
+ "required": true,
6670
+ "schema": {
6671
+ "title": "urlFromUploadInitiation",
6672
+ "type": "string"
6673
+ }
6674
+ },
6675
+ {
6676
+ "name": "filedata",
6677
+ "type": "string",
6678
+ "info": "The plain text file data to upload. Usually the CSV text.",
6679
+ "required": true,
6680
+ "schema": {
6681
+ "title": "filedata",
6682
+ "type": "string"
6683
+ }
6684
+ }
6685
+ ],
6686
+ "output": {
6687
+ "name": "result",
6688
+ "type": "object",
6689
+ "description": "A JSON Object containing status, code and the result",
6690
+ "schema": {
6691
+ "title": "result",
6692
+ "type": "object"
6693
+ }
6694
+ },
6695
+ "roles": [
6696
+ "admin"
6697
+ ],
6698
+ "route": {
6699
+ "verb": "POST",
6700
+ "path": "/uploadFile"
6701
+ },
6702
+ "task": true
6703
+ },
6704
+ {
6705
+ "name": "downloadFile",
6706
+ "summary": "Downloads a file from infoblox",
6707
+ "description": "Downloads a file from infoblox given a url destination",
6708
+ "input": [
6709
+ {
6710
+ "name": "urlFromDownloadInitiation",
6711
+ "type": "string",
6712
+ "info": "The URI path of the file to upload. E.g. https://1.1.1.1/http_direct_file_io/req_id-UPLOAD-123/import_records",
6713
+ "required": true,
6714
+ "schema": {
6715
+ "title": "urlFromDownloadInitiation",
6716
+ "type": "string"
6717
+ }
6718
+ }
6719
+ ],
6720
+ "output": {
6721
+ "name": "result",
6722
+ "type": "object",
6723
+ "description": "The resulting file specified in the urlFromDownloadInitiation",
6724
+ "schema": {
6725
+ "title": "result",
6726
+ "type": "object"
6727
+ }
6728
+ },
6729
+ "roles": [
6730
+ "admin"
6731
+ ],
6732
+ "route": {
6733
+ "verb": "POST",
6734
+ "path": "/uploadFile"
6735
+ },
6736
+ "task": true
6737
+ },
6660
6738
  {
6661
6739
  "name": "deleteExtensibleAttributeDefinition",
6662
6740
  "summary": "Delete Extensible Attribute definition",
@@ -20817,6 +20895,124 @@
20817
20895
  "path": "/deleteZoneStubByReference"
20818
20896
  },
20819
20897
  "task": true
20898
+ },
20899
+ {
20900
+ "name": "getNetworkZoneAssociations",
20901
+ "summary": "getNetworkZoneAssociations",
20902
+ "description": "getNetworkZoneAssociations",
20903
+ "input": [
20904
+ {
20905
+ "name": "networkId",
20906
+ "type": "string",
20907
+ "info": "The id of the network to get zones for",
20908
+ "required": true,
20909
+ "schema": {
20910
+ "title": "networkId",
20911
+ "type": "string"
20912
+ }
20913
+ },
20914
+ {
20915
+ "name": "networkView",
20916
+ "type": "string",
20917
+ "info": "The network view we are getting zones from",
20918
+ "required": false,
20919
+ "schema": {
20920
+ "title": "networkView",
20921
+ "type": "string"
20922
+ }
20923
+ },
20924
+ {
20925
+ "name": "query",
20926
+ "type": "object",
20927
+ "info": "The query parameters to include on the request",
20928
+ "required": false,
20929
+ "schema": {
20930
+ "title": "query",
20931
+ "type": "object"
20932
+ }
20933
+ }
20934
+ ],
20935
+ "output": {
20936
+ "name": "result",
20937
+ "type": "object",
20938
+ "description": "A JSON Object containing status, code and the result",
20939
+ "schema": {
20940
+ "title": "result",
20941
+ "type": "object"
20942
+ }
20943
+ },
20944
+ "roles": [
20945
+ "admin"
20946
+ ],
20947
+ "route": {
20948
+ "verb": "POST",
20949
+ "path": "/getNetworkZoneAssociations"
20950
+ },
20951
+ "task": true
20952
+ },
20953
+ {
20954
+ "name": "addNetworkZoneAssociation",
20955
+ "summary": "addNetworkZoneAssociation",
20956
+ "description": "addNetworkZoneAssociation",
20957
+ "input": [
20958
+ {
20959
+ "name": "networkId",
20960
+ "type": "string",
20961
+ "info": "The id of the network to get zones for",
20962
+ "required": true,
20963
+ "schema": {
20964
+ "title": "networkId",
20965
+ "type": "string"
20966
+ }
20967
+ },
20968
+ {
20969
+ "name": "networkView",
20970
+ "type": "string",
20971
+ "info": "The network view we are getting zones from",
20972
+ "required": false,
20973
+ "schema": {
20974
+ "title": "networkView",
20975
+ "type": "string"
20976
+ }
20977
+ },
20978
+ {
20979
+ "name": "query",
20980
+ "type": "object",
20981
+ "info": "The query parameters to include on the request",
20982
+ "required": false,
20983
+ "schema": {
20984
+ "title": "query",
20985
+ "type": "object"
20986
+ }
20987
+ },
20988
+ {
20989
+ "name": "body",
20990
+ "type": "object",
20991
+ "info": "The zone information to include on the request",
20992
+ "required": true,
20993
+ "schema": {
20994
+ "title": "body",
20995
+ "type": "object"
20996
+ }
20997
+ }
20998
+ ],
20999
+ "output": {
21000
+ "name": "result",
21001
+ "type": "object",
21002
+ "description": "A JSON Object containing status, code and the result",
21003
+ "schema": {
21004
+ "title": "result",
21005
+ "type": "object"
21006
+ }
21007
+ },
21008
+ "roles": [
21009
+ "admin"
21010
+ ],
21011
+ "route": {
21012
+ "verb": "POST",
21013
+ "path": "/addNetworkZoneAssociation"
21014
+ },
21015
+ "task": true
20820
21016
  }
20821
21017
  ]
20822
21018
  }
Binary file
@@ -1,10 +1,10 @@
1
1
  {
2
- "version": "1.10.1",
3
- "configLines": 22273,
2
+ "version": "1.12.0",
3
+ "configLines": 22469,
4
4
  "scriptLines": 1707,
5
- "codeLines": 30001,
6
- "testLines": 22131,
7
- "testCases": 1093,
8
- "totalCodeLines": 53839,
9
- "wfTasks": 394
5
+ "codeLines": 30363,
6
+ "testLines": 22420,
7
+ "testCases": 1109,
8
+ "totalCodeLines": 54490,
9
+ "wfTasks": 398
10
10
  }
@@ -3340,6 +3340,61 @@ describe('[integration] Infoblox Adapter Test', () => {
3340
3340
  }).timeout(attemptTimeout);
3341
3341
  });
3342
3342
 
3343
+ const urlFromUploadInitiation = 'https://1.1.1.1/http_direct_file_io/req_id-UPLOAD-1111111111111111/import_records';
3344
+ const fileData = 'filedata';
3345
+
3346
+ describe('#uploadFile - errors', () => {
3347
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
3348
+ try {
3349
+ a.uploadFile(urlFromUploadInitiation, fileData, (data, error) => {
3350
+ try {
3351
+ if (stub) {
3352
+ const displayE = 'Error 400 received on request';
3353
+ runErrorAsserts(data, error, 'AD.500', 'Test-infoblox-connectorRest-handleEndResponse', displayE);
3354
+ } else {
3355
+ runCommonAsserts(data, error);
3356
+ }
3357
+ saveMockData('FileOps', 'uploadFile', 'default', data);
3358
+ done();
3359
+ } catch (err) {
3360
+ log.error(`Test Failure: ${err}`);
3361
+ done(err);
3362
+ }
3363
+ });
3364
+ } catch (error) {
3365
+ log.error(`Adapter Exception: ${error}`);
3366
+ done(error);
3367
+ }
3368
+ }).timeout(attemptTimeout);
3369
+ });
3370
+
3371
+ const urlFromDownloadInitiation = 'https://1.1.1.1/http_direct_file_io/req_id-DOWNLOAD-111/csv-error.1.csv';
3372
+
3373
+ describe('#downloadFile - errors', () => {
3374
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
3375
+ try {
3376
+ a.downloadFile(urlFromDownloadInitiation, (data, error) => {
3377
+ try {
3378
+ if (stub) {
3379
+ const displayE = 'Error 400 received on request';
3380
+ runErrorAsserts(data, error, 'AD.500', 'Test-infoblox-connectorRest-handleEndResponse', displayE);
3381
+ } else {
3382
+ runCommonAsserts(data, error);
3383
+ }
3384
+ saveMockData('FileOps', 'downloadFile', 'default', data);
3385
+ done();
3386
+ } catch (err) {
3387
+ log.error(`Test Failure: ${err}`);
3388
+ done(err);
3389
+ }
3390
+ });
3391
+ } catch (error) {
3392
+ log.error(`Adapter Exception: ${error}`);
3393
+ done(error);
3394
+ }
3395
+ }).timeout(attemptTimeout);
3396
+ });
3397
+
3343
3398
  const zonesZoneRef = 'fakedata';
3344
3399
 
3345
3400
  describe('#deleteAuthZoneByRef - errors', () => {
@@ -10244,5 +10299,55 @@ describe('[integration] Infoblox Adapter Test', () => {
10244
10299
  }
10245
10300
  }).timeout(attemptTimeout);
10246
10301
  });
10302
+
10303
+ describe('#addNetworkZoneAssociation - errors', () => {
10304
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
10305
+ try {
10306
+ a.addNetworkZoneAssociation('fakedata/16', null, null, { key: 'value' }, (data, error) => {
10307
+ try {
10308
+ if (stub) {
10309
+ const displayE = 'Error 400 received on request';
10310
+ runErrorAsserts(data, error, 'AD.500', 'Test-infoblox-connectorRest-handleEndResponse', displayE);
10311
+ } else {
10312
+ runCommonAsserts(data, error);
10313
+ }
10314
+ saveMockData('Networks', 'addNetworkZoneAssociation', 'default', data);
10315
+ done();
10316
+ } catch (err) {
10317
+ log.error(`Test Failure: ${err}`);
10318
+ done(err);
10319
+ }
10320
+ });
10321
+ } catch (error) {
10322
+ log.error(`Adapter Exception: ${error}`);
10323
+ done(error);
10324
+ }
10325
+ }).timeout(attemptTimeout);
10326
+ });
10327
+
10328
+ describe('#getNetworkZoneAssociations - errors', () => {
10329
+ it('should work if integrated but since no mockdata should error when run standalone', (done) => {
10330
+ try {
10331
+ a.getNetworkZoneAssociations('fakedata/16', null, null, (data, error) => {
10332
+ try {
10333
+ if (stub) {
10334
+ const displayE = 'Error 400 received on request';
10335
+ runErrorAsserts(data, error, 'AD.500', 'Test-infoblox-connectorRest-handleEndResponse', displayE);
10336
+ } else {
10337
+ runCommonAsserts(data, error);
10338
+ }
10339
+ saveMockData('Networks', 'getNetworkZoneAssociations', 'default', data);
10340
+ done();
10341
+ } catch (err) {
10342
+ log.error(`Test Failure: ${err}`);
10343
+ done(err);
10344
+ }
10345
+ });
10346
+ } catch (error) {
10347
+ log.error(`Adapter Exception: ${error}`);
10348
+ done(error);
10349
+ }
10350
+ }).timeout(attemptTimeout);
10351
+ });
10247
10352
  });
10248
10353
  });
@@ -4309,6 +4309,81 @@ describe('[unit] Infoblox Adapter Test', () => {
4309
4309
  }).timeout(attemptTimeout);
4310
4310
  });
4311
4311
 
4312
+ describe('#uploadFile - errors', () => {
4313
+ it('should have a uploadFile function', (done) => {
4314
+ try {
4315
+ assert.equal(true, typeof a.uploadFile === 'function');
4316
+ done();
4317
+ } catch (error) {
4318
+ log.error(`Test Failure: ${error}`);
4319
+ done(error);
4320
+ }
4321
+ }).timeout(attemptTimeout);
4322
+ it('should error if - missing urlFromUploadInitiation', (done) => {
4323
+ try {
4324
+ a.uploadFile(null, 'filedata', (data, error) => {
4325
+ try {
4326
+ const displayE = 'urlFromUploadInitiation is required';
4327
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-uploadFile', displayE);
4328
+ done();
4329
+ } catch (err) {
4330
+ log.error(`Test Failure: ${err}`);
4331
+ done(err);
4332
+ }
4333
+ });
4334
+ } catch (error) {
4335
+ log.error(`Adapter Exception: ${error}`);
4336
+ done(error);
4337
+ }
4338
+ }).timeout(attemptTimeout);
4339
+ it('should error if - missing filedata', (done) => {
4340
+ try {
4341
+ a.uploadFile('https://1.1.1.1/http_direct_file_io/req_id-UPLOAD-1111111111111111/import_records', null, (data, error) => {
4342
+ try {
4343
+ const displayE = 'filedata is required';
4344
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-uploadFile', displayE);
4345
+ done();
4346
+ } catch (err) {
4347
+ log.error(`Test Failure: ${err}`);
4348
+ done(err);
4349
+ }
4350
+ });
4351
+ } catch (error) {
4352
+ log.error(`Adapter Exception: ${error}`);
4353
+ done(error);
4354
+ }
4355
+ }).timeout(attemptTimeout);
4356
+ });
4357
+
4358
+ describe('#downloadFile - errors', () => {
4359
+ it('should have a downloadFile function', (done) => {
4360
+ try {
4361
+ assert.equal(true, typeof a.downloadFile === 'function');
4362
+ done();
4363
+ } catch (error) {
4364
+ log.error(`Test Failure: ${error}`);
4365
+ done(error);
4366
+ }
4367
+ }).timeout(attemptTimeout);
4368
+ it('should error if - missing urlFromDownloadInitiation', (done) => {
4369
+ try {
4370
+ a.downloadFile(null, (data, error) => {
4371
+ try {
4372
+ const displayE = 'urlFromDownloadInitiation is required';
4373
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-downloadFile', displayE);
4374
+ done();
4375
+ } catch (err) {
4376
+ log.error(`Test Failure: ${err}`);
4377
+ done(err);
4378
+ }
4379
+ });
4380
+ } catch (error) {
4381
+ log.error(`Adapter Exception: ${error}`);
4382
+ done(error);
4383
+ }
4384
+ }).timeout(attemptTimeout);
4385
+ });
4386
+
4312
4387
  describe('#deleteExtensibleAttributeDefinition - errors', () => {
4313
4388
  it('should have a deleteExtensibleAttributeDefinition function', (done) => {
4314
4389
  try {
@@ -10747,5 +10822,114 @@ describe('[unit] Infoblox Adapter Test', () => {
10747
10822
  }
10748
10823
  }).timeout(attemptTimeout);
10749
10824
  });
10825
+
10826
+ describe('#getNetworkZoneAssociations - errors', () => {
10827
+ it('should have a getNetworkZoneAssociations function', (done) => {
10828
+ try {
10829
+ assert.equal(true, typeof a.getNetworkZoneAssociations === 'function');
10830
+ done();
10831
+ } catch (error) {
10832
+ log.error(`Test Failure: ${error}`);
10833
+ done(error);
10834
+ }
10835
+ }).timeout(attemptTimeout);
10836
+ it('should error if - missing networkId', (done) => {
10837
+ try {
10838
+ a.getNetworkZoneAssociations(null, null, null, (data, error) => {
10839
+ try {
10840
+ const displayE = 'networkId is required';
10841
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-getNetworkZoneAssociations', displayE);
10842
+ done();
10843
+ } catch (err) {
10844
+ log.error(`Test Failure: ${err}`);
10845
+ done(err);
10846
+ }
10847
+ });
10848
+ } catch (error) {
10849
+ log.error(`Adapter Exception: ${error}`);
10850
+ done(error);
10851
+ }
10852
+ }).timeout(attemptTimeout);
10853
+ it('should error if - missing networkId subnet mask', (done) => {
10854
+ try {
10855
+ a.getNetworkZoneAssociations('fakedata', null, null, (data, error) => {
10856
+ try {
10857
+ const displayE = 'subnet mask in networkId is required';
10858
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-getNetworkZoneAssociations', displayE);
10859
+ done();
10860
+ } catch (err) {
10861
+ log.error(`Test Failure: ${err}`);
10862
+ done(err);
10863
+ }
10864
+ });
10865
+ } catch (error) {
10866
+ log.error(`Adapter Exception: ${error}`);
10867
+ done(error);
10868
+ }
10869
+ }).timeout(attemptTimeout);
10870
+ });
10871
+
10872
+ describe('#addNetworkZoneAssociation - errors', () => {
10873
+ it('should have a addNetworkZoneAssociation function', (done) => {
10874
+ try {
10875
+ assert.equal(true, typeof a.addNetworkZoneAssociation === 'function');
10876
+ done();
10877
+ } catch (error) {
10878
+ log.error(`Test Failure: ${error}`);
10879
+ done(error);
10880
+ }
10881
+ }).timeout(attemptTimeout);
10882
+ it('should error if - missing networkId', (done) => {
10883
+ try {
10884
+ a.addNetworkZoneAssociation(null, null, null, null, (data, error) => {
10885
+ try {
10886
+ const displayE = 'networkId is required';
10887
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-addNetworkZoneAssociation', displayE);
10888
+ done();
10889
+ } catch (err) {
10890
+ log.error(`Test Failure: ${err}`);
10891
+ done(err);
10892
+ }
10893
+ });
10894
+ } catch (error) {
10895
+ log.error(`Adapter Exception: ${error}`);
10896
+ done(error);
10897
+ }
10898
+ }).timeout(attemptTimeout);
10899
+ it('should error if - missing networkId subnet mask', (done) => {
10900
+ try {
10901
+ a.addNetworkZoneAssociation('fakedata', null, null, null, (data, error) => {
10902
+ try {
10903
+ const displayE = 'subnet mask in networkId is required';
10904
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-addNetworkZoneAssociation', displayE);
10905
+ done();
10906
+ } catch (err) {
10907
+ log.error(`Test Failure: ${err}`);
10908
+ done(err);
10909
+ }
10910
+ });
10911
+ } catch (error) {
10912
+ log.error(`Adapter Exception: ${error}`);
10913
+ done(error);
10914
+ }
10915
+ }).timeout(attemptTimeout);
10916
+ it('should error if - missing body', (done) => {
10917
+ try {
10918
+ a.addNetworkZoneAssociation('fakedata/16', null, null, null, (data, error) => {
10919
+ try {
10920
+ const displayE = 'body is required';
10921
+ runErrorAsserts(data, error, 'AD.300', 'Test-infoblox-adapter-addNetworkZoneAssociation', displayE);
10922
+ done();
10923
+ } catch (err) {
10924
+ log.error(`Test Failure: ${err}`);
10925
+ done(err);
10926
+ }
10927
+ });
10928
+ } catch (error) {
10929
+ log.error(`Adapter Exception: ${error}`);
10930
+ done(error);
10931
+ }
10932
+ }).timeout(attemptTimeout);
10933
+ });
10750
10934
  });
10751
10935
  });