Commit 81d9ec42 authored by Patricio Bruna's avatar Patricio Bruna

Added MoveBlobs

parent 0970999c
...@@ -7,6 +7,8 @@ node_modules ...@@ -7,6 +7,8 @@ node_modules
ncp-debug.log ncp-debug.log
npm-debug.log npm-debug.log
.vagrant .vagrant
tmp/
env.sh
### OSX template ### OSX template
.DS_Store .DS_Store
......
...@@ -8,6 +8,7 @@ Makefile ...@@ -8,6 +8,7 @@ Makefile
server.js server.js
lib/* lib/*
TODOS.md TODOS.md
tmp/
.* .*
### JetBrains template ### JetBrains template
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
- [Errors](#errors) - [Errors](#errors)
- [Zimbra Resources](#zimbra-resources) - [Zimbra Resources](#zimbra-resources)
- [Common Functions](#common-functions) - [Common Functions](#common-functions)
- [Server Operations](#server-operations)
- [Batch Request Functions](#batch-request-functions) - [Batch Request Functions](#batch-request-functions)
- [Creating Resources](#creating-resources) - [Creating Resources](#creating-resources)
- [Modify Resources](#modify-resources) - [Modify Resources](#modify-resources)
...@@ -189,6 +190,37 @@ client.getAllAccounts(query_object, callback); ...@@ -189,6 +190,37 @@ client.getAllAccounts(query_object, callback);
// Object {total: 29, more: false, account: Array[29]} // Object {total: 29, more: false, account: Array[29]}
``` ```
## Server Operations
### Move Blobs
Moves blobs between volumes. Unlike `HsmRequest`, this request is synchronous, and reads parameters from the request attributes instead of `zimbraHsmPolicy`.
Takes the following parameters:
* `server`, IP or hostname of the mailbox server,
* `request_object`, Object with attributes to make the request.
The `request_object` has the following attributes:
* `types`: Comma separated list of search types. Legal values are: `conversation|message|contact|appointment|task|wiki|document`,
* `sourceVolumeIds`: A comma separated list of source volume IDs
* `destVolumeId`: Destination volume ID
* `maxBytes`: Limit for the total number of bytes of data to move. Blob move will abort if this threshold is exceeded.
* `query`: An _optional_ query to move only Blobs that match this query. For query syntax check [this documentation](https://wiki.zimbra.com/wiki/Zimbra_Web_Client_Search_Tips).
```javascript
const request_object = {
types: 'all', sourceVolumeIds: '1',
destVolumeId: '3', maxBytes: 100000
};
api.moveBlobs("192.168.0.272", request_object, callback);
// {
// numBlobsMoved: 0,
// numBytesMoved: 0,
// totalMailboxes: 376
// }
```
## Batch Request Functions ## Batch Request Functions
With `BatchRequest` you can ask Zimbra to run multiple requests in just one call, and get With `BatchRequest` you can ask Zimbra to run multiple requests in just one call, and get
the result in just one answer. the result in just one answer.
...@@ -572,7 +604,7 @@ dl.getOwners(callback); ...@@ -572,7 +604,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 +630,4 @@ We are using [Mocha](https://mochajs.org) and [Chai](http://chaijs.com) for test ...@@ -598,4 +630,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
...@@ -690,6 +690,24 @@ class ZimbraAdminApi { ...@@ -690,6 +690,24 @@ class ZimbraAdminApi {
return this.performRequest(request_data); return this.performRequest(request_data);
} }
// Movel Blobs
// https://files.zimbra.com/docs/soap_api/8.7.0/api-reference/zimbraAdmin/MoveBlobs.html
// request is an object
// query: https://wiki.zimbra.com/wiki/Zimbra_Web_Client_Search_Tips
moveBlobs(server, request, callback) {
if (!server) return false;
this.client.options.url = "https://" + server + ":7071/service/admin/soap";
const request_data = this.buildRequestData(`MoveBlobs`, callback);
const query = request.query;
delete(request.query)
request_data.params.params = request;
if (query) {
request_data.params.params.query = {"_content": query};
}
request_data.parse_response = ResponseParser.moveBlobsResponse;
return this.performRequest(request_data);
}
// Set account Password // Set account Password
setPassword(zimbra_id, password, callback) { setPassword(zimbra_id, password, callback) {
const request_data = this.buildRequestData(`SetPassword`, callback); const request_data = this.buildRequestData(`SetPassword`, callback);
......
...@@ -85,6 +85,10 @@ class ResponseParser { ...@@ -85,6 +85,10 @@ class ResponseParser {
return callback(null, result); return callback(null, result);
} }
static debugResponse(data, request_data, callback) {
return callback(null, data.get());
}
// For requests that returns empty Object when Success // For requests that returns empty Object when Success
static emptyResponse(data, request_data, callback){ static emptyResponse(data, request_data, callback){
const response_object = data.get()[request_data.response_name]; const response_object = data.get()[request_data.response_name];
...@@ -115,6 +119,11 @@ class ResponseParser { ...@@ -115,6 +119,11 @@ class ResponseParser {
return callback(null, response_object); return callback(null, response_object);
} }
static moveBlobsResponse(data, request_data, callback) {
const response_object = data.get().MoveBlobsResponse;
return callback(null, response_object);
}
static searchResponse(data, request_data, callback) { static searchResponse(data, request_data, callback) {
const resource_types = ResponseParser.dictionary().searchResponseTypes(); const resource_types = ResponseParser.dictionary().searchResponseTypes();
const response_object = data.get()[request_data.response_name]; const response_object = data.get()[request_data.response_name];
......
...@@ -1044,4 +1044,35 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678'; ...@@ -1044,4 +1044,35 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
}); });
}); });
describe('Misc tests', function() {
this.timeout(5000);
it('MoveBlobs:it should move the Blobs', function(done) {
if (!process.env.TEST_ZIMBRA_NE) {
done();
return true;
}
var auth = {
'url': process.env.ZIMBRA_NE_URL,
'user': process.env.ZIMBRA_NE_USER,
'password': process.env.ZIMBRA_NE_PASSWORD
};
let api = new ZimbraAdminApi(auth);
const maxBytes = 1000000;
const request_object = {
types: 'all',
sourceVolumeIds: '1',
destVolumeId: '3',
maxBytes: maxBytes
};
api.moveBlobs("192.168.0.152", request_object, function(err, data){
if (err) console.log(err);
expect(data.numBlobsMoved).to.be.above(-1);
expect(data.numBytesMoved).to.be.below(maxBytes);
expect(data.totalMailboxes).to.be.above(1);
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