UNPKG

2.34 kBJavaScriptView Raw
1// Copyright IBM Corp. 2016. All Rights Reserved.
2// Node module: apiconnect-cli-catalogs
3// US Government Users Restricted Rights - Use, duplication or disclosure
4// restricted by GSA ADP Schedule Contract with IBM Corp.
5
6/********************************************************* {COPYRIGHT-TOP} ***
7 * IBM Confidential
8 * OCO Source Materials
9 * 5725-C11, 5725-C12, 7198-8FX, 5725-F70, 5725-F71, 5725-F72, 5725-L30
10 *
11 * (C) Copyright IBM Corporation 2015 All Rights Reserved.
12 *
13 * The source code for this program is not published or otherwise
14 * divested of its trade secrets, irrespective of what has been
15 * deposited with the U.S. Copyright Office.
16 ********************************************************* {COPYRIGHT-END} **/
17
18var g = require('strong-globalize')();
19var logger = require('apiconnect-cli-logger');
20
21function catalogFullId(server, org, catalog) {
22 return 'apic-catalog://' + server + '/orgs/' + org + '/catalogs/' + catalog;
23};
24
25exports.listFormatter = function(result, orgOptions) {
26 if (!Object.keys(result).length) {
27 if (orgOptions.allOrganizations) {
28 logger.error(g.f('No catalogs found in all organizations'));
29 }
30 logger.error(g.f('No catalogs found in org %s', orgOptions.organization));
31 }
32 result.forEach(function(catalog) {
33 logger.writeln(catalogFullId(orgOptions.server, catalog.orgName, catalog.shortName));
34 });
35};
36
37exports.createFormatter = function(result, options) {
38 logger.writeln(g.f('Created %s:%s', options.organization, result.name));
39};
40
41exports.getFormatter = function(result, options) {
42 logger.writeln(g.f('name: %s', result.shortName));
43 logger.writeln(g.f('display name: %s', result.name));
44 logger.writeln(g.f('organization: %s', options.organization));
45 if (result.autoDeploy) {
46 logger.writeln(g.f('type: development'));
47 } else {
48 logger.writeln(g.f('type: production'));
49 }
50 if (result.spaceEnabled) {
51 logger.writeln(g.f('spaces: enabled'));
52 } else {
53 logger.writeln(g.f('spaces: disabled'));
54 }
55};
56
57exports.deleteFormatter = function(catalogName, options) {
58 logger.writeln(g.f('Deleted %s:%s', options.organization, catalogName));
59};
60
61exports.setFormatter = function(result, options) {
62 logger.writeln(g.f('Updated catalog %s in %s', result.shortName, options.organization));
63};
64
65exports.error = function(error) {
66 throw error;
67};