Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
a6f5009f
Commit
a6f5009f
authored
Apr 26, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This fixes #4
parent
92c0128f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
30 deletions
+60
-30
zimbra-admin-api.js
lib/zimbra-admin-api.js
+27
-7
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
index.js
src/index.js
+6
-4
domain.js
src/zimbra/domain.js
+11
-5
zimbra.js
src/zimbra/zimbra.js
+4
-4
test.js
test/js/spec/test.js
+11
-9
No files found.
lib/zimbra-admin-api.js
View file @
a6f5009f
...
...
@@ -351,10 +351,13 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'modify',
value: function modify(resource, resource_data, callback) {
var forBatch = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
var request_data = this.buildRequestData('Modify' + resource, callback);
request_data.resource = resource;
request_data.parse_response = this.parseResponse;
request_data.params.params = resource_data;
if (forBatch) return request_data;
this.performRequest(request_data);
}
}, {
...
...
@@ -389,6 +392,8 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'grantRight',
value: function grantRight(target_data, grantee_data, right_name, callback) {
var forBatch = arguments.length <= 4 || arguments[4] === undefined ? false : arguments[4];
var request_data = this.buildRequestData('GrantRight', callback);
var _dictionary$buildTarg = this.dictionary.buildTargetGrantee(target_data, grantee_data);
...
...
@@ -402,6 +407,7 @@ return /******/ (function(modules) { // webpackBootstrap
request_data.params.params.grantee = grantee;
request_data.params.params.target = target;
request_data.params.params.right = { '_content': right_name };
if (forBatch) return request_data;
this.performRequest(request_data);
}
...
...
@@ -558,11 +564,13 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'modifyAccount',
value: function modifyAccount(zimbra_id, attributes, callback) {
var forBatch = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
var resource_data = {
id: zimbra_id,
a: this.dictionary.attributesToArray(attributes)
};
this.modify('Account', resource_data, callback
);
return this.modify('Account', resource_data, callback, forBatch
);
}
// Modify Domain
...
...
@@ -13315,14 +13323,22 @@ return /******/ (function(modules) { // webpackBootstrap
return _this;
}
// TODO: Too ugly code
(0, _createClass3.default)(Domain, [{
key: 'addAdmin',
value: function addAdmin(account_id, callback) {
var grantee_data = {
'type': 'usr',
'identifier': account_id
var request_data = {};
var grantee_data = { 'type': 'usr', 'identifier': account_id };
var modifyAccountRequest = this.api.modifyAccount(account_id, { zimbraIsDelegatedAdminAccount: 'TRUE' }, callback, true);
var grantRightRequest = this.grantRight(grantee_data, this.domainAdminRights, callback, true);
request_data.requests = [modifyAccountRequest, grantRightRequest];
request_data.callback = function (err, data) {
if (err) return callback(err);
callback(null, data.GrantRightResponse);
};
this.
grantRight(grantee_data, this.domainAdminRights, callback
);
this.
api.performRequest(request_data, true
);
}
// TODO: Fix this fucking ugly code
...
...
@@ -13724,12 +13740,16 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: "grantRight",
value: function grantRight(grantee_data, right_name, callback) {
this.api.grantRight(this.buildRighTargetData(), grantee_data, right_name, callback);
var forBatch = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
return this.api.grantRight(this.buildRighTargetData(), grantee_data, right_name, callback, forBatch);
}
}, {
key: "revokeRight",
value: function revokeRight(grantee_data, right_name, callback) {
this.api.revokeRight(this.buildRighTargetData(), grantee_data, right_name, callback);
var forBatch = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
return this.api.revokeRight(this.buildRighTargetData(), grantee_data, right_name, callback, forBatch);
}
}]);
return Zimbra;
lib/zimbra-admin-api.js.map
View file @
a6f5009f
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/index.js
View file @
a6f5009f
...
...
@@ -234,11 +234,12 @@ export default class ZimbraAdminApi {
}
modify
(
resource
,
resource_data
,
callback
){
modify
(
resource
,
resource_data
,
callback
,
forBatch
=
false
){
const
request_data
=
this
.
buildRequestData
(
`Modify
${
resource
}
`
,
callback
);
request_data
.
resource
=
resource
;
request_data
.
parse_response
=
this
.
parseResponse
;
request_data
.
params
.
params
=
resource_data
;
if
(
forBatch
)
return
request_data
;
this
.
performRequest
(
request_data
);
}
...
...
@@ -267,13 +268,14 @@ export default class ZimbraAdminApi {
// type: (account|cos|dl|domain),
// identifier: (name or zimbraId)
// }
grantRight
(
target_data
,
grantee_data
,
right_name
,
callback
)
{
grantRight
(
target_data
,
grantee_data
,
right_name
,
callback
,
forBatch
=
false
)
{
const
request_data
=
this
.
buildRequestData
(
'GrantRight'
,
callback
);
const
[
target
,
grantee
]
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
request_data
.
parse_response
=
this
.
parseEmptyResponse
;
request_data
.
params
.
params
.
grantee
=
grantee
;
request_data
.
params
.
params
.
target
=
target
;
request_data
.
params
.
params
.
right
=
{
'_content'
:
right_name
};
if
(
forBatch
)
return
request_data
;
this
.
performRequest
(
request_data
);
}
...
...
@@ -388,12 +390,12 @@ export default class ZimbraAdminApi {
}
// Modify Account
modifyAccount
(
zimbra_id
,
attributes
,
callback
)
{
modifyAccount
(
zimbra_id
,
attributes
,
callback
,
forBatch
=
false
)
{
let
resource_data
=
{
id
:
zimbra_id
,
a
:
this
.
dictionary
.
attributesToArray
(
attributes
)
};
this
.
modify
(
'Account'
,
resource_data
,
callback
);
return
this
.
modify
(
'Account'
,
resource_data
,
callback
,
forBatch
);
}
// Modify Domain
...
...
src/zimbra/domain.js
View file @
a6f5009f
...
...
@@ -9,12 +9,18 @@ export default class Domain extends Zimbra {
this
.
domainAdminRights
=
'domainAdminRights'
;
}
// TODO: Too ugly code
addAdmin
(
account_id
,
callback
)
{
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
grantRight
(
grantee_data
,
this
.
domainAdminRights
,
callback
);
const
request_data
=
{};
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
};
let
modifyAccountRequest
=
this
.
api
.
modifyAccount
(
account_id
,
{
zimbraIsDelegatedAdminAccount
:
'TRUE'
},
callback
,
true
);
const
grantRightRequest
=
this
.
grantRight
(
grantee_data
,
this
.
domainAdminRights
,
callback
,
true
);
request_data
.
requests
=
[
modifyAccountRequest
,
grantRightRequest
];
request_data
.
callback
=
function
(
err
,
data
)
{
if
(
err
)
return
callback
(
err
);
callback
(
null
,
data
.
GrantRightResponse
);
};
this
.
api
.
performRequest
(
request_data
,
true
);
}
// TODO: Fix this fucking ugly code
...
...
src/zimbra/zimbra.js
View file @
a6f5009f
...
...
@@ -53,12 +53,12 @@ export default class Zimbra {
});
}
grantRight
(
grantee_data
,
right_name
,
callback
){
this
.
api
.
grantRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
);
grantRight
(
grantee_data
,
right_name
,
callback
,
forBatch
=
false
){
return
this
.
api
.
grantRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
,
forBatch
);
}
revokeRight
(
grantee_data
,
right_name
,
callback
){
this
.
api
.
revokeRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
);
revokeRight
(
grantee_data
,
right_name
,
callback
,
forBatch
=
false
){
return
this
.
api
.
revokeRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
,
forBatch
);
}
}
test/js/spec/test.js
View file @
a6f5009f
...
...
@@ -491,16 +491,18 @@
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
domain_admin
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'.dev'
;
api
.
createDomain
(
resource_name
,
{},
function
(
err
,
data
){
if
(
err
)
console
.
error
(
err
);
let
domain
=
data
;
domain
.
addAdmin
(
domain_admin
,
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
err
).
to
.
be
.
null
;
domain
.
getACLs
(
function
(
e
,
d
){
api
.
getAccount
(
domain_admin
,
function
(
err
,
account
){
api
.
createDomain
(
resource_name
,
{},
function
(
err
,
data
){
if
(
err
)
console
.
error
(
err
);
let
domain
=
data
;
domain
.
addAdmin
(
account
.
id
,
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
[
0
].
grantee
.
name
).
to
.
be
.
equal
(
domain_admin
);
done
();
expect
(
err
).
to
.
be
.
null
;
domain
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
[
0
].
grantee
.
name
).
to
.
be
.
equal
(
account
.
name
);
done
();
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment