Commit 4a9c3837 authored by David Gatica's avatar David Gatica

function copyCos, added

parent 50f8a198
...@@ -447,6 +447,18 @@ var attributes = {'zimbraDumpsterEnabled' : 'TRUE'}; ...@@ -447,6 +447,18 @@ var attributes = {'zimbraDumpsterEnabled' : 'TRUE'};
client.modifyCos("cos_Id", attributes, callback); 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 ## Domains
This are functions especifics to `Domains`. This are functions especifics to `Domains`.
......
...@@ -606,6 +606,13 @@ class ZimbraAdminApi { ...@@ -606,6 +606,13 @@ class ZimbraAdminApi {
return this.performRequest(request_data); 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) { removeDomainAdmin(domain, account_id, coses, callback) {
this.getDomain(domain, (err, domain) => { this.getDomain(domain, (err, domain) => {
...@@ -646,6 +653,11 @@ class ZimbraAdminApi { ...@@ -646,6 +653,11 @@ class ZimbraAdminApi {
return this.rename('DistributionList', resource_data, callback); 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) { revokeRight(target_data, grantee_data, right_name, callback) {
const target_grantee = this.dictionary.buildTargetGrantee(target_data, grantee_data); const target_grantee = this.dictionary.buildTargetGrantee(target_data, grantee_data);
const target = target_grantee[0]; const target = target_grantee[0];
......
...@@ -841,20 +841,20 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678'; ...@@ -841,20 +841,20 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
}); });
}) })
// it('Should delete COS "unknow" ', function(done){ it('Should delete COS "unknow" ', function(done){
// let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
// api.getCos("unknow", function(err, cos){ api.getCos("unknow", function(err, cos){
// if (err) return console.error(err); if (err) return console.error(err);
// let cosId = cos.id; let cosId = cos.id;
// console.log(cosId); console.log(cosId);
// api.deleteCos(cosId, 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();
// }) })
// }); });
// }) })
it('Should modify a Cos "basic"', function(done){ it('Should modify a Cos "basic"', function(done){
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
...@@ -870,6 +870,30 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678'; ...@@ -870,6 +870,30 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
}); });
}); });
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 = "Pro2";
api.copyCos("professional", newCos, function(err, res){
if(err) return console.error(err);
console.log(res);
expect(err).to.be.null;
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