@open-xchange/soap-client 0.0.10 → 0.0.12
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/package.json +1 -1
- package/services/common/context.js +15 -11
- package/services/common/index.js +2 -0
- package/services/common/user.js +15 -11
- package/services/reseller/oxaas.js +7 -3
- package/services/reseller/resellerContext.js +12 -8
- package/services/reseller/resellerUser.js +13 -9
- package/services/secondaryAccount.js +9 -5
- package/services/sharedAccount.js +114 -0
package/package.json
CHANGED
|
@@ -20,14 +20,18 @@
|
|
|
20
20
|
|
|
21
21
|
import { createClientAsync, logSoapError } from '../../soap.js'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
let OXContextService
|
|
24
|
+
function getClient () {
|
|
25
|
+
if (!OXContextService) OXContextService = createClientAsync('OXContextService')
|
|
26
|
+
return OXContextService
|
|
27
|
+
}
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* This function retrieves the default context from the OXContextService.
|
|
27
31
|
* @returns {Promise<Object>} The first result from the listAsync method call.
|
|
28
32
|
*/
|
|
29
33
|
export async function getDefault () {
|
|
30
|
-
return (await
|
|
34
|
+
return (await getClient()).listAsync({ search_pattern: 'defaultcontext' })[0]
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
/**
|
|
@@ -36,7 +40,7 @@ export async function getDefault () {
|
|
|
36
40
|
* @param {number} id The ID of the context to remove.
|
|
37
41
|
*/
|
|
38
42
|
export async function remove (id) {
|
|
39
|
-
return (await
|
|
43
|
+
return (await getClient()).deleteAsync({ ctx: { id } })
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
/**
|
|
@@ -59,7 +63,7 @@ export async function remove (id) {
|
|
|
59
63
|
* @returns {Promise<Object>} The created context.
|
|
60
64
|
*/
|
|
61
65
|
export async function create (ctx = {}, adminUser = {}, accessCombinationName = 'all') {
|
|
62
|
-
return (await
|
|
66
|
+
return (await getClient())
|
|
63
67
|
.createAsync({
|
|
64
68
|
ctx,
|
|
65
69
|
admin_user: Object.assign({
|
|
@@ -91,7 +95,7 @@ export async function create (ctx = {}, adminUser = {}, accessCombinationName =
|
|
|
91
95
|
// eslint-disable-next-line camelcase
|
|
92
96
|
export async function changeModuleAccessByName (id, access_combination_name) {
|
|
93
97
|
// eslint-disable-next-line camelcase
|
|
94
|
-
return (await
|
|
98
|
+
return (await getClient()).changeModuleAccessByNameAsync({ ctx: { id }, access_combination_name })
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
/**
|
|
@@ -105,7 +109,7 @@ export async function changeCapabilities (id, capsToAdd, capsToRemove) {
|
|
|
105
109
|
const data = {}
|
|
106
110
|
if (capsToAdd) data.capsToAdd = capsToAdd
|
|
107
111
|
if (capsToRemove) data.capsToRemove = capsToRemove
|
|
108
|
-
return (await
|
|
112
|
+
return (await getClient()).changeCapabilitiesAsync({ ctx: { id }, ...data })
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
/**
|
|
@@ -114,7 +118,7 @@ export async function changeCapabilities (id, capsToAdd, capsToRemove) {
|
|
|
114
118
|
* @returns {Promise<Object>} The module access of the specified context.
|
|
115
119
|
*/
|
|
116
120
|
export async function getModuleAccess (id) {
|
|
117
|
-
return (await
|
|
121
|
+
return (await getClient()).getModuleAccessAsync({ ctx: { id } })
|
|
118
122
|
}
|
|
119
123
|
/**
|
|
120
124
|
* This function changes the module access of the specified context.
|
|
@@ -124,7 +128,7 @@ export async function getModuleAccess (id) {
|
|
|
124
128
|
*/
|
|
125
129
|
export async function changeModuleAccess (id, moduleAccess) {
|
|
126
130
|
const currentAccess = await getModuleAccess(id)
|
|
127
|
-
return (await
|
|
131
|
+
return (await getClient()).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...moduleAccess } })
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
/**
|
|
@@ -135,7 +139,7 @@ export async function changeModuleAccess (id, moduleAccess) {
|
|
|
135
139
|
* @returns {Promise<Array<Object>>} The list of contexts that match the search pattern.
|
|
136
140
|
*/
|
|
137
141
|
export async function list (searchPattern, { excludeDisabled } = { excludeDisabled: true }) {
|
|
138
|
-
return (await
|
|
142
|
+
return (await getClient()).listAsync({ search_pattern: searchPattern, exclude_disabled: excludeDisabled }).catch(e => {
|
|
139
143
|
logSoapError(e)
|
|
140
144
|
return []
|
|
141
145
|
})
|
|
@@ -147,7 +151,7 @@ export async function list (searchPattern, { excludeDisabled } = { excludeDisabl
|
|
|
147
151
|
* @returns {Promise<Object>} The context with the specified ID.
|
|
148
152
|
*/
|
|
149
153
|
export async function get (id) {
|
|
150
|
-
return (await
|
|
154
|
+
return (await getClient()).getDataAsync({ ctx: { id } })
|
|
151
155
|
}
|
|
152
156
|
|
|
153
157
|
/**
|
|
@@ -156,5 +160,5 @@ export async function get (id) {
|
|
|
156
160
|
* @returns {Promise<void>}
|
|
157
161
|
*/
|
|
158
162
|
export async function change (ctx) {
|
|
159
|
-
return (await
|
|
163
|
+
return (await getClient()).changeAsync({ ctx })
|
|
160
164
|
}
|
package/services/common/index.js
CHANGED
|
@@ -2,10 +2,12 @@ import * as contextService from './context.js'
|
|
|
2
2
|
import * as userService from './user.js'
|
|
3
3
|
import { getFilestorageId } from './util.js'
|
|
4
4
|
import * as secondaryAccountService from '../secondaryAccount.js'
|
|
5
|
+
import * as sharedAccountService from '../sharedAccount.js'
|
|
5
6
|
|
|
6
7
|
export {
|
|
7
8
|
contextService,
|
|
8
9
|
userService,
|
|
9
10
|
secondaryAccountService,
|
|
11
|
+
sharedAccountService,
|
|
10
12
|
getFilestorageId
|
|
11
13
|
}
|
package/services/common/user.js
CHANGED
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
|
|
21
21
|
import { createClientAsync, logSoapError } from '../../soap.js'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
let OXUserService
|
|
24
|
+
function getClient () {
|
|
25
|
+
if (!OXUserService) OXUserService = createClientAsync('OXUserService')
|
|
26
|
+
return OXUserService
|
|
27
|
+
}
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* This function removes the user with the specified context and user ID.
|
|
@@ -29,7 +33,7 @@ const OXUserService = createClientAsync('OXUserService')
|
|
|
29
33
|
* @returns {Promise<Boolean>} Returns true if it could remove the user and false if it could not
|
|
30
34
|
*/
|
|
31
35
|
export async function remove (context, userId) {
|
|
32
|
-
return (await
|
|
36
|
+
return (await getClient()).deleteAsync({
|
|
33
37
|
ctx: { id: context.id },
|
|
34
38
|
user: { id: userId },
|
|
35
39
|
auth: context.admin
|
|
@@ -43,7 +47,7 @@ export async function remove (context, userId) {
|
|
|
43
47
|
* @returns {Promise<Object>} The created user.
|
|
44
48
|
*/
|
|
45
49
|
export async function create (context, usrdata) {
|
|
46
|
-
return (await
|
|
50
|
+
return (await getClient()).createAsync({
|
|
47
51
|
ctx: { id: context.id },
|
|
48
52
|
usrdata,
|
|
49
53
|
auth: context.admin
|
|
@@ -57,7 +61,7 @@ export async function create (context, usrdata) {
|
|
|
57
61
|
* @returns {Promise<void>}
|
|
58
62
|
*/
|
|
59
63
|
export async function change (context, usrdata) {
|
|
60
|
-
return (await
|
|
64
|
+
return (await getClient()).changeAsync({
|
|
61
65
|
ctx: { id: context.id },
|
|
62
66
|
usrdata,
|
|
63
67
|
auth: context.admin
|
|
@@ -65,7 +69,7 @@ export async function change (context, usrdata) {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
export async function changeByModuleAccess (context, userId, currentAccess, moduleAccess) {
|
|
68
|
-
return (await
|
|
72
|
+
return (await getClient()).changeByModuleAccessAsync({
|
|
69
73
|
ctx: { id: context.id },
|
|
70
74
|
moduleAccess: Object.assign({}, currentAccess, moduleAccess),
|
|
71
75
|
user: { id: userId },
|
|
@@ -74,7 +78,7 @@ export async function changeByModuleAccess (context, userId, currentAccess, modu
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
export async function changeByModuleAccessName (context, userId, accessCombinationName) {
|
|
77
|
-
return (await
|
|
81
|
+
return (await getClient()).changeByModuleAccessNameAsync({
|
|
78
82
|
ctx: { id: context.id },
|
|
79
83
|
access_combination_name: accessCombinationName,
|
|
80
84
|
user: { id: userId },
|
|
@@ -83,7 +87,7 @@ export async function changeByModuleAccessName (context, userId, accessCombinati
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
export async function getModuleAccess (context, userId) {
|
|
86
|
-
return (await
|
|
90
|
+
return (await getClient()).getModuleAccessAsync({
|
|
87
91
|
ctx: { id: context.id },
|
|
88
92
|
user: { id: userId },
|
|
89
93
|
auth: context.admin
|
|
@@ -100,11 +104,11 @@ export async function changeCapabilities (context, userId, capsToAdd, capsToRemo
|
|
|
100
104
|
}
|
|
101
105
|
if (capsToAdd) data.capsToAdd = capsToAdd
|
|
102
106
|
if (capsToRemove) data.capsToRemove = capsToRemove
|
|
103
|
-
return (await
|
|
107
|
+
return (await getClient()).changeCapabilitiesAsync(data)
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
export async function exists (context, userId) {
|
|
107
|
-
return (await
|
|
111
|
+
return (await getClient()).existsAsync({
|
|
108
112
|
ctx: { id: context.id },
|
|
109
113
|
user: { id: userId },
|
|
110
114
|
auth: context.admin
|
|
@@ -112,7 +116,7 @@ export async function exists (context, userId) {
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
export async function list (context, searchPattern, includeGuests = false) {
|
|
115
|
-
return (await
|
|
119
|
+
return (await getClient()).listAsync({
|
|
116
120
|
ctx: { id: context.id },
|
|
117
121
|
search_pattern: searchPattern,
|
|
118
122
|
include_guests: includeGuests,
|
|
@@ -121,7 +125,7 @@ export async function list (context, searchPattern, includeGuests = false) {
|
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
export async function listAll (context, includeGuests = false, excludeUsers = []) {
|
|
124
|
-
return (await
|
|
128
|
+
return (await getClient()).listAsync({
|
|
125
129
|
ctx: { id: context.id },
|
|
126
130
|
include_guests: includeGuests,
|
|
127
131
|
exclude_users: excludeUsers,
|
|
@@ -20,12 +20,16 @@
|
|
|
20
20
|
|
|
21
21
|
import { createClientAsync } from '../../soap.js'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
let OXaaSService
|
|
24
|
+
function getClient () {
|
|
25
|
+
if (!OXaaSService) OXaaSService = createClientAsync('OXaaSService')
|
|
26
|
+
return OXaaSService
|
|
27
|
+
}
|
|
24
28
|
|
|
25
29
|
export async function setMailQuota (data) {
|
|
26
|
-
return (await
|
|
30
|
+
return (await getClient()).setMailQuotaAsync(data)
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export async function createSharedDomain (data) {
|
|
30
|
-
return (await
|
|
34
|
+
return (await getClient()).createSharedDomain(data)
|
|
31
35
|
}
|
|
@@ -20,36 +20,40 @@
|
|
|
20
20
|
|
|
21
21
|
import { createClientAsync, logSoapError } from '../../soap.js'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
let OXResellerContextService
|
|
24
|
+
function getClient () {
|
|
25
|
+
if (!OXResellerContextService) OXResellerContextService = createClientAsync('OXResellerContextService')
|
|
26
|
+
return OXResellerContextService
|
|
27
|
+
}
|
|
24
28
|
|
|
25
29
|
export async function create (data) {
|
|
26
|
-
return (await
|
|
30
|
+
return (await getClient()).createAsync(data)
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export async function remove (contextId) {
|
|
30
|
-
return (await
|
|
34
|
+
return (await getClient()).deleteAsync({
|
|
31
35
|
ctx: { id: contextId }
|
|
32
36
|
}).catch(logSoapError)
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
export async function change (ctx) {
|
|
36
|
-
return (await
|
|
40
|
+
return (await getClient()).changeAsync({ ctx })
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export async function get (id) {
|
|
40
|
-
return (await
|
|
44
|
+
return (await getClient()).getDataAsync({ ctx: { id } })
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
export async function getModuleAccess (id) {
|
|
44
|
-
return (await
|
|
48
|
+
return (await getClient()).getModuleAccessAsync({ ctx: id })
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
export async function changeModuleAccess (id, access) {
|
|
48
52
|
const currentAccess = await getModuleAccess(id)
|
|
49
53
|
|
|
50
|
-
return (await
|
|
54
|
+
return (await getClient()).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...access } })
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
export async function listAll (data) {
|
|
54
|
-
return (await
|
|
58
|
+
return (await getClient()).listAllAsync(data)
|
|
55
59
|
}
|
|
@@ -20,10 +20,14 @@
|
|
|
20
20
|
|
|
21
21
|
import { createClientAsync, logSoapError } from '../../soap.js'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
let OXResellerUserService
|
|
24
|
+
function getClient () {
|
|
25
|
+
if (!OXResellerUserService) OXResellerUserService = createClientAsync('OXResellerUserService')
|
|
26
|
+
return OXResellerUserService
|
|
27
|
+
}
|
|
24
28
|
|
|
25
29
|
export async function remove (contextId, userId) {
|
|
26
|
-
return (await
|
|
30
|
+
return (await getClient()).deleteAsync({
|
|
27
31
|
ctx: { id: contextId },
|
|
28
32
|
user: { id: userId }
|
|
29
33
|
}).catch(logSoapError)
|
|
@@ -36,7 +40,7 @@ export async function remove (contextId, userId) {
|
|
|
36
40
|
* @returns {Promise<void>}
|
|
37
41
|
*/
|
|
38
42
|
export async function change (context, usrdata) {
|
|
39
|
-
return (await
|
|
43
|
+
return (await getClient()).changeAsync({
|
|
40
44
|
ctx: { id: context.id },
|
|
41
45
|
usrdata,
|
|
42
46
|
auth: { login: context.admin.name, password: context.admin.password }
|
|
@@ -44,11 +48,11 @@ export async function change (context, usrdata) {
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export async function get (data) {
|
|
47
|
-
return (await
|
|
51
|
+
return (await getClient()).getDataAsync(data)
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export async function getModuleAccess (context, userId) {
|
|
51
|
-
return (await
|
|
55
|
+
return (await getClient()).getModuleAccessAsync({
|
|
52
56
|
ctx: { id: context.id },
|
|
53
57
|
user: { id: userId },
|
|
54
58
|
auth: { login: context.admin.name, password: context.admin.password }
|
|
@@ -58,7 +62,7 @@ export async function getModuleAccess (context, userId) {
|
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
export async function changeByModuleAccess (context, userId, currentAccess, moduleAccess) {
|
|
61
|
-
return (await
|
|
65
|
+
return (await getClient()).changeByModuleAccessAsync({
|
|
62
66
|
ctx: { id: context.id },
|
|
63
67
|
moduleAccess: Object.assign({}, currentAccess, moduleAccess),
|
|
64
68
|
user: { id: userId },
|
|
@@ -67,7 +71,7 @@ export async function changeByModuleAccess (context, userId, currentAccess, modu
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
export async function changeByModuleAccessName (context, userId, accessCombinationName) {
|
|
70
|
-
return (await
|
|
74
|
+
return (await getClient()).changeByModuleAccessNameAsync({
|
|
71
75
|
ctx: { id: context.id },
|
|
72
76
|
access_combination_name: accessCombinationName,
|
|
73
77
|
user: { id: userId },
|
|
@@ -76,7 +80,7 @@ export async function changeByModuleAccessName (context, userId, accessCombinati
|
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
export async function createByModuleAccessName (context, usrdata) {
|
|
79
|
-
return (await
|
|
83
|
+
return (await getClient()).createByModuleAccessNameAsync({
|
|
80
84
|
ctx: { id: context.id },
|
|
81
85
|
usrdata,
|
|
82
86
|
access_combination_name: 'all',
|
|
@@ -85,5 +89,5 @@ export async function createByModuleAccessName (context, usrdata) {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
export async function listAll (data) {
|
|
88
|
-
return await (await
|
|
92
|
+
return await (await getClient()).listAllAsync(data)
|
|
89
93
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createClientAsync } from '../soap.js'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let OXSecondaryAccountService
|
|
4
|
+
function getClient () {
|
|
5
|
+
if (!OXSecondaryAccountService) OXSecondaryAccountService = createClientAsync('OXSecondaryAccountService')
|
|
6
|
+
return OXSecondaryAccountService
|
|
7
|
+
}
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Creates a secondary account using the OX Secondary Account Service
|
|
@@ -13,7 +17,7 @@ const OXSecondaryAccountService = createClientAsync('OXSecondaryAccountService')
|
|
|
13
17
|
* @throws {Error} If the account creation fails
|
|
14
18
|
*/
|
|
15
19
|
export async function create (accountData, context, users = [], groups = []) {
|
|
16
|
-
return (await
|
|
20
|
+
return (await getClient()).createAsync({
|
|
17
21
|
accountDataOnCreate: accountData,
|
|
18
22
|
context: { id: context.id },
|
|
19
23
|
users: users || [],
|
|
@@ -22,13 +26,13 @@ export async function create (accountData, context, users = [], groups = []) {
|
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export async function list (context) {
|
|
25
|
-
return (await
|
|
29
|
+
return (await getClient()).listAsync({
|
|
26
30
|
context: { id: context.id },
|
|
27
31
|
auth: context.admin
|
|
28
32
|
})
|
|
29
33
|
}
|
|
30
34
|
export async function remove (primaryAddress, context, users, groups) {
|
|
31
|
-
return (await
|
|
35
|
+
return (await getClient()).deleteAsync({
|
|
32
36
|
primaryAddress,
|
|
33
37
|
context: { id: context.id },
|
|
34
38
|
users,
|
|
@@ -37,7 +41,7 @@ export async function remove (primaryAddress, context, users, groups) {
|
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export async function update (primaryAddress, accountData, context, users, groups) {
|
|
40
|
-
return (await
|
|
44
|
+
return (await getClient()).updateAsync({
|
|
41
45
|
primaryAddress,
|
|
42
46
|
accountDataUpdate: accountData,
|
|
43
47
|
context: { id: context.id },
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { createClientAsync } from '../soap.js'
|
|
22
|
+
|
|
23
|
+
let OXSharedAccountService
|
|
24
|
+
function getClient () {
|
|
25
|
+
if (!OXSharedAccountService) OXSharedAccountService = createClientAsync('OXSharedAccountService')
|
|
26
|
+
return OXSharedAccountService
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates a shared account using the OX Shared Account Service
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} context - The context object where the account will be created
|
|
33
|
+
* @param {Object} sharedAccountData - The data for the shared account to be created
|
|
34
|
+
* @returns {Promise<Object>} The created shared account object
|
|
35
|
+
* @throws {Error} If the shared account creation fails
|
|
36
|
+
*/
|
|
37
|
+
export async function create (context, sharedAccountData) {
|
|
38
|
+
return (await getClient()).createAsync({
|
|
39
|
+
ctx: { id: context.id },
|
|
40
|
+
sharedAccountData, // display_name, given_name, imapServer, language, mailenabled, name, sur_name, primaryEmail, email1, smtpServer, timezone, password
|
|
41
|
+
auth: context.admin
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Add users and groups with specified permissions and capabilities to an existing shared account using the OX Shared Account Service.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} context - The context of the users and groups
|
|
49
|
+
* @param {Object} sharedAccountContext - The context of the shared account
|
|
50
|
+
* @param {Object} sharedAccountData - The shared account
|
|
51
|
+
* @param {Object} mailConfig - The mail configuration (permissionLevel, grantedCapability, deniedCapability)
|
|
52
|
+
* @param {Object} calendarConfig - The calendar configuration (permissionLevel, grantedCapability, deniedCapability)
|
|
53
|
+
* @param {Object[]} users - The users to be added to the shared account
|
|
54
|
+
* @param {Object[]} groups - The groups to be added to the shared account
|
|
55
|
+
* @returns {Promise<Object>} The shared account object
|
|
56
|
+
* @throws {Error} If the creation of the shared account permissions fails
|
|
57
|
+
*/
|
|
58
|
+
export async function createSharedAccountPermissions (context, sharedAccountContext, sharedAccountData, mailConfig, calendarConfig, users = [], groups = []) {
|
|
59
|
+
return (await getClient()).createSharedAccountPermissionsAsync({
|
|
60
|
+
ctx: { id: context.id },
|
|
61
|
+
groups,
|
|
62
|
+
users: users.map(user => { return { id: user.userdata.id } }),
|
|
63
|
+
mailConfig,
|
|
64
|
+
calendarConfig,
|
|
65
|
+
sharedAccountCtx: { id: sharedAccountContext.id },
|
|
66
|
+
sharedAccount: { id: sharedAccountData.id },
|
|
67
|
+
auth: context.admin
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* List all shared accounts in the specified context
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} context - The context object whose shared account will be listed
|
|
75
|
+
* @param {*} pattern - An optional search pattern for the contexts
|
|
76
|
+
* @returns {Promise<Object[]>} The list of shared account objects
|
|
77
|
+
*/
|
|
78
|
+
export async function list (context, pattern = '*') {
|
|
79
|
+
return (await getClient()).listAsync({
|
|
80
|
+
ctx: { id: context.id },
|
|
81
|
+
search_pattern: pattern,
|
|
82
|
+
auth: context.admin
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get all data of a specified shared account in the specified context
|
|
88
|
+
*
|
|
89
|
+
* @param {*} context - The context where the shared account exists
|
|
90
|
+
* @param {*} sharedAccountData - The requested shared account
|
|
91
|
+
* @returns {Promise<Object>} The shared account object
|
|
92
|
+
*/
|
|
93
|
+
export async function getData (context, sharedAccountData) {
|
|
94
|
+
return (await getClient()).getDataAsync({
|
|
95
|
+
ctx: { id: context.id },
|
|
96
|
+
sharedAccount: { id: sharedAccountData.id },
|
|
97
|
+
auth: context.admin
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Remove a specified shared account in the specified context
|
|
103
|
+
*
|
|
104
|
+
* @param {*} context - The context object where the account will be removed
|
|
105
|
+
* @param {*} sharedAccountData - The shared account to be removed
|
|
106
|
+
* @returns {Promise<void>}
|
|
107
|
+
*/
|
|
108
|
+
export async function remove (context, sharedAccountData) {
|
|
109
|
+
return (await getClient()).deleteAsync({
|
|
110
|
+
ctx: { id: context.id },
|
|
111
|
+
sharedAccount: { id: sharedAccountData.id },
|
|
112
|
+
auth: context.admin
|
|
113
|
+
})
|
|
114
|
+
}
|