All files / src/api/storage index.js

100% Statements 17/17
100% Branches 0/0
100% Functions 2/2
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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    1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                                                                       2x     1x     2x                              
// @flow
 
import callStorage, { type StorageConf } from '../../service/storage';
import logger from '../../logger';
import accounts, { type StorageAccountsAPI } from './accounts';
import clusters, { type StorageClustersAPI } from './clusters';
import hosts, { type StorageHostsAPI } from './hosts';
import ipRanges, { type StorageIpRangesAPI } from './ip-ranges';
import networkSwitches, { type NetworkSwitchesAPI } from './network-switches';
import nodes, { type StorageNodesAPI } from './nodes';
import regions, { type StorageRegionsAPI } from './regions';
import serviceAccounts, { type ServiceAccountsAPI } from './service-accounts';
import stamps, { type StorageStampsAPI } from './stamps';
import storageVMs, { type StorageVMsAPI } from './storage-vms';
import volumes, { type StorageVolumesAPI } from './volumes';
import zones, { type StorageZonesAPI } from './zones';
 
export type Caller = (
  method: string,
  command: string,
  data?: any,
) => Promise<any>;
 
export type { StorageConf };
 
/**
 * The NFS storage API. Also known as NFS infrastructure.
 */
export interface Storage {
  accounts: StorageAccountsAPI;
  clusters: StorageClustersAPI;
  hosts: StorageHostsAPI;
  ipRanges: StorageIpRangesAPI;
  networkSwitches: NetworkSwitchesAPI;
  nodes: StorageNodesAPI;
  regions: StorageRegionsAPI;
  serviceAccounts: ServiceAccountsAPI;
  stamps: StorageStampsAPI;
  storageVMs: StorageVMsAPI;
  volumes: StorageVolumesAPI;
  zones: StorageZonesAPI;
}
 
/**
 * Manage NFS storage resources. Also know as NFS infrastructure.
 *
 * @example
 *
 * import storage from 'qstack-client/api/storage';
 *
 * const conf = {
 *   apiKey: 'api-key',
 *   secretKey: 'secret-key',
 *   url: 'http://storage.example.com',
 * };
 *
 * storage(conf).hosts.list();
 */
export default function storage(conf: StorageConf): Storage {
  logger.silly(`Storage conf=${JSON.stringify(conf)}`);
 
  function call(method, command, data) {
    return callStorage(conf, method, command, data);
  }
 
  return {
    accounts: accounts(call),
    clusters: clusters(call),
    hosts: hosts(call),
    ipRanges: ipRanges(call),
    networkSwitches: networkSwitches(call),
    nodes: nodes(call),
    regions: regions(call),
    serviceAccounts: serviceAccounts(call),
    stamps: stamps(call),
    storageVMs: storageVMs(call),
    volumes: volumes(call),
    zones: zones(call),
  };
}