import { map } from 'lodash' ; import api from 'teleport/services/api' ; import cfg from 'teleport/config' ; import makeNode from './makeNode' ; import makeNodeToken from './makeNodeToken' ; import makeAppBashCmd from './makeAppBashCmd' ; import makeNodeBashCmd from './makeNodeBashCmd' ; const service = { fetchNodes ( clusterId ? ) { return api . get ( cfg . getClusterNodesUrl ( clusterId ) ) . then ( json => map ( json . items , makeNode ) ) ; } , createNodeBashCommand ( ) { return api . post ( cfg . getNodeJoinTokenUrl ( ) ) . then ( makeNodeBashCmd ) ; } , createAppBashCommand ( appName , appUri ) { return api . post ( cfg . getNodeJoinTokenUrl ( ) ) . then ( makeNodeToken ) . then ( token => makeAppBashCmd ( token , appName , appUri ) ) ; } , } ; export default service ;