All files / src/api/cloud-sync index.js

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

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    1x 1x 1x 1x 1x 1x                                                                         2x     1x     2x              
// @flow
 
import callCloudSync, { type CloudSyncConf } from '../../service/cloud-sync';
import logger from '../../logger';
import dataBrokers, { type DataBrokersAPI } from './data-brokers';
import messages, { type MessagesAPI } from './messages';
import nfs, { type NfsAPI } from './nfs';
import relationships, { type RelationshipsAPI } from './relationships';
 
export type Caller = (
  method: string,
  command: string,
  data?: { [string]: boolean | number | string },
  params?: { [string]: string },
) => Promise<any>;
 
export type { CloudSyncConf };
 
/**
 * The Cloud Sync resources API.
 */
export interface CloudSync {
  dataBrokers: DataBrokersAPI;
  messages: MessagesAPI;
  nfs: NfsAPI;
  relationships: RelationshipsAPI;
}
 
/**
 * Manage cloud sync resources.
 *
 * @example
 *
 * import api from 'qstack-client/api/cloud-sync';
 *
 * const conf = {
 *   onbehalfToken: 'JWT token',
 *   tolen: 'JWT token',
 *   url: 'http://cloud-sync.example.com',
 * };
 *
 * api(conf).relationships.list();
 */
export default function cloudSync(conf: CloudSyncConf): CloudSync {
  logger.silly(`CloudSync conf=${JSON.stringify(conf)}`);
 
  function call(method, command, data, params) {
    return callCloudSync(conf, method, command, data, params);
  }
 
  return {
    dataBrokers: dataBrokers(call),
    messages: messages(call),
    nfs: nfs(call),
    relationships: relationships(call),
  };
}