@itentialopensource/adapter-meraki 0.8.0 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
package/AUTH.md ADDED
@@ -0,0 +1,39 @@
1
+ ## Authenticating Meraki Adapter
2
+
3
+ This document will go through the steps for authenticating the Meraki adapter with Basic Authentication. Properly configuring the properties for an adapter in IAP is critical for getting the adapter online. You can read more about adapter authentication <a href="https://www.itential.com/automation-platform/integrations/adapters-resources/authentication/" target="_blank">HERE</a>.
4
+
5
+ ### Basic Authentication
6
+ The Meraki adapter requires Basic Authentication. If you change authentication methods, you should change this section accordingly and merge it back into the adapter repository.
7
+
8
+ STEPS
9
+ 1. Ensure you have access to a Meraki server and that it is running
10
+ 2. Follow the steps in the README.md to import the adapter into IAP if you have not already done so
11
+ 3. Use the properties below for the ```properties.authentication``` field
12
+ ```json
13
+ "authentication": {
14
+ "auth_method": "basic user_password",
15
+ "username": "<username>",
16
+ "password": "<password>",
17
+ "token": "",
18
+ "token_timeout": 1800000,
19
+ "token_cache": "local",
20
+ "invalid_token_error": 401,
21
+ "auth_field": "header.headers.Authorization",
22
+ "auth_field_format": "Basic {b64}{username}:{password}{/b64}",
23
+ "auth_logging": false,
24
+ "client_id": "",
25
+ "client_secret": "",
26
+ "grant_type": ""
27
+ }
28
+ ```
29
+ 4. Restart the adapter. If your properties were set correctly, the adapter should go online.
30
+
31
+ ### Troubleshooting
32
+ - Make sure you copied over the correct username and password.
33
+ - Turn on debug level logs for the adapter in IAP Admin Essentials.
34
+ - Turn on auth_logging for the adapter in IAP Admin Essentials (adapter properties).
35
+ - Investigate the logs - in particular:
36
+ - The FULL REQUEST log to make sure the proper headers are being sent with the request.
37
+ - The FULL BODY log to make sure the payload is accurate.
38
+ - The CALL RETURN log to see what the other system is telling us.
39
+ - Remember when you are done to turn auth_logging off as you do not want to log credentials.
package/BROKER.md ADDED
@@ -0,0 +1,195 @@
1
+ ## Integrating Meraki Adapter with IAP Device Broker
2
+
3
+ This document will go through the steps for integrating the Meraki adapter with IAP's Device Broker. IAP Device Broker integration allows for easier interation into several of IAPs applications (e.g. Configuration Manager). Properly configuring the properties for the adapter in IAP is critical for getting the device broker integration to work. Their is additional information in the configuration section of the adapter readme. This document will go through each of the calls that are utilized by the Device Broker.
4
+
5
+ ### getDevicesFiltered
6
+ getDevicesFiltered(options, callback) → This call returns all of the devices within Meraki that match the provided filter.
7
+
8
+ #### input
9
+
10
+ options {object}: defines the options for the search. At current filter is the most important one. The filter can contain the device name (e.g. the options can be { filter: { name: [‘abc’, ‘def’] }}. The adapter currently filters by doing a contains on the name(s) provided in the array and not an exact match. So deviceabc will be returned when this filter is applied. In many adapters, other options (start, limit, sort and order) are not implemented.
11
+
12
+ #### output
13
+
14
+ An Object containing the total number of matching devices and a list containing an array of the details for each device. For example, { total: 2, list: [ { name: ‘abc’, ostype: ‘type’, port: 80, ipaddress: ‘10.10.10.10’ }, { name: ‘def’, ostype: ‘type2’, port: 443, ipaddress: ‘10.10.10.15’ }] }
15
+
16
+ The fields name and ostype are required by the broker and should be mapped through properties to data from the other system. In addition, ipaddress and port should also be mapped as it is utilized by some north bound IAP applications (e.g. Config Manager). There are other fields that can be set as well but consider these the minimal fields.
17
+
18
+ Below is an example of how you may set up the properties for this call.
19
+
20
+ ```json
21
+ "getDevicesFiltered": [
22
+ {
23
+ "path": "/{org}/get/devices",
24
+ "method": "GET",
25
+ "query": {},
26
+ "body": {},
27
+ "headers": {},
28
+ "handleFailure": "ignore",
29
+ "requestFields": {
30
+ "org": "555"
31
+ },
32
+ "responseFields": {
33
+ "name": "host",
34
+ "ostype": "os",
35
+ "ostypePrefix": "system-",
36
+ "ipaddress": "attributes.ipaddr",
37
+ "port": "443"
38
+ }
39
+ },
40
+ {
41
+ "path": "/{org}/get/devices",
42
+ "method": "GET",
43
+ "query": {},
44
+ "body": {},
45
+ "headers": {},
46
+ "handleFailure": "ignore",
47
+ "requestFields": {
48
+ "org": "777"
49
+ },
50
+ "responseFields": {
51
+ "name": "host",
52
+ "ostype": "os",
53
+ "ostypePrefix": "system-",
54
+ "ipaddress": "attributes.ipaddr",
55
+ "port": "443",
56
+ "myorg": "org"
57
+ }
58
+ }
59
+ ]
60
+ ```
61
+
62
+ Notice with the path, there is a variable in it ({org}). This variable must be provided in the data available to the call. For getDevicesFiltered this means the requestFields as a static value. In other calls, it may also come from the result of the getDevicesFiltered call.
63
+
64
+ Notice with the responseFields, it wants the IAP data key as the key and where it is supposed to find the data in the response as the value. You can use nested fields in the response object using standard object notation. You can also add static data as shown in the port field. Finally, you can append data to the response from the requestInformation using its key (e.g. org). The ostypePrefix is a special field that allows you to add static data to the ostype to help define the system you are getting the device from.
65
+
66
+ Notice here that you can also have multiple calls that make up the results provided to the Device Broker. In this example we are making calls to two different organizations and returning the results from both.
67
+
68
+ ### isAlive
69
+ isAlive(deviceName, callback) → This call returns whether the device provided is operational.
70
+
71
+ input
72
+
73
+ deviceName {string}: the name of the device to get details of. The adapter will always call getDevicesFiltered first with this name in the filter in order to get any additional details it needs for this call (e.g. id).
74
+
75
+ output
76
+
77
+ A boolean value. This usually needs to be determined from a particular field in the data returned from the other system. This is where definind a status value and a status field is critical to properly configuring the call.
78
+
79
+ Below is an example of how you may set up the properties for this call.
80
+
81
+ ```json
82
+ "isAlive": [
83
+ {
84
+ "path": "/{org}/get/devices/{id}/status",
85
+ "method": "GET",
86
+ "query": {},
87
+ "body": {},
88
+ "headers": {},
89
+ "handleFailure": "ignore",
90
+ "statusValue": "online",
91
+ "requestFields": {
92
+ "org": "myorg",
93
+ "id": "name"
94
+ },
95
+ "responseFields": {
96
+ "status": "status"
97
+ }
98
+ }
99
+ ]
100
+ ```
101
+
102
+ Notice with the requestFields, it will use the org and name that it got from the response of the getDevicesFiltered call to complete the path for the call.
103
+
104
+ Notice with the responseFields, it use the status field that came back and test to see if the value is online since that is what you defined as the statusValue. If it is it will return true otherwise it will return false.
105
+
106
+ You could have multiple calls here if needed but generally that will not be the case.
107
+
108
+ ### getConfig
109
+ getConfig(deviceName, format, callback) → This call returns the configuration for the device. This can be a simple call or a complex/multiple calls to get all of the “configuration” desirable.
110
+
111
+ input
112
+
113
+ deviceName {string}: the name of the device to get details of. The adapter will always call getDevicesFiltered first with this name in the filter in order to get any additional details it needs for this call (e.g. id).
114
+
115
+ format {string}: is an optional format you want provided back. Most adapters do not support formats by default and just return the “stringified” json object.
116
+
117
+ output
118
+
119
+ An object containing a response field which has the value of the stringified config (e.g. { response: ‘stringified configuration data’ }
120
+
121
+ Below is an example of how you may set up the properties for this call.
122
+
123
+ ```json
124
+ "getConfig": [
125
+ {
126
+ "path": "/{org}/get/devices/{id}/configPart1",
127
+ "method": "GET",
128
+ "query": {},
129
+ "body": {},
130
+ "headers": {},
131
+ "handleFailure": "ignore",
132
+ "requestFields": {
133
+ "org": "myorg",
134
+ "id": "name"
135
+ }
136
+ "responseFields": {}
137
+ },
138
+ {
139
+ "path": "/{org}/get/devices/configPart2",
140
+ "method": "GET",
141
+ "query": {},
142
+ "body": {},
143
+ "headers": {},
144
+ "handleFailure": "ignore",
145
+ "requestFields": {
146
+ "org": "myorg"
147
+ }
148
+ "responseFields": {}
149
+ }
150
+ ]
151
+ ```
152
+
153
+ The example above shows multiple calls. With the handleFailure property set to ignore, if one of the calls fails, the adapter will still send the response with that configuration missing. If you want it to fail set the handleFailure property to fail.
154
+
155
+ There is no limit on the number of calls you can make however understand that the adapter will make all of these calls prior to providing a response so there can be performance implications.
156
+
157
+ ### getDevice - may be deprecated
158
+ getDevice(deviceName, callback) → This call returns details of the device provided. In many systems the getDevicesFiltered only returns summary information and so we also want a more detailed call to get device details.
159
+
160
+ input
161
+
162
+ deviceName {string}: the name of the device to get details of. The adapter will always call getDevicesFiltered first with this name in the filter in order to get any additional details it needs for this call (e.g. id).
163
+
164
+ output
165
+
166
+ An Object containing the details of the device. The object should contain at least the same information that was provided in the getDevicesFiltered call (e.g. the fields name, ostype, port and ipaddress should be mapped in the adapter properties to data from the other system) and may contain many more details about the device.
167
+
168
+ Below is an example of how you may set up the properties for this call.
169
+
170
+ ```json
171
+ "getDevice": [
172
+ {
173
+ "path": "/{org}/get/devices/{id}",
174
+ "method": "GET",
175
+ "query": {},
176
+ "body": {},
177
+ "headers": {},
178
+ "handleFailure": "ignore",
179
+ "requestFields": {
180
+ "org": "myorg",
181
+ "id": "name"
182
+ },
183
+ "responseFields": {
184
+ "name": "host",
185
+ "ostype": "os",
186
+ "ostypePrefix": "system-",
187
+ "ipaddress": "attributes.ipaddr",
188
+ "port": "443",
189
+ "myorg": "org"
190
+ }
191
+ }
192
+ ]
193
+ ```
194
+
195
+ You could have multiple calls here if needed but generally that will not be the case.
package/CALLS.md ADDED
@@ -0,0 +1,169 @@
1
+ ## Using this Adapter
2
+
3
+ The `adapter.js` file contains the calls the adapter makes available to the rest of the Itential Platform. The API detailed for these calls should be available through JSDOC. The following is a brief summary of the calls.
4
+
5
+ ### Generic Adapter Calls
6
+
7
+ These are adapter methods that IAP or you might use. There are some other methods not shown here that might be used for internal adapter functionality.
8
+
9
+ <table border="1" class="bordered-table">
10
+ <tr>
11
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Method Signature</span></th>
12
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Description</span></th>
13
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Workflow?</span></th>
14
+ </tr>
15
+ <tr>
16
+ <td style="padding:15px">connect()</td>
17
+ <td style="padding:15px">This call is run when the Adapter is first loaded by he Itential Platform. It validates the properties have been provided correctly.</td>
18
+ <td style="padding:15px">No</td>
19
+ </tr>
20
+ <tr>
21
+ <td style="padding:15px">healthCheck(callback)</td>
22
+ <td style="padding:15px">This call ensures that the adapter can communicate with Meraki. The actual call that is used is defined in the adapter properties and .system entities action.json file.</td>
23
+ <td style="padding:15px">No</td>
24
+ </tr>
25
+ <tr>
26
+ <td style="padding:15px">refreshProperties(properties)</td>
27
+ <td style="padding:15px">This call provides the adapter the ability to accept property changes without having to restart the adapter.</td>
28
+ <td style="padding:15px">No</td>
29
+ </tr>
30
+ <tr>
31
+ <td style="padding:15px">encryptProperty(property, technique, callback)</td>
32
+ <td style="padding:15px">This 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.</td>
33
+ <td style="padding:15px">No</td>
34
+ </tr>
35
+ <tr>
36
+ <td style="padding:15px">iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback)</td>
37
+ <td style="padding:15px">This call provides the ability to update the adapter configuration from IAP - includes actions, schema, mockdata and other configurations.</td>
38
+ <td style="padding:15px">Yes</td>
39
+ </tr>
40
+ <tr>
41
+ <td style="padding:15px">iapFindAdapterPath(apiPath, callback)</td>
42
+ <td style="padding:15px">This call provides the ability to see if a particular API path is supported by the adapter.</td>
43
+ <td style="padding:15px">Yes</td>
44
+ </tr>
45
+ <tr>
46
+ <td style="padding:15px">iapSuspendAdapter(mode, callback)</td>
47
+ <td style="padding:15px">This 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.</td>
48
+ <td style="padding:15px">Yes</td>
49
+ </tr>
50
+ <tr>
51
+ <td style="padding:15px">iapUnsuspendAdapter(callback)</td>
52
+ <td style="padding:15px">This call provides the ability to resume a suspended adapter. Any requests in queue will be processed before new requests.</td>
53
+ <td style="padding:15px">Yes</td>
54
+ </tr>
55
+ <tr>
56
+ <td style="padding:15px">iapGetAdapterQueue(callback)</td>
57
+ <td style="padding:15px">This call will return the requests that are waiting in the queue if throttling is enabled.</td>
58
+ <td style="padding:15px">Yes</td>
59
+ </tr>
60
+ <tr>
61
+ <td style="padding:15px">iapTroubleshootAdapter(props, persistFlag, adapter, callback)</td>
62
+ <td style="padding:15px">This call can be used to check on the performance of the adapter - it checks connectivity, healthcheck and basic get calls.</td>
63
+ <td style="padding:15px">Yes</td>
64
+ </tr>
65
+
66
+ <tr>
67
+ <td style="padding:15px">iapRunAdapterHealthcheck(adapter, callback)</td>
68
+ <td style="padding:15px">This call will return the results of a healthcheck.</td>
69
+ <td style="padding:15px">Yes</td>
70
+ </tr>
71
+ <tr>
72
+ <td style="padding:15px">iapRunAdapterConnectivity(callback)</td>
73
+ <td style="padding:15px">This call will return the results of a connectivity check.</td>
74
+ <td style="padding:15px">Yes</td>
75
+ </tr>
76
+ <tr>
77
+ <td style="padding:15px">iapRunAdapterBasicGet(callback)</td>
78
+ <td style="padding:15px">This call will return the results of running basic get API calls.</td>
79
+ <td style="padding:15px">Yes</td>
80
+ </tr>
81
+ <tr>
82
+ <td style="padding:15px">iapMoveAdapterEntitiesToDB(callback)</td>
83
+ <td style="padding:15px">This call will push the adapter configuration from the entities directory into the Adapter or IAP Database.</td>
84
+ <td style="padding:15px">Yes</td>
85
+ </tr>
86
+ <tr>
87
+ <td style="padding:15px">genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback)</td>
88
+ <td style="padding:15px">This call allows you to provide the path to have the adapter call. It is an easy way to incorporate paths that have not been built into the adapter yet.</td>
89
+ <td style="padding:15px">Yes</td>
90
+ </tr>
91
+ <tr>
92
+ <td style="padding:15px">genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback)</td>
93
+ <td style="padding:15px">This call is the same as the genericAdapterRequest only it does not add a base_path or version to the call.</td>
94
+ <td style="padding:15px">Yes</td>
95
+ </tr>
96
+ <tr>
97
+ <td style="padding:15px">iapHasAdapterEntity(entityType, entityId, callback)</td>
98
+ <td style="padding:15px">This call verifies the adapter has the specific entity.</td>
99
+ <td style="padding:15px">No</td>
100
+ </tr>
101
+ <tr>
102
+ <td style="padding:15px">iapVerifyAdapterCapability(entityType, actionType, entityId, callback)</td>
103
+ <td style="padding:15px">This call verifies the adapter can perform the provided action on the specific entity.</td>
104
+ <td style="padding:15px">No</td>
105
+ </tr>
106
+ <tr>
107
+ <td style="padding:15px">iapUpdateAdapterEntityCache()</td>
108
+ <td style="padding:15px">This call will update the entity cache.</td>
109
+ <td style="padding:15px">No</td>
110
+ </tr>
111
+ </table>
112
+ <br>
113
+
114
+ ### Adapter Broker Calls
115
+
116
+ These are adapter methods that are used to integrate to IAP Brokers. This adapter currently supports the following broker calls.
117
+
118
+ <table border="1" class="bordered-table">
119
+ <tr>
120
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Method Signature</span></th>
121
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Description</span></th>
122
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Workflow?</span></th>
123
+ </tr>
124
+ <tr>
125
+ <td style="padding:15px">hasEntities(entityType, entityList, callback)</td>
126
+ <td style="padding:15px">This call is utilized by the IAP Device Broker to determine if the adapter has a specific entity and item of the entity.</td>
127
+ <td style="padding:15px">No</td>
128
+ </tr>
129
+ <tr>
130
+ <td style="padding:15px">getDevice(deviceName, callback)</td>
131
+ <td style="padding:15px">This call returns the details of the requested device.</td>
132
+ <td style="padding:15px">Yes</td>
133
+ </tr>
134
+ <tr>
135
+ <td style="padding:15px">getDevicesFiltered(options, callback)</td>
136
+ <td style="padding:15px">This call returns the list of devices that match the criteria provided in the options filter.</td>
137
+ <td style="padding:15px">Yes</td>
138
+ </tr>
139
+ <tr>
140
+ <td style="padding:15px">isAlive(deviceName, callback)</td>
141
+ <td style="padding:15px">This call returns whether the device status is active</td>
142
+ <td style="padding:15px">Yes</td>
143
+ </tr>
144
+ <tr>
145
+ <td style="padding:15px">getConfig(deviceName, format, callback)</td>
146
+ <td style="padding:15px">This call returns the configuration for the selected device.</td>
147
+ <td style="padding:15px">Yes</td>
148
+ </tr>
149
+ <tr>
150
+ <td style="padding:15px">iapGetDeviceCount(callback)</td>
151
+ <td style="padding:15px">This call returns the count of devices.</td>
152
+ <td style="padding:15px">Yes</td>
153
+ </tr>
154
+ </table>
155
+ <br>
156
+
157
+ ### Specific Adapter Calls
158
+
159
+ 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.
160
+
161
+ <table border="1" class="bordered-table">
162
+ <tr>
163
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Method Signature</span></th>
164
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Description</span></th>
165
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Path</span></th>
166
+ <th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Workflow?</span></th>
167
+ </tr>
168
+ </table>
169
+ <br>
package/CHANGELOG.md CHANGED
@@ -1,4 +1,28 @@
1
1
 
2
+ ## 0.8.3 [05-08-2022]
3
+
4
+ * Patch/broker cleanup
5
+
6
+ See merge request itentialopensource/adapters/sd-wan/adapter-meraki!18
7
+
8
+ ---
9
+
10
+ ## 0.8.2 [05-02-2022]
11
+
12
+ * Patch/broker fix
13
+
14
+ See merge request itentialopensource/adapters/sd-wan/adapter-meraki!17
15
+
16
+ ---
17
+
18
+ ## 0.8.1 [04-13-2022]
19
+
20
+ * added properties for broker calls and new documentation
21
+
22
+ See merge request itentialopensource/adapters/sd-wan/adapter-meraki!16
23
+
24
+ ---
25
+
2
26
  ## 0.8.0 [01-21-2022]
3
27
 
4
28
  * migration to the latest foundation and broker ready
@@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
8
8
 
9
9
  Examples of behavior that contributes to creating a positive environment include:
10
10
 
11
- * Using welcoming and inclusive language
12
- * Being respectful of differing viewpoints and experiences
13
- * Gracefully accepting constructive criticism
14
- * Focusing on what is best for the community
15
- * Showing empathy towards other community members
11
+ - Using welcoming and inclusive language
12
+ - Being respectful of differing viewpoints and experiences
13
+ - Gracefully accepting constructive criticism
14
+ - Focusing on what is best for the community
15
+ - Showing empathy towards other community members
16
16
 
17
17
  Examples of unacceptable behavior by participants include:
18
18
 
19
- * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
- * Trolling, insulting/derogatory comments, and personal or political attacks
21
- * Public or private harassment
22
- * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
- * Other conduct which could reasonably be considered inappropriate in a professional setting
19
+ - The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ - Trolling, insulting/derogatory comments, and personal or political attacks
21
+ - Public or private harassment
22
+ - Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
24
24
 
25
25
  ## Our Responsibilities
26
26
 
@@ -34,15 +34,10 @@ This Code of Conduct applies both within project spaces and in public spaces whe
34
34
 
35
35
  ## Enforcement
36
36
 
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [support@itential.com](mailto:support@itential.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@itential.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
38
 
39
39
  Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
40
 
41
41
  ## Attribution
42
42
 
43
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
-
45
- [homepage]: http://contributor-covenant.org
46
- [version]: http://contributor-covenant.org/version/1/4/
47
-
48
- _return to [README](../README.md)_
43
+ This Code of Conduct is adapted from the <a href="http://contributor-covenant.org" target="_blank">Contributor Covenant</a>, version 1.4, available at <a href="http://contributor-covenant.org/version/1/4/" target="_blank">version</a>