Commit 355ff495 authored by Patricio Bruna's avatar Patricio Bruna

Added getAllVolumes()

parent 81d9ec42
......@@ -192,12 +192,46 @@ client.getAllAccounts(query_object, callback);
## Server Operations
### Get All Volumes
Get All Volumes from the server. [This link](https://files.zimbra.com/docs/soap_api/8.7.0/api-reference/zimbraAdmin/GetAllVolumes.html) has full documentation
The `server` param is the `hostname` or `ip address` of the Mailbox Server. You need direct access to the `7071` port on this server.
```javascript
api.getAllVolumes("localhost", callback);
// { message1:
// { id: 1,
// name: 'message1',
// type: 1,
// compressBlobs: false,
// compressionThreshold: 4096,
// mgbits: 8,
// mbits: 12,
// fgbits: 8,
// fbits: 12,
// rootpath: '/opt/zimbra/store',
// isCurrent: true },
// index1:
// { id: 2,
// name: 'index1',
// type: 10,
// compressBlobs: false,
// compressionThreshold: 4096,
// mgbits: 8,
// mbits: 12,
// fgbits: 8,
// fbits: 12,
// rootpath: '/opt/zimbra/index',
// isCurrent: true },
// }
```
### 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,
* `server`, IP or hostname of the mailbox server. You need direct access to the `7071` port on this server,
* `request_object`, Object with attributes to make the request.
The `request_object` has the following attributes:
......
......@@ -690,6 +690,15 @@ class ZimbraAdminApi {
return this.performRequest(request_data);
}
// GetAllVolumes
// Get all volumes
getAllVolumes(server, callback) {
this.client.options.url = "https://" + server + ":7071/service/admin/soap";
const request_data = this.buildRequestData(`GetAllVolumes`, callback);
request_data.parse_response = ResponseParser.getAllVolumesResponse;
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
......
......@@ -95,6 +95,16 @@ class ResponseParser {
return callback(null, response_object);
}
static getAllVolumesResponse(data, request_data, callback) {
const response_object = data.get()[request_data.response_name];
if (!response_object.volume) return callback(null, {});
const result = {};
response_object.volume.forEach((volume) => {
result[volume.name] = volume;
});
callback(null, result);
}
static getMailboxResponse (data, _, callback) {
const response_object = data.get().GetMailboxResponse.mbox[0];
const result = {
......
......@@ -1073,6 +1073,16 @@ var zimbraAdminPassword = process.env.ZIMBRA_PASSWORD || '12345678';
done();
});
});
it('GetAllVolumes: it should return the Volumes info', function(done) {
let api = new ZimbraAdminApi(auth_data);
api.getAllVolumes("localhost", function(err, data){
if (err) console.log(err);
expect(data["message1"]).to.exist;
expect(data["index1"].isCurrent).to.be.true;
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