Commit 50f8a198 authored by David Gatica's avatar David Gatica

function modifyCos, added

parent fa5f6ee6
...@@ -419,6 +419,35 @@ This are functions especifics to `Cos`. ...@@ -419,6 +419,35 @@ This are functions especifics to `Cos`.
client.getAllCos(callback); 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);
```
## Domains ## Domains
This are functions especifics to `Domains`. This are functions especifics to `Domains`.
...@@ -564,6 +593,18 @@ dl.getOwners(callback); ...@@ -564,6 +593,18 @@ dl.getOwners(callback);
// {name: 'email_address', id: 'ZimbraId', type: 'usr|grp'} // {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 ## Contributing
...@@ -572,7 +613,7 @@ dl.getOwners(callback); ...@@ -572,7 +613,7 @@ dl.getOwners(callback);
3. **Commit** changes to your own branch 3. **Commit** changes to your own branch
4. **Push** your work back up to your fork 4. **Push** your work back up to your fork
5. Submit a **Pull request** so that we can review your changes 5. Submit a **Pull request** so that we can review your changes
NOTE: Be sure to merge the latest from "upstream" before making a pull request! NOTE: Be sure to merge the latest from "upstream" before making a pull request!
### Developer Machine ### Developer Machine
...@@ -598,4 +639,4 @@ We are using [Mocha](https://mochajs.org) and [Chai](http://chaijs.com) for test ...@@ -598,4 +639,4 @@ We are using [Mocha](https://mochajs.org) and [Chai](http://chaijs.com) for test
$ npm run test $ npm run test
``` ```
Also we have Travis-CI that run the test for every Pull Request. Also we have Travis-CI that run the test for every Pull Request.
\ No newline at end of file
...@@ -572,6 +572,13 @@ class ZimbraAdminApi { ...@@ -572,6 +572,13 @@ class ZimbraAdminApi {
this.modify('DistributionList', resource_data, callback); 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 // Remove Account
removeAccount(zimbra_id, callback) { removeAccount(zimbra_id, callback) {
let resource_data = { id: zimbra_id }; let resource_data = { id: zimbra_id };
...@@ -599,6 +606,7 @@ class ZimbraAdminApi { ...@@ -599,6 +606,7 @@ class ZimbraAdminApi {
return this.performRequest(request_data); return this.performRequest(request_data);
} }
removeDomainAdmin(domain, account_id, coses, callback) { removeDomainAdmin(domain, account_id, coses, callback) {
this.getDomain(domain, (err, domain) => { this.getDomain(domain, (err, domain) => {
if (err) return callback(err); if (err) return callback(err);
......
...@@ -841,20 +841,34 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678'; ...@@ -841,20 +841,34 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
}); });
}) })
it.only('Should delete COS "unknow" ', function(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 api = new ZimbraAdminApi(auth_data);
api.getCos("unknow", function(err, cos){ let attrs = {'zimbraDumpsterEnabled' : 'TRUE'};
if (err) return console.error(err); api.getCos("basic", function(err, cos){
let cosId = cos.id; if(err) return console.error(err);
console.log(cosId); api.modifyCos(cos.id, attrs, function(err, res){
api.deleteCos(cosId, function(err, res){ if(err) return console.error(err);
if (err) return console.error(err);
console.log(res); console.log(res);
expect(err).to.be.null; expect(err).to.be.null;
done(); done();
}) });
}); });
}) });
}); });
...@@ -916,6 +930,7 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678'; ...@@ -916,6 +930,7 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
let dl = data; let dl = data;
api.addDistributionListAlias(dl.id, alias, function(err, data){ api.addDistributionListAlias(dl.id, alias, function(err, data){
if (err) return console.error(err); if (err) return console.error(err);
console.log(data);
expect(err).to.be.null; expect(err).to.be.null;
done(); done();
}); });
...@@ -931,6 +946,7 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678'; ...@@ -931,6 +946,7 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
if (err) return console.error(err); if (err) return console.error(err);
api.removeDistributionListAlias(dl.id, alias, function(err, data){ api.removeDistributionListAlias(dl.id, alias, function(err, data){
if (err) return console.error(err); if (err) return console.error(err);
console.log(data);
expect(err).to.be.null; expect(err).to.be.null;
done(); done();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment