comprodls-sdk 2.31.4 → 2.32.0

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.
package/lib/comprodls.js CHANGED
@@ -46,6 +46,7 @@ var validations = require('./token/validations');
46
46
  var drive = require('./services/drive');
47
47
  var taxonomy = require('./services/taxonomy');
48
48
  var rules = require('./services/rules');
49
+ var datasyncmanager = require('./services/datasyncmanager');
49
50
 
50
51
 
51
52
  /*********************************
@@ -148,3 +149,4 @@ comproDLS.prototype.Integrations = integrations;
148
149
  comproDLS.prototype.Drive = drive;
149
150
  comproDLS.prototype.Taxonomy = taxonomy;
150
151
  comproDLS.prototype.Rules = rules;
152
+ comproDLS.prototype.Datasyncmanager = datasyncmanager;
@@ -202,6 +202,11 @@ exports.AUTH_API_URLS = {
202
202
  //Showcase related API's
203
203
  showcaseItems: '/org/{orgId}/classes/{classId}/showcase/item',
204
204
 
205
+ //Data-Sync-Manager related APIs
206
+ createDataSyncManager: '/accounts/{accountid}/data-sync-managers',
207
+ dataSyncManager: '/accounts/{accountid}/data-sync-managers/{dsmid}',
208
+ getAllDataSyncManagersOfAGroup: '/accounts/{accountid}/dsm-groups/{dsm_groupid}/data-sync-managers'
209
+
205
210
  };
206
211
 
207
212
  exports.ACTIVITY_API_URLS = {
@@ -0,0 +1,310 @@
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+
21
+ /***********************************************************
22
+ * comproDLS SDK datasyncmanager Adaptor
23
+ * Functions for calling datasyncmanager APIs.
24
+ ************************************************************/
25
+
26
+ var q = require('q');
27
+ var request = require('superagent');
28
+ var Agent = require('agentkeepalive');
29
+
30
+ var helpers = require('../../helpers');
31
+ var DLSError = helpers.errors.DLSError;
32
+
33
+ /*********************************
34
+ * Setting Up Module Entry Point
35
+ **********************************/
36
+ module.exports = datasyncmanager;
37
+
38
+ var keepaliveAgent = new Agent({
39
+ timeout: 60000,
40
+ freeSocketTimeout: 30000
41
+ });
42
+
43
+ function datasyncmanager(accountId) {
44
+ this.accountId = accountId;
45
+
46
+ return {
47
+ createDataSyncManager: createDataSyncManager.bind(this),
48
+ updateDataSyncManager: updateDataSyncManager.bind(this),
49
+ deleteDataSyncManager: deleteDataSyncManager.bind(this),
50
+ getParticularDataSyncManager: getParticularDataSyncManager.bind(this),
51
+ getAllDataSyncManagersOfAGroup: getAllDataSyncManagersOfAGroup.bind(this)
52
+ };
53
+ }
54
+
55
+ /**
56
+ * options = {
57
+ * "*body": {
58
+ * "*dsmid": "string",
59
+ * "dsm_groupid": "string",
60
+ * "rules_orgs": [{"*id": "string"}, ...],
61
+ * "rules_products": [{
62
+ * "*productcode": "string",
63
+ * "*ext_entitlement_meta": { "start_date", "*end_date" },
64
+ * "*target_roles": [role]
65
+ * }],
66
+ * "*category": "entitlement_sync",
67
+ * "*type": "managed",
68
+ * "*ext_user_id": "string",
69
+ * "data": {},
70
+ * "*audit": true
71
+ * }
72
+ */
73
+ function createDataSyncManager(options) {
74
+ var self = this;
75
+ // Initializing promise
76
+ var dfd = q.defer();
77
+
78
+ if(options && options.body) {
79
+ // Passed all validations, Contruct API url
80
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.createDataSyncManager;
81
+ url = helpers.api.constructAPIUrl(url, {
82
+ accountid: self.accountId
83
+ });
84
+
85
+ var requestAPI = request.post(url)
86
+ .set('Content-Type', 'application/json')
87
+ .set('Accept', 'application/json')
88
+ .send(options.body);
89
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
90
+
91
+ requestAPI
92
+ .agent(keepaliveAgent)
93
+ .end(function(error, response) {
94
+ if(error) {
95
+ var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
96
+ dfd.reject(err);
97
+ }
98
+ else { dfd.resolve(response.body); }
99
+ });
100
+ } else {
101
+ var err = {};
102
+ err.message = err.description = 'Mandatory param - body ' +
103
+ 'not found in request options.';
104
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
105
+ dfd.reject(err);
106
+ }
107
+
108
+ return dfd.promise;
109
+ }
110
+
111
+ /**
112
+ * options = {
113
+ * "*dsmid": "datasyncmanagerid",
114
+ * "*body": {
115
+ * "rules_orgs": [{ "*id": "orgid" }, ...],
116
+ * "*rules_products": [{
117
+ * "*productcode": "<productcode-1>",
118
+ * "*ext_entitlement_meta": { "start_date", "*end_date" },
119
+ * "target_roles": ["role"],
120
+ * }],
121
+ * "*ext_user_id": "ext_actor_id",
122
+ * "data": {},
123
+ * "*audit": <boolean>
124
+ * }
125
+ * }
126
+ */
127
+ function updateDataSyncManager(options) {
128
+ // Initializing promise
129
+ var deferred = q.defer();
130
+ var self = this;
131
+
132
+ if (options && options.dsmid && options.body) {
133
+ // Passed all validations, Contruct API url
134
+ var adaptor = self.config.DEFAULT_HOSTS.AUTH,
135
+ apiPath = self.config.AUTH_API_URLS.dataSyncManager,
136
+ url = adaptor + apiPath;
137
+
138
+ url = helpers.api.constructAPIUrl(url, {
139
+ accountid: self.accountId, dsmid: options.dsmid
140
+ });
141
+
142
+ var params = options.body;
143
+ // Setup request with URL and Params
144
+ var requestAPI = request.put(url)
145
+ .set('Content-Type', 'application/json')
146
+ .set('Accept', 'application/json')
147
+ .send(params);
148
+
149
+ if (self.traceid) {
150
+ requestAPI.set('X-Amzn-Trace-Id', self.traceid);
151
+ }
152
+
153
+ requestAPI
154
+ .agent(keepaliveAgent)
155
+ .end(function(error, response) {
156
+ if (error) {
157
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
158
+ deferred.reject(error);
159
+ } else {
160
+ deferred.resolve(response.body);
161
+ }
162
+ });
163
+ } else {
164
+ var error = {};
165
+ error.message = error.description = 'Mandatory params: dsmid, body not found in the request options.';
166
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
167
+ deferred.reject(error);
168
+ }
169
+
170
+ return deferred.promise;
171
+ }
172
+
173
+ /**
174
+ * options = {
175
+ * "*dsmid": "string",
176
+ * "*body": {
177
+ * "*ext_user_id": "string",
178
+ * "*audit": true
179
+ * }
180
+ */
181
+ function deleteDataSyncManager(options) {
182
+ var self = this;
183
+ var dfd = q.defer();
184
+
185
+ if(options && options.dsmid && options.body) {
186
+ // Passed all validations, Contruct API url
187
+ var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.dataSyncManager;
188
+ url = helpers.api.constructAPIUrl(url, { accountid: self.accountId, dsmid: options.dsmid });
189
+
190
+ // Setup request with URL and Params
191
+ var requestAPI = request.delete(url)
192
+ .set('Content-Type', 'application/json')
193
+ .set('Accept', 'application/json')
194
+ .send(options.body);
195
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
196
+
197
+ requestAPI
198
+ .agent(keepaliveAgent)
199
+ .end(function (error, response) {
200
+ if(error) {
201
+ var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
202
+ dfd.reject(err);
203
+ }
204
+ else { dfd.resolve(response.body); }
205
+ });
206
+ }
207
+ else {
208
+ var err = {};
209
+ err.message = err.description = 'Mandatory params - dsmid or body' +
210
+ ' not found in request options.';
211
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
212
+ dfd.reject(err);
213
+ }
214
+
215
+ return dfd.promise;
216
+ }
217
+
218
+ /**
219
+ * options = {
220
+ * "*dsmid": "datasyncmanagerid"
221
+ * }
222
+ */
223
+ function getParticularDataSyncManager(options) {
224
+ // Initializing promise
225
+ var deferred = q.defer();
226
+ var self = this;
227
+
228
+ if (options && options.dsmid) {
229
+ // Passed all validations, Contruct API url
230
+ var adaptor = self.config.DEFAULT_HOSTS.AUTH,
231
+ apiPath = self.config.AUTH_API_URLS.dataSyncManager,
232
+ url = adaptor + apiPath;
233
+
234
+ url = helpers.api.constructAPIUrl(url, {
235
+ accountid: self.accountId, dsmid: options.dsmid
236
+ });
237
+
238
+ // Setup request with URL and Params
239
+ var requestAPI = request.get(url);
240
+
241
+ if (self.traceid) {
242
+ requestAPI.set('X-Amzn-Trace-Id', self.traceid);
243
+ }
244
+
245
+ requestAPI
246
+ .agent(keepaliveAgent)
247
+ .end(function(error, response) {
248
+ if (error) {
249
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
250
+ deferred.reject(error);
251
+ } else {
252
+ deferred.resolve(response.body);
253
+ }
254
+ });
255
+ } else {
256
+ var error = {};
257
+ error.message = error.description = 'Mandatory params: dsmid not found in request options.';
258
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
259
+ deferred.reject(error);
260
+ }
261
+
262
+ return deferred.promise;
263
+ }
264
+
265
+ /**
266
+ * options = {
267
+ * "*dsm_groupid": "datasyncmanagergroupid"
268
+ * }
269
+ */
270
+ function getAllDataSyncManagersOfAGroup(options) {
271
+ // Initializing promise
272
+ var deferred = q.defer();
273
+ var self = this;
274
+
275
+ if (options && options.dsm_groupid) {
276
+ // Passed all validations, Contruct API url
277
+ var adaptor = self.config.DEFAULT_HOSTS.AUTH,
278
+ apiPath = self.config.AUTH_API_URLS.getAllDataSyncManagersOfAGroup,
279
+ url = adaptor + apiPath;
280
+
281
+ url = helpers.api.constructAPIUrl(url, {
282
+ accountid: self.accountId, dsm_groupid: options.dsm_groupid
283
+ });
284
+
285
+ // Setup request with URL and Params
286
+ var requestAPI = request.get(url);
287
+
288
+ if (self.traceid) {
289
+ requestAPI.set('X-Amzn-Trace-Id', self.traceid);
290
+ }
291
+
292
+ requestAPI
293
+ .agent(keepaliveAgent)
294
+ .end(function(error, response) {
295
+ if (error) {
296
+ error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
297
+ deferred.reject(error);
298
+ } else {
299
+ deferred.resolve(response.body);
300
+ }
301
+ });
302
+ } else {
303
+ var error = {};
304
+ error.message = error.description = 'Mandatory params: dsm_groupid not found in request options.';
305
+ error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
306
+ deferred.reject(error);
307
+ }
308
+
309
+ return deferred.promise;
310
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "comprodls-sdk",
3
3
  "description": "comproDLS SDK for JavaScript",
4
- "version": "2.31.4",
4
+ "version": "2.32.0",
5
5
  "author": {
6
6
  "name": "Compro Technologies Private Limited",
7
7
  "url": "http://www.comprotechnologies.com/"