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
983b7758
Commit
983b7758
authored
Apr 19, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing Resources
parent
2f1dea10
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
169 additions
and
4 deletions
+169
-4
README.md
README.md
+20
-0
TODOS.md
TODOS.md
+1
-1
zimbra-admin-api.js
lib/zimbra-admin-api.js
+57
-0
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
index.js
src/index.js
+47
-0
test.js
test/js/spec/test.js
+43
-2
No files found.
README.md
View file @
983b7758
...
...
@@ -9,6 +9,7 @@
-
[
Common Functions
](
#common-functions
)
-
[
Creating Resources
](
#creating-resources
)
-
[
Modify Resources
](
#modify-resources
)
-
[
Remove Resources
](
#remove-resources
)
## Example
...
...
@@ -237,3 +238,22 @@ zimbraApi.modifyAccount(zimbraId, zimbra_attributes, callback);
// attrs.sn = 'Hanks'
// attrs.givenName = 'Tom'
```
## Remove Resources
For deleting resources
**you have**
to use the
`ZimbraId`
*
`removeAccount(zimbra_id, callback)`
,
*
`removeDomain(zimbra_id, callback)`
,
*
`removeDistributionList(zimbra_id, callback)`
For example:
```
javascript
// user@example.com
var
zimbraId
=
"1919c856-08cc-43c9-b927-0c4cf88f50c7"
;
zimbraApi
.
removeAccount
(
zimbraId
,
callback
);
```
*
If everything goes OK you receive
**nothing**
as result.
*
You
**can't delete**
a
`Domain`
that is not empty, that has
`Accounts`
or
`DistributionList`
. You
have to empty it first.
TODOS.md
View file @
983b7758
## Todos los Resourcers
*
[
X
]
Poder Modificar
*
[
]
Poder Elmininar
*
[
X
]
Poder Elmininar
## Accounts
...
...
lib/zimbra-admin-api.js
View file @
983b7758
...
...
@@ -125,6 +125,7 @@ return /******/ (function(modules) { // webpackBootstrap
this._client = new jszimbra.Communication({ url: auth_object.url });
this.parseAllResponse = this.parseAllResponse.bind(this);
this.parseResponse = this.parseResponse.bind(this);
this.parseRemoveResponse = this.parseRemoveResponse.bind(this);
this.parseSearchResponse = this.parseSearchResponse.bind(this);
this.dictionary = new _dictionary2.default();
}
...
...
@@ -217,6 +218,12 @@ return /******/ (function(modules) { // webpackBootstrap
var result = that.dictionary.classFactory(resource, response_object);
return callback(null, result);
}
}, {
key: 'parseRemoveResponse',
value: function parseRemoveResponse(data, request_data, callback) {
var response_object = data.get()[request_data.response_name];
return callback(null, response_object);
}
}, {
key: 'parseSearchResponse',
value: function parseSearchResponse(data, request_data, callback) {
...
...
@@ -264,6 +271,20 @@ return /******/ (function(modules) { // webpackBootstrap
request_data.params.params = resource_data;
this.performRequest(request_data);
}
}, {
key: 'remove',
value: function remove(resource, resource_data, callback) {
var request_data = {};
request_data.params = this.requestParams();
request_data.request_name = 'Delete' + resource;
request_data.response_name = 'Delete' + resource + 'Response';
request_data.params.name = request_data.request_name + 'Request';
request_data.resource = resource;
request_data.callback = callback;
request_data.parse_response = this.parseRemoveResponse;
request_data.params.params = resource_data;
this.performRequest(request_data);
}
}, {
key: 'modify',
value: function modify(resource, resource_data, callback) {
...
...
@@ -350,6 +371,15 @@ return /******/ (function(modules) { // webpackBootstrap
value: function getDistributionList(identifier, callback) {
this.get('DistributionList', identifier, callback);
}
}, {
key: 'createDistributionList',
value: function createDistributionList(name, attributes, callback) {
var resource_data = {
name: { '_content': name },
a: this.dictionary.attributesToArray(attributes)
};
this.create('DistributionList', resource_data, callback);
}
}, {
key: 'getAllDomains',
value: function getAllDomains(callback) {
...
...
@@ -436,6 +466,33 @@ return /******/ (function(modules) { // webpackBootstrap
this.modify('DistributionList', resource_data, callback);
}
// Remove Account
}, {
key: 'removeAccount',
value: function removeAccount(zimbra_id, callback) {
var resource_data = { id: zimbra_id };
this.remove('Account', resource_data, callback);
}
// Remove Account
}, {
key: 'removeDomain',
value: function removeDomain(zimbra_id, callback) {
var resource_data = { id: zimbra_id };
this.remove('Domain', resource_data, callback);
}
// Remove DL
}, {
key: 'removeDistributionList',
value: function removeDistributionList(zimbra_id, callback) {
var resource_data = { id: zimbra_id };
this.remove('DistributionList', resource_data, callback);
}
// Search the Directory
// search_object = {
// query: An LDAP query or null for everything,
lib/zimbra-admin-api.js.map
View file @
983b7758
This diff is collapsed.
Click to expand it.
src/index.js
View file @
983b7758
...
...
@@ -32,6 +32,7 @@ export default class ZimbraAdminApi {
this
.
_client
=
new
jszimbra
.
Communication
({
url
:
auth_object
.
url
});
this
.
parseAllResponse
=
this
.
parseAllResponse
.
bind
(
this
);
this
.
parseResponse
=
this
.
parseResponse
.
bind
(
this
);
this
.
parseRemoveResponse
=
this
.
parseRemoveResponse
.
bind
(
this
);
this
.
parseSearchResponse
=
this
.
parseSearchResponse
.
bind
(
this
);
this
.
dictionary
=
new
Dictionary
();
}
...
...
@@ -125,6 +126,11 @@ export default class ZimbraAdminApi {
return
callback
(
null
,
result
);
}
parseRemoveResponse
(
data
,
request_data
,
callback
){
const
response_object
=
data
.
get
()[
request_data
.
response_name
];
return
callback
(
null
,
response_object
);
}
parseSearchResponse
(
data
,
request_data
,
callback
)
{
const
response_types
=
this
.
dictionary
.
searchResponseTypes
();
const
response_object
=
data
.
get
()[
request_data
.
response_name
];
...
...
@@ -169,6 +175,20 @@ export default class ZimbraAdminApi {
this
.
performRequest
(
request_data
);
}
remove
(
resource
,
resource_data
,
callback
){
let
request_data
=
{
};
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
`Delete
${
resource
}
`
;
request_data
.
response_name
=
`Delete
${
resource
}
Response`
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
resource
=
resource
;
request_data
.
callback
=
callback
;
request_data
.
parse_response
=
this
.
parseRemoveResponse
;
request_data
.
params
.
params
=
resource_data
;
this
.
performRequest
(
request_data
);
}
modify
(
resource
,
resource_data
,
callback
){
let
request_data
=
{
};
request_data
.
params
=
this
.
requestParams
();
...
...
@@ -245,6 +265,15 @@ export default class ZimbraAdminApi {
this
.
get
(
'DistributionList'
,
identifier
,
callback
);
}
createDistributionList
(
name
,
attributes
,
callback
)
{
let
resource_data
=
{
name
:
{
'_content'
:
name
},
a
:
this
.
dictionary
.
attributesToArray
(
attributes
)
};
this
.
create
(
'DistributionList'
,
resource_data
,
callback
);
}
getAllDomains
(
callback
,
query_object
=
{})
{
query_object
.
types
=
'domains'
;
this
.
directorySearch
(
query_object
,
callback
);
...
...
@@ -306,6 +335,24 @@ export default class ZimbraAdminApi {
this
.
modify
(
'DistributionList'
,
resource_data
,
callback
);
}
// Remove Account
removeAccount
(
zimbra_id
,
callback
)
{
let
resource_data
=
{
id
:
zimbra_id
};
this
.
remove
(
'Account'
,
resource_data
,
callback
);
}
// Remove Account
removeDomain
(
zimbra_id
,
callback
)
{
let
resource_data
=
{
id
:
zimbra_id
};
this
.
remove
(
'Domain'
,
resource_data
,
callback
);
}
// Remove DL
removeDistributionList
(
zimbra_id
,
callback
)
{
let
resource_data
=
{
id
:
zimbra_id
};
this
.
remove
(
'DistributionList'
,
resource_data
,
callback
);
}
// Search the Directory
// search_object = {
// query: An LDAP query or null for everything,
...
...
test/js/spec/test.js
View file @
983b7758
...
...
@@ -280,7 +280,48 @@
});
});
it
(
'should remove account'
,
function
(
done
){
let
account_name
=
Date
.
now
()
+
'@big.com'
;
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
);
api
.
removeAccount
(
data
.
id
,
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
expect
(
data
.
_jsns
).
to
.
equal
(
"urn:zimbraAdmin"
);
done
();
});
});
});
it
(
'should remove 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
);
api
.
removeDomain
(
data
.
id
,
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
expect
(
data
.
_jsns
).
to
.
equal
(
"urn:zimbraAdmin"
);
done
();
});
});
});
it
(
'should remove DL'
,
function
(
done
){
let
resource_name
=
Date
.
now
()
+
'@zboxapp.dev'
;
let
resource_attributes
=
{};
let
api
=
new
ZimbraAdminApi
(
auth_data
);
api
.
createDistributionList
(
resource_name
,
resource_attributes
,
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
api
.
removeDistributionList
(
data
.
id
,
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
expect
(
data
.
_jsns
).
to
.
equal
(
"urn:zimbraAdmin"
);
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