opal-security 3.1.1-beta.778ef29 → 3.1.1-beta.7cc0a74

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
@@ -22,7 +22,7 @@ $ npm install -g opal-security
22
22
  $ opal COMMAND
23
23
  running command...
24
24
  $ opal (--version)
25
- opal-security/3.1.1-beta.778ef29 linux-x64 node-v20.19.1
25
+ opal-security/3.1.1-beta.7cc0a74 linux-x64 node-v20.19.2
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -101,7 +101,7 @@ EXAMPLES
101
101
  $ opal aws:identity
102
102
  ```
103
103
 
104
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/aws/identity.ts)_
104
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/aws/identity.ts)_
105
105
 
106
106
  ## `opal clear-auth-provider`
107
107
 
@@ -121,7 +121,7 @@ EXAMPLES
121
121
  $ opal clear-auth-provider
122
122
  ```
123
123
 
124
- _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/clear-auth-provider.ts)_
124
+ _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/clear-auth-provider.ts)_
125
125
 
126
126
  ## `opal curl-example`
127
127
 
@@ -138,7 +138,7 @@ DESCRIPTION
138
138
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
139
139
  ```
140
140
 
141
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/curl-example.ts)_
141
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/curl-example.ts)_
142
142
 
143
143
  ## `opal groups get`
144
144
 
@@ -150,7 +150,7 @@ USAGE
150
150
 
151
151
  FLAGS
152
152
  -h, --help Show CLI help.
153
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
153
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
154
154
 
155
155
  DESCRIPTION
156
156
  Get group info for a particular group.
@@ -159,7 +159,7 @@ EXAMPLES
159
159
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
160
160
  ```
161
161
 
162
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/groups/get.ts)_
162
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/groups/get.ts)_
163
163
 
164
164
  ## `opal help [COMMANDS]`
165
165
 
@@ -191,7 +191,7 @@ USAGE
191
191
 
192
192
  FLAGS
193
193
  -h, --help Show CLI help.
194
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
194
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
195
195
  https://opal.dev/resources/[ID]
196
196
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
197
197
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -209,7 +209,7 @@ EXAMPLES
209
209
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
210
210
  ```
211
211
 
212
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/iam-roles/start.ts)_
212
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/iam-roles/start.ts)_
213
213
 
214
214
  ## `opal kube-roles start`
215
215
 
@@ -222,7 +222,7 @@ USAGE
222
222
  FLAGS
223
223
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
224
224
  -h, --help Show CLI help.
225
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
225
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
226
226
  https://opal.dev/resources/[ID]
227
227
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
228
228
  expire.
@@ -240,7 +240,7 @@ EXAMPLES
240
240
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
241
241
  ```
242
242
 
243
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/kube-roles/start.ts)_
243
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/kube-roles/start.ts)_
244
244
 
245
245
  ## `opal login`
246
246
 
@@ -261,7 +261,7 @@ EXAMPLES
261
261
  $ opal login
262
262
  ```
263
263
 
264
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/login.ts)_
264
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/login.ts)_
265
265
 
266
266
  ## `opal logout`
267
267
 
@@ -281,7 +281,7 @@ EXAMPLES
281
281
  $ opal logout
282
282
  ```
283
283
 
284
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/logout.ts)_
284
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/logout.ts)_
285
285
 
286
286
  ## `opal postgres-instances start`
287
287
 
@@ -294,7 +294,7 @@ USAGE
294
294
  FLAGS
295
295
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
296
296
  -h, --help Show CLI help.
297
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
297
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
298
298
  https://opal.dev/resources/[ID]
299
299
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
300
300
  expire.
@@ -318,7 +318,7 @@ EXAMPLES
318
318
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
319
319
  ```
320
320
 
321
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/postgres-instances/start.ts)_
321
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/postgres-instances/start.ts)_
322
322
 
323
323
  ## `opal resources get`
324
324
 
@@ -330,7 +330,7 @@ USAGE
330
330
 
331
331
  FLAGS
332
332
  -h, --help Show CLI help.
333
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
333
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
334
334
 
335
335
  DESCRIPTION
336
336
  Get resource info for a particular resource.
@@ -339,7 +339,7 @@ EXAMPLES
339
339
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
340
340
  ```
341
341
 
342
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/resources/get.ts)_
342
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/resources/get.ts)_
343
343
 
344
344
  ## `opal set-auth-provider`
345
345
 
@@ -365,7 +365,7 @@ EXAMPLES
365
365
  $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
366
366
  ```
367
367
 
368
- _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-auth-provider.ts)_
368
+ _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/set-auth-provider.ts)_
369
369
 
370
370
  ## `opal set-custom-header`
371
371
 
@@ -386,7 +386,7 @@ EXAMPLES
386
386
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
387
387
  ```
388
388
 
389
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-custom-header.ts)_
389
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/set-custom-header.ts)_
390
390
 
391
391
  ## `opal set-token`
392
392
 
@@ -406,7 +406,7 @@ EXAMPLES
406
406
  $ opal set-token
407
407
  ```
408
408
 
409
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-token.ts)_
409
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/set-token.ts)_
410
410
 
411
411
  ## `opal set-url [URL]`
412
412
 
@@ -430,7 +430,7 @@ EXAMPLES
430
430
  $ opal set-url
431
431
  ```
432
432
 
433
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-url.ts)_
433
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/set-url.ts)_
434
434
 
435
435
  ## `opal ssh copyFrom`
436
436
 
@@ -442,7 +442,7 @@ USAGE
442
442
 
443
443
  FLAGS
444
444
  -h, --help Show CLI help.
445
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
445
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
446
446
  https://opal.dev/resources/[ID]
447
447
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
448
448
  web flow.
@@ -461,7 +461,7 @@ EXAMPLES
461
461
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
462
462
  ```
463
463
 
464
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/ssh/copyFrom.ts)_
464
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/ssh/copyFrom.ts)_
465
465
 
466
466
  ## `opal ssh copyTo`
467
467
 
@@ -473,7 +473,7 @@ USAGE
473
473
 
474
474
  FLAGS
475
475
  -h, --help Show CLI help.
476
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
476
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
477
477
  https://opal.dev/resources/[ID]
478
478
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
479
479
  web flow.
@@ -492,7 +492,7 @@ EXAMPLES
492
492
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
493
493
  ```
494
494
 
495
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/ssh/copyTo.ts)_
495
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/ssh/copyTo.ts)_
496
496
 
497
497
  ## `opal ssh start`
498
498
 
@@ -504,7 +504,7 @@ USAGE
504
504
 
505
505
  FLAGS
506
506
  -h, --help Show CLI help.
507
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
507
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
508
508
  https://opal.dev/resources/[ID]
509
509
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
510
510
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -519,7 +519,7 @@ EXAMPLES
519
519
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
520
520
  ```
521
521
 
522
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/ssh/start.ts)_
522
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7cc0a74/src/commands/ssh/start.ts)_
523
523
 
524
524
  ## `opal version`
525
525
 
@@ -2,5 +2,11 @@ import { Command } from "@oclif/core";
2
2
  export default class RequestCreate extends Command {
3
3
  static hidden: boolean;
4
4
  static description: string;
5
+ static flags: {
6
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ reason: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ duration: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ };
5
11
  run(): Promise<void>;
6
12
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const apollo_1 = require("../../lib/apollo");
5
+ const flags_1 = require("../../lib/flags");
5
6
  const requests_1 = require("../../lib/requests");
6
7
  const displays_1 = require("../../utils/displays");
7
8
  const utils_1 = require("../../utils/utils");
@@ -10,28 +11,66 @@ class RequestCreate extends core_1.Command {
10
11
  await (0, apollo_1.initClient)(this, true);
11
12
  const client = await (0, apollo_1.getClient)(this, true);
12
13
  (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
13
- const requestMap = new Map();
14
- (0, displays_1.headerMessage)(this);
15
- let shouldProceed = false;
16
- while (!shouldProceed) {
17
- // Step 1: Select first round of assets from an app
18
- await (0, requests_1.selectRequestableItems)(this, client, requestMap);
19
- // Step 2: Display the selected items in a tree format
14
+ const { flags } = await this.parse(RequestCreate);
15
+ const metadata = (0, requests_1.initEmptyRequestMetadata)();
16
+ if (flags.id) {
17
+ // if IDs are provided, bypass the interactive selection process
18
+ (0, requests_1.bypassRequestSelection)(this, client, flags.id, metadata);
19
+ }
20
+ else {
20
21
  (0, displays_1.headerMessage)(this);
21
- this.log((0, displays_1.treeifyRequestMap)(requestMap), "\n");
22
- // Step 3: Prompt to add more items, repeat 1-3 if needed
23
- shouldProceed = await (0, requests_1.doneSelectingAssets)();
22
+ let shouldProceed = false;
23
+ while (!shouldProceed) {
24
+ // Step 1: Select first round of assets from an app
25
+ await (0, requests_1.selectRequestableItems)(this, client, metadata.requestMap);
26
+ // Step 2: Display the selected items in a tree format
27
+ (0, displays_1.headerMessage)(this);
28
+ (0, displays_1.treeifyRequestMap)(this, metadata.requestMap);
29
+ // Step 3: Prompt to add more items, repeat 1-3 if needed
30
+ shouldProceed = await (0, requests_1.doneSelectingAssets)();
31
+ }
24
32
  }
33
+ // Step 4: Set Request Defaults
34
+ await (0, requests_1.setRequestDefaults)(this, client, metadata);
25
35
  // Step 4: Prompt for request reason
26
- const { reason } = await (0, requests_1.promptForReason)();
36
+ if (flags.reason) {
37
+ metadata.reason = flags.reason;
38
+ }
39
+ else {
40
+ await (0, requests_1.promptForReason)(metadata);
41
+ }
27
42
  // Step 5: Prompt for expiration
28
- const { expiration } = await (0, requests_1.promptForExpiration)();
43
+ if (flags.duration) {
44
+ (0, requests_1.bypassDuration)(this, flags.duration, metadata);
45
+ }
46
+ else {
47
+ await (0, requests_1.promptForExpiration)(metadata);
48
+ }
29
49
  // Step 6: Display final summary of request
30
- (0, displays_1.displayFinalRequestSummary)(this, requestMap, reason, expiration);
50
+ if (!(flags.id && flags.reason && flags.duration)) {
51
+ await (0, requests_1.promptRequestSubmition)(this, metadata);
52
+ }
31
53
  // Step 7: Prompt for final submition
32
- await (0, requests_1.submitFinalRequest)(this);
54
+ await (0, requests_1.submitFinalRequest)(this, client, metadata);
33
55
  }
34
56
  }
35
57
  RequestCreate.hidden = true;
36
- RequestCreate.description = "Opens an Opal access request";
58
+ RequestCreate.description = "Creates an Opal access request via an interactive form";
59
+ RequestCreate.flags = {
60
+ help: flags_1.SHARED_FLAGS.help,
61
+ id: core_1.Flags.string({
62
+ char: "i",
63
+ multiple: true,
64
+ description: "The id of the asset (resource, group) to request access to. Append a role ID using a colon if needed, e.g. `--id 123:456`.\
65
+ \n If not provided, an interactive selection flow will be available to select assets to request.",
66
+ }),
67
+ reason: core_1.Flags.string({
68
+ char: "r",
69
+ description: "The reason for the request, contained in quotes. If not provided, you will be prompted.",
70
+ }),
71
+ duration: core_1.Flags.integer({
72
+ char: "d",
73
+ description: "The duration of access for the request in minutes. If not provided, you will be prompted.",
74
+ }),
75
+ };
37
76
  exports.default = RequestCreate;
@@ -1,6 +1,12 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class RequestGet extends Command {
2
+ export default class GetRequest extends Command {
3
3
  static hidden: boolean;
4
4
  static description: string;
5
+ static flags: {
6
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ static examples: string[];
5
11
  run(): Promise<void>;
6
12
  }
@@ -1,13 +1,114 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
+ const chalk_1 = require("chalk");
5
+ const graphql_1 = require("../../graphql");
6
+ const apollo_1 = require("../../lib/apollo");
7
+ const cmd_1 = require("../../lib/cmd");
8
+ const config_1 = require("../../lib/config");
9
+ const flags_1 = require("../../lib/flags");
10
+ const displays_1 = require("../../utils/displays");
4
11
  const utils_1 = require("../../utils/utils");
5
- class RequestGet extends core_1.Command {
12
+ const GET_REQUEST = (0, graphql_1.graphql)(`
13
+ query GetRequest(
14
+ $id: RequestId!
15
+ ) {
16
+ request(input: {id: $id}) {
17
+ __typename
18
+ ... on RequestResult {
19
+ request {
20
+ id
21
+ createdAt
22
+ status
23
+ requester {
24
+ displayName
25
+ }
26
+ targetUser {
27
+ displayName
28
+ }
29
+ requestedResources {
30
+ resource {
31
+ displayName
32
+ id
33
+ }
34
+ accessLevel {
35
+ accessLevelName
36
+ accessLevelRemoteId
37
+ }
38
+ }
39
+ durationInMinutes
40
+ requestedGroups {
41
+ group {
42
+ id
43
+ name
44
+ }
45
+ accessLevel {
46
+ accessLevelName
47
+ accessLevelRemoteId
48
+ }
49
+ }
50
+ reason
51
+ }
52
+ }
53
+ ... on RequestNotFoundError {
54
+ message
55
+ }
56
+ }
57
+ }
58
+ `);
59
+ class GetRequest extends core_1.Command {
6
60
  async run() {
7
61
  (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
8
- this.log("Running the get command");
62
+ (0, cmd_1.setMostRecentCommand)(this);
63
+ const configData = (0, config_1.getOrCreateConfigData)(this.config.configDir);
64
+ const client = await (0, apollo_1.getClient)(this, true);
65
+ // Verify id tag was provided
66
+ const { flags } = await this.parse(GetRequest);
67
+ if (!flags.id) {
68
+ this.log("Error: Please provide a group ID using the --id flag.");
69
+ this.log("ex. opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4");
70
+ return;
71
+ }
72
+ const resp = await client.query({
73
+ query: GET_REQUEST,
74
+ variables: {
75
+ id: flags.id,
76
+ },
77
+ fetchPolicy: "network-only", // to avoid caching
78
+ });
79
+ switch (resp.data.request.__typename) {
80
+ case "RequestResult": {
81
+ if (flags.verbose) {
82
+ (0, apollo_1.printResponse)(this, resp);
83
+ }
84
+ else {
85
+ (0, displays_1.displayRequestDetails)(this, resp);
86
+ }
87
+ const url = `${configData[config_1.urlKey]}/requests/sent/${flags.id}`;
88
+ this.log(`\n💡Link to request details: ${chalk_1.default.underline(url)}`);
89
+ return;
90
+ }
91
+ case "RequestNotFoundError":
92
+ this.log(`🚫 Request with id ${flags.id} was not found`);
93
+ return;
94
+ default:
95
+ this.log("🚫 Error retrieving request data");
96
+ }
9
97
  }
10
98
  }
11
- RequestGet.hidden = true;
12
- RequestGet.description = "Lists access requests";
13
- exports.default = RequestGet;
99
+ GetRequest.hidden = true;
100
+ GetRequest.description = "Lists access requests";
101
+ GetRequest.flags = {
102
+ help: flags_1.SHARED_FLAGS.help,
103
+ id: flags_1.SHARED_FLAGS.id,
104
+ verbose: core_1.Flags.boolean({
105
+ char: "v",
106
+ description: "Enable verbose output, prints full response in JSON format. Defaults to false.",
107
+ default: false,
108
+ }),
109
+ };
110
+ GetRequest.examples = [
111
+ "opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4",
112
+ "opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose",
113
+ ];
114
+ exports.default = GetRequest;
@@ -1,6 +1,13 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class RequestList extends Command {
2
+ export default class ListRequests extends Command {
3
3
  static hidden: boolean;
4
4
  static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
8
+ n: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ pending: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
5
12
  run(): Promise<void>;
6
13
  }
@@ -1,14 +1,121 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
+ const graphql_1 = require("../../graphql");
5
+ const apollo_1 = require("../../lib/apollo");
6
+ const cmd_1 = require("../../lib/cmd");
7
+ const flags_1 = require("../../lib/flags");
8
+ const displays_1 = require("../../utils/displays");
4
9
  const utils_1 = require("../../utils/utils");
5
- class RequestList extends core_1.Command {
6
- // static aliases = ["request:ls"];
10
+ // Add date filters, search query,
11
+ const GET_REQUESTS = (0, graphql_1.graphql)(`
12
+ query GetRequests($pageSize: Int, $showPendingOnly: Boolean!) {
13
+ requests(input: {
14
+ requestType: OUTGOING
15
+ maxNumEntries: $pageSize
16
+ filters: {
17
+ showPendingOnly: $showPendingOnly
18
+ }
19
+ }) {
20
+ __typename
21
+ ... on RequestsResult {
22
+ requestType
23
+ requests {
24
+ durationInMinutes
25
+ id
26
+ requester {
27
+ displayName
28
+ }
29
+ targetUser {
30
+ displayName
31
+ }
32
+ reason
33
+ requestedResources {
34
+ resource {
35
+ displayName
36
+ id
37
+ }
38
+ accessLevel {
39
+ accessLevelName
40
+ accessLevelRemoteId
41
+ }
42
+ }
43
+ requestedGroups {
44
+ group {
45
+ name
46
+ id
47
+ }
48
+ accessLevel {
49
+ accessLevelName
50
+ accessLevelRemoteId
51
+ }
52
+ }
53
+ status
54
+ }
55
+
56
+ }
57
+
58
+ }
59
+ }`);
60
+ class ListRequests extends core_1.Command {
7
61
  async run() {
8
62
  (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
9
- this.log("Running the list command");
63
+ (0, cmd_1.setMostRecentCommand)(this);
64
+ const client = await (0, apollo_1.getClient)(this, true);
65
+ let pageSize = 10;
66
+ let showPendingOnly = false;
67
+ const { flags } = await this.parse(ListRequests);
68
+ if (flags.n) {
69
+ pageSize = flags.n;
70
+ }
71
+ if (flags.showPendingOnly) {
72
+ showPendingOnly = flags.showPendingOnly;
73
+ }
74
+ const resp = await client.query({
75
+ query: GET_REQUESTS,
76
+ variables: {
77
+ pageSize: pageSize,
78
+ showPendingOnly: showPendingOnly,
79
+ },
80
+ fetchPolicy: "network-only", // to avoid caching
81
+ });
82
+ //TODO: Make this pretty
83
+ if (flags.verbose) {
84
+ (0, apollo_1.printResponse)(this, resp);
85
+ }
86
+ else {
87
+ (0, displays_1.displayRequestListTable)(this, resp);
88
+ }
10
89
  }
11
90
  }
12
- RequestList.hidden = true;
13
- RequestList.description = "Lists access requests";
14
- exports.default = RequestList;
91
+ ListRequests.hidden = true;
92
+ ListRequests.description = "Lists your n recent outgoing access requests";
93
+ ListRequests.examples = [
94
+ "opal request list --n 5",
95
+ "opal request list --n 5 --pending",
96
+ "opal request list --n 5 --verbose",
97
+ "opal request list --n 5 --pending --verbose",
98
+ ];
99
+ // static aliases = ["request:ls"]; // uncomment when ready for release
100
+ ListRequests.flags = {
101
+ help: flags_1.SHARED_FLAGS.help,
102
+ n: core_1.Flags.integer({
103
+ char: "n",
104
+ multiple: false,
105
+ description: "Defines number of requests to be returned. 1 <= n <= 100.",
106
+ default: 10,
107
+ min: 1,
108
+ max: 100,
109
+ }),
110
+ pending: core_1.Flags.boolean({
111
+ char: "p",
112
+ description: "Show only pending requests. Defaults to false.",
113
+ default: false,
114
+ }),
115
+ verbose: core_1.Flags.boolean({
116
+ char: "v",
117
+ description: "Enable verbose output, prints full response in JSON format. Defaults to false.",
118
+ default: false,
119
+ }),
120
+ };
121
+ exports.default = ListRequests;