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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 4x 3x 1x 1x 1x 1x | // @flow import { type Caller } from '.'; /** * A description of a storage host. */ export type StorageHost = { id: string, name: string, type: string, version: string, capabilities: string, ipAddress: string, port: number, protocol: string, publicAccess: boolean, maintenanceMode: boolean, username: string, stamp: { id: string, name: string, }, lifeCycle: { state: string, details: string, }, vendorId: ?string, created: Date, updated: Date, deleted: ?Date, }; /** * Parameters passed when creating storage host. */ export type CreateStorageHostValues = any; /** * Parameters passed when updating storage host. */ export type UpdateStorageHostValues = any; /** * Manage storage hosts. */ export interface StorageHostsAPI { list(): Promise<[StorageHost]>; create(values: CreateStorageHostValues): Promise<StorageHost>; update(id: string, values: UpdateStorageHostValues): Promise<StorageHost>; delete(id: string): Promise<any>; } function into(host: any): StorageHost { return { id: host.uuid, name: host.name, type: host.type, version: host.version, capabilities: host.capabilities, ipAddress: host.ipAddress, port: host.port, protocol: host.protocol, publicAccess: !!host.publicAccess, maintenanceMode: !!host.maintenanceMode, username: host.username, stamp: { id: host.stampUUID, name: host.stampName, }, lifeCycle: { state: host.state, details: host.stateDetails, }, vendorId: host.vendorID || null, created: new Date(host.createdAt), updated: new Date(host.updatedAt), deleted: (host.deletedAt && new Date(host.deletedAt)) || null, }; } export default function hosts(call: Caller): StorageHostsAPI { return { async list() { return (await call('GET', 'host')).map(into); }, async create(values) { return into(await call('POST', `host`, values)); }, async update(id, values) { return into(await call('PUT', `host/${id}`, values)); }, async delete(id) { return call('DELETE', `host/${id}`); }, }; } |