@itentialopensource/adapter-meraki 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +12 -12
  3. package/CHANGELOG.md +32 -0
  4. package/README.md +270 -68
  5. package/adapter.js +2786 -24
  6. package/adapterBase.js +544 -17
  7. package/entities/.generic/action.json +109 -0
  8. package/entities/.generic/schema.json +23 -0
  9. package/entities/.system/action.json +1 -1
  10. package/entities/CameraQualityRetentionProfiles/action.json +3 -0
  11. package/entities/ConnectivityMonitoringDestinations/action.json +1 -0
  12. package/entities/DashboardBrandingPolicies/action.json +4 -0
  13. package/entities/Floorplans/action.json +3 -0
  14. package/entities/Licenses/action.json +5 -0
  15. package/entities/LinkAggregations/action.json +3 -0
  16. package/entities/MGConnectivityMonitoringDestinations/action.json +1 -0
  17. package/entities/MGDHCPSettings/action.json +1 -0
  18. package/entities/MGLANSettings/action.json +1 -0
  19. package/entities/MGPortforwardingRules/action.json +1 -0
  20. package/entities/MGSubnetPoolSettings/action.json +1 -0
  21. package/entities/MGUplinkSettings/action.json +1 -0
  22. package/entities/MXVLANPorts/action.json +1 -0
  23. package/entities/MXWarmSpareSettings/action.json +2 -0
  24. package/entities/NetFlowSettings/action.json +1 -0
  25. package/entities/Switch settings/action.json +9 -0
  26. package/entities/SwitchACLs/action.json +1 -0
  27. package/entities/SwitchPortsSchedules/action.json +3 -0
  28. package/entities/TrafficAnalysisSettings/action.json +1 -0
  29. package/entities/WirelessSettings/action.json +1 -0
  30. package/error.json +6 -0
  31. package/package.json +45 -23
  32. package/pronghorn.json +586 -16
  33. package/propertiesSchema.json +84 -11
  34. package/refs?service=git-upload-pack +0 -0
  35. package/report/meraki-newcalls-OpenApi3Json.json +5460 -0
  36. package/report/updateReport1594225126093.json +95 -0
  37. package/report/updateReport1615384306128.json +95 -0
  38. package/report/updateReport1642739939352.json +95 -0
  39. package/sampleProperties.json +20 -5
  40. package/test/integration/adapterTestBasicGet.js +85 -0
  41. package/test/integration/adapterTestConnectivity.js +93 -0
  42. package/test/integration/adapterTestIntegration.js +30 -11
  43. package/test/unit/adapterBaseTestUnit.js +944 -0
  44. package/test/unit/adapterTestUnit.js +638 -12
  45. package/utils/addAuth.js +94 -0
  46. package/utils/artifactize.js +9 -14
  47. package/utils/basicGet.js +50 -0
  48. package/utils/checkMigrate.js +63 -0
  49. package/utils/entitiesToDB.js +224 -0
  50. package/utils/findPath.js +74 -0
  51. package/utils/modify.js +154 -0
  52. package/utils/packModificationScript.js +1 -1
  53. package/utils/patches2bundledDeps.js +90 -0
  54. package/utils/pre-commit.sh +1 -1
  55. package/utils/removeHooks.js +20 -0
  56. package/utils/tbScript.js +169 -0
  57. package/utils/tbUtils.js +451 -0
  58. package/utils/troubleshootingAdapter.js +190 -0
  59. package/gl-code-quality-report.json +0 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Meraki Adapter
1
+ # Adapter for Meraki
2
2
 
3
3
  This adapter is used to integrate the Itential Automation Platform (IAP) with the Meraki System. The API for Meraki is available at [undefined API URL]. The adapter utilizes the Meraki API to provide the integrations that are deemed pertinent to IAP. This ReadMe file is intended to provide information on this adapter.
4
4
 
@@ -22,12 +22,31 @@ Release notes can be viewed in CHANGELOG.md or in the [Customer Knowledge Base](
22
22
 
23
23
  These instructions will help you get a copy of the project on your local machine for development and testing. Reading this section is also helpful for deployments as it provides you with pertinent information on prerequisites and properties.
24
24
 
25
+ ### Adapter Technical Resources
26
+
27
+ There is adapter documentation available on the Itential Developer Site [HERE](https://developer.itential.io/adapters-resources/). This documentation includes information and examples that are helpful for:
28
+
29
+ ```text
30
+ Authentication
31
+ Properties
32
+ Code Files
33
+ Action Files
34
+ Schema Files
35
+ Mock Data Files
36
+ Linting and Testing
37
+ Troubleshooting
38
+ ```
39
+
40
+ Others will be added over time.
41
+ Want to build a new adapter? Use the Adapter Builder [HERE](https://adapters.itential.io)
42
+
25
43
  ### Environment Prerequisites
26
44
 
27
45
  The following is a list of required packages for an adapter.
28
46
 
29
- ```json
47
+ ```text
30
48
  Node.js
49
+ npm
31
50
  Git
32
51
  ```
33
52
 
@@ -39,21 +58,29 @@ The following list of packages are required for Itential product adapters or cus
39
58
  | ------- | ------- |
40
59
  | @itentialopensource/adapter-utils | Runtime library classes for all adapters; includes request handling, connection, throttling, and translation. |
41
60
  | ajv | Required for validation of adapter properties to integrate with Meraki. |
61
+ | axios | Utilized by the node scripts that are included with the adapter; helps to build and extend the functionality. |
62
+ | commander | Utilized by the node scripts that are included with the adapter; helps to build and extend the functionality. |
42
63
  | fs-extra | Utilized by the node scripts that are included with the adapter; helps to build and extend the functionality. |
43
- | readline-sync | Utilized by the testRunner script that comes with the adapter; helps to test unit and integration functionality. |
64
+ | network-diagnostics | Utilized by the node scripts that are included with the adapter; helps to build and extend the functionality. |
65
+ | readline-sync | Utilized by the node script that comes with the adapter; helps to test unit and integration functionality. |
66
+ | semver | Utilized by the node scripts that are included with the adapter; helps to build and extend the functionality. |
67
+
68
+ Some of the adapter node scripts run testing scripts which require the dev dependencies listed below.
44
69
 
45
70
  ### Additional Prerequisites for Development and Testing
46
71
 
47
72
  If you are developing and testing a custom adapter, or have testing capabilities on an Itential product adapter, you will need to install these packages as well.
48
73
 
49
- ```json
74
+ ```text
50
75
  chai
51
76
  eslint
52
77
  eslint-config-airbnb-base
53
78
  eslint-plugin-import
54
79
  eslint-plugin-json
55
80
  mocha
81
+ mocha-param
56
82
  nyc
83
+ package-json-validator
57
84
  testdouble
58
85
  winston
59
86
  ```
@@ -62,7 +89,7 @@ winston
62
89
 
63
90
  The following provides a local copy of the repository along with adapter dependencies.
64
91
 
65
- ```json
92
+ ```bash
66
93
  git clone git@gitlab.com:\@itentialopensource/adapters/adapter-meraki
67
94
  npm install
68
95
  ```
@@ -80,6 +107,7 @@ This section defines **all** the properties that are available for the adapter,
80
107
  "base_path": "/",
81
108
  "version": "v1",
82
109
  "cache_location": "local",
110
+ "encode_pathvars": true,
83
111
  "save_metric": true,
84
112
  "stub": false,
85
113
  "protocol": "https",
@@ -87,20 +115,23 @@ This section defines **all** the properties that are available for the adapter,
87
115
  "auth_method": "basic user_password",
88
116
  "username": "username",
89
117
  "password": "password",
90
- "auth_field": "header.headers.X-AUTH-TOKEN",
91
- "auth_field_format": "{token}",
92
118
  "token": "token",
93
119
  "invalid_token_error": 401,
94
120
  "token_timeout": 0,
95
- "token_cache": "local"
121
+ "token_cache": "local",
122
+ "auth_field": "header.headers.X-AUTH-TOKEN",
123
+ "auth_field_format": "{token}",
124
+ "auth_logging": false
96
125
  },
97
126
  "healthcheck": {
98
127
  "type": "startup",
99
- "frequency": 300000
128
+ "frequency": 300000,
129
+ "query_object": {}
100
130
  },
101
131
  "request": {
132
+ "number_redirects": 0,
102
133
  "number_retries": 3,
103
- "limit_retry_error": 401,
134
+ "limit_retry_error": [401],
104
135
  "failover_codes": [404, 405],
105
136
  "attempt_timeout": 5000,
106
137
  "global_request": {
@@ -111,13 +142,16 @@ This section defines **all** the properties that are available for the adapter,
111
142
  },
112
143
  "healthcheck_on_timeout": false,
113
144
  "return_raw": false,
114
- "archiving": false
145
+ "archiving": false,
146
+ "return_request": false
115
147
  },
116
148
  "ssl": {
117
149
  "ecdhCurve": "",
118
150
  "enabled": false,
119
151
  "accept_invalid_cert": false,
120
152
  "ca_file": "",
153
+ "key_file": "",
154
+ "cert_file": "",
121
155
  "secure_protocol": "",
122
156
  "ciphers": ""
123
157
  },
@@ -128,20 +162,31 @@ This section defines **all** the properties that are available for the adapter,
128
162
  "max_in_queue": 1000,
129
163
  "concurrent_max": 1,
130
164
  "expire_timeout": 0,
131
- "avg_runtime": 200
165
+ "avg_runtime": 200,
166
+ "priorities": []
132
167
  },
133
168
  "proxy": {
134
169
  "enabled": false,
135
170
  "host": "localhost",
136
171
  "port": 9999,
137
- "protocol": "http"
172
+ "protocol": "http",
173
+ "username": "",
174
+ "password": "",
138
175
  },
139
176
  "mongo": {
140
177
  "host": "",
141
178
  "port": 0,
142
179
  "database": "",
143
180
  "username": "",
144
- "password": ""
181
+ "password": "",
182
+ "replSet": "",
183
+ "db_ssl": {
184
+ "enabled": false,
185
+ "accept_invalid_cert": false,
186
+ "ca_file": "",
187
+ "key_file": "",
188
+ "cert_file": ""
189
+ }
145
190
  }
146
191
  },
147
192
  "type": "YOUR ADAPTER CLASS"
@@ -159,6 +204,7 @@ These base properties are used to connect to Meraki upon the adapter initially c
159
204
  | base_path | Optional. Used to define part of a path that is consistent for all or most endpoints. It makes the URIs easier to use and maintain but can be overridden on individual calls. An example **base_path** might be `/rest/api`. Default is ``.|
160
205
  | version | Optional. Used to set a global version for action endpoints. This makes it faster to update the adapter when endpoints change. As with the base-path, version can be overridden on individual endpoints. Default is ``.|
161
206
  | cache\_location | Optional. Used to define where the adapter cache is located. The cache is used to maintain an entity list to improve performance. Storage locally is lost when the adapter is restarted. Storage in Redis is preserved upon adapter restart. Default is none which means no caching of the entity list.|
207
+ | encode\_pathvars | Optional. Used to tell the adapter to encode path variables or not. The default behavior is to encode them so this property can b e used to stop that behavior.|
162
208
  | save\_metric | Optional. Used to tell the adapter to save metric information (this does not impact metrics returned on calls). This allows the adapter to gather metrics over time. Metric data can be stored in a database or on the file system.|
163
209
  | stub | Optional. Indicates whether the stub should run instead of making calls to Meraki (very useful during basic testing). Default is false (which means connect to Meraki).|
164
210
  | protocol | Optional. Notifies the adapter whether to use HTTP or HTTPS. Default is HTTP.|
@@ -176,19 +222,20 @@ The following properties are used to define the authentication process to Meraki
176
222
  | auth\_method | Required. Used to define the type of authentication currently supported. Authentication methods currently supported are: `basic user_password`, `static_token`, `request_token`, and `no_authentication`.|
177
223
  | username | Used to authenticate with Meraki on every request or when pulling a token that will be used in subsequent requests.|
178
224
  | password | Used to authenticate with Meraki on every request or when pulling a token that will be used in subsequent requests.|
179
- | auth\_field | Defines the request field the authentication (e.g., token are basic auth credentials) needs to be placed in order for the calls to work.|
180
- | auth\_field\_format | Defines the format of the auth\_field. See examples below. Items enclosed in {} inform the adapter to perofrm an action prior to sending the data. It may be to replace the item with a value or it may be to encode the item. |
181
225
  | token | Defines a static token that can be used on all requests. Only used with `static_token` as an authentication method (auth\_method).|
182
226
  | invalid\_token\_error | Defines the HTTP error that is received when the token is invalid. Notifies the adapter to pull a new token and retry the request. Default is 401.|
183
227
  | token\_timeout | Defines how long a token is valid. Measured in milliseconds. Once a dynamic token is no longer valid, the adapter has to pull a new token. If the token\_timeout is set to -1, the adapter will pull a token on every request to Meraki. If the timeout\_token is 0, the adapter will use the expiration from the token response to determine when the token is no longer valid.|
184
228
  | token\_cache | Used to determine where the token should be stored (local memory or in Redis).|
229
+ | auth\_field | Defines the request field the authentication (e.g., token are basic auth credentials) needs to be placed in order for the calls to work.|
230
+ | auth\_field\_format | Defines the format of the auth\_field. See examples below. Items enclosed in {} inform the adapter to perofrm an action prior to sending the data. It may be to replace the item with a value or it may be to encode the item. |
231
+ | auth\_logging | Setting this true will add some additional logs but this should only be done when trying to debug an issue as certain credential information may be logged out when this is true. |
185
232
 
186
233
  #### Examples of authentication field format
187
234
 
188
235
  ```json
189
- "{token}",
190
- "Token {token}",
191
- "{username}:{password}",
236
+ "{token}"
237
+ "Token {token}"
238
+ "{username}:{password}"
192
239
  "Basic {b64}{username}:{password}{/b64}"
193
240
  ```
194
241
 
@@ -204,6 +251,7 @@ The healthcheck properties defines the API that runs the healthcheck to tell the
204
251
  | ------- | ------- |
205
252
  | type | Required. The type of health check to run. |
206
253
  | frequency | Required if intermittent. Defines how often the health check should run. Measured in milliseconds. Default is 300000.|
254
+ | query_object | Query parameters to be added to the adapter healthcheck call.|
207
255
 
208
256
  ### Request Properties
209
257
 
@@ -211,8 +259,9 @@ The request section defines properties to help handle requests.
211
259
 
212
260
  | Property | Description |
213
261
  | ------- | ------- |
262
+ | number\_redirects | Optional. Tells the adapter that the request may be redirected and gives it a maximum number of redirects to allow before returning an error. Default is 0 - no redirects.|
214
263
  | number\_retries | Tells the adapter how many times to retry a request that has either aborted or reached a limit error before giving up and returning an error.|
215
- | limit\_retry\_error | Optional. Indicates the http error status number to define that no capacity was available and, after waiting a short interval, the adapter can retry the request. Default is 0.|
264
+ | limit\_retry\_error | Optional. Can be either an integer or an array. Indicates the http error status number to define that no capacity was available and, after waiting a short interval, the adapter can retry the request. If an array is provvided, the array can contain integers or strings. Strings in the array are used to define ranges (e.g. "502-506"). Default is [0].|
216
265
  | failover\_codes | An array of error codes for which the adapter will send back a failover flag to IAP so that the Platform can attempt the action in another adapter.|
217
266
  | attempt\_timeout | Optional. Tells how long the adapter should wait before aborting the attempt. On abort, the adapter will do one of two things: 1) return the error; or 2) if **healthcheck\_on\_timeout** is set to true, it will abort the request and run a Healthcheck until it re-establishes connectivity to Meraki, and then will re-attempt the request that aborted. Default is 5000 milliseconds.|
218
267
  | global\_request | Optional. This is information that the adapter can include in all requests to the other system. This is easier to define and maintain than adding this information in either the code (adapter.js) or the action files.|
@@ -223,6 +272,7 @@ The request section defines properties to help handle requests.
223
272
  | healthcheck\_on\_timeout | Required. Defines if the adapter should run a health check on timeout. If set to true, the adapter will abort the request and run a health check until it re-establishes connectivity and then it will re-attempt the request.|
224
273
  | return\_raw | Optional. Tells the adapter whether the raw response should be returned as well as the IAP response. This is helpful when running integration tests to save mock data. It does add overhead to the response object so it is not ideal from production.|
225
274
  | archiving | Optional flag. Default is false. It archives the request, the results and the various times (wait time, Meraki time and overall time) in the `adapterid_results` collection in MongoDB. Although archiving might be desirable, be sure to develop a strategy before enabling this capability. Consider how much to archive and what strategy to use for cleaning up the collection in the database so that it does not become too large, especially if the responses are large.|
275
+ | return\_request | Optional flag. Default is false. Will return the actual request that is made including headers. This should only be used during debugging issues as there could be credentials in the actual request.|
226
276
 
227
277
  ### SSL Properties
228
278
 
@@ -233,6 +283,8 @@ The SSL section defines the properties utilized for ssl authentication with Mera
233
283
  | enabled | If SSL is required, set to true. |
234
284
  | accept\_invalid\_certs | Defines if the adapter should accept invalid certificates (only recommended for lab environments). Required if SSL is enabled. Default is false.|
235
285
  | ca\_file | Defines the path name to the CA file used for SSL. If SSL is enabled and the accept invalid certifications is false, then ca_file is required.|
286
+ | key\_file | Defines the path name to the Key file used for SSL. The key_file may be needed for some systems but it is not required for SSL.|
287
+ | cert\_file | Defines the path name to the Certificate file used for SSL. The cert_file may be needed for some systems but it is not required for SSL.|
236
288
  | secure\_protocol | Defines the protocol (e.g., SSLv3_method) to use on the SSL request.|
237
289
  | ciphers | Required if SSL enabled. Specifies a list of SSL ciphers to use.|
238
290
  | ecdhCurve | During testing on some Node 8 environments, you need to set `ecdhCurve` to auto. If you do not, you will receive PROTO errors when attempting the calls. This is the only usage of this property and to our knowledge it only impacts Node 8 and 9. |
@@ -250,6 +302,7 @@ The throttle section is used when requests to Meraki must be queued (throttled).
250
302
  | concurrent\_max | Defines the number of requests the adapter can send to Meraki at one time (minimum = 1, maximum = 1000). The default is 1 meaning each request must be sent to Meraki in a serial manner. |
251
303
  | expire\_timeout | Default is 0. Defines a graceful timeout of the request session. After a request has completed, the adapter will wait additional time prior to sending the next request. Measured in milliseconds (minimum = 0, maximum = 60000).|
252
304
  | average\_runtime | Represents the approximate average of how long it takes Meraki to handle each request. Measured in milliseconds (minimum = 50, maximum = 60000). Default is 200. This metric has performance implications. If the runtime number is set too low, it puts extra burden on the CPU and memory as the requests will continually try to run. If the runtime number is set too high, requests may wait longer than they need to before running. The number does not need to be exact but your throttling strategy depends heavily on this number being within reason. If averages range from 50 to 250 milliseconds you might pick an average run-time somewhere in the middle so that when Meraki performance is exceptional you might run a little slower than you might like, but when it is poor you still run efficiently.|
305
+ | priorities | An array of priorities and how to handle them in relation to the throttle queue. Array of objects that include priority value and percent of queue to put the item ex { value: 1, percent: 10 }|
253
306
 
254
307
  ### Proxy Properties
255
308
 
@@ -261,6 +314,8 @@ The proxy section defines the properties to utilize when Meraki is behind a prox
261
314
  | host | Host information for the proxy server. Required if `enabled` is true.|
262
315
  | port | Port information for the proxy server. Required if `enabled` is true.|
263
316
  | protocol | The protocol (i.e., http, https, etc.) used to connect to the proxy. Default is http.|
317
+ | username | If there is authentication for the proxy, provide the username here.|
318
+ | password | If there is authentication for the proxy, provide the password here.|
264
319
 
265
320
  ### Mongo Properties
266
321
 
@@ -273,6 +328,13 @@ The mongo section defines the properties used to connect to a Mongo database. Mo
273
328
  | database | Optional. The database for the adapter to use for its data.|
274
329
  | username | Optional. If credentials are required to access mongo, this is the user to login as.|
275
330
  | password | Optional. If credentials are required to access mongo, this is the password to login with.|
331
+ | replSet | Optional. If the database is set up to use replica sets, define it here so it can be added to the database connection.|
332
+ | db\_ssl | Optional. Contains information for SSL connectivity to the database.|
333
+ | db\_ssl -> enabled | If SSL is required, set to true.|
334
+ | db\_ssl -> accept_invalid_cert | Defines if the adapter should accept invalid certificates (only recommended for lab environments). Required if SSL is enabled. Default is false.|
335
+ | db\_ssl -> ca_file | Defines the path name to the CA file used for SSL. If SSL is enabled and the accept invalid certifications is false, then ca_file is required.|
336
+ | db\_ssl -> key_file | Defines the path name to the Key file used for SSL. The key_file may be needed for some systems but it is not required for SSL.|
337
+ | db\_ssl -> cert_file | Defines the path name to the Certificate file used for SSL. The cert_file may be needed for some systems but it is not required for SSL.|
276
338
 
277
339
  ## Testing an Itential Product Adapter
278
340
 
@@ -283,10 +345,11 @@ Mocha is generally used to test all Itential Product Adapters. There are unit te
283
345
  Unit Testing includes testing basic adapter functionality as well as error conditions that are triggered in the adapter prior to any integration. There are two ways to run unit tests. The prefered method is to use the testRunner script; however, both methods are provided here.
284
346
 
285
347
 
286
- ```json
348
+ ```bash
287
349
  node utils/testRunner --unit
288
350
 
289
351
  npm run test:unit
352
+ npm run test:baseunit
290
353
  ```
291
354
 
292
355
  To add new unit tests, edit the `test/unit/adapterTestUnit.js` file. The tests that are already in this file should provide guidance for adding additional tests.
@@ -297,7 +360,7 @@ Standalone Integration Testing requires mock data to be provided with the entiti
297
360
 
298
361
  Similar to unit testing, there are two ways to run integration tests. Using the testRunner script is better because it prevents you from having to edit the test script; it will also resets information after testing is complete so that credentials are not saved in the file.
299
362
 
300
- ```json
363
+ ```bash
301
364
  node utils/testRunner
302
365
  answer no at the first prompt
303
366
 
@@ -312,7 +375,7 @@ Integration Testing requires connectivity to Meraki. By using the testRunner scr
312
375
 
313
376
  > **Note**: These tests have been written as a best effort to make them work in most environments. However, the Adapter Builder often does not have the necessary information that is required to set up valid integration tests. For example, the order of the requests can be very important and data is often required for `creates` and `updates`. Hence, integration tests may have to be enhanced before they will work (integrate) with Meraki. Even after tests have been set up properly, it is possible there are environmental constraints that could result in test failures. Some examples of possible environmental issues are customizations that have been made within Meraki which change order dependencies or required data.
314
377
 
315
- ```json
378
+ ```bash
316
379
  node utils/testRunner
317
380
  answer yes at the first prompt
318
381
  answer all other questions on connectivity and credentials
@@ -322,38 +385,52 @@ Test should also be written to clean up after themselves. However, it is importa
322
385
 
323
386
  > **Reminder**: Do not check in code with actual credentials to systems.
324
387
 
388
+ ## Adapter Node Scripts
389
+
390
+ There are several node scripts that now accompany the adapter. These scripts are provided to make several activities easier. Each of these scripts are described below.
391
+
392
+ | Run | Description |
393
+ | ------- | ------- |
394
+ | npm run adapter:install | Provides an easier way to install the adapter.|
395
+ | npm run adapter:checkMigrate | Checks whether your adapter can and should be migrated to the latest foundation.|
396
+ | npm run adapter:findPath | Can be used to see if the adapter supports a particular API call.|
397
+ | npm run adapter:migrate | Provides an easier way to migrate your adapter after you download the migration zip from Itential DevSite|
398
+ | npm run adapter:update | Provides an easier way to update your adapter after you download the migration zip from Itential DevSite|
399
+ | npm run adapter:revert | Allows you to revert after a migration or update if it resulted in issues.|
400
+ | npm run troubleshoot | Provides a way to troubleshoot the adapter - runs connectivity, healthcheck and basic get.|
401
+ | npm run connectivity | Provides a connectivity check to the Meraki system.|
402
+ | npm run healthcheck | Checks whether the configured healthcheck call works to Meraki.|
403
+ | npm run basicget | Checks whether the basic get calls works to Meraki.|
404
+
325
405
  ## Installing an Itential Product Adapter
326
406
 
327
407
  If you have App-Artifact installed in IAP, you can follow the instruction for that application to install the adapter into IAP. If not, follow these instructions.
328
408
 
329
409
  1. Set up the name space location in your IAP node_modules.
330
410
 
331
- ```json
411
+ ```bash
332
412
  cd /opt/pronghorn/current/node_modules
333
413
  if the @itentialopensource directory does not exist, create it:
334
414
  mkdir @itentialopensource
335
415
  ```
336
416
 
337
- 1. Clone the adapter into your IAP environment.
417
+ 2. Clone the adapter into your IAP environment.
338
418
 
339
- ```json
419
+ ```bash
340
420
  cd \@itentialopensource
341
421
  git clone git@gitlab.com:\@itentialopensource/adapters/adapter-meraki
342
422
  ```
343
423
 
344
- 1. Install the dependencies for the adapter.
424
+ 3. Run the adapter install script.
345
425
 
346
- ```json
426
+ ```bash
347
427
  cd adapter-meraki
348
- npm install
428
+ npm run adapter:install
349
429
  ```
350
430
 
351
- 1. If you are running IAP 2019.1 or older, add the adapter properties for Meraki (created from Adapter Builder) to the `properties.json` file for your Itential build. You will need to change the credentials and possibly the host information below.
352
- [Meraki sample properties](sampleProperties.json). If you are running IAP 2019.2 the adapter properties need to go into the database. You can review IAP documentation for how to do this.
353
-
354
- 1. Restart IAP
431
+ 4. Restart IAP
355
432
 
356
- ```json
433
+ ```bash
357
434
  systemctl restart pronghorn
358
435
  ```
359
436
 
@@ -363,7 +440,7 @@ If you built this as a custom adapter through the Adapter Builder, it is recomme
363
440
 
364
441
  1. Move the adapter into the IAP `node_modules` directory.
365
442
 
366
- ```json
443
+ ```text
367
444
  Depending on where your code is located, this process is different.
368
445
  Could be a tar, move, untar
369
446
  Could be a git clone of a repository
@@ -371,7 +448,7 @@ Depending on where your code is located, this process is different.
371
448
  Adapter should be placed into: /opt/pronghorn/current/node_modules/\@itentialopensource
372
449
  ```
373
450
 
374
- 1. Follow Steps 3-5 (above) to install an Itential adapter to load your properties, dependencies and restart IAP.
451
+ 2. Follow Steps 3-4 (above) to install an Itential adapter to load your properties, dependencies and restart IAP.
375
452
 
376
453
  ## Using this Adapter
377
454
 
@@ -379,86 +456,211 @@ The `adapter.js` file contains the calls the adapter makes available to the rest
379
456
 
380
457
  ### Generic Adapter Calls
381
458
 
382
- ```json
459
+ The `connect` call is run when the Adapter is first loaded by he Itential Platform. It validates the properties have been provided correctly.
460
+ ```js
383
461
  connect()
384
- The connect call is run when the Adapter is first loaded by he Itential Platform. It validates the properties have been provided correctly.
385
462
  ```
386
463
 
387
- ```json
464
+ The `healthCheck` call ensures that the adapter can communicate with Meraki. The actual call that is used is defined in the adapter properties.
465
+ ```js
388
466
  healthCheck(callback)
389
- Insures that the adapter can communicate with Meraki. The actual call that is used is defined in the adapter properties.
390
467
  ```
391
468
 
392
- ```json
469
+ The `refreshProperties` call provides the adapter the ability to accept property changes without having to restart the adapter.
470
+ ```js
393
471
  refreshProperties(properties)
394
- Provides the adapter the ability to accept property changes without having to restart the adapter.
395
472
  ```
396
473
 
397
- ```json
474
+ The `encryptProperty` call will take the provided property and technique, and return the property encrypted with the technique. This allows the property to be used in the adapterProps section for the credential password so that the password does not have to be in clear text. The adapter will decrypt the property as needed for communications with Meraki.
475
+ ```js
398
476
  encryptProperty(property, technique, callback)
399
- Will take the provided property and technique, and return the property encrypted with the technique. This allows the property to be used in the adapterProps section for the credential password so that the password does not have to be in clear text. The adapter will decrypt the property as needed for communications with Meraki.
400
477
  ```
401
478
 
402
- ```json
403
- getQueue(callback)
404
- Will return the requests that are waiting in the queue if throttling is enabled.
405
- ```
406
-
407
- ```json
479
+ The `addEntityCache` call will take the entities and add the list to the entity cache to expedite performance.
480
+ ```js
408
481
  addEntityCache(entityType, entities, key, callback)
409
- Will take the entities and add the list to the entity cache to expedite performance.
410
482
  ```
411
483
 
412
- ```json
484
+ The `capabilityResults` call will take the results from a verifyCompatibility and put them in the format to be passed back to the Itential Platform.
485
+ ```js
413
486
  capabilityResults(results, callback)
414
- Will take the results from a verifyCompatibility and put them in the format to be passed back to the Itential Platform.
415
487
  ```
416
488
 
417
- ```json
489
+ The `hasEntity` call verifies the adapter has the specific entity.
490
+ ```js
418
491
  hasEntity(entityType, entityId, callback)
419
- Verifies the adapter has the specific entity.
420
492
  ```
421
493
 
422
- ```json
494
+ The `verifyCapability` call verifies the adapter can perform the provided action on the specific entity.
495
+ ```js
423
496
  verifyCapability(entityType, actionType, entityId, callback)
424
- Verifies the adapter can perform the provided action on the specific entity.
425
497
  ```
426
498
 
427
- ```json
499
+ The `updateEntityCache` call will update the entity cache.
500
+ ```js
428
501
  updateEntityCache()
429
- Call to update the entity cache.
502
+ ```
503
+
504
+ The `updateAdapterConfiguration` call provides the ability to update the adapter configuration from IAP - includes actions, schema, mockdata and other configurations.
505
+ ```js
506
+ updateAdapterConfiguration(configFile, changes, entity, type, action, callback)
507
+ ```
508
+
509
+ The `suspend` call provides the ability to suspend the adapter and either have requests rejected or put into a queue to be processed after the adapter is resumed.
510
+ ```js
511
+ suspend(mode, callback)
512
+ ```
513
+
514
+ The `unsuspend` call provides the ability to resume a suspended adapter. Any requests in queue will be processed before new requests.
515
+ ```js
516
+ unsuspend(callback)
517
+ ```
518
+
519
+ The `findPath` call provides the ability to see if a particular API path is supported by the adapter.
520
+ ```js
521
+ findPath(apiPath, callback)
522
+ ```
523
+
524
+ The `troubleshoot` call can be used to check on the performance of the adapter - it checks connectivity, healthcheck and basic get calls.
525
+ ```js
526
+ troubleshoot(props, persistFlag, adapter, callback)
527
+ ```
528
+
529
+ The `runHealthcheck` call will return the results of a healthcheck.
530
+ ```js
531
+ runHealthcheck(adapter, callback)
532
+ ```
533
+
534
+ The `runConnectivity` call will return the results of a connectivity check.
535
+ ```js
536
+ runConnectivity(callback)
537
+ ```
538
+
539
+ The `runBasicGet` call will return the results of running basic get API calls.
540
+ ```js
541
+ runBasicGet(callback)
542
+ ```
543
+
544
+ The `getQueue` call will return the requests that are waiting in the queue if throttling is enabled.
545
+ ```js
546
+ getQueue(callback)
430
547
  ```
431
548
 
432
549
  ### Specific Adapter Calls
433
550
 
434
551
  Specific adapter calls are built based on the API of the Meraki. The Adapter Builder creates the proper method comments for generating JS-DOC for the adapter. This is the best way to get information on the calls.
435
552
 
553
+
554
+ ## Extending/Enhancing the Adapter
555
+
556
+ ### Adding a Second Instance of an Adapter
557
+
558
+ You can add a second instance of this adapter without adding new code on the file system. To do this go into the IAP Admin Essentials and add a new service config for this adapter. The two instances of the adapter should have unique ids. In addition, they should point to different instances of the other system. For example, they should be configured to talk to different hosts.
559
+
560
+ ### Adding Adapter Calls
561
+
562
+ There are multiple ways to add calls to an existing adapter.
563
+
564
+ The easiest way would be to use the Adapter Builder update process. This process takes in a Swagger or OpenAPI document, allows you to select the calls you want to add and then generates a zip file that can be used to update the adapter. Once you have the zip file simple put it in the adapter direcctory and execute `npm run adapter:update`.
565
+
566
+ ```bash
567
+ mv updatePackage.zip adapter-meraki
568
+ cd adapter-meraki
569
+ npm run adapter:update
570
+ ```
571
+
572
+ If you do not have a Swagger or OpenAPI document, you can use a Postman Collection and convert that to an OpenAPI document using APIMatic and then follow the first process.
573
+
574
+ If you want to manually update the adapter that can also be done the key thing is to make sure you update all of the right files. Within the entities directory you will find 1 or more entities. You can create a new entity or add to an existing entity. Each entity has an action.json file, any new call will need to be put in the action.json file. It will also need to be added to the enum for the ph_request_type in the appropriate schema files. Once this configuration is complete you will need to add the call to the adapter.js file and in order to make it available as a workflow task in IAP, it should also be added to the pronghorn.json file. You can optionally add it to the unit and integration test files. There is more information on how to work on each of these files in the Adapter Technical Resources on Dev Site [HERE](https://developer.itential.io/adapters-resources/)
575
+
576
+ ```text
577
+ Files to update
578
+ * entities/<entity>/action.json: add an action
579
+ * entities/<entity>/schema.json (or the schema defined on the action): add action to the enum for ph_request_type
580
+ * adapter.js: add the new method and make sure it calls the proper entity and action
581
+ * pronghorn.json: add the new method
582
+ * test/unit/adapterTestUnit.js (optional but best practice): add unit test(s) - function is there, any required parameters error when not passed in
583
+ * test/integration/adapterTestIntegration.js (optional but best practice): add integration test
584
+ ```
585
+
586
+ ### Adding Adapter Properties
587
+
588
+ While changing adapter properties is done in the service instance configuration section of IAP, adding properties has to be done in the adapter. To add a property you should edit the propertiesSchema.json with the proper information for the property. In addition, you should modify the sampleProperties to have the new property in it.
589
+
590
+ ```text
591
+ Files to update
592
+ * propertiesSchema.json: add the new property and how it is defined
593
+ * sampleProperties: add the new property with a default value
594
+ * test/unit/adapterTestUnit.js (optional but best practice): add the property to the global properties
595
+ * test/integration/adapterTestIntegration.js (optional but best practice): add the property to the global properties
596
+ ```
597
+
598
+ ### Changing Adapter Authentication
599
+
600
+ Often an adapter is built before knowing the authentication and authentication process can also change over time. The adapter supports many different kinds of authentication but it does require configuration. Some forms of authentication can be defined entirely with the adapter properties but others require configuration.
601
+
602
+ ```text
603
+ Files to update
604
+ * entities/<entity>/action.json: change the getToken action as needed
605
+ * entities/<entity>/schemaTokenReq.json: add input parameters (external name is name in other system)
606
+ * entities/<entity>/schemaTokenResp.json: add response parameters (external name is name in other system)
607
+ * propertiesSchema.json: add any new property and how it is defined
608
+ * sampleProperties: add any new property with a default value
609
+ * test/unit/adapterTestUnit.js (optional but best practice): add the property to the global properties
610
+ * test/integration/adapterTestIntegration.js (optional but best practice): add the property to the global properties
611
+ ```
612
+
613
+ ### Enhancing Adapter Integration Tests
614
+
615
+ The adapter integration tests are written to be able to test in either stub (standalone) mode or integrated to the other system. However, if integrating to the other system, you may need to provide better data than what the adapter provides by default as that data is likely to fail for create and update. To provide better data, edit the adapter integration test file. Make sure you do not remove the marker and keep custom code below the marker so you do not impact future migrations. Once the edits are complete, run the integration test as it instructs you to above. When you run integrated to the other system, you can also save mockdata for future use by changing the isSaveMockData flag to true.
616
+
617
+ ```text
618
+ Files to update
619
+ * test/integration/adapterTestIntegration.js: add better data for the create and update calls so that they will not fail.
620
+ ```
621
+
622
+ As mentioned previously, for most of these changes as well as other possible changes, there is more information on how to work on an adapter in the Adapter Technical Resources on Dev Site [HERE](https://developer.itential.io/adapters-resources/)
623
+
436
624
  ## Troubleshooting the Adapter
437
625
 
626
+ Run `npm run troubleshoot` to start the interactive troubleshooting process. The command allows user to verify and update connection, authentication as well as healthcheck configuration. After that it will test these properties by sending HTTP request to the endpoint. If the tests pass, it will persist these changes into IAP.
627
+
628
+ User also have the option to run individual command to perform specific test
629
+
630
+ - `npm run healthcheck` will perform a healthcheck request of with current setting.
631
+ - `npm run basicget` will perform some non-parameter GET request with current setting.
632
+ - `npm run connectivity` will perform networking diagnostics of the adatper endpoint.
633
+
438
634
  ### Connectivity Issues
439
635
 
440
- 1. Verify the adapter properties are set up correctly.
636
+ 1. You can run the adapter troubleshooting script which will check connectivity, run the healthcheck and run basic get calls.
441
637
 
442
- ```json
638
+ ```bash
639
+ npm run troubleshoot
640
+ ```
641
+
642
+ 2. Verify the adapter properties are set up correctly.
643
+
644
+ ```text
443
645
  Go into the Itential Platform GUI and verify/update the properties
444
646
  ```
445
647
 
446
- 1. Verify there is connectivity between the Itential Platform Server and Meraki Server.
648
+ 3. Verify there is connectivity between the Itential Platform Server and Meraki Server.
447
649
 
448
- ```json
650
+ ```text
449
651
  ping the ip address of Meraki server
450
652
  try telnet to the ip address port of Meraki
451
653
  ```
452
654
 
453
- 1. Verify the credentials provided for Meraki.
655
+ 4. Verify the credentials provided for Meraki.
454
656
 
455
- ```json
657
+ ```text
456
658
  login to Meraki using the provided credentials
457
659
  ```
458
660
 
459
- 1. Verify the API of the call utilized for Meraki Healthcheck.
661
+ 5. Verify the API of the call utilized for Meraki Healthcheck.
460
662
 
461
- ```json
663
+ ```text
462
664
  Go into the Itential Platform GUI and verify/update the properties
463
665
  ```
464
666
 
@@ -474,7 +676,7 @@ Please check out the [Contributing Guidelines](./CONTRIBUTING.md).
474
676
 
475
677
  ### Maintained By
476
678
 
477
- ```json
679
+ ```text
478
680
  Itential Product Adapters are maintained by the Itential Adapter Team.
479
681
  Itential OpenSource Adapters are maintained by the community at large.
480
682
  Custom Adapters are maintained by other sources.