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
458a4bf5
Commit
458a4bf5
authored
Apr 21, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added getGrant(), Grant Class, and refactor test
parent
bc6eb4cb
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
283 additions
and
145 deletions
+283
-145
zimbra-admin-api.js
lib/zimbra-admin-api.js
+81
-20
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
index.js
src/index.js
+27
-10
dictionary.js
src/utils/dictionary.js
+12
-8
domain.js
src/zimbra/domain.js
+1
-0
grant.js
src/zimbra/grant.js
+10
-0
test.js
test/js/spec/test.js
+151
-106
No files found.
lib/zimbra-admin-api.js
View file @
458a4bf5
...
@@ -131,6 +131,7 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -131,6 +131,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.parseRemoveResponse = this.parseRemoveResponse.bind(this);
this.parseRemoveResponse = this.parseRemoveResponse.bind(this);
this.parseCountAccountResponse = this.parseCountAccountResponse.bind(this);
this.parseCountAccountResponse = this.parseCountAccountResponse.bind(this);
this.parseSearchResponse = this.parseSearchResponse.bind(this);
this.parseSearchResponse = this.parseSearchResponse.bind(this);
this.parseGrantsResponse = this.parseGrantsResponse.bind(this);
this.dictionary = new _dictionary2.default();
this.dictionary = new _dictionary2.default();
}
}
...
@@ -225,6 +226,13 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -225,6 +226,13 @@ return /******/ (function(modules) { // webpackBootstrap
});
});
return callback(null, result);
return callback(null, result);
}
}
}, {
key: 'parseGrantsResponse',
value: function parseGrantsResponse(data, request_data, callback) {
var result = {};
var response_object = data.get().GetGrantsResponse;
callback(null, response_object);
}
}, {
}, {
key: 'parseResponse',
key: 'parseResponse',
value: function parseResponse(data, request_data, callback) {
value: function parseResponse(data, request_data, callback) {
...
@@ -268,7 +276,7 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -268,7 +276,7 @@ return /******/ (function(modules) { // webpackBootstrap
var response_name = that.dictionary.resourceResponseName(resource);
var response_name = that.dictionary.resourceResponseName(resource);
var response_object = data.get()[request_data.response_name][response_name];
var response_object = data.get()[request_data.response_name][response_name];
var response_array = [];
var response_array = [];
response_object.forEach(function (r) {
if (response_object)
response_object.forEach(function (r) {
var element = that.dictionary.classFactory(resource, r, that);
var element = that.dictionary.classFactory(resource, r, that);
response_array.push(element);
response_array.push(element);
});
});
...
@@ -448,25 +456,36 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -448,25 +456,36 @@ return /******/ (function(modules) { // webpackBootstrap
request_data.parse_response = this.parseAllResponse;
request_data.parse_response = this.parseAllResponse;
this.performRequest(request_data);
this.performRequest(request_data);
}
}
// Returns all grants on the specified target entry, or all grants granted to the specified grantee entry.
// target_data and grantee_data are both objects like:
// {
// type: (account|cos|dl|domain),
// identifier: (name or zimbraId)
// }
}, {
}, {
key: 'getGrants',
key: 'getGrants',
value: function getGrants(target_data, grantee_data, callback) {
value: function getGrants(target_data, grantee_data, callback) {
var request_data = {};
var request_data = {};
var resource = 'Grant';
request_data.params = this.requestParams();
request_data.params = this.requestParams();
request_data.request_name = 'Get
Grant
s';
request_data.request_name = 'Get
' + resource + '
s';
request_data.response_name = 'Get
Grant
sResponse';
request_data.response_name = 'Get
' + resource + '
sResponse';
request_data.params.name = request_data.request_name + 'Request';
request_data.params.name = request_data.request_name + 'Request';
request_data.callback = callback;
request_data.callback = callback;
request_data.parse_response = this.parseGetGrantsResponse;
request_data.resource = resource;
request_data.params.params.target = {
request_data.parse_response = this.parseAllResponse;
if (target_data) request_data.params.params.target = {
'type': target_data.type,
'type': target_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier),
'by': this.dictionary.byIdOrName(target_data.identifier),
'_content': target_data.identifier
'_content': target_data.identifier
};
};
request_data.params.params.grantee = {
if (grantee_data) request_data.params.params.grantee = {
'type': target_data.type,
'type': grantee_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier),
'by': this.dictionary.byIdOrName(grantee_data.identifier),
'_content': target_data.identifier
'all': 1,
'_content': grantee_data.identifier
};
};
this.performRequest(request_data);
this.performRequest(request_data);
}
}
...
@@ -12207,12 +12226,19 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -12207,12 +12226,19 @@ return /******/ (function(modules) { // webpackBootstrap
var _cos2 = _interopRequireDefault(_cos);
var _cos2 = _interopRequireDefault(_cos);
var _grant = __webpack_require__(283);
var _grant2 = _interopRequireDefault(_grant);
var _distribution_list = __webpack_require__(117);
var _distribution_list = __webpack_require__(117);
var _distribution_list2 = _interopRequireDefault(_distribution_list);
var _distribution_list2 = _interopRequireDefault(_distribution_list);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
var Dictionary = function () {
var Dictionary = function () {
function Dictionary() {
function Dictionary() {
(0, _classCallCheck3.default)(this, Dictionary);
(0, _classCallCheck3.default)(this, Dictionary);
...
@@ -12284,6 +12310,14 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -12284,6 +12310,14 @@ return /******/ (function(modules) { // webpackBootstrap
class_name: _account2.default,
class_name: _account2.default,
response_name: 'account'
response_name: 'account'
},
},
alias: {
response_name: 'alias',
class_name: _alias2.default
},
cos: {
class_name: _cos2.default,
response_name: 'cos'
},
distributionlist: {
distributionlist: {
class_name: _distribution_list2.default,
class_name: _distribution_list2.default,
response_name: 'dl'
response_name: 'dl'
...
@@ -12292,21 +12326,15 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -12292,21 +12326,15 @@ return /******/ (function(modules) { // webpackBootstrap
class_name: _distribution_list2.default,
class_name: _distribution_list2.default,
response_name: 'dl'
response_name: 'dl'
},
},
alias: {
grant: {
response_name: 'alias',
class_name: _grant2.default,
class_name: _alias2.default
response_name: 'grant'
},
cos: {
class_name: _cos2.default,
response_name: 'cos'
}
}
};
};
}
}
}]);
}]);
return Dictionary;
return Dictionary;
}(); // Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
}();
// See LICENSE.txt for license information.
exports.default = Dictionary;
exports.default = Dictionary;
...
@@ -13068,7 +13096,11 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -13068,7 +13096,11 @@ return /******/ (function(modules) { // webpackBootstrap
function Domain(domain_obj, zimbra_api_client) {
function Domain(domain_obj, zimbra_api_client) {
(0, _classCallCheck3.default)(this, Domain);
(0, _classCallCheck3.default)(this, Domain);
return (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Domain).call(this, domain_obj, zimbra_api_client));
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Domain).call(this, domain_obj, zimbra_api_client));
_this.domainAdminRights = 'domainAdminRights';
return _this;
}
}
(0, _createClass3.default)(Domain, [{
(0, _createClass3.default)(Domain, [{
...
@@ -40110,6 +40142,35 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -40110,6 +40142,35 @@ return /******/ (function(modules) { // webpackBootstrap
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(139).Buffer))
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(139).Buffer))
/***/ },
/* 283 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(68);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
var Grant = function Grant(grant) {
(0, _classCallCheck3.default)(this, Grant);
this.grantee = grant.grantee[0];
this.target = grant.target[0];
this.right = grant.right[0];
};
exports.default = Grant;
/***/ }
/***/ }
/******/ ])
/******/ ])
});
});
lib/zimbra-admin-api.js.map
View file @
458a4bf5
This diff is collapsed.
Click to expand it.
src/index.js
View file @
458a4bf5
...
@@ -37,6 +37,7 @@ export default class ZimbraAdminApi {
...
@@ -37,6 +37,7 @@ export default class ZimbraAdminApi {
this
.
parseRemoveResponse
=
this
.
parseRemoveResponse
.
bind
(
this
);
this
.
parseRemoveResponse
=
this
.
parseRemoveResponse
.
bind
(
this
);
this
.
parseCountAccountResponse
=
this
.
parseCountAccountResponse
.
bind
(
this
);
this
.
parseCountAccountResponse
=
this
.
parseCountAccountResponse
.
bind
(
this
);
this
.
parseSearchResponse
=
this
.
parseSearchResponse
.
bind
(
this
);
this
.
parseSearchResponse
=
this
.
parseSearchResponse
.
bind
(
this
);
this
.
parseGrantsResponse
=
this
.
parseGrantsResponse
.
bind
(
this
);
this
.
dictionary
=
new
Dictionary
();
this
.
dictionary
=
new
Dictionary
();
}
}
...
@@ -127,11 +128,17 @@ export default class ZimbraAdminApi {
...
@@ -127,11 +128,17 @@ export default class ZimbraAdminApi {
result
[
cos
.
name
]
=
{
result
[
cos
.
name
]
=
{
used
:
parseInt
(
cos
.
_content
),
used
:
parseInt
(
cos
.
_content
),
id
:
cos
.
id
id
:
cos
.
id
}
}
;
});
});
return
callback
(
null
,
result
);
return
callback
(
null
,
result
);
}
}
parseGrantsResponse
(
data
,
request_data
,
callback
)
{
const
result
=
{};
const
response_object
=
data
.
get
().
GetGrantsResponse
;
callback
(
null
,
response_object
);
}
parseResponse
(
data
,
request_data
,
callback
)
{
parseResponse
(
data
,
request_data
,
callback
)
{
const
resource
=
request_data
.
resource
.
toLowerCase
();
const
resource
=
request_data
.
resource
.
toLowerCase
();
const
that
=
this
;
const
that
=
this
;
...
@@ -170,7 +177,7 @@ export default class ZimbraAdminApi {
...
@@ -170,7 +177,7 @@ export default class ZimbraAdminApi {
const
response_name
=
that
.
dictionary
.
resourceResponseName
(
resource
);
const
response_name
=
that
.
dictionary
.
resourceResponseName
(
resource
);
const
response_object
=
data
.
get
()[
request_data
.
response_name
][
response_name
];
const
response_object
=
data
.
get
()[
request_data
.
response_name
][
response_name
];
const
response_array
=
[];
const
response_array
=
[];
response_object
.
forEach
((
r
)
=>
{
if
(
response_object
)
response_object
.
forEach
((
r
)
=>
{
let
element
=
that
.
dictionary
.
classFactory
(
resource
,
r
,
that
);
let
element
=
that
.
dictionary
.
classFactory
(
resource
,
r
,
that
);
response_array
.
push
(
element
);
response_array
.
push
(
element
);
});
});
...
@@ -326,23 +333,33 @@ export default class ZimbraAdminApi {
...
@@ -326,23 +333,33 @@ export default class ZimbraAdminApi {
this
.
performRequest
(
request_data
);
this
.
performRequest
(
request_data
);
}
}
// Returns all grants on the specified target entry, or all grants granted to the specified grantee entry.
// target_data and grantee_data are both objects like:
// {
// type: (account|cos|dl|domain),
// identifier: (name or zimbraId)
// }
getGrants
(
target_data
,
grantee_data
,
callback
)
{
getGrants
(
target_data
,
grantee_data
,
callback
)
{
const
request_data
=
{
};
const
request_data
=
{
};
const
resource
=
'Grant'
;
request_data
.
params
=
this
.
requestParams
();
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
'GetGrants'
;
request_data
.
request_name
=
`Get
${
resource
}
s`
;
request_data
.
response_name
=
'GetGrantsResponse'
;
request_data
.
response_name
=
`Get
${
resource
}
sResponse`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
callback
=
callback
;
request_data
.
callback
=
callback
;
request_data
.
parse_response
=
this
.
parseGetGrantsResponse
;
request_data
.
resource
=
resource
;
request_data
.
params
.
params
.
target
=
{
request_data
.
parse_response
=
this
.
parseAllResponse
;
if
(
target_data
)
request_data
.
params
.
params
.
target
=
{
'type'
:
target_data
.
type
,
'type'
:
target_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
target_data
.
identifier
),
'by'
:
this
.
dictionary
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
'_content'
:
target_data
.
identifier
};
};
request_data
.
params
.
params
.
grantee
=
{
if
(
grantee_data
)
request_data
.
params
.
params
.
grantee
=
{
'type'
:
target_data
.
type
,
'type'
:
grantee_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
target_data
.
identifier
),
'by'
:
this
.
dictionary
.
byIdOrName
(
grantee_data
.
identifier
),
'_content'
:
target_data
.
identifier
'all'
:
1
,
'_content'
:
grantee_data
.
identifier
};
};
this
.
performRequest
(
request_data
);
this
.
performRequest
(
request_data
);
}
}
...
...
src/utils/dictionary.js
View file @
458a4bf5
...
@@ -5,6 +5,7 @@ import Domain from './../zimbra/domain.js';
...
@@ -5,6 +5,7 @@ import Domain from './../zimbra/domain.js';
import
Account
from
'./../zimbra/account.js'
;
import
Account
from
'./../zimbra/account.js'
;
import
Alias
from
'./../zimbra/alias.js'
;
import
Alias
from
'./../zimbra/alias.js'
;
import
Cos
from
'./../zimbra/cos.js'
;
import
Cos
from
'./../zimbra/cos.js'
;
import
Grant
from
'./../zimbra/grant.js'
;
import
DistributionList
from
'./../zimbra/distribution_list.js'
;
import
DistributionList
from
'./../zimbra/distribution_list.js'
;
export
default
class
Dictionary
{
export
default
class
Dictionary
{
...
@@ -64,6 +65,14 @@ export default class Dictionary {
...
@@ -64,6 +65,14 @@ export default class Dictionary {
class_name
:
Account
,
class_name
:
Account
,
response_name
:
'account'
response_name
:
'account'
},
},
alias
:
{
response_name
:
'alias'
,
class_name
:
Alias
,
},
cos
:
{
class_name
:
Cos
,
response_name
:
'cos'
},
distributionlist
:
{
distributionlist
:
{
class_name
:
DistributionList
,
class_name
:
DistributionList
,
response_name
:
'dl'
response_name
:
'dl'
...
@@ -72,15 +81,10 @@ export default class Dictionary {
...
@@ -72,15 +81,10 @@ export default class Dictionary {
class_name
:
DistributionList
,
class_name
:
DistributionList
,
response_name
:
'dl'
response_name
:
'dl'
},
},
alias
:
{
grant
:
{
response_name
:
'alias'
,
class_name
:
Grant
,
class_name
:
Alias
,
response_name
:
'grant'
},
cos
:
{
class_name
:
Cos
,
response_name
:
'cos'
}
}
};
};
}
}
...
...
src/zimbra/domain.js
View file @
458a4bf5
...
@@ -6,6 +6,7 @@ import Zimbra from './zimbra.js';
...
@@ -6,6 +6,7 @@ import Zimbra from './zimbra.js';
export
default
class
Domain
extends
Zimbra
{
export
default
class
Domain
extends
Zimbra
{
constructor
(
domain_obj
,
zimbra_api_client
)
{
constructor
(
domain_obj
,
zimbra_api_client
)
{
super
(
domain_obj
,
zimbra_api_client
);
super
(
domain_obj
,
zimbra_api_client
);
this
.
domainAdminRights
=
'domainAdminRights'
;
}
}
countAccounts
(
callback
)
{
countAccounts
(
callback
)
{
...
...
src/zimbra/grant.js
0 → 100644
View file @
458a4bf5
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
export
default
class
Grant
{
constructor
(
grant
)
{
this
.
grantee
=
grant
.
grantee
[
0
];
this
.
target
=
grant
.
target
[
0
];
this
.
right
=
grant
.
right
[
0
];
}
}
test/js/spec/test.js
View file @
458a4bf5
This diff is collapsed.
Click to expand it.
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