all files / src/network/remote/ volumes.js

30% Statements 6/20
0% Branches 0/12
11.11% Functions 1/9
30% Lines 6/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90                                                                                                                                                                       
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
exports.default = function (_ref) {
  var client = _ref.client,
      filterQuery = _ref.filterQuery,
      mustContain = _ref.mustContain,
      encodeQueryAsString = _ref.encodeQueryAsString,
      busy = _ref.busy;
 
  return {
    // get /volumes
    //     List available volumes.
    listVolumes: function listVolumes() {
      var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
 
      if (limit) {
        return busy(client._.get('/volumes?limit=' + limit));
      }
      return busy(client._.get('/volumes'));
    },
 
 
    // post /volumes
    //     Create a volume
    createVolume: function createVolume(volume) {
      return busy(client._.post('/volumes', volume, {
        transformRequest: _utils.transformRequest,
        headers: headers
      }));
    },
 
 
    // get /volumes/{id}
    //     Get a volume
    getVolume: function getVolume(id) {
      return busy(client._.get('/volumes/' + id));
    },
 
 
    // delete /volumes/{id}
    //     Delete a volume
    deleteVolume: function deleteVolume(id) {
      return busy(client._.delete('/volumes/' + id));
    },
 
 
    // get /volumes/{id}/log
    //     Get log entries for volume
    getVolumeLog: function getVolumeLog(volumeId) {
      var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
 
      if (offset) {
        return busy(client._.get('/volumes/' + volumeId + '/log?offset=' + offset));
      }
      return busy(client._.get('/volumes/' + volumeId + '/log'));
    },
 
 
    // get /volumes/{id}/status
    //     Get the volume's current state
    getVolumeStatus: function getVolumeStatus(id) {
      return busy(client._.get('/volumes/' + id + '/status'));
    },
 
 
    // put /volumes/{id}/attach/{cluster}
    //     Attach a volume to a cluster
    attachVolume: function attachVolume(id, cluster) {
      return busy(client._.put('/volumes/' + id + '/attach/' + cluster));
    },
 
 
    // put /volumes/{id}/attach/{cluster}
    //     Detach a volume to a cluster
    detachVolume: function detachVolume(id) {
      return busy(client._.put('/volumes/' + id + '/detach'));
    }
  };
};
 
var _utils = require('./utils');
 
var headers = {
  'Content-Type': 'application/json'
};