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
6c1d1f7d
Commit
6c1d1f7d
authored
Apr 19, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs v1.
parent
d2d21704
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
170 additions
and
22 deletions
+170
-22
README.md
README.md
+161
-17
zimbra-admin-api.js
lib/zimbra-admin-api.js
+4
-2
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
index.js
src/index.js
+4
-2
No files found.
README.md
View file @
6c1d1f7d
#
##### DRAFT ....
#
Zimbra Admin Api Javascript
## Como se usa
## Table of Contents
-
[
Example
](
https://github.com/ZBoxApp/zimbra-admin-api-js#example
)
-
[
Install
](
https://github.com/ZBoxApp/zimbra-admin-api-js#install
)
-
[
Callback
](
https://github.com/ZBoxApp/zimbra-admin-api-js#callback
)
-
[
Errors
](
https://github.com/ZBoxApp/zimbra-admin-api-js#callback
)
-
[
Zimbra Resources
](
https://github.com/ZBoxApp/zimbra-admin-api-js#zimbra-resources
)
-
[
Common Functions
](
https://github.com/ZBoxApp/zimbra-admin-api-js#common-functions
)
-
[
Creating Resources
](
https://github.com/ZBoxApp/zimbra-admin-api-js#creating-resources
)
## Example
First, instantiate the wrapper.
First, instantiate the wrapper.
```
javascript
```
javascript
...
@@ -9,30 +19,164 @@ var zimbraApi = new ZimbraAdminApi({
...
@@ -9,30 +19,164 @@ var zimbraApi = new ZimbraAdminApi({
'user'
:
'admin@zboxapp.dev'
,
'user'
:
'admin@zboxapp.dev'
,
'password'
:
'12345678'
'password'
:
'12345678'
});
});
var
callback
=
function
(
err
,
data
)
{
if
(
err
)
return
console
.
log
(
err
);
console
.
log
(
data
);
};
zimbraApi
.
getAllDomains
(
callback
);
```
```
Here you see how to get basic information using a function like
`getAllDomains`
:
## Install
**TODO**
## Callback
You have to pass a
`callback`
to all the functions, that receives to params:
1.
`error`
, if any
2.
`data`
, if any
For this documentations
`callback`
will always be:
```
javascript
```
javascript
zimbraApi
.
getAllDomains
(
function
(
err
,
data
)
{
function
(
err
,
data
)
{
if
(
err
)
return
console
.
log
(
err
);
if
(
err
)
return
console
.
log
(
err
);
data
.
forEach
(
function
(
v
){
console
.
log
(
data
);
console
.
log
(
v
.
id
+
' '
+
v
.
name
);
};
})
});
```
```
Here you see how to get basic information using a function like
`getAllAccounts`
:
## Errors
If Zimbra returns an Error, the library returns an
`Error`
Object with the Zimbra Error
information. For example, if you look for a non existing
`Domain`
:
```
javascript
```
javascript
zimbraApi
.
getAllAccounts
(
function
(
err
,
data
){
api
.
getDomain
(
'example.com'
,
callback
);
if
(
err
)
return
console
.
log
(
err
);
data
.
forEach
(
function
(
v
){
// Error: {status: 500, title: "Internal Server Error", extra: Object}
console
.
log
(
v
.
id
+
' '
+
v
.
name
);
// Error.extra: {
})
// code: "account.NO_SUCH_DOMAIN",
});
// reason: "no such domain: example.com"
// }
```
## Zimbra Resources
Zimbra Resources are the things you can manage, like:
*
`Accounts`
, the email users,
*
`Domains`
,
*
`Distribution Lists`
,
*
`CoS`
, Class of services
*
`Servers`
, Zimbra servers
## Common Functions
This are similar functions that you can call for all the
`Resources`
, so we grouped here
for brevity:
### Get a Resource
You can use the resource
`name`
or
`zimbraId`
:
```
javascript
zimbraApi
.
getAccount
(
'account@domain.com'
,
callback
);
// Account {name: "admin@domain.com", id: "eda93f93-ba26-4344-8ae0-1d03964b612a", attrs: Object}
zimbraApi
.
getAccount
(
'eda93f93-ba26-4344-8ae0-1d03964b612a'
,
callback
);
// Account {name: "admin@domain.com", id: "eda93f93-ba26-4344-8ae0-1d03964b612a", attrs: Object}
zimbraApi
.
getDomain
(
'domain.com'
,
callback
);
// Domain {name: "domain.com", id: "cc0fd82b-7833-4de2-8954-88eb97fb81e9", attrs: Object}
zimbraApi
.
getDistributionList
(
'list@domain.com'
,
callback
);
// DistributionList {name: "list@domain.com", id: "747972ab-a410-4f17-8d5e-db7be21d75e9", attrs: Object, members: Array[4]}
```
```
## TODOS:
A successful response will always return a
`Object`
named after the
`Resource`
your are requesting.
### Get All and Search
You have the following functions:
*
`getAllAccounts(callback, query_object)`
,
*
`getAllDomains(callback, query_object)`
,
*
`getAllDistributionLists(callback, query_object)`
,
`query_object`
is an
**optional**
`Object`
that accept the following attributes:
*
`query`
: An LDAP query or null for everything,
*
`maxResults`
: Maximum results that the backend will attempt to fetch from the directory before
returning an
`account.TOO_MANY_SEARCH_RESULTS`
error.,
*
`limit`
: the maximum number of accounts to return ,
*
`offset`
: The starting offset (0, 25, etc),
*
`domain`
: The domain name to limit the search to,
*
`sortBy`
: Name of attribute to sort on. Default is the account name.,
*
`sortAscending`
: Whether to sort in ascending order. Default is 1 (true)
*
`countOnly`
: Whether response should be count only. Default is 0 (false),
*
`attrs`
: Comma separated list of attributes to ask for
#### Examples
##### 1. Get All Accounts without a query_object
```
javascript
zimbraApi
.
getAllAccounts
(
callback
);
// Object {total: 261, more: false, account: Array[261]}
```
The
**Result Object**
has the following information:
*
`total`
: The total quantity of resources that you _request_ can return,
*
`account`
, An array with all the
`Accounts`
objects,
*
`more`
:
`true`
if there are more results that.
##### 2. Get All Accounts with limit and offset
This is useful if you are doing pagination.
```
javascript
var
query_object
=
{
limit
:
10
,
offset
:
2
}
zimbraApi
.
getAllAccounts
(
callback
);
// Object {total: 261, more: true, account: Array[10]}
```
##### 3. Get All DistributionList for the `example.com` Domain
```
javascript
var
query_object
=
{
domain
:
'example.com'
}
zimbraApi
.
getAllDistributionLists
(
callback
,
query_object
);
// Object {total: 6, more: false, dl: Array[6]}
```
##### 4. Get All Accounts with an email containing 'basic'
```
javascript
var
query_object
=
{
query
:
'mail=*basic*'
}
zimbraApi
.
getAllAccounts
(
callback
,
query_object
);
// Object {total: 29, more: false, account: Array[29]}
```
## Creating Resources
The methods are:
*
`createAccount('email_address', password, zimbra_attributes, callback)`
,
*
`createDomain('domain_name', zimbra_attributes, callback)`
,
*
`createDistributionList('email_address', zimbra_attributes, callback)`
`zimbra_attributes`
must be an
`Object`
, that can be empty, that should have valid Zimbra attributes
for the
`Resource`
being created. For example, lets create an
`Account`
with:
*
First Name (
`givenName`
),
*
Last Name (
`sn`
), and
*
A Mail Quota of
`50GB`
(
`zimbraMailQuota`
)
```
javascript
var
zimbra_attributes
=
{
givenName
:
'John'
,
sn
:
'Smith'
,
zimbraMailQuota
:
53687091200
}
zimbraApi
.
createAccount
(
'user@example.com'
,
'SuP3rS3cur3P4ss'
,
zimbra_attributes
,
callback
);
// Account {name: "user@customer.dev", id: "1919c856-08cc-43c9-b927-0c4cf88f50c7", attrs: Object}
```
Muchas, pero ya viene
.
All the functions returns the created resource
`Object`
.
lib/zimbra-admin-api.js
View file @
6c1d1f7d
...
@@ -302,8 +302,10 @@ return /******/ (function(modules) { // webpackBootstrap
...
@@ -302,8 +302,10 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
// attributes debe ser un arreglo de objetos:
// attributes debe ser un arreglo de objetos:
// resource_data.a = attributes
// let resource_attributes = {
// attributes = [ { n: 'NOMBRE_DEL_CAMPO_ZIMBRA', '_content': 'VALOR_DEL_CAMPO' } ]
// zimbraSkinLogoURL: 'http://www.zboxapp.com',
// postOfficeBox: 'ZBoxApp'
// };
}, {
}, {
key: 'createAccount',
key: 'createAccount',
lib/zimbra-admin-api.js.map
View file @
6c1d1f7d
This diff is collapsed.
Click to expand it.
src/index.js
View file @
6c1d1f7d
...
@@ -203,8 +203,10 @@ export default class ZimbraAdminApi {
...
@@ -203,8 +203,10 @@ export default class ZimbraAdminApi {
}
}
// attributes debe ser un arreglo de objetos:
// attributes debe ser un arreglo de objetos:
// resource_data.a = attributes
// let resource_attributes = {
// attributes = [ { n: 'NOMBRE_DEL_CAMPO_ZIMBRA', '_content': 'VALOR_DEL_CAMPO' } ]
// zimbraSkinLogoURL: 'http://www.zboxapp.com',
// postOfficeBox: 'ZBoxApp'
// };
createAccount
(
name
,
password
,
attributes
,
callback
)
{
createAccount
(
name
,
password
,
attributes
,
callback
)
{
let
resource_data
=
{
let
resource_data
=
{
name
:
{
'_content'
:
name
},
name
:
{
'_content'
:
name
},
...
...
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