auth0 2.37.0 → 2.38.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 +18 -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 +237 -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 -583
- package/src/errors.js +23 -23
- package/src/index.js +3 -2
- package/src/management/ActionsManager.js +503 -585
- 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 -239
- 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 -784
- 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 -3625
- package/src/utils.js +31 -60
|
@@ -1,870 +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 {Object} params Organization parameters.
|
|
268
|
-
* @param {String} params.id Organization ID.
|
|
269
|
-
* @param {Function} [cb] Callback function.
|
|
270
|
-
*
|
|
271
|
-
* @return {Promise|undefined}
|
|
272
|
-
*/
|
|
273
|
-
OrganizationsManager.prototype.getEnabledConnections = function(params, callback) {
|
|
274
|
-
return this.connections.getAll(params, callback);
|
|
275
|
-
};
|
|
173
|
+
getByName(...args) {
|
|
174
|
+
return this.organizationsByName.get(...args);
|
|
175
|
+
}
|
|
276
176
|
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
OrganizationsManager.prototype.getEnabledConnection = function(params, callback) {
|
|
301
|
-
return this.connections.get(params, callback);
|
|
302
|
-
};
|
|
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
|
+
}
|
|
303
200
|
|
|
304
|
-
/**
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
* @param {String} data.connection_id connection ID to enable
|
|
324
|
-
* @param {Boolean} data.assign_membership_on_login flag to allow assign membership on login
|
|
325
|
-
* @param {Function} [cb] Callback function.
|
|
326
|
-
*
|
|
327
|
-
* @return {Promise|undefined}
|
|
328
|
-
*/
|
|
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
|
+
}
|
|
329
220
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
221
|
+
/**
|
|
222
|
+
*Organization Connections
|
|
223
|
+
*/
|
|
333
224
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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);
|
|
339
243
|
}
|
|
340
244
|
|
|
341
|
-
|
|
342
|
-
|
|
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);
|
|
343
264
|
}
|
|
344
265
|
|
|
345
|
-
|
|
346
|
-
|
|
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
|
+
*/
|
|
347
286
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
* @method removeEnabledConnection
|
|
352
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
353
|
-
*
|
|
354
|
-
* @example
|
|
355
|
-
* var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
|
|
356
|
-
*
|
|
357
|
-
* management.organizations.removeEnabledConnection(params, function (err) {
|
|
358
|
-
* if (err) {
|
|
359
|
-
* // Handle error.
|
|
360
|
-
* }
|
|
361
|
-
* });
|
|
362
|
-
* @param {Object} params Organization parameters
|
|
363
|
-
* @param {String} params.id ID of the Organization.
|
|
364
|
-
* @param {String} params.connection_id ID of the Connection.
|
|
365
|
-
* @param {Function} [cb] Callback function.
|
|
366
|
-
*
|
|
367
|
-
* @return {Promise|undefined}
|
|
368
|
-
*/
|
|
287
|
+
addEnabledConnection(params, data, cb) {
|
|
288
|
+
data = data || {};
|
|
289
|
+
params = params || {};
|
|
369
290
|
|
|
370
|
-
|
|
371
|
-
|
|
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
|
+
}
|
|
372
297
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (typeof params.id !== 'string') {
|
|
377
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
378
|
-
}
|
|
298
|
+
if (cb && cb instanceof Function) {
|
|
299
|
+
return this.connections.create(params, data, cb);
|
|
300
|
+
}
|
|
379
301
|
|
|
380
|
-
|
|
381
|
-
throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
|
|
382
|
-
}
|
|
383
|
-
if (typeof params.connection_id !== 'string') {
|
|
384
|
-
throw new ArgumentError('The connection ID has to be a string');
|
|
302
|
+
return this.connections.create(params, data);
|
|
385
303
|
}
|
|
386
304
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
+
*/
|
|
390
322
|
|
|
391
|
-
|
|
392
|
-
};
|
|
323
|
+
removeEnabledConnection(params, cb) {
|
|
324
|
+
params = params || {};
|
|
393
325
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
* @example
|
|
401
|
-
* var params = { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
|
|
402
|
-
* var data = { assign_membership_on_login: true };
|
|
403
|
-
*
|
|
404
|
-
* management.organizations.updateEnabledConnection(params, data, function (err) {
|
|
405
|
-
* if (err) {
|
|
406
|
-
* // Handle error.
|
|
407
|
-
* }
|
|
408
|
-
* });
|
|
409
|
-
*
|
|
410
|
-
* @param {Object} params Organization parameters
|
|
411
|
-
* @param {String} params.id ID of the Organization.
|
|
412
|
-
* @param {String} params.connection_id ID of the Connection.
|
|
413
|
-
* @param {Object} data Updated connection.
|
|
414
|
-
* @param {Function} [cb] Callback function.
|
|
415
|
-
*
|
|
416
|
-
* @return {Promise|undefined}
|
|
417
|
-
*/
|
|
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
|
+
}
|
|
418
332
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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
|
+
}
|
|
422
339
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (typeof params.id !== 'string') {
|
|
427
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
428
|
-
}
|
|
340
|
+
if (cb && cb instanceof Function) {
|
|
341
|
+
return this.connections.delete(params, {}, cb);
|
|
342
|
+
}
|
|
429
343
|
|
|
430
|
-
|
|
431
|
-
throw new ArgumentError('The connection ID passed in params cannot be null or undefined');
|
|
432
|
-
}
|
|
433
|
-
if (typeof params.connection_id !== 'string') {
|
|
434
|
-
throw new ArgumentError('The connection ID has to be a string');
|
|
344
|
+
return this.connections.delete(params, {});
|
|
435
345
|
}
|
|
436
346
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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
|
+
*/
|
|
440
366
|
|
|
441
|
-
|
|
442
|
-
};
|
|
367
|
+
updateEnabledConnection(params, data, cb) {
|
|
368
|
+
data = data || {};
|
|
369
|
+
params = params || {};
|
|
443
370
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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
|
+
}
|
|
447
377
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
* @example
|
|
455
|
-
* var params = {id : 'ORGANIZATION_ID'}
|
|
456
|
-
* @example <caption>
|
|
457
|
-
* This method takes an organization ID and returns the members in an Organization
|
|
458
|
-
* </caption>
|
|
459
|
-
*
|
|
460
|
-
* management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) {
|
|
461
|
-
* console.log(members);
|
|
462
|
-
* });
|
|
463
|
-
*
|
|
464
|
-
* @param {Object} params Organization parameters
|
|
465
|
-
* @param {String} params.id Organization ID
|
|
466
|
-
* @param {String} [params.from] For checkpoint pagination, the Id from which to start selection from.
|
|
467
|
-
* @param {Number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
|
|
468
|
-
* @param {Function} [cb] Callback function.
|
|
469
|
-
*
|
|
470
|
-
* @return {Promise|undefined}
|
|
471
|
-
*/
|
|
472
|
-
OrganizationsManager.prototype.getMembers = function(params, callback) {
|
|
473
|
-
return this.members.getAll(params, callback);
|
|
474
|
-
};
|
|
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
|
+
}
|
|
475
384
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
* @method addMembers
|
|
480
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
481
|
-
*
|
|
482
|
-
* @example
|
|
483
|
-
* var params = { id :'ORGANIZATION_ID'};
|
|
484
|
-
* var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
|
|
485
|
-
* management.organizations.addMembers(params, data, function (err) {
|
|
486
|
-
* if (err) {
|
|
487
|
-
* // Handle error.
|
|
488
|
-
* }
|
|
489
|
-
* });
|
|
490
|
-
*
|
|
491
|
-
* @param {Object} params Organization parameters
|
|
492
|
-
* @param {String} params.id ID of the Organization.
|
|
493
|
-
* @param {Object} data add members data
|
|
494
|
-
* @param {Array} data.members Array of user IDs
|
|
495
|
-
* @param {Function} [cb] Callback function.
|
|
496
|
-
*
|
|
497
|
-
* @return {Promise|undefined}
|
|
498
|
-
*/
|
|
499
|
-
OrganizationsManager.prototype.addMembers = function(params, data, cb) {
|
|
500
|
-
data = data || {};
|
|
501
|
-
params = params || {};
|
|
385
|
+
if (cb && cb instanceof Function) {
|
|
386
|
+
return this.connections.patch(params, data, cb);
|
|
387
|
+
}
|
|
502
388
|
|
|
503
|
-
|
|
504
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
505
|
-
}
|
|
506
|
-
if (typeof params.id !== 'string') {
|
|
507
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
389
|
+
return this.connections.patch(params, data);
|
|
508
390
|
}
|
|
509
391
|
|
|
510
|
-
|
|
511
|
-
|
|
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);
|
|
512
417
|
}
|
|
513
418
|
|
|
514
|
-
|
|
515
|
-
|
|
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 || {};
|
|
516
440
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
* @example
|
|
524
|
-
* var params = { id :'ORGANIZATION_ID' };
|
|
525
|
-
* var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
|
|
526
|
-
*
|
|
527
|
-
* management.organizations.removeMembers(params, data, function (err) {
|
|
528
|
-
* if (err) {
|
|
529
|
-
* // Handle error.
|
|
530
|
-
* }
|
|
531
|
-
* });
|
|
532
|
-
*
|
|
533
|
-
* @param {Object} params Organization parameters
|
|
534
|
-
* @param {String} params.id ID of the Organization.
|
|
535
|
-
* @param {Object} data add members data
|
|
536
|
-
* @param {Array} data.members Array of user IDs
|
|
537
|
-
* @param {Function} [cb] Callback function.
|
|
538
|
-
*
|
|
539
|
-
* @return {Promise|undefined}
|
|
540
|
-
*/
|
|
541
|
-
OrganizationsManager.prototype.removeMembers = function(params, data, cb) {
|
|
542
|
-
data = data || {};
|
|
543
|
-
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
|
+
}
|
|
544
447
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
if (typeof params.id !== 'string') {
|
|
549
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
550
|
-
}
|
|
448
|
+
if (cb && cb instanceof Function) {
|
|
449
|
+
return this.members.create(params, data, cb);
|
|
450
|
+
}
|
|
551
451
|
|
|
552
|
-
|
|
553
|
-
return this.members.delete(params, data, cb);
|
|
452
|
+
return this.members.create(params, data);
|
|
554
453
|
}
|
|
555
454
|
|
|
556
|
-
|
|
557
|
-
|
|
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 || {};
|
|
558
477
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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
|
+
}
|
|
562
484
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
* @method getInvitations
|
|
567
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
* var params = {id : 'ORGANIZATION_ID'}
|
|
571
|
-
* @example <caption>
|
|
572
|
-
* This method takes an organization ID and returns the invites in an Organization
|
|
573
|
-
* </caption>
|
|
574
|
-
*
|
|
575
|
-
* management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) {
|
|
576
|
-
* console.log(invites);
|
|
577
|
-
* });
|
|
578
|
-
*
|
|
579
|
-
* @param {Object} params Organization parameters
|
|
580
|
-
* @param {String} params.id Organization ID
|
|
581
|
-
* @param {Number} [params.per_page] Number of results per page.
|
|
582
|
-
* @param {Number} [params.page] Page number, zero indexed.
|
|
583
|
-
* @param {String} [params.from] For checkpoint pagination, the Id from which to start selection from.
|
|
584
|
-
* @param {Number} [params.take] For checkpoint pagination, the number of entries to retrieve. Default 50.
|
|
585
|
-
* @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.
|
|
586
|
-
* @param {Boolean} [params.include_fields] Whether specified fields are to be included (true) or excluded (false). Defaults to true.
|
|
587
|
-
* @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.
|
|
588
|
-
* @param {Function} [cb] Callback function.
|
|
589
|
-
*
|
|
590
|
-
* @return {Promise|undefined}
|
|
591
|
-
*/
|
|
592
|
-
OrganizationsManager.prototype.getInvitations = function(params, callback) {
|
|
593
|
-
return this.invitations.getAll(params, callback);
|
|
594
|
-
};
|
|
485
|
+
if (cb && cb instanceof Function) {
|
|
486
|
+
return this.members.delete(params, data, cb);
|
|
487
|
+
}
|
|
595
488
|
|
|
596
|
-
|
|
597
|
-
* Get an Invitation in a Organization
|
|
598
|
-
*
|
|
599
|
-
* @method getInvitation
|
|
600
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
601
|
-
*
|
|
602
|
-
* @example
|
|
603
|
-
* var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}
|
|
604
|
-
* @example <caption>
|
|
605
|
-
* This methods takes the organization ID and user ID and returns the invitation
|
|
606
|
-
* </caption>
|
|
607
|
-
*
|
|
608
|
-
* management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) {
|
|
609
|
-
* console.log(invite);
|
|
610
|
-
* });
|
|
611
|
-
*
|
|
612
|
-
* @param {Object} params Organization parameters
|
|
613
|
-
* @param {String} params.id Organization ID
|
|
614
|
-
* @param {String} params.invitation_id Invitation ID
|
|
615
|
-
* @param {Function} [cb] Callback function.
|
|
616
|
-
*
|
|
617
|
-
* @return {Promise|undefined}
|
|
618
|
-
*/
|
|
619
|
-
OrganizationsManager.prototype.getInvitation = function(params, callback) {
|
|
620
|
-
if (!params.id) {
|
|
621
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
622
|
-
}
|
|
623
|
-
if (typeof params.id !== 'string') {
|
|
624
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
489
|
+
return this.members.delete(params, data);
|
|
625
490
|
}
|
|
626
491
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
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);
|
|
632
523
|
}
|
|
633
524
|
|
|
634
|
-
|
|
635
|
-
|
|
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
|
+
}
|
|
636
551
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
* @example
|
|
644
|
-
* var params = { id :'ORGANIZATION_ID'};
|
|
645
|
-
* var data = {
|
|
646
|
-
* client_id: CLIENT_ID,
|
|
647
|
-
* invitee: { email: 'invitee@example.com' },
|
|
648
|
-
* inviter: { name: 'John Doe' }
|
|
649
|
-
* };
|
|
650
|
-
*
|
|
651
|
-
* management.organizations.createInvitation(params, data, function (err) {
|
|
652
|
-
* if (err) {
|
|
653
|
-
* // Handle error.
|
|
654
|
-
* }
|
|
655
|
-
* });
|
|
656
|
-
*
|
|
657
|
-
* @param {Object} params Organization parameters
|
|
658
|
-
* @param {String} params.id ID of the Organization.
|
|
659
|
-
* @param {Array} data Invitation data
|
|
660
|
-
* @param {Object} data.inviter The person who is sending the invite.
|
|
661
|
-
* @param {String} data.inviter.name Name of the person who is sending the invite
|
|
662
|
-
* @param {Object} data.invitee Invitee to whom invitation is intended for
|
|
663
|
-
* @param {Object} data.invitee.email Email of the invitee to whom invitation is intended for
|
|
664
|
-
* @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
|
|
665
|
-
* @param {String} [data.connection_id] Force user to authenticate against a specific identity provider.
|
|
666
|
-
* @param {Object} [data.app_metadata] Application metadata to be assigned to the user after accept the invitation.
|
|
667
|
-
* @param {Object} [data.user_metadata] User metadata to be assigned to the user after accept the invitation.
|
|
668
|
-
* @param {Array} [data.roles] List of roles to be assigned to the user
|
|
669
|
-
* @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.
|
|
670
|
-
* @param {Boolean} [data.send_invitation_email] Whether the user will receive an invitation email (true) or no email (false). Default is true.
|
|
671
|
-
* @param {Function} [cb] Callback function.
|
|
672
|
-
*
|
|
673
|
-
* @return {Promise|undefined}
|
|
674
|
-
*/
|
|
675
|
-
OrganizationsManager.prototype.createInvitation = function(params, data, cb) {
|
|
676
|
-
data = data || [];
|
|
677
|
-
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
|
+
}
|
|
678
558
|
|
|
679
|
-
|
|
680
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
681
|
-
}
|
|
682
|
-
if (typeof params.id !== 'string') {
|
|
683
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
559
|
+
return this.invitations.get(params, callback);
|
|
684
560
|
}
|
|
685
561
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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 || {};
|
|
692
598
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
* @example
|
|
700
|
-
* var params = { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID };
|
|
701
|
-
*
|
|
702
|
-
* management.organizations.deleteInvitation(params, function (err) {
|
|
703
|
-
* if (err) {
|
|
704
|
-
* // Handle error.
|
|
705
|
-
* }
|
|
706
|
-
* });
|
|
707
|
-
*
|
|
708
|
-
* @param {Object} params Organization parameters
|
|
709
|
-
* @param {String} params.id ID of the Organization.
|
|
710
|
-
* @param {String} params.invitation_id Invitation ID
|
|
711
|
-
* @param {Function} [cb] Callback function.
|
|
712
|
-
*
|
|
713
|
-
* @return {Promise|undefined}
|
|
714
|
-
*/
|
|
715
|
-
OrganizationsManager.prototype.deleteInvitation = function(params, cb) {
|
|
716
|
-
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
|
+
}
|
|
717
605
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (typeof params.id !== 'string') {
|
|
722
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
723
|
-
}
|
|
606
|
+
if (cb && cb instanceof Function) {
|
|
607
|
+
return this.invitations.create(params, data, cb);
|
|
608
|
+
}
|
|
724
609
|
|
|
725
|
-
|
|
726
|
-
throw new ArgumentError('The invitation ID passed in params cannot be null or undefined');
|
|
727
|
-
}
|
|
728
|
-
if (typeof params.invitation_id !== 'string') {
|
|
729
|
-
throw new ArgumentError('The invitation ID has to be a string');
|
|
610
|
+
return this.invitations.create(params, data);
|
|
730
611
|
}
|
|
731
612
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
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 || {};
|
|
735
632
|
|
|
736
|
-
|
|
737
|
-
|
|
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
|
+
}
|
|
738
639
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
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
|
+
}
|
|
742
646
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
* @method getMemberRoles
|
|
747
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
748
|
-
*
|
|
749
|
-
* @example
|
|
750
|
-
* var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}
|
|
751
|
-
* @example <caption>
|
|
752
|
-
* This methods takes the organization ID and user ID and returns the roles
|
|
753
|
-
* </caption>
|
|
754
|
-
*
|
|
755
|
-
* management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) {
|
|
756
|
-
* console.log(roles);
|
|
757
|
-
* });
|
|
758
|
-
*
|
|
759
|
-
* @param {Object} params Organization parameters
|
|
760
|
-
* @param {String} params.id ID of the Organization.
|
|
761
|
-
* @param {String} params.user_id ID of the user.
|
|
762
|
-
* @param {Function} [cb] Callback function.
|
|
763
|
-
*
|
|
764
|
-
* @return {Promise|undefined}
|
|
765
|
-
*/
|
|
766
|
-
OrganizationsManager.prototype.getMemberRoles = function(params, callback) {
|
|
767
|
-
return this.roles.getAll(params, callback);
|
|
768
|
-
};
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* Add a Role to a Member in an organization
|
|
772
|
-
*
|
|
773
|
-
* @method addMemberRoles
|
|
774
|
-
* @memberOf module:management.OrganizationsManager.prototype
|
|
775
|
-
*
|
|
776
|
-
* @example
|
|
777
|
-
* var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'};
|
|
778
|
-
* var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
|
|
779
|
-
*
|
|
780
|
-
* management.organizations.addMemberRoles(params, data, function (err) {
|
|
781
|
-
* if (err) {
|
|
782
|
-
* // Handle error.
|
|
783
|
-
* }
|
|
784
|
-
* });
|
|
785
|
-
*
|
|
786
|
-
* @param {Object} params Organization parameters
|
|
787
|
-
* @param {String} params.id ID of the Organization.
|
|
788
|
-
* @param {String} params.user_id ID of the user.
|
|
789
|
-
* @param {Object} data Add member roles data.
|
|
790
|
-
* @param {Array} data.roles Array of role IDs.
|
|
791
|
-
* @param {Function} [cb] Callback function.
|
|
792
|
-
*
|
|
793
|
-
* @return {Promise|undefined}
|
|
794
|
-
*/
|
|
795
|
-
OrganizationsManager.prototype.addMemberRoles = function(params, data, cb) {
|
|
796
|
-
data = data || {};
|
|
797
|
-
params = params || {};
|
|
647
|
+
if (cb && cb instanceof Function) {
|
|
648
|
+
return this.invitations.delete(params, {}, cb);
|
|
649
|
+
}
|
|
798
650
|
|
|
799
|
-
|
|
800
|
-
throw new ArgumentError('The organization ID passed in params cannot be null or undefined');
|
|
801
|
-
}
|
|
802
|
-
if (typeof params.id !== 'string') {
|
|
803
|
-
throw new ArgumentError('The organization ID has to be a string');
|
|
651
|
+
return this.invitations.delete(params, {});
|
|
804
652
|
}
|
|
805
653
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
if (typeof params.user_id !== 'string') {
|
|
810
|
-
throw new ArgumentError('The user ID has to be a string');
|
|
811
|
-
}
|
|
654
|
+
/**
|
|
655
|
+
*Organization Roles Membership
|
|
656
|
+
*/
|
|
812
657
|
|
|
813
|
-
|
|
814
|
-
|
|
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);
|
|
815
679
|
}
|
|
816
680
|
|
|
817
|
-
|
|
818
|
-
|
|
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 || {};
|
|
819
704
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
* @example
|
|
827
|
-
* var params = { id :'ORGANIZATION_ID', user_id: 'USER_ID };
|
|
828
|
-
* var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}
|
|
829
|
-
*
|
|
830
|
-
* management.organizations.removeMemberRoles(params, data, function (err) {
|
|
831
|
-
* if (err) {
|
|
832
|
-
* // Handle error.
|
|
833
|
-
* }
|
|
834
|
-
* });
|
|
835
|
-
*
|
|
836
|
-
* @param {Object} params Organization parameters
|
|
837
|
-
* @param {String} params.id ID of the Organization.
|
|
838
|
-
* @param {String} params.user_id Id of the User
|
|
839
|
-
* @param {Object} data Remove member roles data.
|
|
840
|
-
* @param {Array} data.roles Array of role IDs.
|
|
841
|
-
* @param {Function} [cb] Callback function.
|
|
842
|
-
*
|
|
843
|
-
* @return {Promise|undefined}
|
|
844
|
-
*/
|
|
845
|
-
OrganizationsManager.prototype.removeMemberRoles = function(params, data, cb) {
|
|
846
|
-
data = data || {};
|
|
847
|
-
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
|
+
}
|
|
848
711
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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
|
+
}
|
|
855
718
|
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (typeof params.user_id !== 'string') {
|
|
860
|
-
throw new ArgumentError('The user ID has to be a string');
|
|
861
|
-
}
|
|
719
|
+
if (cb && cb instanceof Function) {
|
|
720
|
+
return this.roles.create(params, data, cb);
|
|
721
|
+
}
|
|
862
722
|
|
|
863
|
-
|
|
864
|
-
return this.roles.delete(params, data, cb);
|
|
723
|
+
return this.roles.create(params, data);
|
|
865
724
|
}
|
|
866
725
|
|
|
867
|
-
|
|
868
|
-
|
|
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
|
+
}
|
|
869
771
|
|
|
870
772
|
module.exports = OrganizationsManager;
|