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
fa21268f
Commit
fa21268f
authored
Sep 21, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Plain Diff
merge pull #15
parents
909af3a2
23c59849
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
3 deletions
+181
-3
README.md
README.md
+53
-0
package.json
package.json
+1
-1
index.js
src/index.js
+39
-2
test.js
test/test.js
+88
-0
No files found.
README.md
View file @
fa21268f
...
...
@@ -499,6 +499,47 @@ This are functions especifics to `Cos`.
client
.
getAllCos
(
callback
);
```
## Create / Delete Cos
To create a Cos
```
javascript
//Simple, without attributes
var
attributes
=
{};
client
.
createCos
(
"cos_name"
,
attributes
,
callback
);
// With attributes
var
attributes
=
{
'zimbraFeatureContactsEnabled'
:
'FALSE'
};
client
.
createCos
(
"cos_name"
,
attributes
,
callback
)
```
To delete a Cos
```
javascript
client
.
deleteCos
(
"cos_Id"
,
callback
)
```
## Get Cos
```
javascript
client
.
getCos
(
name
|
id
,
callback
);
```
## Modify Cos
```
javascript
var
attributes
=
{
'zimbraDumpsterEnabled'
:
'TRUE'
};
client
.
modifyCos
(
"cos_Id"
,
attributes
,
callback
);
```
## Rename Cos
```
javascript
var
newName
=
"basicv2"
client
.
renameCos
(
"cos_Id"
,
newName
,
callback
);
```
## Copy Cos
To copy a Cos with other name
```
javascript
var
newCos
=
"Pro2"
;
client
.
copyCos
(
nameCos
|
idCos
,
newCos
,
callback
);
```
## Domains
This are functions especifics to
`Domains`
.
...
...
@@ -644,6 +685,18 @@ dl.getOwners(callback);
// {name: 'email_address', id: 'ZimbraId', type: 'usr|grp'}
```
### Add / Remove Alias
To set alias at
`DL`
.
```
javascript
client
.
addDistributionListAlias
(
dl
.
id
,
alias
,
callback
);
```
To delete alias of
`DL`
.
```
javascript
api
.
removeDistributionListAlias
(
dl
.
id
,
alias
,
callback
);
```
## Contributing
...
...
package.json
View file @
fa21268f
{
"name"
:
"zimbra-admin-api-js"
,
"version"
:
"0.3.1
0
"
,
"version"
:
"0.3.1
2
"
,
"main"
:
"src/index.js"
,
"engines"
:
{
"node"
:
">=6.2"
...
...
src/index.js
View file @
fa21268f
...
...
@@ -254,8 +254,6 @@ class ZimbraAdminApi {
return
this
.
performRequest
(
request_data
);
}
//Add distribution list alias
//
addDistributionListAlias
(
dl_id
,
alias
,
callback
)
{
const
request_data
=
this
.
buildRequestData
(
'AddDistributionListAlias'
,
callback
);
request_data
.
parse_response
=
ResponseParser
.
emptyResponse
;
...
...
@@ -263,6 +261,13 @@ class ZimbraAdminApi {
return
this
.
performRequest
(
request_data
);
}
removeDistributionListAlias
(
dl_id
,
alias
,
callback
)
{
const
request_data
=
this
.
buildRequestData
(
'RemoveDistributionListAlias'
,
callback
);
request_data
.
parse_response
=
ResponseParser
.
emptyResponse
;
request_data
.
params
.
params
=
{
'id'
:
dl_id
,
'alias'
:
alias
};
return
this
.
performRequest
(
request_data
);
}
// Add New members tos distributionlists
// members is an array of emails
addDistributionListMember
(
dl_id
,
members
,
callback
)
{
...
...
@@ -396,6 +401,11 @@ class ZimbraAdminApi {
return
this
.
create
(
'Domain'
,
resource_data
,
callback
);
}
createCos
(
name
,
attributes
,
callback
)
{
const
resource_data
=
this
.
buildResourceData
(
name
,
attributes
);
return
this
.
create
(
'Cos'
,
resource_data
,
callback
);
}
getDistributionList
(
identifier
,
callback
)
{
return
this
.
get
(
'DistributionList'
,
identifier
,
callback
);
}
...
...
@@ -563,6 +573,13 @@ class ZimbraAdminApi {
this
.
modify
(
'DistributionList'
,
resource_data
,
callback
);
}
modifyCos
(
id_cos
,
attributes
,
callback
){
const
request_data
=
this
.
buildRequestData
(
'ModifyCos'
,
callback
);
request_data
.
parse_response
=
ResponseParser
.
emptyResponse
;
request_data
.
params
.
params
=
{
'id'
:{
'_content'
:
id_cos
},
'a'
:
this
.
dictionary
.
attributesToArray
(
attributes
)};
return
this
.
performRequest
(
request_data
);
}
// Remove Account
removeAccount
(
zimbra_id
,
callback
)
{
let
resource_data
=
{
id
:
zimbra_id
};
...
...
@@ -583,6 +600,21 @@ class ZimbraAdminApi {
return
this
.
remove
(
'Domain'
,
resource_data
,
callback
);
}
deleteCos
(
id_cos
,
callback
){
const
request_data
=
this
.
buildRequestData
(
'DeleteCos'
,
callback
);
request_data
.
parse_response
=
ResponseParser
.
emptyResponse
;
request_data
.
params
.
params
=
{
'id'
:
{
'_content'
:
id_cos
}};
return
this
.
performRequest
(
request_data
);
}
copyCos
(
cos
,
newcos
,
callback
){
const
request_data
=
this
.
buildRequestData
(
'CopyCos'
,
callback
);
request_data
.
parse_response
=
ResponseParser
.
emptyResponse
;
request_data
.
params
.
params
=
{
'name'
:
{
'_content'
:
newcos
},
'cos'
:{
'_content'
:
cos
,
by
:
this
.
dictionary
.
byIdOrName
(
cos
)}};
return
this
.
performRequest
(
request_data
);
}
removeDomainAdmin
(
domain
,
account_id
,
coses
,
callback
)
{
this
.
getDomain
(
domain
,
(
err
,
domain
)
=>
{
if
(
err
)
return
callback
(
err
);
...
...
@@ -622,6 +654,11 @@ class ZimbraAdminApi {
return
this
.
rename
(
'DistributionList'
,
resource_data
,
callback
);
}
renameCos
(
cos_Id
,
new_name
,
callback
)
{
const
resource_data
=
{
id
:
{
'_content'
:
cos_Id
},
newName
:
{
'_content'
:
new_name
}
}
return
this
.
rename
(
'Cos'
,
resource_data
,
callback
);
}
revokeRight
(
target_data
,
grantee_data
,
right_name
,
callback
)
{
const
target_grantee
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
const
target
=
target_grantee
[
0
];
...
...
test/test.js
View file @
fa21268f
...
...
@@ -826,6 +826,75 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
});
});
});
describe
(
'COS tests'
,
function
()
{
this
.
timeout
(
5000
);
it
(
'Should create a COS'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
cos_name
=
Date
.
now
();
let
attrs
=
{
'zimbraFeatureContactsEnabled'
:
'FALSE'
};
api
.
createCos
(
cos_name
,
attrs
,
function
(
err
,
cos
){
if
(
err
)
return
console
.
error
(
err
);
expect
(
err
).
to
.
be
.
null
;
done
();
});
})
it
(
'Should delete COS "unknow" '
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
api
.
getCos
(
"unknow"
,
function
(
err
,
cos
){
if
(
err
)
return
console
.
error
(
err
);
let
cosId
=
cos
.
id
;
console
.
log
(
cosId
);
api
.
deleteCos
(
cosId
,
function
(
err
,
res
){
if
(
err
)
return
console
.
error
(
err
);
console
.
log
(
res
);
expect
(
err
).
to
.
be
.
null
;
done
();
})
});
})
it
(
'Should modify a Cos "basic"'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
attrs
=
{
'zimbraDumpsterEnabled'
:
'TRUE'
};
api
.
getCos
(
"basic"
,
function
(
err
,
cos
){
if
(
err
)
return
console
.
error
(
err
);
api
.
modifyCos
(
cos
.
id
,
attrs
,
function
(
err
,
res
){
if
(
err
)
return
console
.
error
(
err
);
console
.
log
(
res
);
expect
(
err
).
to
.
be
.
null
;
done
();
});
});
});
it
(
'Should rename Cos "Basic"'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
newName
=
"basicv2"
api
.
getCos
(
"basic"
,
function
(
err
,
cos
){
if
(
err
)
return
console
.
error
(
err
);
api
.
renameCos
(
cos
.
id
,
newName
,
function
(
err
,
res
){
if
(
err
)
return
console
.
log
(
err
);
console
.
log
(
res
);
expect
(
err
).
to
.
be
.
null
;
done
();
});
});
});
it
.
only
(
'Should create a copy of Cos Professional, called Pro2 '
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
newCos
=
Date
.
now
();
api
.
copyCos
(
"professional"
,
newCos
,
function
(
err
,
res
){
if
(
err
)
return
console
.
error
(
err
);
console
.
log
(
res
);
expect
(
err
).
to
.
be
.
null
;
done
();
})
});
});
describe
(
'DistributionList tests'
,
function
()
{
...
...
@@ -885,12 +954,31 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
let
dl
=
data
;
api
.
addDistributionListAlias
(
dl
.
id
,
alias
,
function
(
err
,
data
){
if
(
err
)
return
console
.
error
(
err
);
console
.
log
(
data
);
expect
(
err
).
to
.
be
.
null
;
done
();
});
});
});
it
(
'removeDistributionListAlias should remove the alias'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
alias
=
Date
.
now
()
+
'@itlinux.cl'
;
api
.
getDistributionList
(
'abierta@customer.dev'
,
function
(
err
,
data
){
let
dl
=
data
;
api
.
addDistributionListAlias
(
dl
.
id
,
alias
,
function
(
err
,
data
){
if
(
err
)
return
console
.
error
(
err
);
api
.
removeDistributionListAlias
(
dl
.
id
,
alias
,
function
(
err
,
data
){
if
(
err
)
return
console
.
error
(
err
);
console
.
log
(
data
);
expect
(
err
).
to
.
be
.
null
;
done
();
});
});
});
});
it
(
'Add member to DL should work with only one'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
member
=
Date
.
now
().
toString
()
+
'@customer.dev'
;
...
...
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