|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const querystring = require('querystring'); |
| 4 | +const { get, list } = require('../../../api'); |
| 5 | +const print = require('../../../print'); |
| 6 | +const formatPage = require('../../../formatPage'); |
| 7 | + |
| 8 | +exports.command = 'list <projectId>'; |
| 9 | +exports.desc = 'List ingestions by <projectId>'; |
| 10 | +exports.builder = yargs => { |
| 11 | + yargs.positional('projectId', { |
| 12 | + describe: 'The project ID.', |
| 13 | + type: 'string' |
| 14 | + }).option('page-size', { |
| 15 | + describe: 'The page size.', |
| 16 | + type: 'number', |
| 17 | + alias: 'n', |
| 18 | + default: 25 |
| 19 | + }).option('next-page-token', { |
| 20 | + describe: 'The next page token.', |
| 21 | + alias: 't', |
| 22 | + type: 'string' |
| 23 | + }).option('limit', { |
| 24 | + describe: 'The maximum number of items to return.', |
| 25 | + alias: 'l', |
| 26 | + type: 'number' |
| 27 | + }).option('name', { |
| 28 | + describe: 'Filter ingestions where the ingestion name contains this', |
| 29 | + type: 'string' |
| 30 | + }).option('failed', { |
| 31 | + describe: 'Filter ingestions that have failed', |
| 32 | + type: 'boolean' |
| 33 | + }).option('step', { |
| 34 | + describe: 'Filter ingestions that are on this step', |
| 35 | + type: 'string', |
| 36 | + choices: ['AwaitingFiles', 'Submitted', 'Transformed', 'Normalized', 'TestCreated', 'TestNotCreated'] |
| 37 | + }); |
| 38 | +}; |
| 39 | + |
| 40 | +exports.handler = async argv => { |
| 41 | + const opts = { |
| 42 | + pageSize: argv.limit ? 1000 : argv.pageSize |
| 43 | + }; |
| 44 | + |
| 45 | + if (argv.nextPageToken) opts.nextPageToken = argv.nextPageToken; |
| 46 | + if (argv.name) opts.name = argv.name; |
| 47 | + if (argv.failed) opts.failed = argv.failed; |
| 48 | + if (argv.step) opts.steps = argv.step; |
| 49 | + |
| 50 | + const path = `/v1/genomic-ingestion/projects/${argv.projectId}/ingestions?${querystring.stringify(opts)}`; |
| 51 | + |
| 52 | + const response = await (argv.limit ? list(argv, path) : get(argv, path)); |
| 53 | + print(formatPage(response.data), argv); |
| 54 | +}; |
0 commit comments