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

58.82% Statements 10/17
14.29% Branches 2/14
33.33% Functions 3/9
58.82% Lines 10/17
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                                                                                               
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
exports.default = function (_ref) {
  var client = _ref.client,
      filterQuery = _ref.filterQuery,
      mustContain = _ref.mustContain,
      busy = _ref.busy;
 
  return {
    listAWSProfiles: function listAWSProfiles() {
      return getUnauthenticatedPromise(client) || busy(client._.get('/user/' + client.user._id + '/aws/profiles'));
    },
    createAWSProfile: function createAWSProfile(awsProfile) {
      return getUnauthenticatedPromise(client) || busy(client._.post('/user/' + client.user._id + '/aws/profiles', awsProfile, {
        headers: headers,
        transformRequest: _utils.transformRequest
      }));
    },
    updateAWSProfile: function updateAWSProfile(awsProfile) {
      return getUnauthenticatedPromise(client) || busy(client._.patch('/user/' + client.user._id + '/aws/profiles/' + awsProfile._id, awsProfile, { headers: headers, transformRequest: _utils.transformRequest }));
    },
    listAWSRunningInstances: function listAWSRunningInstances(id) {
      return getUnauthenticatedPromise(client) || busy(client._.get('/user/' + client.user._id + '/aws/profiles/' + id + '/runninginstances'));
    },
    getAWSMaxInstances: function getAWSMaxInstances(id) {
      return getUnauthenticatedPromise(client) || busy(client._.get('/user/' + client.user._id + '/aws/profiles/' + id + '/maxinstances'));
    },
    getEC2InstanceTypes: function getEC2InstanceTypes() {
      return (0, _utils.getJSON)('/ec2_instance_types.json');
    },
    deleteAWSProfile: function deleteAWSProfile(id) {
      return getUnauthenticatedPromise(client) || busy(client._.delete('/user/' + client.user._id + '/aws/profiles/' + id));
    }
  };
};
 
var _utils = require('./utils');
 
var headers = {
  'Content-Type': 'application/json'
};
 
function getUnauthenticatedPromise(client) {
  Iif (client.user) {
    return null;
  }
 
  return Promise.reject({
    data: {
      message: 'Must be logged in.'
    }
  });
}