auth0 2.36.2 → 2.39.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/CHANGELOG.md +41 -0
- package/README.md +33 -11
- package/package.json +22 -14
- package/src/Auth0RestClient.js +72 -71
- package/src/RetryRestClient.js +78 -81
- package/src/auth/DatabaseAuthenticator.js +242 -259
- package/src/auth/OAUthWithIDTokenValidation.js +99 -103
- package/src/auth/OAuthAuthenticator.js +325 -344
- package/src/auth/PasswordlessAuthenticator.js +238 -252
- package/src/auth/TokensManager.js +231 -246
- package/src/auth/UsersManager.js +149 -160
- package/src/auth/idToken.js +22 -19
- package/src/auth/index.js +510 -581
- package/src/errors.js +23 -23
- package/src/index.js +3 -2
- package/src/management/ActionsManager.js +510 -584
- package/src/management/BlacklistedTokensManager.js +77 -84
- package/src/management/BrandingManager.js +141 -163
- package/src/management/ClientGrantsManager.js +132 -145
- package/src/management/ClientsManager.js +145 -161
- package/src/management/ConnectionsManager.js +215 -204
- package/src/management/CustomDomainsManager.js +140 -157
- package/src/management/DeviceCredentialsManager.js +95 -111
- package/src/management/EmailProviderManager.js +110 -128
- package/src/management/EmailTemplatesManager.js +96 -112
- package/src/management/GrantsManager.js +94 -101
- package/src/management/GuardianManager.js +381 -455
- package/src/management/HooksManager.js +283 -325
- package/src/management/JobsManager.js +310 -343
- package/src/management/LogStreamsManager.js +142 -158
- package/src/management/LogsManager.js +92 -99
- package/src/management/ManagementTokenProvider.js +112 -120
- package/src/management/MigrationsManager.js +81 -90
- package/src/management/OrganizationsManager.js +686 -761
- package/src/management/PromptsManager.js +160 -182
- package/src/management/ResourceServersManager.js +143 -160
- package/src/management/RolesManager.js +323 -369
- package/src/management/RulesConfigsManager.js +94 -110
- package/src/management/RulesManager.js +154 -176
- package/src/management/StatsManager.js +87 -103
- package/src/management/TenantManager.js +81 -97
- package/src/management/TicketsManager.js +107 -115
- package/src/management/UserBlocksManager.js +135 -162
- package/src/management/UsersManager.js +729 -852
- package/src/management/index.js +3094 -3619
- package/src/utils.js +31 -60
|
@@ -1,847 +1,772 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var RetryRestClient = require('../RetryRestClient');
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
* Simple facade for consuming a REST API endpoint.
|
|
8
|
-
* @external RestClient
|
|
9
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @class OrganizationsManager
|
|
14
6
|
* The organizations class provides a simple abstraction for performing CRUD operations
|
|
15
7
|
* on Auth0 OrganizationsManager.
|
|
16
|
-
* @constructor
|
|
17
|
-
* @memberOf module:management
|
|
18
|
-
*
|
|
19
|
-
* @param {Object} options The client options.
|
|
20
|
-
* @param {String} options.baseUrl The URL of the API.
|
|
21
|
-
* @param {Object} [options.headers] Headers to be included in all requests.
|
|
22
|
-
* @param {Object} [options.retry] Retry Policy Config
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
class OrganizationsManager {
|
|
10
|
+
/**
|
|
11
|
+
* @param {object} options The client options.
|
|
12
|
+
* @param {string} options.baseUrl The URL of the API.
|
|
13
|
+
* @param {object} [options.headers] Headers to be included in all requests.
|
|
14
|
+
* @param {object} [options.retry] Retry Policy Config
|
|
15
|
+
*/
|
|
16
|
+
constructor(options) {
|
|
17
|
+
if (options === null || typeof options !== 'object') {
|
|
18
|
+
throw new ArgumentError('Must provide manager options');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
22
|
+
throw new ArgumentError('Must provide a base URL for the API');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
26
|
+
throw new ArgumentError('The provided base URL is invalid');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Options object for the Rest Client instance.
|
|
31
|
+
*
|
|
32
|
+
* @type {object}
|
|
33
|
+
*/
|
|
34
|
+
const clientOptions = {
|
|
35
|
+
headers: options.headers,
|
|
36
|
+
query: { repeatParams: false },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Provides an abstraction layer for performing CRUD operations on
|
|
41
|
+
* {@link https://auth0.com/docs/api/v2}.
|
|
42
|
+
*
|
|
43
|
+
* @type {external:RestClient}
|
|
44
|
+
*/
|
|
45
|
+
const auth0RestClient = new Auth0RestClient(
|
|
46
|
+
`${options.baseUrl}/organizations/:id`,
|
|
47
|
+
clientOptions,
|
|
48
|
+
options.tokenProvider
|
|
49
|
+
);
|
|
50
|
+
this.organizations = new RetryRestClient(auth0RestClient, options.retry);
|
|
51
|
+
|
|
52
|
+
const connectionsInRoleClient = new Auth0RestClient(
|
|
53
|
+
`${options.baseUrl}/organizations/:id/enabled_connections/:connection_id`,
|
|
54
|
+
clientOptions,
|
|
55
|
+
options.tokenProvider
|
|
56
|
+
);
|
|
57
|
+
this.connections = new RetryRestClient(connectionsInRoleClient, options.retry);
|
|
58
|
+
|
|
59
|
+
const membersClient = new Auth0RestClient(
|
|
60
|
+
`${options.baseUrl}/organizations/:id/members/:user_id`,
|
|
61
|
+
clientOptions,
|
|
62
|
+
options.tokenProvider
|
|
63
|
+
);
|
|
64
|
+
this.members = new RetryRestClient(membersClient, options.retry);
|
|
65
|
+
|
|
66
|
+
const invitationClient = new Auth0RestClient(
|
|
67
|
+
`${options.baseUrl}/organizations/:id/invitations/:invitation_id`,
|
|
68
|
+
clientOptions,
|
|
69
|
+
options.tokenProvider
|
|
70
|
+
);
|
|
71
|
+
this.invitations = new RetryRestClient(invitationClient, options.retry);
|
|
72
|
+
|
|
73
|
+
const rolesClient = new Auth0RestClient(
|
|
74
|
+
`${options.baseUrl}/organizations/:id/members/:user_id/roles`,
|
|
75
|
+
clientOptions,
|
|
76
|
+
options.tokenProvider
|
|
77
|
+
);
|
|
78
|
+
this.roles = new RetryRestClient(rolesClient, options.retry);
|
|
79
|
+
|
|
80
|
+
const organizationByNameClient = new Auth0RestClient(
|
|
81
|
+
`${options.baseUrl}/organizations/name/:name`,
|
|
82
|
+
clientOptions,
|
|
83
|
+
options.tokenProvider
|
|
84
|
+
);
|
|
85
|
+
this.organizationsByName = new RetryRestClient(organizationByNameClient, options.retry);
|
|
27
86
|
}
|
|
28
87
|
|
|
29
|
-
|
|
30
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Create a new organization.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* management.organizations.create(data, function (err) {
|
|
93
|
+
* if (err) {
|
|
94
|
+
* // Handle error.
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* // Organization created.
|
|
98
|
+
* });
|
|
99
|
+
* @param {object} data Organization data object.
|
|
100
|
+
* @param {Function} [cb] Callback function.
|
|
101
|
+
* @returns {Promise|undefined}
|
|
102
|
+
*/
|
|
103
|
+
create(...args) {
|
|
104
|
+
return this.organizations.create(...args);
|
|
31
105
|
}
|
|
32
106
|
|
|
33
|
-
|
|
34
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Get all organizations.
|
|
109
|
+
*
|
|
110
|
+
* @example <caption>
|
|
111
|
+
* This method takes an optional object as first argument that may be used to
|
|
112
|
+
* specify pagination settings. If pagination options are not present,
|
|
113
|
+
* the first page of a limited number of results will be returned.
|
|
114
|
+
* </caption>
|
|
115
|
+
*
|
|
116
|
+
* // Pagination settings.
|
|
117
|
+
* var params = {
|
|
118
|
+
* per_page: 10,
|
|
119
|
+
* page: 0
|
|
120
|
+
* };
|
|
121
|
+
*
|
|
122
|
+
* management.organizations.getAll(params, function (err, organizations) {
|
|
123
|
+
* console.log(organizations.length);
|
|
124
|
+
* });
|
|
125
|
+
* @param {object} [params] Organizations parameters.
|
|
126
|
+
* @param {number} [params.per_page] Number of results per page.
|
|
127
|
+
* @param {number} [params.page] Page number, zero indexed.
|
|
128
|
+
* @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from.
|
|
129
|
+
* @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
|
|
130
|
+
* @param {Function} [cb] Callback function.
|
|
131
|
+
* @returns {Promise|undefined}
|
|
132
|
+
*/
|
|
133
|
+
getAll(...args) {
|
|
134
|
+
return this.organizations.getAll(...args);
|
|
35
135
|
}
|
|
36
136
|
|
|
37
137
|
/**
|
|
38
|
-
*
|
|
138
|
+
* Get an Auth0 organization.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* management.organizations.getByID({ id: ORGANIZATION_ID }, function (err, role) {
|
|
142
|
+
* if (err) {
|
|
143
|
+
* // Handle error.
|
|
144
|
+
* }
|
|
39
145
|
*
|
|
40
|
-
*
|
|
146
|
+
* console.log(organization);
|
|
147
|
+
* });
|
|
148
|
+
* @param {object} params Organization parameters.
|
|
149
|
+
* @param {string} params.id Organization ID.
|
|
150
|
+
* @param {Function} [cb] Callback function.
|
|
151
|
+
* @returns {Promise|undefined}
|
|
41
152
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
153
|
+
getByID(...args) {
|
|
154
|
+
return this.organizations.get(...args);
|
|
155
|
+
}
|
|
46
156
|
|
|
47
157
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
158
|
+
* Get an Auth0 organization.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* management.organizations.getByName({ name: ORGANIZATION_NAME}, function (err, role) {
|
|
162
|
+
* if (err) {
|
|
163
|
+
* // Handle error.
|
|
164
|
+
* }
|
|
50
165
|
*
|
|
51
|
-
*
|
|
166
|
+
* console.log(organization);
|
|
167
|
+
* });
|
|
168
|
+
* @param {object} params Organization parameters.
|
|
169
|
+
* @param {string} params.name Organization name.
|
|
170
|
+
* @param {Function} [cb] Callback function.
|
|
171
|
+
* @returns {Promise|undefined}
|
|
52
172
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
options.tokenProvider
|
|
57
|
-
);
|
|
58
|
-
this.organizations = new RetryRestClient(auth0RestClient, options.retry);
|
|
59
|
-
|
|
60
|
-
var connectionsInRoleClient = new Auth0RestClient(
|
|
61
|
-
options.baseUrl + '/organizations/:id/enabled_connections/:connection_id',
|
|
62
|
-
clientOptions,
|
|
63
|
-
options.tokenProvider
|
|
64
|
-
);
|
|
65
|
-
this.connections = new RetryRestClient(connectionsInRoleClient, options.retry);
|
|
66
|
-
|
|
67
|
-
var membersClient = new Auth0RestClient(
|
|
68
|
-
options.baseUrl + '/organizations/:id/members/:user_id',
|
|
69
|
-
clientOptions,
|
|
70
|
-
options.tokenProvider
|
|
71
|
-
);
|
|
72
|
-
this.members = new RetryRestClient(membersClient, options.retry);
|
|
73
|
-
|
|
74
|
-
var invitationClient = new Auth0RestClient(
|
|
75
|
-
options.baseUrl + '/organizations/:id/invitations/:invitation_id',
|
|
76
|
-
clientOptions,
|
|
77
|
-
options.tokenProvider
|
|
78
|
-
);
|
|
79
|
-
this.invitations = new RetryRestClient(invitationClient, options.retry);
|
|
80
|
-
|
|
81
|
-
var rolesClient = new Auth0RestClient(
|
|
82
|
-
options.baseUrl + '/organizations/:id/members/:user_id/roles',
|
|
83
|
-
clientOptions,
|
|
84
|
-
options.tokenProvider
|
|
85
|
-
);
|
|
86
|
-
this.roles = new RetryRestClient(rolesClient, options.retry);
|
|
87
|
-
|
|
88
|
-
var organizationByNameClient = new Auth0RestClient(
|
|
89
|
-
options.baseUrl + '/organizations/name/:name',
|
|
90
|
-
clientOptions,
|
|
91
|
-
options.tokenProvider
|
|
92
|
-
);
|
|
93
|
-
this.organizationsByName = new RetryRestClient(organizationByNameClient, options.retry);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Create a new organization.
|
|
98
|
-
*
|
|
99
|
-
* @method create
|
|
100
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* management.organizations.create(data, function (err) {
|
|
104
|
-
* if (err) {
|
|
105
|
-
* // Handle error.
|
|
106
|
-
* }
|
|
107
|
-
*
|
|
108
|
-
* // Organization created.
|
|
109
|
-
* });
|
|
110
|
-
*
|
|
111
|
-
* @param {Object} data Organization data object.
|
|
112
|
-
* @param {Function} [cb] Callback function.
|
|
113
|
-
*
|
|
114
|
-
* @return {Promise|undefined}
|
|
115
|
-
*/
|
|
116
|
-
utils.wrapPropertyMethod(OrganizationsManager, 'create', 'organizations.create');
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Get all organizations.
|
|
120
|
-
*
|
|
121
|
-
* @method getAll
|
|
122
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
123
|
-
*
|
|
124
|
-
* @example <caption>
|
|
125
|
-
* This method takes an optional object as first argument that may be used to
|
|
126
|
-
* specify pagination settings. If pagination options are not present,
|
|
127
|
-
* the first page of a limited number of results will be returned.
|
|
128
|
-
* </caption>
|
|
129
|
-
*
|
|
130
|
-
* // Pagination settings.
|
|
131
|
-
* var params = {
|
|
132
|
-
* per_page: 10,
|
|
133
|
-
* page: 0
|
|
134
|
-
* };
|
|
135
|
-
*
|
|
136
|
-
* management.organizations.getAll(params, function (err, organizations) {
|
|
137
|
-
* console.log(organizations.length);
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* @param {Object} [params] Organizations parameters.
|
|
141
|
-
* @param {Number} [params.per_page] Number of results per page.
|
|
142
|
-
* @param {Number} [params.page] Page number, zero indexed.
|
|
143
|
-
* @param {String} [params.from] For checkpoint pagination, the Id from which to start selection from.
|
|
144
|
-
* @param {Number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
|
|
145
|
-
* @param {Function} [cb] Callback function.
|
|
146
|
-
*
|
|
147
|
-
* @return {Promise|undefined}
|
|
148
|
-
*/
|
|
149
|
-
utils.wrapPropertyMethod(OrganizationsManager, 'getAll', 'organizations.getAll');
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Get an Auth0 organization.
|
|
153
|
-
*
|
|
154
|
-
* @method getByID
|
|
155
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* management.organizations.getByID({ id: ORGANIZATION_ID }, function (err, role) {
|
|
159
|
-
* if (err) {
|
|
160
|
-
* // Handle error.
|
|
161
|
-
* }
|
|
162
|
-
*
|
|
163
|
-
* console.log(organization);
|
|
164
|
-
* });
|
|
165
|
-
*
|
|
166
|
-
* @param {Object} params Organization parameters.
|
|
167
|
-
* @param {String} params.id Organization ID.
|
|
168
|
-
* @param {Function} [cb] Callback function.
|
|
169
|
-
*
|
|
170
|
-
* @return {Promise|undefined}
|
|
171
|
-
*/
|
|
172
|
-
utils.wrapPropertyMethod(OrganizationsManager, 'getByID', 'organizations.get');
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Get an Auth0 organization.
|
|
176
|
-
*
|
|
177
|
-
* @method getByName
|
|
178
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* management.organizations.getByName({ name: ORGANIZATION_NAME}, function (err, role) {
|
|
182
|
-
* if (err) {
|
|
183
|
-
* // Handle error.
|
|
184
|
-
* }
|
|
185
|
-
*
|
|
186
|
-
* console.log(organization);
|
|
187
|
-
* });
|
|
188
|
-
*
|
|
189
|
-
* @param {Object} params Organization parameters.
|
|
190
|
-
* @param {String} params.name Organization name.
|
|
191
|
-
* @param {Function} [cb] Callback function.
|
|
192
|
-
*
|
|
193
|
-
* @return {Promise|undefined}
|
|
194
|
-
*/
|
|
195
|
-
utils.wrapPropertyMethod(OrganizationsManager, 'getByName', 'organizationsByName.get');
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Update an existing organization.
|
|
199
|
-
*
|
|
200
|
-
* @method update
|
|
201
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* var data = { display_name: 'New name' };
|
|
205
|
-
* var params = { id: ORGANIZATION_ID };
|
|
206
|
-
*
|
|
207
|
-
* management.organizations.update(params, data, function (err, organization) {
|
|
208
|
-
* if (err) {
|
|
209
|
-
* // Handle error.
|
|
210
|
-
* }
|
|
211
|
-
*
|
|
212
|
-
* console.log(organization.name); // 'New name'
|
|
213
|
-
* });
|
|
214
|
-
*
|
|
215
|
-
* @param {Object} params Organization parameters.
|
|
216
|
-
* @param {String} params.id Organization ID.
|
|
217
|
-
* @param {Object} data Updated organization data.
|
|
218
|
-
* @param {Function} [cb] Callback function.
|
|
219
|
-
*
|
|
220
|
-
* @return {Promise|undefined}
|
|
221
|
-
*/
|
|
222
|
-
utils.wrapPropertyMethod(OrganizationsManager, 'update', 'organizations.patch');
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Delete an existing organization.
|
|
226
|
-
*
|
|
227
|
-
* @method delete
|
|
228
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* management.organizations.delete({ id: ORGANIZATION_ID }, function (err) {
|
|
232
|
-
* if (err) {
|
|
233
|
-
* // Handle error.
|
|
234
|
-
* }
|
|
235
|
-
*
|
|
236
|
-
* // Organization deleted.
|
|
237
|
-
* });
|
|
238
|
-
*
|
|
239
|
-
* @param {Object} params Organization parameters.
|
|
240
|
-
* @param {String} params.id Organization ID.
|
|
241
|
-
* @param {Function} [cb] Callback function.
|
|
242
|
-
*
|
|
243
|
-
* @return {Promise|undefined}
|
|
244
|
-
*/
|
|
245
|
-
utils.wrapPropertyMethod(OrganizationsManager, 'delete', 'organizations.delete');
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
**** Organization Connections
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Get Enabled Connections in a Organization
|
|
253
|
-
*
|
|
254
|
-
* @method getEnabledConnections
|
|
255
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* var params = {id : 'ORGANIZATION_ID'}
|
|
259
|
-
* @example <caption>
|
|
260
|
-
* This method takes an organization ID and returns the enabled connections in an Organization
|
|
261
|
-
* </caption>
|
|
262
|
-
*
|
|
263
|
-
* management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID'}, function (err, enabled_connections) {
|
|
264
|
-
* console.log(enabled_connections);
|
|
265
|
-
* });
|
|
266
|
-
*
|
|
267
|
-
* @param {String} [organization_id] Organization ID
|
|
268
|
-
* @param {Function} [cb] Callback function.
|
|
269
|
-
*
|
|
270
|
-
* @return {Promise|undefined}
|
|
271
|
-
*/
|
|
272
|
-
OrganizationsManager.prototype.getEnabledConnections = function(params, callback) {
|
|
273
|
-
return this.connections.getAll(params, callback);
|
|
274
|
-
};
|
|
173
|
+
getByName(...args) {
|
|
174
|
+
return this.organizationsByName.get(...args);
|
|
175
|
+
}
|
|
275
176
|
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
};
|
|
177
|
+
/**
|
|
178
|
+
* Update an existing organization.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* var data = { display_name: 'New name' };
|
|
182
|
+
* var params = { id: ORGANIZATION_ID };
|
|
183
|
+
*
|
|
184
|
+
* management.organizations.update(params, data, function (err, organization) {
|
|
185
|
+
* if (err) {
|
|
186
|
+
* // Handle error.
|
|
187
|
+
* }
|
|
188
|
+
*
|
|
189
|
+
* console.log(organization.name); // 'New name'
|
|
190
|
+
* });
|
|
191
|
+
* @param {object} params Organization parameters.
|
|
192
|
+
* @param {string} params.id Organization ID.
|
|
193
|
+
* @param {object} data Updated organization data.
|
|
194
|
+
* @param {Function} [cb] Callback function.
|
|
195
|
+
* @returns {Promise|undefined}
|
|
196
|
+
*/
|
|
197
|
+
update(...args) {
|
|
198
|
+
return this.organizations.patch(...args);
|
|
199
|
+
}
|
|
300
200
|
|
|
301
|
-
/**
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
* @param {Boolean} data.assign_membership_on_login flag to allow assign membership on login
|
|
321
|
-
* @param {Function} [cb] Callback function.
|
|
322
|
-
*
|
|
323
|
-
* @return {Promise|undefined}
|
|
324
|
-
*/
|
|
201
|
+
/**
|
|
202
|
+
* Delete an existing organization.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* management.organizations.delete({ id: ORGANIZATION_ID }, function (err) {
|
|
206
|
+
* if (err) {
|
|
207
|
+
* // Handle error.
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* // Organization deleted.
|
|
211
|
+
* });
|
|
212
|
+
* @param {object} params Organization parameters.
|
|
213
|
+
* @param {string} params.id Organization ID.
|
|
214
|
+
* @param {Function} [cb] Callback function.
|
|
215
|
+
* @returns {Promise|undefined}
|
|
216
|
+
*/
|
|
217
|
+
delete(...args) {
|
|
218
|
+
return this.organizations.delete(...args);
|
|
219
|
+
}
|
|
325
220
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
221
|
+
/**
|
|
222
|
+
*Organization Connections
|
|
223
|
+
*/
|
|
329
224
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Get Enabled Connections in a Organization
|
|
227
|
+
*
|
|
228
|
+
* @example <caption>
|
|
229
|
+
* This method takes an organization ID and returns the enabled connections in an Organization
|
|
230
|
+
* </caption>
|
|
231
|
+
* var params = {id : 'ORGANIZATION_ID'}
|
|
232
|
+
*
|
|
233
|
+
* management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID'}, function (err, enabled_connections) {
|
|
234
|
+
* console.log(enabled_connections);
|
|
235
|
+
* });
|
|
236
|
+
* @param {object} params Organization parameters.
|
|
237
|
+
* @param {string} params.id Organization ID.
|
|
238
|
+
* @param {Function} [cb] Callback function.
|
|
239
|
+
* @returns {Promise|undefined}
|
|
240
|
+
*/
|
|
241
|
+
getEnabledConnections(params, callback) {
|
|
242
|
+
return this.connections.getAll(params, callback);
|
|
335
243
|
}
|
|
336
244
|
|
|
337
|
-
|
|
338
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Get Enabled Connection in a Organization
|
|
247
|
+
*
|
|
248
|
+
* @example <caption>
|
|
249
|
+
* This methods takes the organization ID and connection ID and returns the enabled connection
|
|
250
|
+
* </caption>
|
|
251
|
+
* var params = {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}
|
|
252
|
+
*
|
|
253
|
+
* management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}, function (err, enabled_connection) {
|
|
254
|
+
* console.log(enabled_connection);
|
|
255
|
+
* });
|
|
256
|
+
* @param {object} params Organization parameters.
|
|
257
|
+
* @param {string} params.id Organization ID.
|
|
258
|
+
* @param {string} params.connection_id Connection ID.
|
|
259
|
+
* @param {Function} [callback] Callback function.
|
|
260
|
+
* @returns {Promise|undefined}
|
|
261
|
+
*/
|
|
262
|
+
getEnabledConnection(params, callback) {
|
|
263
|
+
return this.connections.get(params, callback);
|
|
339
264
|
}
|
|
340
265
|
|
|
341
|
-
|
|
342
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Add an enabled connection for an organization
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* var params = { id :'ORGANIZATION_ID'};
|
|
271
|
+
* var data = { "connection_id" : "CONNECTION_ID", assign_membership_on_login: false };
|
|
272
|
+
*
|
|
273
|
+
* management.organizations.addEnabledConnection(params, data, function (err) {
|
|
274
|
+
* if (err) {
|
|
275
|
+
* // Handle error.
|
|
276
|
+
* }
|
|
277
|
+
* });
|
|
278
|
+
* @param {object} params Organization parameters
|
|
279
|
+
* @param {string} params.id ID of the Organization.
|
|
280
|
+
* @param {object} data enable connection data
|
|
281
|
+
* @param {string} data.connection_id connection ID to enable
|
|
282
|
+
* @param {boolean} data.assign_membership_on_login flag to allow assign membership on login
|
|
283
|
+
* @param {Function} [cb] Callback function.
|
|
284
|
+
* @returns {Promise|undefined}
|
|
285
|
+
*/
|
|
343
286
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
* @method removeEnabledConnection
|
|
348
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
349
|
-
*
|
|
350
|
-
* @example
|
|
351
|
-
* var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
|
|
352
|
-
*
|
|
353
|
-
* management.organizations.removeEnabledConnection(params, function (err) {
|
|
354
|
-
* if (err) {
|
|
355
|
-
* // Handle error.
|
|
356
|
-
* }
|
|
357
|
-
* });
|
|
358
|
-
*
|
|
359
|
-
* @param {String} params.id ID of the Organization.
|
|
360
|
-
* @param {String} params.connection_id ID of the Connection.
|
|
361
|
-
* @param {Function} [cb] Callback function.
|
|
362
|
-
*
|
|
363
|
-
* @return {Promise|undefined}
|
|
364
|
-
*/
|
|
287
|
+
addEnabledConnection(params, data, cb) {
|
|
288
|
+
data = data || {};
|
|
289
|
+
params = params || {};
|
|
365
290
|
|
|
366
|
-
|
|
367
|
-
|
|
291
|
+
if (!params.id) {
|
|
292
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
293
|
+
}
|
|
294
|
+
if (typeof params.id !== 'string') {
|
|
295
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
296
|
+
}
|
|
368
297
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (typeof params.id !== 'string') {
|
|
373
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
374
|
-
}
|
|
298
|
+
if (cb && cb instanceof Function) {
|
|
299
|
+
return this.connections.create(params, data, cb);
|
|
300
|
+
}
|
|
375
301
|
|
|
376
|
-
|
|
377
|
-
throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
|
|
378
|
-
}
|
|
379
|
-
if (typeof params.connection_id !== 'string') {
|
|
380
|
-
throw new ArgumentError('The connection ID has to be a string');
|
|
302
|
+
return this.connections.create(params, data);
|
|
381
303
|
}
|
|
382
304
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Remove an enabled connection from an organization
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
|
|
310
|
+
*
|
|
311
|
+
* management.organizations.removeEnabledConnection(params, function (err) {
|
|
312
|
+
* if (err) {
|
|
313
|
+
* // Handle error.
|
|
314
|
+
* }
|
|
315
|
+
* });
|
|
316
|
+
* @param {object} params Organization parameters
|
|
317
|
+
* @param {string} params.id ID of the Organization.
|
|
318
|
+
* @param {string} params.connection_id ID of the Connection.
|
|
319
|
+
* @param {Function} [cb] Callback function.
|
|
320
|
+
* @returns {Promise|undefined}
|
|
321
|
+
*/
|
|
386
322
|
|
|
387
|
-
|
|
388
|
-
};
|
|
323
|
+
removeEnabledConnection(params, cb) {
|
|
324
|
+
params = params || {};
|
|
389
325
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
* @example
|
|
397
|
-
* var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
|
|
398
|
-
* var data = { assign_membership_on_login: true };
|
|
399
|
-
*
|
|
400
|
-
* management.organizations.updateEnabledConnection(params, data, function (err) {
|
|
401
|
-
* if (err) {
|
|
402
|
-
* // Handle error.
|
|
403
|
-
* }
|
|
404
|
-
* });
|
|
405
|
-
*
|
|
406
|
-
* @param {String} params.id ID of the Organization.
|
|
407
|
-
* @param {String} params.connection_id ID of the Connection.
|
|
408
|
-
* @param {Object} data Updated connection.
|
|
409
|
-
* @param {Function} [cb] Callback function.
|
|
410
|
-
*
|
|
411
|
-
* @return {Promise|undefined}
|
|
412
|
-
*/
|
|
326
|
+
if (!params.id) {
|
|
327
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
328
|
+
}
|
|
329
|
+
if (typeof params.id !== 'string') {
|
|
330
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
331
|
+
}
|
|
413
332
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
333
|
+
if (!params.connection_id) {
|
|
334
|
+
throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
|
|
335
|
+
}
|
|
336
|
+
if (typeof params.connection_id !== 'string') {
|
|
337
|
+
throw new ArgumentError('The connection ID has to be a string');
|
|
338
|
+
}
|
|
417
339
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (typeof params.id !== 'string') {
|
|
422
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
423
|
-
}
|
|
340
|
+
if (cb && cb instanceof Function) {
|
|
341
|
+
return this.connections.delete(params, {}, cb);
|
|
342
|
+
}
|
|
424
343
|
|
|
425
|
-
|
|
426
|
-
throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
|
|
427
|
-
}
|
|
428
|
-
if (typeof params.connection_id !== 'string') {
|
|
429
|
-
throw new ArgumentError('The connection ID has to be a string');
|
|
344
|
+
return this.connections.delete(params, {});
|
|
430
345
|
}
|
|
431
346
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
347
|
+
/**
|
|
348
|
+
* Update an enabled connection from an organization
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
|
|
352
|
+
* var data = { assign_membership_on_login: true };
|
|
353
|
+
*
|
|
354
|
+
* management.organizations.updateEnabledConnection(params, data, function (err) {
|
|
355
|
+
* if (err) {
|
|
356
|
+
* // Handle error.
|
|
357
|
+
* }
|
|
358
|
+
* });
|
|
359
|
+
* @param {object} params Organization parameters
|
|
360
|
+
* @param {string} params.id ID of the Organization.
|
|
361
|
+
* @param {string} params.connection_id ID of the Connection.
|
|
362
|
+
* @param {object} data Updated connection.
|
|
363
|
+
* @param {Function} [cb] Callback function.
|
|
364
|
+
* @returns {Promise|undefined}
|
|
365
|
+
*/
|
|
435
366
|
|
|
436
|
-
|
|
437
|
-
};
|
|
367
|
+
updateEnabledConnection(params, data, cb) {
|
|
368
|
+
data = data || {};
|
|
369
|
+
params = params || {};
|
|
438
370
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
371
|
+
if (!params.id) {
|
|
372
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
373
|
+
}
|
|
374
|
+
if (typeof params.id !== 'string') {
|
|
375
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
376
|
+
}
|
|
442
377
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
* @example
|
|
450
|
-
* var params = {id : 'ORGANIZATION_ID'}
|
|
451
|
-
* @example <caption>
|
|
452
|
-
* This method takes an organization ID and returns the members in an Organization
|
|
453
|
-
* </caption>
|
|
454
|
-
*
|
|
455
|
-
* management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) {
|
|
456
|
-
* console.log(members);
|
|
457
|
-
* });
|
|
458
|
-
*
|
|
459
|
-
* @param {String} [params.id] Organization ID
|
|
460
|
-
* @param {String} [params.from] For checkpoint pagination, the Id from which to start selection from.
|
|
461
|
-
* @param {Number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
|
|
462
|
-
* @param {Function} [cb] Callback function.
|
|
463
|
-
*
|
|
464
|
-
* @return {Promise|undefined}
|
|
465
|
-
*/
|
|
466
|
-
OrganizationsManager.prototype.getMembers = function(params, callback) {
|
|
467
|
-
return this.members.getAll(params, callback);
|
|
468
|
-
};
|
|
378
|
+
if (!params.connection_id) {
|
|
379
|
+
throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
|
|
380
|
+
}
|
|
381
|
+
if (typeof params.connection_id !== 'string') {
|
|
382
|
+
throw new ArgumentError('The connection ID has to be a string');
|
|
383
|
+
}
|
|
469
384
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
* @method addMembers
|
|
474
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* var params = { id :'ORGANIZATION_ID'};
|
|
478
|
-
* var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
|
|
479
|
-
* management.organizations.addMembers(params, data, function (err) {
|
|
480
|
-
* if (err) {
|
|
481
|
-
* // Handle error.
|
|
482
|
-
* }
|
|
483
|
-
* });
|
|
484
|
-
*
|
|
485
|
-
* @param {String} params.id ID of the Organization.
|
|
486
|
-
* @param {Object} data add members data
|
|
487
|
-
* @param {Array} data.members Array of user IDs
|
|
488
|
-
* @param {Function} [cb] Callback function.
|
|
489
|
-
*
|
|
490
|
-
* @return {Promise|undefined}
|
|
491
|
-
*/
|
|
492
|
-
OrganizationsManager.prototype.addMembers = function(params, data, cb) {
|
|
493
|
-
data = data || {};
|
|
494
|
-
params = params || {};
|
|
385
|
+
if (cb && cb instanceof Function) {
|
|
386
|
+
return this.connections.patch(params, data, cb);
|
|
387
|
+
}
|
|
495
388
|
|
|
496
|
-
|
|
497
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
498
|
-
}
|
|
499
|
-
if (typeof params.id !== 'string') {
|
|
500
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
389
|
+
return this.connections.patch(params, data);
|
|
501
390
|
}
|
|
502
391
|
|
|
503
|
-
|
|
504
|
-
|
|
392
|
+
/**
|
|
393
|
+
*Organization Members
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Get Members in a Organization
|
|
398
|
+
*
|
|
399
|
+
* @example <caption>
|
|
400
|
+
* This method takes an organization ID and returns the members in an Organization
|
|
401
|
+
* </caption>
|
|
402
|
+
*
|
|
403
|
+
* var params = {id : 'ORGANIZATION_ID'}
|
|
404
|
+
*
|
|
405
|
+
* management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) {
|
|
406
|
+
* console.log(members);
|
|
407
|
+
* });
|
|
408
|
+
* @param {object} params Organization parameters
|
|
409
|
+
* @param {string} params.id Organization ID
|
|
410
|
+
* @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from.
|
|
411
|
+
* @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
|
|
412
|
+
* @param {Function} [cb] Callback function.
|
|
413
|
+
* @returns {Promise|undefined}
|
|
414
|
+
*/
|
|
415
|
+
getMembers(params, callback) {
|
|
416
|
+
return this.members.getAll(params, callback);
|
|
505
417
|
}
|
|
506
418
|
|
|
507
|
-
|
|
508
|
-
|
|
419
|
+
/**
|
|
420
|
+
* Add members in an organization
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* var params = { id :'ORGANIZATION_ID'};
|
|
424
|
+
* var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
|
|
425
|
+
* management.organizations.addMembers(params, data, function (err) {
|
|
426
|
+
* if (err) {
|
|
427
|
+
* // Handle error.
|
|
428
|
+
* }
|
|
429
|
+
* });
|
|
430
|
+
* @param {object} params Organization parameters
|
|
431
|
+
* @param {string} params.id ID of the Organization.
|
|
432
|
+
* @param {object} data add members data
|
|
433
|
+
* @param {Array} data.members Array of user IDs
|
|
434
|
+
* @param {Function} [cb] Callback function.
|
|
435
|
+
* @returns {Promise|undefined}
|
|
436
|
+
*/
|
|
437
|
+
addMembers(params, data, cb) {
|
|
438
|
+
data = data || {};
|
|
439
|
+
params = params || {};
|
|
509
440
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
* @example
|
|
517
|
-
* var params = { id :'ORGANIZATION_ID' };
|
|
518
|
-
* var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
|
|
519
|
-
*
|
|
520
|
-
* management.organizations.removeMembers(params, data, function (err) {
|
|
521
|
-
* if (err) {
|
|
522
|
-
* // Handle error.
|
|
523
|
-
* }
|
|
524
|
-
* });
|
|
525
|
-
*
|
|
526
|
-
* @param {String} params.id ID of the Organization.
|
|
527
|
-
* @param {Object} data add members data
|
|
528
|
-
* @param {Array} data.members Array of user IDs
|
|
529
|
-
* @param {Function} [cb] Callback function.
|
|
530
|
-
*
|
|
531
|
-
* @return {Promise|undefined}
|
|
532
|
-
*/
|
|
533
|
-
OrganizationsManager.prototype.removeMembers = function(params, data, cb) {
|
|
534
|
-
data = data || {};
|
|
535
|
-
params = params || {};
|
|
441
|
+
if (!params.id) {
|
|
442
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
443
|
+
}
|
|
444
|
+
if (typeof params.id !== 'string') {
|
|
445
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
446
|
+
}
|
|
536
447
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
if (typeof params.id !== 'string') {
|
|
541
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
542
|
-
}
|
|
448
|
+
if (cb && cb instanceof Function) {
|
|
449
|
+
return this.members.create(params, data, cb);
|
|
450
|
+
}
|
|
543
451
|
|
|
544
|
-
|
|
545
|
-
return this.members.delete(params, data, cb);
|
|
452
|
+
return this.members.create(params, data);
|
|
546
453
|
}
|
|
547
454
|
|
|
548
|
-
|
|
549
|
-
|
|
455
|
+
/**
|
|
456
|
+
* Remove members from an organization
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* var params = { id :'ORGANIZATION_ID' };
|
|
460
|
+
* var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
|
|
461
|
+
*
|
|
462
|
+
* management.organizations.removeMembers(params, data, function (err) {
|
|
463
|
+
* if (err) {
|
|
464
|
+
* // Handle error.
|
|
465
|
+
* }
|
|
466
|
+
* });
|
|
467
|
+
* @param {object} params Organization parameters
|
|
468
|
+
* @param {string} params.id ID of the Organization.
|
|
469
|
+
* @param {object} data add members data
|
|
470
|
+
* @param {Array} data.members Array of user IDs
|
|
471
|
+
* @param {Function} [cb] Callback function.
|
|
472
|
+
* @returns {Promise|undefined}
|
|
473
|
+
*/
|
|
474
|
+
removeMembers(params, data, cb) {
|
|
475
|
+
data = data || {};
|
|
476
|
+
params = params || {};
|
|
550
477
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
478
|
+
if (!params.id) {
|
|
479
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
480
|
+
}
|
|
481
|
+
if (typeof params.id !== 'string') {
|
|
482
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
483
|
+
}
|
|
554
484
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
* @method getInvitations
|
|
559
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
560
|
-
*
|
|
561
|
-
* @example
|
|
562
|
-
* var params = {id : 'ORGANIZATION_ID'}
|
|
563
|
-
* @example <caption>
|
|
564
|
-
* This method takes an organization ID and returns the invites in an Organization
|
|
565
|
-
* </caption>
|
|
566
|
-
*
|
|
567
|
-
* management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) {
|
|
568
|
-
* console.log(invites);
|
|
569
|
-
* });
|
|
570
|
-
*
|
|
571
|
-
* @param {String} [params.id] Organization ID
|
|
572
|
-
* @param {Function} [cb] Callback function.
|
|
573
|
-
*
|
|
574
|
-
* @return {Promise|undefined}
|
|
575
|
-
*/
|
|
576
|
-
OrganizationsManager.prototype.getInvitations = function(params, callback) {
|
|
577
|
-
return this.invitations.getAll(params, callback);
|
|
578
|
-
};
|
|
485
|
+
if (cb && cb instanceof Function) {
|
|
486
|
+
return this.members.delete(params, data, cb);
|
|
487
|
+
}
|
|
579
488
|
|
|
580
|
-
|
|
581
|
-
* Get an Invitation in a Organization
|
|
582
|
-
*
|
|
583
|
-
* @method getInvitation
|
|
584
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
585
|
-
*
|
|
586
|
-
* @example
|
|
587
|
-
* var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}
|
|
588
|
-
* @example <caption>
|
|
589
|
-
* This methods takes the organization ID and user ID and returns the invitation
|
|
590
|
-
* </caption>
|
|
591
|
-
*
|
|
592
|
-
* management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) {
|
|
593
|
-
* console.log(invite);
|
|
594
|
-
* });
|
|
595
|
-
*
|
|
596
|
-
* @param {String} [organization_id] Organization ID
|
|
597
|
-
* @param {Function} [cb] Callback function.
|
|
598
|
-
*
|
|
599
|
-
* @return {Promise|undefined}
|
|
600
|
-
*/
|
|
601
|
-
OrganizationsManager.prototype.getInvitation = function(params, callback) {
|
|
602
|
-
if (!params.id) {
|
|
603
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
604
|
-
}
|
|
605
|
-
if (typeof params.id !== 'string') {
|
|
606
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
489
|
+
return this.members.delete(params, data);
|
|
607
490
|
}
|
|
608
491
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
492
|
+
/**
|
|
493
|
+
*Organization Invites
|
|
494
|
+
*/
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Get Invites in a Organization
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* var params = {id : 'ORGANIZATION_ID'}
|
|
501
|
+
* @example <caption>
|
|
502
|
+
* This method takes an organization ID and returns the invites in an Organization
|
|
503
|
+
* </caption>
|
|
504
|
+
*
|
|
505
|
+
* management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) {
|
|
506
|
+
* console.log(invites);
|
|
507
|
+
* @param callback
|
|
508
|
+
* });
|
|
509
|
+
* @param {object} params Organization parameters
|
|
510
|
+
* @param {string} params.id Organization ID
|
|
511
|
+
* @param {number} [params.per_page] Number of results per page.
|
|
512
|
+
* @param {number} [params.page] Page number, zero indexed.
|
|
513
|
+
* @param {string} [params.from] For checkpoint pagination, the Id from which to start selection from.
|
|
514
|
+
* @param {number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
|
|
515
|
+
* @param {string} [params.fields] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.
|
|
516
|
+
* @param {boolean} [params.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true.
|
|
517
|
+
* @param {string} [params.sort] Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1.
|
|
518
|
+
* @param {Function} [cb] Callback function.
|
|
519
|
+
* @returns {Promise|undefined}
|
|
520
|
+
*/
|
|
521
|
+
getInvitations(params, callback) {
|
|
522
|
+
return this.invitations.getAll(params, callback);
|
|
614
523
|
}
|
|
615
524
|
|
|
616
|
-
|
|
617
|
-
|
|
525
|
+
/**
|
|
526
|
+
* Get an Invitation in a Organization
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}
|
|
530
|
+
* @param callback
|
|
531
|
+
* @example <caption>
|
|
532
|
+
* This methods takes the organization ID and user ID and returns the invitation
|
|
533
|
+
* </caption>
|
|
534
|
+
*
|
|
535
|
+
* management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) {
|
|
536
|
+
* console.log(invite);
|
|
537
|
+
* });
|
|
538
|
+
* @param {object} params Organization parameters
|
|
539
|
+
* @param {string} params.id Organization ID
|
|
540
|
+
* @param {string} params.invitation_id Invitation ID
|
|
541
|
+
* @param {Function} [cb] Callback function.
|
|
542
|
+
* @returns {Promise|undefined}
|
|
543
|
+
*/
|
|
544
|
+
getInvitation(params, callback) {
|
|
545
|
+
if (!params.id) {
|
|
546
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
547
|
+
}
|
|
548
|
+
if (typeof params.id !== 'string') {
|
|
549
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
550
|
+
}
|
|
618
551
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
* @example
|
|
626
|
-
* var params = { id :'ORGANIZATION_ID'};
|
|
627
|
-
* var data = {
|
|
628
|
-
* client_id: CLIENT_ID,
|
|
629
|
-
* invitee: { email: 'invitee@example.com' },
|
|
630
|
-
* inviter: { name: 'John Doe' }
|
|
631
|
-
* };
|
|
632
|
-
*
|
|
633
|
-
* management.organizations.createInvitation(params, data, function (err) {
|
|
634
|
-
* if (err) {
|
|
635
|
-
* // Handle error.
|
|
636
|
-
* }
|
|
637
|
-
* });
|
|
638
|
-
*
|
|
639
|
-
* @param {String} params.id ID of the Organization.
|
|
640
|
-
* @param {Array} data Invitation data
|
|
641
|
-
* @param {Object} data.inviter The person who is sending the invite.
|
|
642
|
-
* @param {String} data.inviter.name Name of the person who is sending the invite
|
|
643
|
-
* @param {Object} data.invitee Invitee to whom invitation is intended for
|
|
644
|
-
* @param {Object} data.invitee.email Email of the invitee to whom invitation is intended for
|
|
645
|
-
* @param {String} data.client_id Auth0 client used to resolve the default application login URI. This endpoint must expect &invitation=... and &organization=... parameters (added by API2) to continue the flow with /authorize. If client_id does not have configured login URI, use the tenant level default login route if configured, otherwise return 400
|
|
646
|
-
* @param {String} [data.connection_id] Force user to authenticate against a specific identity provider.
|
|
647
|
-
* @param {Object} [data.app_metadata] Application metadata to be assigned to the user after accept the invitation.
|
|
648
|
-
* @param {Object} [data.user_metadata] User metadata to be assigned to the user after accept the invitation.
|
|
649
|
-
* @param {Array} [data.roles] List of roles to be assigned to the user
|
|
650
|
-
* @param {Number} [data.ttl_sec] Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Upper limit on ttl_sec is 30 days.
|
|
651
|
-
* @param {Boolean} [data.send_invitation_email] Whether the user will receive an invitation email (true) or no email (false). Default is true.
|
|
652
|
-
* @param {Function} [cb] Callback function.
|
|
653
|
-
*
|
|
654
|
-
* @return {Promise|undefined}
|
|
655
|
-
*/
|
|
656
|
-
OrganizationsManager.prototype.createInvitation = function(params, data, cb) {
|
|
657
|
-
data = data || [];
|
|
658
|
-
params = params || {};
|
|
552
|
+
if (!params.invitation_id) {
|
|
553
|
+
throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
|
|
554
|
+
}
|
|
555
|
+
if (typeof params.invitation_id !== 'string') {
|
|
556
|
+
throw new ArgumentError('The invitation ID has to be a string');
|
|
557
|
+
}
|
|
659
558
|
|
|
660
|
-
|
|
661
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
662
|
-
}
|
|
663
|
-
if (typeof params.id !== 'string') {
|
|
664
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
559
|
+
return this.invitations.get(params, callback);
|
|
665
560
|
}
|
|
666
561
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
562
|
+
/**
|
|
563
|
+
* Create an invitation in an organization
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* var params = { id :'ORGANIZATION_ID'};
|
|
567
|
+
* var data = {
|
|
568
|
+
* client_id: CLIENT_ID,
|
|
569
|
+
* invitee: { email: 'invitee@example.com' },
|
|
570
|
+
* inviter: { name: 'John Doe' }
|
|
571
|
+
* };
|
|
572
|
+
*
|
|
573
|
+
* management.organizations.createInvitation(params, data, function (err) {
|
|
574
|
+
* if (err) {
|
|
575
|
+
* // Handle error.
|
|
576
|
+
* }
|
|
577
|
+
* });
|
|
578
|
+
* @param {object} params Organization parameters
|
|
579
|
+
* @param {string} params.id ID of the Organization.
|
|
580
|
+
* @param {Array} data Invitation data
|
|
581
|
+
* @param {object} data.inviter The person who is sending the invite.
|
|
582
|
+
* @param {string} data.inviter.name Name of the person who is sending the invite
|
|
583
|
+
* @param {object} data.invitee Invitee to whom invitation is intended for
|
|
584
|
+
* @param {object} data.invitee.email Email of the invitee to whom invitation is intended for
|
|
585
|
+
* @param {string} data.client_id Auth0 client used to resolve the default application login URI. This endpoint must expect &invitation=... and &organization=... parameters (added by API2) to continue the flow with /authorize. If client_id does not have configured login URI, use the tenant level default login route if configured, otherwise return 400
|
|
586
|
+
* @param {string} [data.connection_id] Force user to authenticate against a specific identity provider.
|
|
587
|
+
* @param {object} [data.app_metadata] Application metadata to be assigned to the user after accept the invitation.
|
|
588
|
+
* @param {object} [data.user_metadata] User metadata to be assigned to the user after accept the invitation.
|
|
589
|
+
* @param {Array} [data.roles] List of roles to be assigned to the user
|
|
590
|
+
* @param {number} [data.ttl_sec] Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Upper limit on ttl_sec is 30 days.
|
|
591
|
+
* @param {boolean} [data.send_invitation_email] Whether the user will receive an invitation email (true) or no email (false). Default is true.
|
|
592
|
+
* @param {Function} [cb] Callback function.
|
|
593
|
+
* @returns {Promise|undefined}
|
|
594
|
+
*/
|
|
595
|
+
createInvitation(params, data, cb) {
|
|
596
|
+
data = data || [];
|
|
597
|
+
params = params || {};
|
|
673
598
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
* @example
|
|
681
|
-
* var params = { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID };
|
|
682
|
-
*
|
|
683
|
-
* management.organizations.deleteInvitation(params, function (err) {
|
|
684
|
-
* if (err) {
|
|
685
|
-
* // Handle error.
|
|
686
|
-
* }
|
|
687
|
-
* });
|
|
688
|
-
*
|
|
689
|
-
* @param {String} params.id ID of the Organization.
|
|
690
|
-
* @param {String} params.invitation_id Invitation ID
|
|
691
|
-
* @param {Function} [cb] Callback function.
|
|
692
|
-
*
|
|
693
|
-
* @return {Promise|undefined}
|
|
694
|
-
*/
|
|
695
|
-
OrganizationsManager.prototype.deleteInvitation = function(params, cb) {
|
|
696
|
-
params = params || {};
|
|
599
|
+
if (!params.id) {
|
|
600
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
601
|
+
}
|
|
602
|
+
if (typeof params.id !== 'string') {
|
|
603
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
604
|
+
}
|
|
697
605
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
if (typeof params.id !== 'string') {
|
|
702
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
703
|
-
}
|
|
606
|
+
if (cb && cb instanceof Function) {
|
|
607
|
+
return this.invitations.create(params, data, cb);
|
|
608
|
+
}
|
|
704
609
|
|
|
705
|
-
|
|
706
|
-
throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
|
|
707
|
-
}
|
|
708
|
-
if (typeof params.invitation_id !== 'string') {
|
|
709
|
-
throw new ArgumentError('The invitation ID has to be a string');
|
|
610
|
+
return this.invitations.create(params, data);
|
|
710
611
|
}
|
|
711
612
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
613
|
+
/**
|
|
614
|
+
* Delete an invitation from an organization
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* var params = { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID };
|
|
618
|
+
*
|
|
619
|
+
* management.organizations.deleteInvitation(params, function (err) {
|
|
620
|
+
* if (err) {
|
|
621
|
+
* // Handle error.
|
|
622
|
+
* }
|
|
623
|
+
* });
|
|
624
|
+
* @param {object} params Organization parameters
|
|
625
|
+
* @param {string} params.id ID of the Organization.
|
|
626
|
+
* @param {string} params.invitation_id Invitation ID
|
|
627
|
+
* @param {Function} [cb] Callback function.
|
|
628
|
+
* @returns {Promise|undefined}
|
|
629
|
+
*/
|
|
630
|
+
deleteInvitation(params, cb) {
|
|
631
|
+
params = params || {};
|
|
715
632
|
|
|
716
|
-
|
|
717
|
-
|
|
633
|
+
if (!params.id) {
|
|
634
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
635
|
+
}
|
|
636
|
+
if (typeof params.id !== 'string') {
|
|
637
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
638
|
+
}
|
|
718
639
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
640
|
+
if (!params.invitation_id) {
|
|
641
|
+
throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
|
|
642
|
+
}
|
|
643
|
+
if (typeof params.invitation_id !== 'string') {
|
|
644
|
+
throw new ArgumentError('The invitation ID has to be a string');
|
|
645
|
+
}
|
|
722
646
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
* @method getMemberRoles
|
|
727
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
728
|
-
*
|
|
729
|
-
* @example
|
|
730
|
-
* var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}
|
|
731
|
-
* @example <caption>
|
|
732
|
-
* This methods takes the organization ID and user ID and returns the roles
|
|
733
|
-
* </caption>
|
|
734
|
-
*
|
|
735
|
-
* management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) {
|
|
736
|
-
* console.log(roles);
|
|
737
|
-
* });
|
|
738
|
-
*
|
|
739
|
-
* @param {String} params.id ID of the Organization.
|
|
740
|
-
* @param {String} params.user_id ID of the user.
|
|
741
|
-
* @param {Function} [cb] Callback function.
|
|
742
|
-
*
|
|
743
|
-
* @return {Promise|undefined}
|
|
744
|
-
*/
|
|
745
|
-
OrganizationsManager.prototype.getMemberRoles = function(params, callback) {
|
|
746
|
-
return this.roles.getAll(params, callback);
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
/**
|
|
750
|
-
* Add a Role to a Member in an organization
|
|
751
|
-
*
|
|
752
|
-
* @method addMemberRoles
|
|
753
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
754
|
-
*
|
|
755
|
-
* @example
|
|
756
|
-
* var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'};
|
|
757
|
-
* var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
|
|
758
|
-
*
|
|
759
|
-
* management.organizations.addMemberRoles(params, data, function (err) {
|
|
760
|
-
* if (err) {
|
|
761
|
-
* // Handle error.
|
|
762
|
-
* }
|
|
763
|
-
* });
|
|
764
|
-
*
|
|
765
|
-
* @param {String} params.id ID of the Organization.
|
|
766
|
-
* @param {String} params.user_id ID of the user.
|
|
767
|
-
* @param {Object} data Add member roles data.
|
|
768
|
-
* @param {Array} data.roles Array of role IDs.
|
|
769
|
-
* @param {Function} [cb] Callback function.
|
|
770
|
-
*
|
|
771
|
-
* @return {Promise|undefined}
|
|
772
|
-
*/
|
|
773
|
-
OrganizationsManager.prototype.addMemberRoles = function(params, data, cb) {
|
|
774
|
-
data = data || {};
|
|
775
|
-
params = params || {};
|
|
647
|
+
if (cb && cb instanceof Function) {
|
|
648
|
+
return this.invitations.delete(params, {}, cb);
|
|
649
|
+
}
|
|
776
650
|
|
|
777
|
-
|
|
778
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
779
|
-
}
|
|
780
|
-
if (typeof params.id !== 'string') {
|
|
781
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
651
|
+
return this.invitations.delete(params, {});
|
|
782
652
|
}
|
|
783
653
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
if (typeof params.user_id !== 'string') {
|
|
788
|
-
throw new ArgumentError('The user ID has to be a string');
|
|
789
|
-
}
|
|
654
|
+
/**
|
|
655
|
+
*Organization Roles Membership
|
|
656
|
+
*/
|
|
790
657
|
|
|
791
|
-
|
|
792
|
-
|
|
658
|
+
/**
|
|
659
|
+
* Get Roles from a Member in a Organization
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}
|
|
663
|
+
* @param callback
|
|
664
|
+
* @example <caption>
|
|
665
|
+
* This methods takes the organization ID and user ID and returns the roles
|
|
666
|
+
* </caption>
|
|
667
|
+
*
|
|
668
|
+
* management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) {
|
|
669
|
+
* console.log(roles);
|
|
670
|
+
* });
|
|
671
|
+
* @param {object} params Organization parameters
|
|
672
|
+
* @param {string} params.id ID of the Organization.
|
|
673
|
+
* @param {string} params.user_id ID of the user.
|
|
674
|
+
* @param {Function} [cb] Callback function.
|
|
675
|
+
* @returns {Promise|undefined}
|
|
676
|
+
*/
|
|
677
|
+
getMemberRoles(params, callback) {
|
|
678
|
+
return this.roles.getAll(params, callback);
|
|
793
679
|
}
|
|
794
680
|
|
|
795
|
-
|
|
796
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Add a Role to a Member in an organization
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'};
|
|
686
|
+
* var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
|
|
687
|
+
*
|
|
688
|
+
* management.organizations.addMemberRoles(params, data, function (err) {
|
|
689
|
+
* if (err) {
|
|
690
|
+
* // Handle error.
|
|
691
|
+
* }
|
|
692
|
+
* });
|
|
693
|
+
* @param {object} params Organization parameters
|
|
694
|
+
* @param {string} params.id ID of the Organization.
|
|
695
|
+
* @param {string} params.user_id ID of the user.
|
|
696
|
+
* @param {object} data Add member roles data.
|
|
697
|
+
* @param {Array} data.roles Array of role IDs.
|
|
698
|
+
* @param {Function} [cb] Callback function.
|
|
699
|
+
* @returns {Promise|undefined}
|
|
700
|
+
*/
|
|
701
|
+
addMemberRoles(params, data, cb) {
|
|
702
|
+
data = data || {};
|
|
703
|
+
params = params || {};
|
|
797
704
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
* @example
|
|
805
|
-
* var params = { id :'ORGANIZATION_ID', user_id: 'USER_ID };
|
|
806
|
-
* var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
|
|
807
|
-
*
|
|
808
|
-
* management.organizations.removeMemberRoles(params, data, function (err) {
|
|
809
|
-
* if (err) {
|
|
810
|
-
* // Handle error.
|
|
811
|
-
* }
|
|
812
|
-
* });
|
|
813
|
-
*
|
|
814
|
-
* @param {String} params.id ID of the Organization.
|
|
815
|
-
* @param {String} params.user_id Id of the User
|
|
816
|
-
* @param {Object} data Remove member roles data.
|
|
817
|
-
* @param {Array} data.roles Array of role IDs.
|
|
818
|
-
* @param {Function} [cb] Callback function.
|
|
819
|
-
*
|
|
820
|
-
* @return {Promise|undefined}
|
|
821
|
-
*/
|
|
822
|
-
OrganizationsManager.prototype.removeMemberRoles = function(params, data, cb) {
|
|
823
|
-
data = data || {};
|
|
824
|
-
params = params || {};
|
|
705
|
+
if (!params.id) {
|
|
706
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
707
|
+
}
|
|
708
|
+
if (typeof params.id !== 'string') {
|
|
709
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
710
|
+
}
|
|
825
711
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
712
|
+
if (!params.user_id) {
|
|
713
|
+
throw new ArgumentError('The user ID passed in params cannot be null or undefined');
|
|
714
|
+
}
|
|
715
|
+
if (typeof params.user_id !== 'string') {
|
|
716
|
+
throw new ArgumentError('The user ID has to be a string');
|
|
717
|
+
}
|
|
832
718
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
if (typeof params.user_id !== 'string') {
|
|
837
|
-
throw new ArgumentError('The user ID has to be a string');
|
|
838
|
-
}
|
|
719
|
+
if (cb && cb instanceof Function) {
|
|
720
|
+
return this.roles.create(params, data, cb);
|
|
721
|
+
}
|
|
839
722
|
|
|
840
|
-
|
|
841
|
-
return this.roles.delete(params, data, cb);
|
|
723
|
+
return this.roles.create(params, data);
|
|
842
724
|
}
|
|
843
725
|
|
|
844
|
-
|
|
845
|
-
|
|
726
|
+
/**
|
|
727
|
+
* Remove Roles from a Member of an organization
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
* var params = { id :'ORGANIZATION_ID', user_id: 'USER_ID };
|
|
731
|
+
* var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
|
|
732
|
+
*
|
|
733
|
+
* management.organizations.removeMemberRoles(params, data, function (err) {
|
|
734
|
+
* if (err) {
|
|
735
|
+
* // Handle error.
|
|
736
|
+
* }
|
|
737
|
+
* });
|
|
738
|
+
* @param {object} params Organization parameters
|
|
739
|
+
* @param {string} params.id ID of the Organization.
|
|
740
|
+
* @param {string} params.user_id Id of the User
|
|
741
|
+
* @param {object} data Remove member roles data.
|
|
742
|
+
* @param {Array} data.roles Array of role IDs.
|
|
743
|
+
* @param {Function} [cb] Callback function.
|
|
744
|
+
* @returns {Promise|undefined}
|
|
745
|
+
*/
|
|
746
|
+
removeMemberRoles(params, data, cb) {
|
|
747
|
+
data = data || {};
|
|
748
|
+
params = params || {};
|
|
749
|
+
|
|
750
|
+
if (!params.id) {
|
|
751
|
+
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
752
|
+
}
|
|
753
|
+
if (typeof params.id !== 'string') {
|
|
754
|
+
throw new ArgumentError('The organization ID has to be a string');
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (!params.user_id) {
|
|
758
|
+
throw new ArgumentError('The user ID passed in params cannot be null or undefined');
|
|
759
|
+
}
|
|
760
|
+
if (typeof params.user_id !== 'string') {
|
|
761
|
+
throw new ArgumentError('The user ID has to be a string');
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
if (cb && cb instanceof Function) {
|
|
765
|
+
return this.roles.delete(params, data, cb);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
return this.roles.delete(params, data);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
846
771
|
|
|
847
772
|
module.exports = OrganizationsManager;
|