@contrail/cli 3.6.0-alpha-8-alpha.53e9604 → 3.6.0-alpha-8-alpha.65a5f6a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ The Contrail CLI is the best way to manage your instance data through a programm
|
|
|
6
6
|
* [Contrail CLI](#contrail-cli)
|
|
7
7
|
* [Usage](#usage)
|
|
8
8
|
* [Autocomplete](#autocomplete)
|
|
9
|
+
* [Entities](#entities)
|
|
9
10
|
* [Commands](#commands)
|
|
10
11
|
<!-- tocstop -->
|
|
11
12
|
|
|
@@ -17,7 +18,7 @@ $ npm install -g @contrail/cli
|
|
|
17
18
|
$ contrail COMMAND
|
|
18
19
|
running command...
|
|
19
20
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.6.0-alpha-8-alpha.
|
|
21
|
+
@contrail/cli/3.6.0-alpha-8-alpha.65a5f6a linux-x64 node-v24.22.1
|
|
21
22
|
$ contrail --help [COMMAND]
|
|
22
23
|
USAGE
|
|
23
24
|
$ contrail COMMAND
|
|
@@ -29,6 +30,54 @@ USAGE
|
|
|
29
30
|
|
|
30
31
|
To get instructions on how to set up autocomplete for your shell, run `contrail autocomplete`.
|
|
31
32
|
|
|
33
|
+
# Entities
|
|
34
|
+
|
|
35
|
+
The `contrail entities` commands create, query, update, and delete platform entities. They are built to be called from scripts. Per-command flags and examples are under [Commands](#commands) below.
|
|
36
|
+
|
|
37
|
+
## stdout is JSON, everything else is stderr
|
|
38
|
+
|
|
39
|
+
Every `entities` command writes JSON and nothing else to stdout. Progress logs, warnings, and prompts go to stderr, so output pipes without filtering:
|
|
40
|
+
|
|
41
|
+
```sh-session
|
|
42
|
+
$ contrail entities get item -e=false -t 3 -p id,name | jq -r '.[].name'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Redirect the two streams separately to keep the logs:
|
|
46
|
+
|
|
47
|
+
```sh-session
|
|
48
|
+
$ contrail entities get item -e=false > items.json 2> run.log
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`-o/--outputFile` writes the JSON to a file and leaves stdout empty.
|
|
52
|
+
|
|
53
|
+
## Scripts need `-e=false`
|
|
54
|
+
|
|
55
|
+
`--alwaysConfirmEnv` defaults to true, so the command prints the current environment and waits for you to confirm it. With no terminal attached there is nothing to answer the prompt, and the command exits 130 having written no output. Pass `-e=false` from any script, cron job, or CI step.
|
|
56
|
+
|
|
57
|
+
## Property values go after `--`
|
|
58
|
+
|
|
59
|
+
Values are `slug=value` pairs. Everything before `--` is flags and ids:
|
|
60
|
+
|
|
61
|
+
```sh-session
|
|
62
|
+
$ contrail entities create color -e=false -- name="Electric Blue" hex=0000ff
|
|
63
|
+
$ contrail entities update color abc123 -e=false -- name=obsidian
|
|
64
|
+
$ contrail entities get color -e=false -- createdOn=2025-09-15..2025-09-16
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Quote any value containing a space. Repeat a key to pass several values to a multi-select property (`-- colors=option colors=family`); a comma inside one value is kept as part of that value.
|
|
68
|
+
|
|
69
|
+
On `update`, `slug=` unsets a property and `slug='""'` sets it to an empty string.
|
|
70
|
+
|
|
71
|
+
## Exit codes
|
|
72
|
+
|
|
73
|
+
| Code | Meaning |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| 0 | Every row succeeded |
|
|
76
|
+
| 1 | At least one row failed; the JSON summary names which |
|
|
77
|
+
| 130 | The environment prompt could not be answered (see `-e=false`) |
|
|
78
|
+
|
|
79
|
+
Bulk commands run every row to completion. One failure does not stop the rest, and the summary reports each row's outcome.
|
|
80
|
+
|
|
32
81
|
# Commands
|
|
33
82
|
|
|
34
83
|
<!-- commands -->
|
|
@@ -51,9 +100,9 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
|
|
|
51
100
|
* [`contrail config list`](#contrail-config-list)
|
|
52
101
|
* [`contrail config set`](#contrail-config-set)
|
|
53
102
|
* [`contrail config use [NAME]`](#contrail-config-use-name)
|
|
54
|
-
* [`contrail entities create
|
|
103
|
+
* [`contrail entities create ENTITYNAME`](#contrail-entities-create-entityname)
|
|
55
104
|
* [`contrail entities delete ENTITYNAME [IDS]`](#contrail-entities-delete-entityname-ids)
|
|
56
|
-
* [`contrail entities get
|
|
105
|
+
* [`contrail entities get ENTITYNAME [IDS]`](#contrail-entities-get-entityname-ids)
|
|
57
106
|
* [`contrail entities update ENTITYNAME [IDS]`](#contrail-entities-update-entityname-ids)
|
|
58
107
|
* [`contrail feature-flags export`](#contrail-feature-flags-export)
|
|
59
108
|
* [`contrail feature-flags import`](#contrail-feature-flags-import)
|
|
@@ -543,17 +592,17 @@ EXAMPLES
|
|
|
543
592
|
$ contrail config use demo-org
|
|
544
593
|
```
|
|
545
594
|
|
|
546
|
-
## `contrail entities create
|
|
595
|
+
## `contrail entities create ENTITYNAME`
|
|
547
596
|
|
|
548
597
|
Create entities
|
|
549
598
|
|
|
550
599
|
```
|
|
551
600
|
USAGE
|
|
552
|
-
$ contrail entities create
|
|
601
|
+
$ contrail entities create ENTITYNAME [-l error|warn|info|debug] [-e true|false] [-n <value>] [-d] [-i <value>] [-o
|
|
553
602
|
<value>] [-g] [-r] [-S] [--suffix <value>] [--apiVersion 1|2]
|
|
554
603
|
|
|
555
604
|
ARGUMENTS
|
|
556
|
-
|
|
605
|
+
ENTITYNAME The name of the entity type to create
|
|
557
606
|
|
|
558
607
|
FLAGS
|
|
559
608
|
-S, --skipHydrateRelationships If true, does not hydrate relationships for the created entities
|
|
@@ -563,7 +612,7 @@ FLAGS
|
|
|
563
612
|
-g, --generateValues If true, generates random values for properties that are not specified. By default,
|
|
564
613
|
only specified properties are used.
|
|
565
614
|
-i, --inputFile=<value> A file with a JSON array of objects where each object is one entity to create. Cannot
|
|
566
|
-
be used with --count. Unless --
|
|
615
|
+
be used with --count. Unless --generateValues is specified, only the properties in
|
|
567
616
|
the file will be used.
|
|
568
617
|
-l, --logLevel=<option> The Log Level
|
|
569
618
|
<options: error|warn|info|debug>
|
|
@@ -635,18 +684,18 @@ EXAMPLES
|
|
|
635
684
|
$ contrail entities delete item -i ids.json
|
|
636
685
|
```
|
|
637
686
|
|
|
638
|
-
## `contrail entities get
|
|
687
|
+
## `contrail entities get ENTITYNAME [IDS]`
|
|
639
688
|
|
|
640
689
|
Get an entity
|
|
641
690
|
|
|
642
691
|
```
|
|
643
692
|
USAGE
|
|
644
|
-
$ contrail entities get
|
|
645
|
-
[-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>] [--apiVersion 1|2]
|
|
693
|
+
$ contrail entities get ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-o <value>] [-p <value>]
|
|
694
|
+
[-P] [-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>] [--apiVersion 1|2]
|
|
646
695
|
|
|
647
696
|
ARGUMENTS
|
|
648
|
-
|
|
649
|
-
IDS
|
|
697
|
+
ENTITYNAME The name of the entity type to fetch
|
|
698
|
+
IDS One or more entity ids; shorthand for the id/ids criteria
|
|
650
699
|
|
|
651
700
|
FLAGS
|
|
652
701
|
-P, --paginated If true, fetches all entities in a paginated manner
|
|
@@ -20,7 +20,7 @@ export default class CreateEntity extends BaseCommand {
|
|
|
20
20
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
21
|
};
|
|
22
22
|
static args: {
|
|
23
|
-
|
|
23
|
+
entityName: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
24
24
|
};
|
|
25
25
|
static strict: boolean;
|
|
26
26
|
init(): Promise<void>;
|
|
@@ -154,7 +154,7 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
154
154
|
}),
|
|
155
155
|
inputFile: core_1.Flags.string({
|
|
156
156
|
char: 'i',
|
|
157
|
-
description: 'A file with a JSON array of objects where each object is one entity to create. Cannot be used with --count. Unless --
|
|
157
|
+
description: 'A file with a JSON array of objects where each object is one entity to create. Cannot be used with --count. Unless --generateValues is specified, only the properties in the file will be used.',
|
|
158
158
|
required: false,
|
|
159
159
|
multiple: false,
|
|
160
160
|
}),
|
|
@@ -193,8 +193,8 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
193
193
|
}),
|
|
194
194
|
};
|
|
195
195
|
static args = {
|
|
196
|
-
|
|
197
|
-
description: '
|
|
196
|
+
entityName: core_1.Args.string({
|
|
197
|
+
description: 'The name of the entity type to create',
|
|
198
198
|
required: true,
|
|
199
199
|
multiple: false,
|
|
200
200
|
}),
|
|
@@ -208,7 +208,7 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
208
208
|
await (0, login_1.authUser)();
|
|
209
209
|
const { flags, argv, args } = await this.parse(CreateEntity);
|
|
210
210
|
const { count, dryRun: isDryRun, inputFile: inputFilename, outputFile: outputFilename, generateValues: shouldGenerateMissingValues, readableIds: shouldUseReadableIds, skipHydrateRelationships, suffix, apiVersion, } = flags;
|
|
211
|
-
const {
|
|
211
|
+
const { entityName: entityTypePath } = args;
|
|
212
212
|
// Global flags is a little hacky, but it was easier
|
|
213
213
|
// and it doesn't see *that* bad because they are only valid
|
|
214
214
|
// for the lifecycle of the command.
|
|
@@ -226,7 +226,7 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
226
226
|
this.error('You must specify an entity type path.');
|
|
227
227
|
}
|
|
228
228
|
if (inputFilename && count) {
|
|
229
|
-
throw new Error('You cannot use --
|
|
229
|
+
throw new Error('You cannot use --inputFile and --count together. Please specify one or the other.');
|
|
230
230
|
}
|
|
231
231
|
if (count !== undefined && count <= 0) {
|
|
232
232
|
this.error('Count must be a positive integer.');
|
|
@@ -317,7 +317,7 @@ async function buildEntitiesToCreate(entityTypePath, entities, propertySpecifica
|
|
|
317
317
|
}));
|
|
318
318
|
// Skip system value generation unless -g flag is set (generateValues mode)
|
|
319
319
|
if (!SHOULD_GENERATE_MISSING_VALUES) {
|
|
320
|
-
console.error('Using only specified properties. Use --
|
|
320
|
+
console.error('Using only specified properties. Use --generateValues to auto-generate missing values.');
|
|
321
321
|
return populatedEntities;
|
|
322
322
|
}
|
|
323
323
|
// Add system values if needed
|
|
@@ -16,7 +16,7 @@ export default class GetEntity extends BaseCommand {
|
|
|
16
16
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
17
|
};
|
|
18
18
|
static args: {
|
|
19
|
-
|
|
19
|
+
entityName: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
20
20
|
ids: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
21
21
|
};
|
|
22
22
|
static strict: boolean;
|
|
@@ -73,7 +73,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
73
73
|
}),
|
|
74
74
|
};
|
|
75
75
|
static args = {
|
|
76
|
-
|
|
76
|
+
entityName: core_1.Args.string({
|
|
77
77
|
description: 'The name of the entity type to fetch',
|
|
78
78
|
required: true,
|
|
79
79
|
}),
|
|
@@ -90,7 +90,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
90
90
|
async run() {
|
|
91
91
|
await (0, login_1.authUser)();
|
|
92
92
|
const { args, flags, argv } = await this.parse(GetEntity);
|
|
93
|
-
const { typePath } = args;
|
|
93
|
+
const { entityName: typePath } = args;
|
|
94
94
|
const { outputFile, paginated: shouldUsePaginatedFind, propertySlugs, relations: relationString, skip, skipHydrateRelationships, suffix, apiVersion, take, } = flags;
|
|
95
95
|
SHOULD_USE_PAGINATED_FIND = shouldUsePaginatedFind;
|
|
96
96
|
MAX_NUMBER_OF_ENTITIES_TO_FETCH = take;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.6.0-alpha-8-alpha.
|
|
2
|
+
"version": "3.6.0-alpha-8-alpha.65a5f6a",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -739,7 +739,7 @@
|
|
|
739
739
|
"name": "inputFile",
|
|
740
740
|
"type": "option",
|
|
741
741
|
"char": "i",
|
|
742
|
-
"description": "A file with a JSON array of objects where each object is one entity to create. Cannot be used with --count. Unless --
|
|
742
|
+
"description": "A file with a JSON array of objects where each object is one entity to create. Cannot be used with --count. Unless --generateValues is specified, only the properties in the file will be used.",
|
|
743
743
|
"required": false,
|
|
744
744
|
"multiple": false
|
|
745
745
|
},
|
|
@@ -795,9 +795,9 @@
|
|
|
795
795
|
}
|
|
796
796
|
},
|
|
797
797
|
"args": {
|
|
798
|
-
"
|
|
799
|
-
"name": "
|
|
800
|
-
"description": "
|
|
798
|
+
"entityName": {
|
|
799
|
+
"name": "entityName",
|
|
800
|
+
"description": "The name of the entity type to create",
|
|
801
801
|
"required": true
|
|
802
802
|
}
|
|
803
803
|
}
|
|
@@ -1011,8 +1011,8 @@
|
|
|
1011
1011
|
}
|
|
1012
1012
|
},
|
|
1013
1013
|
"args": {
|
|
1014
|
-
"
|
|
1015
|
-
"name": "
|
|
1014
|
+
"entityName": {
|
|
1015
|
+
"name": "entityName",
|
|
1016
1016
|
"description": "The name of the entity type to fetch",
|
|
1017
1017
|
"required": true
|
|
1018
1018
|
},
|