endpoints/pii.js

  1. const pii = {
  2. /**
  3. * Personal Idetifying Information
  4. * @module Pii
  5. */
  6. /**
  7. * List the keys required to access Personally Identifiable Information (PII) for a given identifier.
  8. * Exactly one identifier will be accepted.
  9. * If the organization contains org-wide Systems Manager users matching the key provided then
  10. * there will be an entry with the key "0" containing the applicable keys.
  11. * PARAMETERS
  12. username
  13. The username of a Systems Manager user
  14. email
  15. The email of a network user account or a Systems Manager device
  16. mac
  17. The MAC of a network client device or a Systems Manager device
  18. serial
  19. The serial of a Systems Manager device
  20. imei
  21. The IMEI of a Systems Manager device
  22. * @memberof module:Pii
  23. * @param {string} orgId
  24. * @param {string} pii
  25. * @param {string} value
  26. * @return { Promise } A promise holding the PII keys
  27. * @example <caption>Example request</caption>
  28. *
  29. meraki.getPiiKeys(orgId, pii).then((res) => {
  30. console.log(res);
  31. });
  32. *
  33. * @example <caption>Example response</caption>
  34. *
  35. Successful HTTP Status: 200
  36. {
  37. [networkId]:{
  38. "macs":[
  39. "00:77:00:77:00:77"
  40. ],
  41. "emails":[
  42. "fake@example.com"
  43. ],
  44. "usernames":[
  45. "fakename"
  46. ],
  47. "serials":[
  48. "abcd1234"
  49. ],
  50. "imei":[
  51. 990000862471854
  52. ]
  53. }
  54. }
  55. */
  56. getPiiKeys(orgId, piiType, value) {
  57. if (!orgId) {
  58. return Promise.reject(new Error('The orgId is required'))
  59. }
  60. return this.meraki.get(`/organizations/${orgId}/pii/piiKeys?${piiType}=${value}`).then((res) => res.data);
  61. },
  62. /**
  63. * Given a piece of Personally Identifiable Information (PII), return the Systems Manager device ID(s) associated with that identifier.
  64. * These device IDs can be used with the Systems Manager API endpoints to retrieve device details. Exactly one identifier will be accepted.
  65. * @memberof module:Pii
  66. * @param {string} orgId
  67. * @param {string} pii
  68. * @param {string} value
  69. * @return { Promise } A promise holding the device identifier
  70. * @example <caption>Example request</caption>
  71. * PARAMETERS
  72. username
  73. The username of a Systems Manager user
  74. email
  75. The email of a network user account or a Systems Manager device
  76. mac
  77. The MAC of a network client device or a Systems Manager device
  78. serial
  79. The serial of a Systems Manager device
  80. imei
  81. The IMEI of a Systems Manager device
  82. *
  83. * meraki.getSmDevicesForKey(orgId, pii, value).then((res) => {
  84. * console.log(res.data);
  85. * });
  86. *
  87. * @example <caption>Example response</caption>
  88. {
  89. [networkId]:["1099541095293", "8348382288234"]
  90. }
  91. */
  92. getSmDevicesForKey(orgId, pii, value) {
  93. if (!orgId) {
  94. return Promise.reject(new Error('The orgId is required'))
  95. }
  96. if (!pii) {
  97. return Promise.reject(new Error('The pii type is required: username,email,serial or imei'))
  98. }
  99. if (!value) {
  100. return Promise.reject(new Error('The pii value is required: the username, email, serial or imei'))
  101. }
  102. return this.meraki.get(`/organizations/${orgId}/pii/smDevicesForKey?${pii}=${value}`).then((res) => res.data);
  103. },
  104. /**
  105. * Given a piece of Personally Identifiable Information (PII), return the Systems Manager owner ID(s) associated with that identifier.
  106. * These owner IDs can be used with the Systems Manager API endpoints to retrieve owner details. Exactly one identifier will be accepted.
  107. * @memberof module:Pii
  108. * @param {string} orgId
  109. * @param {string} pii
  110. * @param {string} value
  111. * @return { Promise } A promise holding the Systems Manager owner ID(s) associated with that identifier.
  112. * @example <caption>Example request</caption>
  113. * PARAMETERS
  114. username
  115. The username of a Systems Manager user
  116. email
  117. The email of a network user account or a Systems Manager device
  118. mac
  119. The MAC of a network client device or a Systems Manager device
  120. serial
  121. The serial of a Systems Manager device
  122. imei
  123. The IMEI of a Systems Manager device
  124. *
  125. * meraki.getSmOwnersForKey(orgId, pii, value).then((res) => {
  126. * console.log(res.data);
  127. * });
  128. *
  129. * @example <caption>Example response</caption>
  130. {
  131. [networkId]:["1099541095293"]
  132. }
  133. */
  134. getSmOwnersForKey(orgId, pii, value) {
  135. if (!orgId) {
  136. return Promise.reject(new Error('The orgId is required'))
  137. }
  138. if (!pii) {
  139. return Promise.reject(new Error('The pii type is required: username,email,serial or imei'))
  140. }
  141. if (!value) {
  142. return Promise.reject(new Error('The pii value is required: the username, email, serial or imei'))
  143. }
  144. const params = Object.keys(key);
  145. const param = params[0];
  146. return this.meraki.get(`/organizations/${orgId}/pii/smOwnersForKey?${pii}=${value}`).then((res) => res.data);
  147. },
  148. /**
  149. * List the PII requests for this organization
  150. * @memberof module:Pii
  151. * @param {string} orgId
  152. * @return { Promise } A promise holding the PII requests for an organization
  153. * @example <caption>Example request</caption>
  154. *
  155. meraki.getPiiRequests(orgId).then((res) => {
  156. console.log(res);
  157. });
  158. *
  159. * @example <caption>Example response</caption>
  160. [
  161. {
  162. "id": "1234",
  163. "organizationWide": false,
  164. "networkId": "N_1234",
  165. "type": "delete",
  166. "mac": "00:77:00:77:00:77",
  167. "datasets": "['usage', 'events']",
  168. "createdAt": 1524692227,
  169. "completedAt": 1524702227
  170. }
  171. ]
  172. */
  173. getPiiRequests(orgId) {
  174. if (!orgId) {
  175. return Promise.reject(new Error('The orgId is required'))
  176. }
  177. return this.meraki.get(`/organizations/${orgId}/pii/requests`).then((res) => res.data);
  178. },
  179. /**
  180. * Return a PII request
  181. * @memberof module:Pii
  182. * @param {string} orgId
  183. * @param {string} piiId
  184. * @return { Promise } A promise holding the PII requests for a pii ID
  185. * @example <caption>Example request</caption>
  186. *
  187. meraki.getPiiRequest(orgId, piiId).then((res) => {
  188. console.log(res.data);
  189. });
  190. *
  191. * @example <caption>Example response</caption>
  192. {
  193. "id": "1234",
  194. "organizationWide": false,
  195. "networkId": "N_1234",
  196. "type": "delete",
  197. "mac": "00:77:00:77:00:77",
  198. "datasets": "['usage', 'events']",
  199. "createdAt": 1524692227,
  200. "completedAt": 1524702227
  201. }
  202. */
  203. getPiiRequest(orgId, piiId) {
  204. if (!orgId) {
  205. return Promise.reject(new Error('The orgId is required'))
  206. }
  207. if (!piiId) {
  208. return Promise.reject(new Error('The piiId is required'))
  209. }
  210. return this.meraki.get(`/organizations/${orgId}/pii/requests/${piiId}`).then((res) => res.data);
  211. },
  212. getPiiRequests(orgId) {
  213. if (!orgId) {
  214. return Promise.reject(new Error('The orgId is required'))
  215. }
  216. return this.meraki.get(`/organizations/${orgId}/pii/requests`).then((res) => res.data);
  217. },
  218. /**
  219. * Submit a new delete or restrict processing PII request
  220. *
  221. * Options
  222. type
  223. One of "delete" or "restrict processing"
  224. datasets
  225. The datasets related to the provided key that should be deleted. Only applies to "delete" requests. The value "all" will be expanded to all datasets applicable to this pii_type.
  226. username
  227. The username of a network log in. Only applies to "delete" requests.
  228. email
  229. The email of a network user account. Only applies to "delete" requests.
  230. mac
  231. The MAC of a network client device. Applies to both "restrict processing" and "delete" requests.
  232. smDeviceId
  233. The sm_device_id of a Systems Manager device. The only way to "restrict processing" or "delete" a Systems Manager device. Must include "device" in the dataset for a "delete" request to destroy the device.
  234. smUserId
  235. The sm_user_id of a Systems Manager user. The only way to "restrict processing" or "delete" a Systems Manager user. Must include "user" in the dataset for a "delete" request to destroy the user.
  236. * @memberof module:Pii
  237. * @param {string} orgId
  238. * @param {options} options
  239. * @return { Promise } A promise holding the PII request and status
  240. * @example <caption>Example request</caption>
  241. const options = {
  242. "type":"delete",
  243. "datasets":"["usage","events"]",
  244. "mac":"00:77:00:77:00:77"
  245. }
  246. meraki.submitPiiRequest(orgId, options).then((res) => {
  247. console.log(res.data);
  248. });
  249. *
  250. * @example <caption>Example response</caption>
  251. {
  252. "id": "1234",
  253. "organizationWide": false,
  254. "networkId": "N_1234",
  255. "type": "delete",
  256. "mac": "00:77:00:77:00:77",
  257. "datasets": "['usage', 'events']",
  258. "status": "in progress"
  259. }
  260. */
  261. submitPiiRequest(orgId, options) {
  262. if (!orgId) {
  263. return Promise.reject(new Error('The orgId is required'))
  264. }
  265. if (!options) {
  266. return Promise.reject(new Error('The options are required'))
  267. }
  268. return this.meraki.post(`/organizations/${orgId}/pii/requests`,options).then((res) => res.data);
  269. },
  270. /**
  271. * Delete a restrict processing PII request
  272. * @memberof module:Pii
  273. * @param {string} orgId
  274. * @param {string} piiId
  275. * @return { Promise } A promise holding the status code, 204 for success
  276. * @example <caption>Example request</caption>
  277. *
  278. * meraki.deletePiiRequest(orgId).then((res) => {
  279. * console.log(res);
  280. * });
  281. *
  282. * @example <caption>Example response</caption>
  283. Successful HTTP Status: 204
  284. */
  285. deletePiiRequest(orgId, piiId) {
  286. if (!orgId) {
  287. return Promise.reject(new Error('The orgId is required'))
  288. }
  289. if (!piiId) {
  290. return Promise.reject(new Error('The piiId is required'))
  291. }
  292. return this.meraki.delete(`/organizations/${orgId}/pii/requests/${piiId}`).then((res) => res.data);
  293. },
  294. }
  295. module.exports = pii;