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 | 4x 3x 2x 1x 1x 1x | // @flow import { type Caller } from '.'; /** * A description of a storage region. */ export type StorageRegion = { id: string, name: string, created: Date, updated: Date, deleted: ?Date, }; /** * Parameters passed when creating storage region. */ type CreateStorageRegionValues = any; /** * Parameters passed when updating storage region. */ type UpdateStorageRegionValues = any; /** * Manage storage regions. */ export interface StorageRegionsAPI { list(): Promise<[StorageRegion]>; create(values: CreateStorageRegionValues): Promise<StorageRegion>; update(id: string, values: UpdateStorageRegionValues): Promise<StorageRegion>; delete(id: string): Promise<any>; } function into(region: any): StorageRegion { return { id: region.uuid, name: region.name, created: new Date(region.createdAt), updated: new Date(region.updatedAt), deleted: (region.deletedAt && new Date(region.deletedAt)) || null, }; } export default function regions(call: Caller): StorageRegionsAPI { return { async list() { return (await call('GET', 'region')).map(into); }, async create(values) { return into(await call('POST', `region`, values)); }, async update(id, values) { return into(await call('PUT', `region/${id}`, values)); }, async delete(id) { return call('DELETE', `region/${id}`); }, }; } |