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
3f589551
Commit
3f589551
authored
Apr 14, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creates (Without Attributes) accounts, domains and dls
parent
96008369
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
3 deletions
+101
-3
zimbra-admin-api.js
lib/zimbra-admin-api.js
+35
-0
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
index.js
src/index.js
+32
-2
test.js
test/js/spec/test.js
+33
-0
No files found.
lib/zimbra-admin-api.js
View file @
3f589551
...
@@ -19269,6 +19269,19 @@ var ZimbraAdminApi =
...
@@ -19269,6 +19269,19 @@ var ZimbraAdminApi =
});
});
return callback(null, response_array);
return callback(null, response_array);
}
}
}, {
key: 'create',
value: function create(resource, resource_data, callback) {
var request_data = {};
request_data.params = this.requestParams();
request_data.request_name = 'Create' + resource;
request_data.params.name = request_data.request_name + 'Request';
request_data.resource = resource;
request_data.callback = callback;
request_data.parse_response = this.parseResponse;
request_data.params.params = resource_data;
this.performRequest(request_data);
}
}, {
}, {
key: 'get',
key: 'get',
value: function get(resource, resource_identifier, callback) {
value: function get(resource, resource_identifier, callback) {
...
@@ -19303,11 +19316,33 @@ var ZimbraAdminApi =
...
@@ -19303,11 +19316,33 @@ var ZimbraAdminApi =
value: function getAccount(identifier, callback) {
value: function getAccount(identifier, callback) {
this.get('Account', identifier, callback);
this.get('Account', identifier, callback);
}
}
// attributes debe ser un arreglo de objetos:
// resource_data.a = attributes
// attributes = [ { n: 'NOMBRE_DEL_CAMPO_ZIMBRA', '_content': 'VALOR_DEL_CAMPO' } ]
}, {
key: 'createAccount',
value: function createAccount(name, password, attributes, callback) {
var resource_data = {
name: { '_content': name },
password: { '_content': password }
};
this.create('Account', resource_data, callback);
}
}, {
}, {
key: 'getDomain',
key: 'getDomain',
value: function getDomain(identifier, callback) {
value: function getDomain(identifier, callback) {
this.get('Domain', identifier, callback);
this.get('Domain', identifier, callback);
}
}
}, {
key: 'createDomain',
value: function createDomain(name, attributes, callback) {
var resource_data = {
name: { '_content': name }
};
this.create('Domain', resource_data, callback);
}
}, {
}, {
key: 'getDistributionList',
key: 'getDistributionList',
value: function getDistributionList(identifier, callback) {
value: function getDistributionList(identifier, callback) {
lib/zimbra-admin-api.js.map
View file @
3f589551
This diff is collapsed.
Click to expand it.
src/index.js
View file @
3f589551
...
@@ -141,8 +141,20 @@ class ZimbraAdminApi {
...
@@ -141,8 +141,20 @@ class ZimbraAdminApi {
return
callback
(
null
,
response_array
);
return
callback
(
null
,
response_array
);
}
}
create
(
resource
,
resource_data
,
callback
){
let
request_data
=
{
};
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
`Create
${
resource
}
`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
resource
=
resource
;
request_data
.
callback
=
callback
;
request_data
.
parse_response
=
this
.
parseResponse
;
request_data
.
params
.
params
=
resource_data
;
this
.
performRequest
(
request_data
);
}
get
(
resource
,
resource_identifier
,
callback
){
get
(
resource
,
resource_identifier
,
callback
){
let
request_data
=
{
}
let
request_data
=
{
}
;
request_data
.
params
=
this
.
requestParams
();
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
`Get
${
resource
}
`
;
request_data
.
request_name
=
`Get
${
resource
}
`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
...
@@ -158,7 +170,7 @@ class ZimbraAdminApi {
...
@@ -158,7 +170,7 @@ class ZimbraAdminApi {
}
}
getAll
(
resource
,
callback
)
{
getAll
(
resource
,
callback
)
{
let
request_data
=
{
}
let
request_data
=
{
}
;
request_data
.
params
=
this
.
requestParams
();
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
`GetAll
${
resource
}
s`
;
request_data
.
request_name
=
`GetAll
${
resource
}
s`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
...
@@ -172,10 +184,28 @@ class ZimbraAdminApi {
...
@@ -172,10 +184,28 @@ class ZimbraAdminApi {
this
.
get
(
'Account'
,
identifier
,
callback
);
this
.
get
(
'Account'
,
identifier
,
callback
);
}
}
// attributes debe ser un arreglo de objetos:
// resource_data.a = attributes
// attributes = [ { n: 'NOMBRE_DEL_CAMPO_ZIMBRA', '_content': 'VALOR_DEL_CAMPO' } ]
createAccount
(
name
,
password
,
attributes
,
callback
)
{
let
resource_data
=
{
name
:
{
'_content'
:
name
},
password
:
{
'_content'
:
password
}
};
this
.
create
(
'Account'
,
resource_data
,
callback
);
}
getDomain
(
identifier
,
callback
)
{
getDomain
(
identifier
,
callback
)
{
this
.
get
(
'Domain'
,
identifier
,
callback
);
this
.
get
(
'Domain'
,
identifier
,
callback
);
}
}
createDomain
(
name
,
attributes
,
callback
)
{
let
resource_data
=
{
name
:
{
'_content'
:
name
}
};
this
.
create
(
'Domain'
,
resource_data
,
callback
);
}
getDistributionList
(
identifier
,
callback
)
{
getDistributionList
(
identifier
,
callback
)
{
this
.
get
(
'DistributionList'
,
identifier
,
callback
);
this
.
get
(
'DistributionList'
,
identifier
,
callback
);
}
}
...
...
test/js/spec/test.js
View file @
3f589551
...
@@ -144,6 +144,39 @@
...
@@ -144,6 +144,39 @@
api
.
getDomain
(
'zboxapp.dev'
,
callback
);
api
.
getDomain
(
'zboxapp.dev'
,
callback
);
});
});
it
(
'should create and return an account'
,
function
(
done
){
let
account_name
=
Date
.
now
()
+
'@zboxapp.dev'
;
let
account_password
=
Date
.
now
();
let
account_attributes
=
{};
let
api
=
new
ZimbraAdminApi
(
auth_data
);
api
.
createAccount
(
account_name
,
account_password
,
account_attributes
,
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
expect
(
data
.
name
).
to
.
equal
(
account_name
);
done
();
});
});
it
(
'should create and return Domain'
,
function
(
done
){
let
resource_name
=
Date
.
now
()
+
'.dev'
;
let
resource_attributes
=
{};
let
api
=
new
ZimbraAdminApi
(
auth_data
);
api
.
createDomain
(
resource_name
,
resource_attributes
,
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
expect
(
data
.
name
).
to
.
equal
(
resource_name
);
done
();
});
});
it
(
'should return error "account.DOMAIN_EXISTS" if Domain Exists'
,
function
(
done
){
let
resource_name
=
'zboxapp.dev'
;
let
resource_attributes
=
{};
let
api
=
new
ZimbraAdminApi
(
auth_data
);
api
.
createDomain
(
resource_name
,
resource_attributes
,
function
(
err
,
data
){
expect
(
err
.
extra
.
code
).
to
.
equal
(
'account.DOMAIN_EXISTS'
);
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