@itentialopensource/adapter-aruba_central 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,164 +0,0 @@
1
-
2
- /**
3
- * @function apiInstallManagerExternalApiInviteInstaller
4
- * @pronghornType method
5
- * @name apiInstallManagerExternalApiInviteInstaller
6
- * @summary Invite a new installer
7
- *
8
- * @param {object} body - Installer Object to be invited
9
- * @param {getCallback} callback - a callback function to return the result
10
- * @return {object} results - An object containing the response of the action
11
- *
12
- * @route {POST} /apiInstallManagerExternalApiInviteInstaller
13
- * @roles admin
14
- * @task true
15
- */
16
- /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
17
- apiInstallManagerExternalApiInviteInstaller(body, callback) {
18
- const meth = 'adapter-apiInstallManagerExternalApiInviteInstaller';
19
- const origin = `${this.id}-${meth}`;
20
- log.trace(origin);
21
-
22
- if (this.suspended && this.suspendMode === 'error') {
23
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
24
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
25
- return callback(null, errorObj);
26
- }
27
-
28
- /* HERE IS WHERE YOU VALIDATE DATA */
29
- if (body === undefined || body === null || body === '') {
30
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
31
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
32
- return callback(null, errorObj);
33
- }
34
-
35
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
36
- const queryParamsAvailable = {};
37
- const queryParams = {};
38
- const pathVars = [];
39
- const bodyVars = body;
40
-
41
- // loop in template. long callback arg name to avoid identifier conflicts
42
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
43
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
44
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
45
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
46
- }
47
- });
48
-
49
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
50
- // see adapter code documentation for more information on the request object's fields
51
- const reqObj = {
52
- payload: bodyVars,
53
- uriPathVars: pathVars,
54
- uriQuery: queryParams
55
- };
56
-
57
- try {
58
- // Make the call -
59
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
60
- return this.requestHandlerInst.identifyRequest('Installers', 'apiInstallManagerExternalApiInviteInstaller', reqObj, true, (irReturnData, irReturnError) => {
61
- // if we received an error or their is no response on the results
62
- // return an error
63
- if (irReturnError) {
64
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
65
- return callback(null, irReturnError);
66
- }
67
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
68
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['apiInstallManagerExternalApiInviteInstaller'], null, null, null);
69
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
70
- return callback(null, errorObj);
71
- }
72
-
73
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
74
- // return the response
75
- return callback(irReturnData, null);
76
- });
77
- } catch (ex) {
78
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
79
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
80
- return callback(null, errorObj);
81
- }
82
- }
83
-
84
- /**
85
- * @function apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites
86
- * @pronghornType method
87
- * @name apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites
88
- * @summary For a given set of site names, assign Group Names for each device type
89
- *
90
- * @param {object} body - The Device Types to Groups mapping for a set of Sites
91
- * @param {getCallback} callback - a callback function to return the result
92
- * @return {object} results - An object containing the response of the action
93
- *
94
- * @route {POST} /apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites
95
- * @roles admin
96
- * @task true
97
- */
98
- /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
99
- apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites(body, callback) {
100
- const meth = 'adapter-apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites';
101
- const origin = `${this.id}-${meth}`;
102
- log.trace(origin);
103
-
104
- if (this.suspended && this.suspendMode === 'error') {
105
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
106
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
107
- return callback(null, errorObj);
108
- }
109
-
110
- /* HERE IS WHERE YOU VALIDATE DATA */
111
- if (body === undefined || body === null || body === '') {
112
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
113
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
114
- return callback(null, errorObj);
115
- }
116
-
117
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
118
- const queryParamsAvailable = {};
119
- const queryParams = {};
120
- const pathVars = [];
121
- const bodyVars = body;
122
-
123
- // loop in template. long callback arg name to avoid identifier conflicts
124
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
125
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
126
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
127
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
128
- }
129
- });
130
-
131
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
132
- // see adapter code documentation for more information on the request object's fields
133
- const reqObj = {
134
- payload: bodyVars,
135
- uriPathVars: pathVars,
136
- uriQuery: queryParams
137
- };
138
-
139
- try {
140
- // Make the call -
141
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
142
- return this.requestHandlerInst.identifyRequest('Sites', 'apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites', reqObj, true, (irReturnData, irReturnError) => {
143
- // if we received an error or their is no response on the results
144
- // return an error
145
- if (irReturnError) {
146
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
147
- return callback(null, irReturnError);
148
- }
149
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
150
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites'], null, null, null);
151
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
152
- return callback(null, errorObj);
153
- }
154
-
155
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
156
- // return the response
157
- return callback(irReturnData, null);
158
- });
159
- } catch (ex) {
160
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
161
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
162
- return callback(null, errorObj);
163
- }
164
- }
@@ -1,22 +0,0 @@
1
- [
2
- {
3
- "name": "apiInstallManagerExternalApiInviteInstaller",
4
- "protocol": "REST",
5
- "method": "POST",
6
- "entitypath": "{base_path}/{version}/v1/invite_installer?{query}",
7
- "requestSchema": "schema.json",
8
- "responseSchema": "schema.json",
9
- "timeout": 0,
10
- "sendEmpty": false,
11
- "requestDatatype": "JSON",
12
- "responseDatatype": "JSON",
13
- "headers": {},
14
- "responseObjects": [
15
- {
16
- "type": "default",
17
- "key": "",
18
- "mockFile": ""
19
- }
20
- ]
21
- }
22
- ]
@@ -1,20 +0,0 @@
1
- {
2
- "$id": "schema.json",
3
- "type": "object",
4
- "schema": "http://json-schema.org/draft-07/schema#",
5
- "translate": false,
6
- "dynamicfields": true,
7
- "properties": {
8
- "ph_request_type": {
9
- "type": "string",
10
- "description": "type of request (internal to adapter)",
11
- "default": "apiInstallManagerExternalApiInviteInstaller",
12
- "enum": [
13
- "apiInstallManagerExternalApiInviteInstaller",
14
- "apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites"
15
- ],
16
- "external_name": "ph_request_type"
17
- }
18
- },
19
- "definitions": {}
20
- }
@@ -1,22 +0,0 @@
1
- [
2
- {
3
- "name": "apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites",
4
- "protocol": "REST",
5
- "method": "POST",
6
- "entitypath": "{base_path}/{version}/v1/assign_group_to_device_types_in_sites?{query}",
7
- "requestSchema": "schema.json",
8
- "responseSchema": "schema.json",
9
- "timeout": 0,
10
- "sendEmpty": false,
11
- "requestDatatype": "JSON",
12
- "responseDatatype": "JSON",
13
- "headers": {},
14
- "responseObjects": [
15
- {
16
- "type": "default",
17
- "key": "",
18
- "mockFile": ""
19
- }
20
- ]
21
- }
22
- ]
@@ -1,20 +0,0 @@
1
- {
2
- "$id": "schema.json",
3
- "type": "object",
4
- "schema": "http://json-schema.org/draft-07/schema#",
5
- "translate": false,
6
- "dynamicfields": true,
7
- "properties": {
8
- "ph_request_type": {
9
- "type": "string",
10
- "description": "type of request (internal to adapter)",
11
- "default": "apiInstallManagerExternalApiInviteInstaller",
12
- "enum": [
13
- "apiInstallManagerExternalApiInviteInstaller",
14
- "apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites"
15
- ],
16
- "external_name": "ph_request_type"
17
- }
18
- },
19
- "definitions": {}
20
- }
@@ -1,204 +0,0 @@
1
- {
2
- "toDelByName": [],
3
- "toAppByName": [
4
- {
5
- "name": "Installers",
6
- "func": {
7
- "truePath": "/v1/invite_installer",
8
- "entityPath": "/v1/invite_installer",
9
- "fnName": "apiInstallManagerExternalApiInviteInstaller",
10
- "entityName": "Installers",
11
- "basePath": "/install_manager/external",
12
- "api_type": "POST",
13
- "summary": "Invite a new installer",
14
- "consumes": "JSON",
15
- "produces": "JSON",
16
- "description": "Invite a new installer using First Name, Last Name, Country Code, Mobile Number",
17
- "mode": "append",
18
- "parameters": [
19
- {
20
- "name": "body",
21
- "required": true,
22
- "in": "body",
23
- "description": "Installer Object to be invited",
24
- "trueName": "body",
25
- "type": "object",
26
- "schema": {
27
- "type": "object",
28
- "properties": {
29
- "first_name": {
30
- "type": "string",
31
- "description": "First Name of Installer",
32
- "example": "John"
33
- },
34
- "last_name": {
35
- "type": "string",
36
- "description": "Last Name of Installer",
37
- "example": "Smith"
38
- },
39
- "country_code": {
40
- "type": "string",
41
- "description": "Country code of Installer mobile number",
42
- "example": "+1"
43
- },
44
- "mobile_number": {
45
- "type": "string",
46
- "description": "Installer mobile number without spaces or special characters",
47
- "example": "9600024979"
48
- },
49
- "expire_at": {
50
- "type": "number",
51
- "description": "Date upto which the installer should be given access. Value is in epoch seconds",
52
- "example": 1619784760
53
- },
54
- "allow_config": {
55
- "type": "boolean",
56
- "description": "Allow the installer to add a device name during installation",
57
- "example": true
58
- },
59
- "sites": {
60
- "type": "array",
61
- "description": "The list of sites assigned to the installer",
62
- "items": {
63
- "type": "object",
64
- "properties": {
65
- "site_name": {
66
- "type": "string",
67
- "description": "Name of the site that installer has to setup",
68
- "example": "Market Street"
69
- }
70
- }
71
- }
72
- }
73
- },
74
- "definitions": {}
75
- },
76
- "hint": "{\\\"first_name\\\": \\\"string\\\", \\\"last_name\\\": \\\"string\\\", \\\"country_code\\\": \\\"string\\\", \\\"mobile_number\\\": \\\"string\\\", \\\"expire_at\\\": 123, \\\"allow_config\\\": \\\"boolean\\\", \\\"sites\\\": [{\\\"site_name\\\": \\\"string\\\"}]}",
77
- "defaultVal": "",
78
- "mockRequest": {
79
- "first_name": "John",
80
- "last_name": "Smith",
81
- "country_code": "+1",
82
- "mobile_number": "9600024979",
83
- "expire_at": 1619784760,
84
- "allow_config": true,
85
- "sites": [
86
- {
87
- "site_name": "Market Street"
88
- }
89
- ]
90
- }
91
- }
92
- ],
93
- "headerParameters": [],
94
- "fnMetaData": {
95
- "url": "/v1/invite_installer",
96
- "query": [],
97
- "body": [
98
- {
99
- "name": "body",
100
- "type": "object"
101
- }
102
- ],
103
- "path": []
104
- },
105
- "response": []
106
- },
107
- "fnName": "apiInstallManagerExternalApiInviteInstaller"
108
- },
109
- {
110
- "name": "Sites",
111
- "func": {
112
- "truePath": "/v1/assign_group_to_device_types_in_sites",
113
- "entityPath": "/v1/assign_group_to_device_types_in_sites",
114
- "fnName": "apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites",
115
- "entityName": "Sites",
116
- "basePath": "/install_manager/external",
117
- "api_type": "POST",
118
- "summary": "For a given set of site names, assign Group Names for each device type",
119
- "consumes": "JSON",
120
- "produces": "JSON",
121
- "description": "Site Name, Device Type, Group Name mapping",
122
- "mode": "append",
123
- "parameters": [
124
- {
125
- "name": "body",
126
- "required": true,
127
- "in": "body",
128
- "description": "The Device Types to Groups mapping for a set of Sites",
129
- "trueName": "body",
130
- "type": "object",
131
- "schema": {
132
- "type": "object",
133
- "properties": {
134
- "groups_association": {
135
- "type": "array",
136
- "items": {
137
- "type": "object",
138
- "properties": {
139
- "device_type": {
140
- "type": "string",
141
- "enum": [
142
- "IAP",
143
- "SWITCH",
144
- "GATEWAY"
145
- ]
146
- },
147
- "group_name": {
148
- "type": "string",
149
- "description": "Name of the Group that has to be assigned to this device-type"
150
- }
151
- }
152
- }
153
- },
154
- "sites_association": {
155
- "type": "array",
156
- "items": {
157
- "type": "object",
158
- "properties": {
159
- "site_name": {
160
- "type": "string",
161
- "description": "Name of the site that installer has to setup",
162
- "example": "Big Street"
163
- }
164
- }
165
- }
166
- }
167
- },
168
- "definitions": {}
169
- },
170
- "hint": "{\\\"groups_association\\\": [{\\\"device_type\\\": \\\"Must be one of [IAP, SWITCH, GATEWAY]\\\", \\\"group_name\\\": \\\"string\\\"}], \\\"sites_association\\\": [{\\\"site_name\\\": \\\"string\\\"}]}",
171
- "defaultVal": "",
172
- "mockRequest": {
173
- "groups_association": [
174
- {
175
- "device_type": "GATEWAY",
176
- "group_name": "string"
177
- }
178
- ],
179
- "sites_association": [
180
- {
181
- "site_name": "Big Street"
182
- }
183
- ]
184
- }
185
- }
186
- ],
187
- "headerParameters": [],
188
- "fnMetaData": {
189
- "url": "/v1/assign_group_to_device_types_in_sites",
190
- "query": [],
191
- "body": [
192
- {
193
- "name": "body",
194
- "type": "object"
195
- }
196
- ],
197
- "path": []
198
- },
199
- "response": []
200
- },
201
- "fnName": "apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites"
202
- }
203
- ]
204
- }
@@ -1,77 +0,0 @@
1
- [ {
2
- "name": "apiInstallManagerExternalApiInviteInstaller",
3
- "summary": "Invite a new installer",
4
- "description": "Invite a new installer using First Name, Last Name, Country Code, Mobile Number",
5
- "input": [
6
- {
7
- "name": "body",
8
- "type": "object",
9
-
10
- "info": "Installer Object to be invited: {\"first_name\": \"string\", \"last_name\": \"string\", \"country_code\": \"string\", \"mobile_number\": \"string\", \"expire_at\": 123, \"allow_config\": \"boolean\", \"sites\": [{\"site_name\": \"string\"}]}",
11
- "required": true,
12
- "schema":
13
-
14
- {"type":"object","properties":{"first_name":{"type":"string","description":"First Name of Installer","example":"John"},"last_name":{"type":"string","description":"Last Name of Installer","example":"Smith"},"country_code":{"type":"string","description":"Country code of Installer mobile number","example":"+1"},"mobile_number":{"type":"string","description":"Installer mobile number without spaces or special characters","example":"9600024979"},"expire_at":{"type":"number","description":"Date upto which the installer should be given access. Value is in epoch seconds","example":1619784760},"allow_config":{"type":"boolean","description":"Allow the installer to add a device name during installation","example":true},"sites":{"type":"array","description":"The list of sites assigned to the installer","items":{"type":"object","properties":{"site_name":{"type":"string","description":"Name of the site that installer has to setup","example":"Market Street"}}}}},"definitions":{}}
15
-
16
- }
17
-
18
- ],
19
- "output": {
20
- "name": "result",
21
- "type": "object",
22
- "description": "A JSON Object containing status, code and the result",
23
- "schema": {
24
- "title": "result",
25
- "type": "object"
26
- }
27
-
28
- },
29
- "roles": [
30
- "admin"
31
- ],
32
- "route": {
33
- "verb": "POST",
34
-
35
- "path": "/apiInstallManagerExternalApiInviteInstaller"
36
- },
37
- "task": true
38
- },
39
- {
40
- "name": "apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites",
41
- "summary": "For a given set of site names, assign Group Names for each device type",
42
- "description": "Site Name, Device Type, Group Name mapping",
43
- "input": [
44
- {
45
- "name": "body",
46
- "type": "object",
47
-
48
- "info": "The Device Types to Groups mapping for a set of Sites: {\"groups_association\": [{\"device_type\": \"Must be one of [IAP, SWITCH, GATEWAY]\", \"group_name\": \"string\"}], \"sites_association\": [{\"site_name\": \"string\"}]}",
49
- "required": true,
50
- "schema":
51
-
52
- {"type":"object","properties":{"groups_association":{"type":"array","items":{"type":"object","properties":{"device_type":{"type":"string","enum":["IAP","SWITCH","GATEWAY"]},"group_name":{"type":"string","description":"Name of the Group that has to be assigned to this device-type"}}}},"sites_association":{"type":"array","items":{"type":"object","properties":{"site_name":{"type":"string","description":"Name of the site that installer has to setup","example":"Big Street"}}}}},"definitions":{}}
53
-
54
- }
55
-
56
- ],
57
- "output": {
58
- "name": "result",
59
- "type": "object",
60
- "description": "A JSON Object containing status, code and the result",
61
- "schema": {
62
- "title": "result",
63
- "type": "object"
64
- }
65
-
66
- },
67
- "roles": [
68
- "admin"
69
- ],
70
- "route": {
71
- "verb": "POST",
72
-
73
- "path": "/apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites"
74
- },
75
- "task": true
76
- }
77
- ]
@@ -1,76 +0,0 @@
1
-
2
- const installersApiInstallManagerExternalApiInviteInstallerBodyParam = {
3
- first_name: 'John',
4
- last_name: 'Smith',
5
- country_code: '+1',
6
- mobile_number: '9600024979',
7
- expire_at: 1619784760,
8
- allow_config: true,
9
- sites: [
10
- {
11
- site_name: 'Market Street'
12
- }
13
- ]
14
- };
15
- describe('#apiInstallManagerExternalApiInviteInstaller - errors', () => {
16
- it('should work if integrated but since no mockdata should error when run standalone', (done) => {
17
- try {
18
- a.apiInstallManagerExternalApiInviteInstaller(installersApiInstallManagerExternalApiInviteInstallerBodyParam, (data, error) => {
19
- try {
20
- if (stub) {
21
- const displayE = 'Error 400 received on request';
22
- runErrorAsserts(data, error, 'AD.500', 'Test-append-connectorRest-handleEndResponse', displayE);
23
- } else {
24
- runCommonAsserts(data, error);
25
- }
26
- saveMockData('Installers', 'apiInstallManagerExternalApiInviteInstaller', 'default', data);
27
- done();
28
- } catch (err) {
29
- log.error(`Test Failure: ${err}`);
30
- done(err);
31
- }
32
- });
33
- } catch (error) {
34
- log.error(`Adapter Exception: ${error}`);
35
- done(error);
36
- }
37
- }).timeout(attemptTimeout);
38
- });
39
-
40
- const sitesApiInstallManagerExternalApiAssignGroupToDeviceTypesInSitesBodyParam = {
41
- groups_association: [
42
- {
43
- device_type: 'GATEWAY',
44
- group_name: 'string'
45
- }
46
- ],
47
- sites_association: [
48
- {
49
- site_name: 'Big Street'
50
- }
51
- ]
52
- };
53
- describe('#apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites - errors', () => {
54
- it('should work if integrated but since no mockdata should error when run standalone', (done) => {
55
- try {
56
- a.apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites(sitesApiInstallManagerExternalApiAssignGroupToDeviceTypesInSitesBodyParam, (data, error) => {
57
- try {
58
- if (stub) {
59
- const displayE = 'Error 400 received on request';
60
- runErrorAsserts(data, error, 'AD.500', 'Test-append-connectorRest-handleEndResponse', displayE);
61
- } else {
62
- runCommonAsserts(data, error);
63
- }
64
- saveMockData('Sites', 'apiInstallManagerExternalApiAssignGroupToDeviceTypesInSites', 'default', data);
65
- done();
66
- } catch (err) {
67
- log.error(`Test Failure: ${err}`);
68
- done(err);
69
- }
70
- });
71
- } catch (error) {
72
- log.error(`Adapter Exception: ${error}`);
73
- done(error);
74
- }
75
- }).timeout(attemptTimeout);
76
- });