Repository navigation
Expand file tree
/
Copy pathDevice-Onboarding.postman_collection.json
More file actions
566 lines (566 loc) · 23.3 KB
/
Copy pathDevice-Onboarding.postman_collection.json
File metadata and controls
566 lines (566 loc) · 23.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
{
"info": {
"_postman_id": "961b35d8-a689-4472-bb6c-75303f2ef1e6",
"name": "Device Onboarding (GLP)",
"description": "This workflow is designed to onboard devices to the HPE GreenLake Cloud Platform (GLP) and HPE Aruba Networking Central using GLP API calls. It supports the following steps:\n\n- Adding devices\n \n- Assigning devices to a Central application\n \n- Applying subscriptions to devices\n \n\n## Prerequisites\n\nThis workflow requires that a user has access to the HPE GreenLake Cloud Platform. The first step in executing this workflow is to fill out the Variables section of the Device Onboarding collection. The list of variables is used throughout the workflow to make a series of sequential API requests. Pay attention when filling out these variables. If they are incorrect or not in the proper format, errors may occur.\n\n### Import the Postman Collection\n\n1. Download the [provided Postman Collection](https://Device-Onboarding.json).\n \n2. Open Postman, click on the \"Import\" button, and select the collection file.\n \n3. Once imported, you will see all the available API endpoints in the collection.\n \n\n### Update Variables in the Collection\n\n1. Go to the **Variables** tab in the imported collection.\n \n2. Update the following variables before making any API calls in this collection:\n \n\n| **Name** | **Description** | **Example** |\n| --- | --- | --- |\n| glp_client_id | HPE GreenLake Cloud Platform credential client ID | 34a47b6e-1789-435d-bk0f-3bd547art5f8 |\n| glp_client_secret | HPE GreenLake Cloud Platform credential client secret | 45ad273a695f12ek83a4360765e04a2e |\n| glp_token | HPE GreenLake Cloud Platform token obtained by following the guide below | JWT Bearer Token |\n| device_mac | Device MAC Address | xx:xx:xx:xx:xx:xx |\n| device_sn | Device Serial Number | SGxxxxxxx |\n| central_application_id | Application ID | 373a74a1-xxxx-xxxx-xxxx-xxxxxxxxx |\n| central_application_region | Region of Application Deployment | us-west |\n| glp_device_id | Device ID | 22206f15-xxxx-xxxx-xxxx-xxxxxxxxx |\n| glp_subscription_id | Subscription ID | 73428f10-xxxx-xxxx-xxxx-xxxxxxxxx |\n\n## API Workflow\n\n### Authentication\n\nTo obtain API client credentials for GLP, follow [this guide](https://developer.arubanetworks.com/hpe-aruba-networking-central/docs/generating-a-hpe-greenlake-cloud-platform-token) on the HPE Aruba Networking Developer Hub. Fill out the `glp_client_id` and `glp_client_secret` variables, then run **Generate Access Token** to generate a token. If the API call is successful, the generated GLP access token will automatically be saved as the Postman variable `glp_token`. The GLP access token is valid for 15 minutes.\n\n> \\[!NOTE\\] \nFor each step in the onboarding workflow, all required API calls are organized in folders within the Postman collection. This structure is intended to help guide you through each step of the process. \n \n\n### 1\\. Add Devices\n\nThe first step of onboarding is to add devices to the GLP workspace. For this step, you need the device's unique Serial Number and MAC Address. The device Serial Number and MAC Address are listed physically on the device itself. Each device type has a slightly different location for this information:\n\n- Access Points: Bottom of the device\n \n- AOS-CX Switch: A tab you can pull out and view\n \n- Gateways: Back of the device\n \n\nOn the CLI of the device, you can also run an equivalent 'show system' command, which differs depending on whether you're on AOS-CX, AOS8, or AOS10.\n\n- AOS-CX Switch CLI: `show system`\n \n- AOS10 CLI: `show inventory`\n \n\nOnce you have identified the device's serial number and MAC address, save these as the `device_sn` and `device_mac` Postman collection variables, respectively. You can then run the **Add Device(s)** API call. \nThis is an asynchronous operation. If the add device API call has been accepted, you will receive a 202 API response code. You need to verify the device was added by logging into the GLP workspace. You can now continue with the rest of the onboarding process.\n\n### 2\\. Assign Devices to Application\n\nAfter devices have been added to a GLP workspace, they need to be assigned to a Central application. Ensure that the following collection variables are populated:\n\n1. `central_application_id` - The central application ID can be determined by making a **Get Service Manager(s)** API call. The \"id\" variable in the same array element as the Central application whose name matches the \"name\" key is the central application ID.\n \n2. `central_application_region` - The central application region that corresponds to the region's deployment can be found in the following [list here](https://developer.greenlake.hpe.com/docs/greenlake/services/service-catalog/public/glossary/#region).\n \n3. `glp_device_id` - This can be found with the **Get Device** API call. For each device, the device's GLP ID will be returned with the 'id' attribute. You need to save the \"id\" attribute for the device you would like to assign to the application.\n \n\nThe **Assign Device(s) to Application** API call is an asynchronous operation. If the API call has been accepted, you will receive a 202 response with a transaction_id. The transaction ID will automatically be saved to the `device_app_transaction_id` Postman variable.\n\nYou can then run the **Get Device Assignment Status** API call to verify that the device assignment operation was successful. The API response will include `status` and `results` attributes, which will indicate if the device assignment to the application was successful or failed.\n\n### 3\\. Apply Subscription to Devices\n\nThe next onboarding step is applying subscriptions to devices. There are two variables needed for this step:\n\n1. `glp_device_id` - This can be found with the **Get Device(s)** API call. For each device, the device's GLP ID will be returned with the 'id' attribute. You need to save the \"id\" attribute for the device you would like to apply the subscription to.\n \n2. `glp_subscription_id` - This can be found with the **Get Subscription(s)** API call. For each subscription, the subscription's GLP ID will be returned with the 'id' attribute. You need to save the \"id\" attribute for the subscription you would like to apply to the device.\n \n\nThe **Apply Subscription to Device(s)** API call is an asynchronous operation. If the API call has been accepted, you will receive a 202 response with a transaction_id. The transaction ID will automatically be saved to the `device_sub_transaction_id` Postman variable.\n\nYou can then run the **Get Subscription Assignment Status** API call to verify that the subscription assignment operation was successful. The API response will include `status` and `results` attributes, which will indicate if the subscription assignment to the device was successful or failed.\n\n## Conclusion\n\nBy following this workflow and utilizing the organized API call folders in the Postman collection, you can efficiently onboard devices to HPE GreenLake Cloud Platform and HPE Aruba Networking Central. Ensure all required variables are set correctly and refer to the documentation links for additional guidance. If you encounter any issues, please contact the [Automation team](https://mailto:aruba-automation@hpe.com).",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "32717089"
},
"item": [
{
"name": "Authorization",
"item": [
{
"name": "Generate Access Token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code == 200){",
" console.log('Successfully obtained Access Token')",
" const response = pm.response.json()",
" var access_token = response['access_token']",
" console.info('Setting Access Token(glp_token) in Postman collection')",
" pm.collectionVariables.set(\"glp_token\", access_token);",
" console.log('You are now ready & authenticated to make API calls to your HPE GreenLake account')",
"}"
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"console.log('Generating Access Token...')",
"var required_variables = [\"client_id\", \"client_secret\"]",
"",
"required_variables.forEach(variable => {",
" if (!pm.collectionVariables.get(variable)) {",
" console.error('Missing required variable ' + variable + ' in Postman collection variables. Please add required variables before running the collection')",
" pm.execution.skipRequest()",
" }",
"})"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
},
{
"key": "client_id",
"value": "{{client_id}}",
"type": "text"
},
{
"key": "client_secret",
"value": "{{client_secret}}",
"type": "text"
}
]
},
"url": {
"raw": "https://sso.common.cloud.hpe.com/as/token.oauth2",
"protocol": "https",
"host": [
"sso",
"common",
"cloud",
"hpe",
"com"
],
"path": [
"as",
"token.oauth2"
]
}
},
"response": []
}
]
},
{
"name": "Step 1 - Add Device",
"item": [
{
"name": "Add Device(s)",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"network\": [\n {\n \"serialNumber\": \"{{device_sn}}\",\n \"macAddress\": \"{{device_mac}}\"\n }\n ],\n \"compute\": [],\n \"storage\": []\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://global.api.greenlake.hpe.com/devices/v1/devices",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"devices",
"v1",
"devices"
]
}
},
"response": []
}
],
"description": "The first step of onboarding is to add devices to the GLP workspace. For this step, you need the device's unique Serial Number and MAC Address. The device Serial Number and MAC Address are listed physically on the device itself. Each device type has a slightly different location for this information:\n\n- Access Points: Bottom of the device\n \n- AOS-CX Switch: A tab you can pull out and view\n \n- Gateways: Back of the device\n \n\nOn the CLI of the device, you can also run an equivalent 'show system' command, which differs depending on whether you're on AOS-CX, AOS8, or AOS10.\n\n- AOS-CX Switch CLI: `show system`\n \n- AOS10 CLI: `show inventory`\n \n\nOnce you have identified the device's serial number and MAC address, save these as the `device_sn` and `device_mac` Postman collection variables, respectively. You can then run the **Add Device(s)** API call. \nThis is an asynchronous operation. If the add device API call has been accepted, you will receive a 202 API response code. You need to verify the device was added by logging into the GLP workspace. You can now continue with the rest of the onboarding process."
},
{
"name": "Step 2 - Assign Device to Application",
"item": [
{
"name": "Get Service Manager(s)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://global.api.greenlake.hpe.com/service-catalog/v1/service-managers",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"service-catalog",
"v1",
"service-managers"
]
}
},
"response": []
},
{
"name": "Get Device(s)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://global.api.greenlake.hpe.com/devices/v1/devices?select=id,serialNumber,macAddress",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"devices",
"v1",
"devices"
],
"query": [
{
"key": "select",
"value": "id,serialNumber,macAddress"
}
]
}
},
"response": []
},
{
"name": "Assign Device(s) to Application",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 202) {",
" var jsonData = pm.response.json();",
" if (jsonData.transactionId) {",
" pm.collectionVariables.set(\"device_app_transaction_id\", jsonData.transactionId);",
" }",
"}"
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"const requiredVars = ['glp_token', 'glp_device_id', 'central_application_id', 'central_application_region']; ",
"let missingVars = [];",
"",
"requiredVars.forEach(varName => {",
" if (!pm.collectionVariables.has(varName) || !pm.collectionVariables.get(varName)) {",
" missingVars.push(varName);",
" }",
"});",
"",
"if (missingVars.length > 0) {",
" throw new Error(",
" `Missing required collection variable(s): ${missingVars.join(', ')}. Please set them in your collection variables.`",
" );",
"}"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"application\": {\n \"id\": \"{{central_application_id}}\"\n },\n \"region\": \"{{central_application_region}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://global.api.greenlake.hpe.com/devices/v1/devices?id={{glp_device_id}}",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"devices",
"v1",
"devices"
],
"query": [
{
"key": "id",
"value": "{{glp_device_id}}",
"description": "GLP ID of device"
}
]
}
},
"response": []
},
{
"name": "Get Device Assignment Status (Get progress of async operations in devices)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://global.api.greenlake.hpe.com/devices/v1/async-operations/{{device_app_transaction_id}}",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"devices",
"v1",
"async-operations",
"{{device_app_transaction_id}}"
]
}
},
"response": []
}
],
"description": "After devices have been added to a GLP workspace, they need to be assigned to a Central application. Ensure that the following collection variables are populated:\n\n1. `central_application_id` - The central application ID can be determined by making a **Get Service Manager(s)** API call. The \"id\" variable in the same array element as the Central application whose name matches the \"name\" key is the central application ID.\n \n2. `central_application_region` - The central application region that corresponds to the region's deployment can be found in the following [list here](https://developer.greenlake.hpe.com/docs/greenlake/services/service-catalog/public/glossary/#region).\n \n3. `glp_device_id` - This can be found with the **Get Device** API call. For each device, the device's GLP ID will be returned with the 'id' attribute. You need to save the \"id\" attribute for the device you would like to assign to the application.\n \n\nThe **Assign Device(s) to Application** API call is an asynchronous operation. If the API call has been accepted, you will receive a 202 response with a transaction_id. The transaction ID will automatically be saved to the `device_app_transaction_id` Postman variable.\n\nYou can then run the **Get Device Assignment Status** API call to verify that the device assignment operation was successful. The API response will include `status` and `results` attributes, which will indicate if the device assignment to the application was successful or failed."
},
{
"name": "Step 3 - Apply Subscription to Device",
"item": [
{
"name": "Get Subscription(s)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://global.api.greenlake.hpe.com/subscriptions/v1/subscriptions?select=id,key",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"subscriptions",
"v1",
"subscriptions"
],
"query": [
{
"key": "select",
"value": "id,key"
}
]
}
},
"response": []
},
{
"name": "Get Device(s)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://global.api.greenlake.hpe.com/devices/v1/devices?select=id,serialNumber,macAddress",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"devices",
"v1",
"devices"
],
"query": [
{
"key": "select",
"value": "id,serialNumber,macAddress"
}
]
}
},
"response": []
},
{
"name": "Apply Subscription to Device(s)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 202) {",
" var jsonData = pm.response.json();",
" if (jsonData.transactionId) {",
" pm.collectionVariables.set(\"device_sub_transaction_id\", jsonData.transactionId);",
" }",
"}"
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"const requiredVars = ['glp_token', 'glp_device_id', 'glp_subscription_id']; ",
"let missingVars = [];",
"",
"requiredVars.forEach(varName => {",
" if (!pm.collectionVariables.has(varName) || !pm.collectionVariables.get(varName)) {",
" missingVars.push(varName);",
" }",
"});",
"",
"if (missingVars.length > 0) {",
" throw new Error(",
" `Missing required collection variable(s): ${missingVars.join(', ')}. Please set them in your collection variables.`",
" );",
"}"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"subscription\": [\n {\n \"id\": \"{{glp_subscription_id}}\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://global.api.greenlake.hpe.com/devices/v1/devices?id={{glp_device_id}}",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"devices",
"v1",
"devices"
],
"query": [
{
"key": "id",
"value": "{{glp_device_id}}"
}
]
}
},
"response": []
},
{
"name": "Get Subscription Assignment Status (Get progress of async operations in devices)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://global.api.greenlake.hpe.com/devices/v1/async-operations/{{device_sub_transaction_id}}",
"protocol": "https",
"host": [
"global",
"api",
"greenlake",
"hpe",
"com"
],
"path": [
"devices",
"v1",
"async-operations",
"{{device_sub_transaction_id}}"
]
}
},
"response": []
}
],
"description": "The next onboarding step is applying subscriptions to devices. There are two variables needed for this step:\n\n1. `glp_device_id` - This can be found with the **Get Device(s)** API call. For each device, the device's GLP ID will be returned with the 'id' attribute. You need to save the \"id\" attribute for the device you would like to apply the subscription to.\n \n2. `glp_subscription_id` - This can be found with the **Get Subscription(s)** API call. For each subscription, the subscription's GLP ID will be returned with the 'id' attribute. You need to save the \"id\" attribute for the subscription you would like to apply to the device.\n \n\nThe **Apply Subscription to Device(s)** API call is an asynchronous operation. If the API call has been accepted, you will receive a 202 response with a transaction_id. The transaction ID will automatically be saved to the `device_sub_transaction_id` Postman variable.\n\nYou can then run the **Get Subscription Assignment Status** API call to verify that the subscription assignment operation was successful. The API response will include `status` and `results` attributes, which will indicate if the subscription assignment to the device was successful or failed."
}
],
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{glp_token}}",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
}
],
"variable": [
{
"key": "client_id",
"value": "",
"type": "string"
},
{
"key": "client_secret",
"value": "",
"type": "string"
},
{
"key": "glp_token",
"value": "",
"type": "string"
},
{
"key": "device_mac",
"value": "",
"type": "string"
},
{
"key": "device_sn",
"value": "",
"type": "string"
},
{
"key": "central_application_id",
"value": "",
"type": "string"
},
{
"key": "central_application_region",
"value": "",
"type": "string"
},
{
"key": "glp_device_id",
"value": "",
"type": "string"
},
{
"key": "glp_subscription_id",
"value": "",
"type": "string"
},
{
"key": "device_app_transaction_id",
"value": ""
},
{
"key": "device_sub_transaction_id",
"value": ""
}
]
}