File tree Expand file tree Collapse file tree 5 files changed +93
-1
lines changed
Expand file tree Collapse file tree 5 files changed +93
-1
lines changed Original file line number Diff line number Diff line change 11import 'package:celest_cli/celest_cli.dart' ;
22import 'package:celest_cli/src/commands/auth/auth_command.dart' ;
3+ import 'package:celest_cli/src/commands/cloud/operations/operations_command.dart' ;
34import 'package:celest_cli/src/commands/cloud/organizations/organizations_command.dart' ;
45import 'package:celest_cli/src/commands/cloud/project_environments/project_environments_command.dart' ;
56import 'package:celest_cli/src/commands/cloud/projects/projects_command.dart' ;
@@ -32,7 +33,8 @@ void main(List<String> args) async {
3233 cli
3334 ..addCommand (OrganizationsCommand ())
3435 ..addCommand (ProjectsCommand ())
35- ..addCommand (ProjectEnvironmentsCommand ());
36+ ..addCommand (ProjectEnvironmentsCommand ())
37+ ..addCommand (OperationsCommand ());
3638
3739 await cli.run (args);
3840}
Original file line number Diff line number Diff line change @@ -484,6 +484,8 @@ abstract base class CloudDeleteCommand<R extends GeneratedMessage>
484484
485485extension type CloudCommandOptions (ArgResults argResults)
486486 implements ArgResults {
487+ String ? get maybeResourceId => rest.elementAtOrNull (0 );
488+
487489 String get resourceId {
488490 final id = rest.elementAtOrNull (0 );
489491 if (id == null ) {
Original file line number Diff line number Diff line change 1+ import 'package:celest_cli/src/commands/cloud/cloud_command.dart' ;
2+ import 'package:celest_cli/src/context.dart' show cloud;
3+ import 'package:celest_cloud/celest_cloud.dart' ;
4+
5+ final class GetOperationCommand extends CloudGetCommand <Operation > {
6+ @override
7+ String get description => 'Gets an operation.' ;
8+
9+ @override
10+ String get name => 'get' ;
11+
12+ @override
13+ String get resourceType => 'Operation' ;
14+
15+ @override
16+ Operation createEmptyResource () => Operation ();
17+
18+ @override
19+ Future <Operation ?> callService () async {
20+ return cloud.operations.get (options.resourceId);
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ import 'package:celest_cli/src/commands/cloud/cloud_command.dart' ;
2+ import 'package:celest_cli/src/context.dart' show cloud;
3+ import 'package:celest_cloud/celest_cloud.dart' ;
4+ import 'package:celest_cloud_core/celest_cloud_core.dart' ;
5+
6+ final class ListOperationsCommand extends CloudListCommand <Operation > {
7+ @override
8+ String get description => 'Lists operations.' ;
9+
10+ @override
11+ String get name => 'list' ;
12+
13+ @override
14+ String get resourceType => 'Operation' ;
15+
16+ @override
17+ String ? get parentResourceType => null ;
18+
19+ @override
20+ Operation createEmptyResource () => Operation ();
21+
22+ @override
23+ Future <CloudListResult <Operation >> callService () async {
24+ var filter = options.filter;
25+ if (options.maybeResourceId case final resourceId? ) {
26+ final resourceName = ResourceName .parse (resourceId);
27+ final resourceFilter = 'resource_type = "${resourceName .uid .type }" AND '
28+ 'resource_id = "${resourceName .uid .id }"' ;
29+ if (filter == null || filter.isEmpty) {
30+ filter = resourceFilter;
31+ } else {
32+ filter = '$filter AND $resourceFilter ' ;
33+ }
34+ }
35+ final result = await cloud.operations.list (
36+ filter: filter,
37+ pageSize: options.pageSize,
38+ );
39+ return (
40+ items: result.operations,
41+ nextPageToken: result.hasNextPageToken () ? result.nextPageToken : null ,
42+ );
43+ }
44+ }
Original file line number Diff line number Diff line change 1+ import 'package:celest_cli/src/commands/celest_command.dart' ;
2+ import 'package:celest_cli/src/commands/cloud/operations/get_operation_command.dart' ;
3+ import 'package:celest_cli/src/commands/cloud/operations/list_operations_command.dart' ;
4+
5+ final class OperationsCommand extends CelestCommand {
6+ OperationsCommand () {
7+ addSubcommand (GetOperationCommand ());
8+ addSubcommand (ListOperationsCommand ());
9+ }
10+
11+ @override
12+ String get description => 'Manage Celest Cloud operations.' ;
13+
14+ @override
15+ String get name => 'operations' ;
16+
17+ @override
18+ String get category => 'Cloud' ;
19+
20+ @override
21+ bool get hidden => true ;
22+ }
You can’t perform that action at this time.
0 commit comments