Skip to content

Commit 1594040

Browse files
author
serverpod_cloud
committed
refactor(gc): 196831e53f5c2f88e6c26ba3695464067dd4ebaf
1 parent cf1c1a4 commit 1594040

4 files changed

Lines changed: 41 additions & 40 deletions

File tree

ground_control_client/lib/src/protocol/client.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,25 @@ class EndpointAdminProcurement extends _i1.EndpointRef {
7474
@override
7575
String get name => 'adminProcurement';
7676

77-
/// Procures a product for a user.
78-
/// If [productVersion] is not provided, the latest version is used.
77+
/// Procures a plan for a user.
78+
/// If [planProductVersion] is not provided, the latest version is used.
7979
/// If [overrideChecks] is true, the product availability checks are overridden.
8080
///
8181
/// Throws a [NotFoundException] if the user or product is not found.
8282
/// Throws a [InvalidValueException] if the user has no owner (not fully registered).
83-
_i2.Future<void> procureProduct({
83+
_i2.Future<void> procurePlan({
8484
required String userEmail,
85-
required String productName,
86-
int? productVersion,
85+
required String planProductName,
86+
int? planProductVersion,
8787
bool? overrideChecks,
8888
}) =>
8989
caller.callServerEndpoint<void>(
9090
'adminProcurement',
91-
'procureProduct',
91+
'procurePlan',
9292
{
9393
'userEmail': userEmail,
94-
'productName': productName,
95-
'productVersion': productVersion,
94+
'planProductName': planProductName,
95+
'planProductVersion': planProductVersion,
9696
'overrideChecks': overrideChecks,
9797
},
9898
);

serverpod_cloud_cli/lib/command_runner/commands/admin/admin_product_commands.dart

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AdminProductCommand extends CloudCliCommand {
1313

1414
AdminProductCommand({required super.logger}) {
1515
addSubcommand(AdminListProcuredCommand(logger: logger));
16-
addSubcommand(AdminProcureCommand(logger: logger));
16+
addSubcommand(AdminProcurePlanCommand(logger: logger));
1717
}
1818
}
1919

@@ -53,7 +53,7 @@ class AdminListProcuredCommand
5353
}
5454
}
5555

56-
enum AdminProcureOption<V> implements OptionDefinition<V> {
56+
enum AdminProcurePlanOption<V> implements OptionDefinition<V> {
5757
user(
5858
UserEmailOption(argPos: 0, mandatory: true),
5959
),
@@ -62,7 +62,7 @@ enum AdminProcureOption<V> implements OptionDefinition<V> {
6262
argName: 'name',
6363
argAbbrev: 'n',
6464
argPos: 1,
65-
helpText: 'The name of the product to procure.'
65+
helpText: 'The name of the plan to procure.'
6666
' Can be passed as the second argument.',
6767
mandatory: true,
6868
),
@@ -72,7 +72,7 @@ enum AdminProcureOption<V> implements OptionDefinition<V> {
7272
argName: 'version',
7373
argAbbrev: 'v',
7474
argPos: 2,
75-
helpText: 'The product version (latest if unspecified).'
75+
helpText: 'The plan version (latest if unspecified).'
7676
' Can be passed as the third argument.',
7777
min: 0,
7878
),
@@ -86,39 +86,40 @@ enum AdminProcureOption<V> implements OptionDefinition<V> {
8686
),
8787
);
8888

89-
const AdminProcureOption(this.option);
89+
const AdminProcurePlanOption(this.option);
9090

9191
@override
9292
final ConfigOptionBase<V> option;
9393
}
9494

95-
class AdminProcureCommand extends CloudCliCommand<AdminProcureOption> {
95+
class AdminProcurePlanCommand extends CloudCliCommand<AdminProcurePlanOption> {
9696
@override
97-
final name = 'procure';
97+
final name = 'procure-plan';
9898

9999
@override
100-
final description = 'Procure a product for an owner.\n'
101-
'By specifying the override flag, the product is procured '
100+
final description = 'Procure a plan for a user.\n'
101+
'By specifying the override flag, the plan is procured '
102102
'even if locked or the owner lacks allowance.';
103103

104-
AdminProcureCommand({required super.logger})
105-
: super(options: AdminProcureOption.values);
104+
AdminProcurePlanCommand({required super.logger})
105+
: super(options: AdminProcurePlanOption.values);
106106

107107
@override
108108
Future<void> runWithConfig(
109-
final Configuration<AdminProcureOption> commandConfig,
109+
final Configuration<AdminProcurePlanOption> commandConfig,
110110
) async {
111-
final userEmail = commandConfig.value(AdminProcureOption.user);
112-
final productName = commandConfig.value(AdminProcureOption.productName);
113-
final ver = commandConfig.optionalValue(AdminProcureOption.productVersion);
114-
final override = commandConfig.value(AdminProcureOption.overrideChecks);
111+
final userEmail = commandConfig.value(AdminProcurePlanOption.user);
112+
final productName = commandConfig.value(AdminProcurePlanOption.productName);
113+
final ver =
114+
commandConfig.optionalValue(AdminProcurePlanOption.productVersion);
115+
final override = commandConfig.value(AdminProcurePlanOption.overrideChecks);
115116

116-
await ProductAdminCommands.procureProduct(
117+
await ProductAdminCommands.procurePlan(
117118
runner.serviceProvider.cloudApiClient,
118119
logger: logger,
119120
userEmail: userEmail,
120-
productName: productName,
121-
productVersion: ver,
121+
planName: productName,
122+
planVersion: ver,
122123
overrideChecks: override,
123124
);
124125
}

serverpod_cloud_cli/lib/commands/admin/product_admin.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ abstract class ProductAdminCommands {
2626
table.writeLines(logger.line);
2727
}
2828

29-
static Future<void> procureProduct(
29+
static Future<void> procurePlan(
3030
final Client cloudApiClient, {
3131
required final CommandLogger logger,
3232
required final String userEmail,
33-
required final String productName,
34-
final int? productVersion,
33+
required final String planName,
34+
final int? planVersion,
3535
final bool? overrideChecks,
3636
}) async {
37-
await cloudApiClient.adminProcurement.procureProduct(
37+
await cloudApiClient.adminProcurement.procurePlan(
3838
userEmail: userEmail,
39-
productName: productName,
40-
productVersion: productVersion,
39+
planProductName: planName,
40+
planProductVersion: planVersion,
4141
overrideChecks: overrideChecks,
4242
);
4343

4444
logger.success(
45-
'The product has been procured for the user.',
45+
'The plan $planName has been procured for the user.',
4646
newParagraph: true,
4747
);
4848
}

serverpod_cloud_cli/test_integration/commands/admin/admin_product_procure_cmd_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void main() {
3131
test(
3232
'Given admin product procure command when instantiated then requires login',
3333
() {
34-
expect(AdminProcureCommand(logger: logger).requireLogin, isTrue);
34+
expect(AdminProcurePlanCommand(logger: logger).requireLogin, isTrue);
3535
});
3636

3737
group('Given authenticated', () {
@@ -42,10 +42,10 @@ void main() {
4242
group('when executing admin product procure', () {
4343
late Future commandResult;
4444
setUp(() async {
45-
when(() => client.adminProcurement.procureProduct(
45+
when(() => client.adminProcurement.procurePlan(
4646
userEmail: any(named: 'userEmail'),
47-
productName: any(named: 'productName'),
48-
productVersion: any(named: 'productVersion'),
47+
planProductName: any(named: 'planProductName'),
48+
planProductVersion: any(named: 'planProductVersion'),
4949
overrideChecks: any(named: 'overrideChecks'),
5050
)).thenAnswer(
5151
(final invocation) async => Future.value(),
@@ -54,7 +54,7 @@ void main() {
5454
commandResult = cli.run([
5555
'admin',
5656
'product',
57-
'procure',
57+
'procure-plan',
5858
'test@example.com',
5959
'test-plan',
6060
]);
@@ -70,7 +70,7 @@ void main() {
7070
expect(
7171
logger.successCalls.first,
7272
equalsSuccessCall(
73-
message: 'The product has been procured for the user.',
73+
message: 'The plan test-plan has been procured for the user.',
7474
newParagraph: true,
7575
),
7676
);

0 commit comments

Comments
 (0)