Skip to content

Commit b3ef206

Browse files
author
serverpod_cloud
committed
feat: 2b28934ed5cfd1a8e8f4dd08ee3fdcfe16b1b9fb
1 parent 30bcd46 commit b3ef206

3 files changed

Lines changed: 494 additions & 324 deletions

File tree

ground_control_client/lib/src/protocol/domains/capsules/models/capsule.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import '../../../features/environment_variables/models/environment_variable.dart
1616
as _i4;
1717
import '../../../features/custom_domain_name/models/custom_domain_name.dart'
1818
as _i5;
19+
import '../../../domains/capsules/models/capsule_resource_config.dart' as _i6;
1920

2021
/// Represents an infrastructure capsule instance (a deployment target).
2122
abstract class Capsule implements _i1.SerializableModel {
@@ -28,6 +29,7 @@ abstract class Capsule implements _i1.SerializableModel {
2829
this.project,
2930
this.environmentVariables,
3031
this.domainNames,
32+
this.resourceConfig,
3133
});
3234

3335
factory Capsule({
@@ -39,6 +41,7 @@ abstract class Capsule implements _i1.SerializableModel {
3941
_i3.Project? project,
4042
List<_i4.EnvironmentVariable>? environmentVariables,
4143
List<_i5.CustomDomainName>? domainNames,
44+
_i6.CapsuleResource? resourceConfig,
4245
}) = _CapsuleImpl;
4346

4447
factory Capsule.fromJson(Map<String, dynamic> jsonSerialization) {
@@ -61,6 +64,10 @@ abstract class Capsule implements _i1.SerializableModel {
6164
?.map(
6265
(e) => _i5.CustomDomainName.fromJson((e as Map<String, dynamic>)))
6366
.toList(),
67+
resourceConfig: jsonSerialization['resourceConfig'] == null
68+
? null
69+
: _i6.CapsuleResource.fromJson(
70+
(jsonSerialization['resourceConfig'] as Map<String, dynamic>)),
6471
);
6572
}
6673

@@ -89,6 +96,9 @@ abstract class Capsule implements _i1.SerializableModel {
8996
/// The domain names for this capsule.
9097
List<_i5.CustomDomainName>? domainNames;
9198

99+
/// The resource config for the capsule.
100+
_i6.CapsuleResource? resourceConfig;
101+
92102
/// Returns a shallow copy of this [Capsule]
93103
/// with some or all fields replaced by the given arguments.
94104
@_i1.useResult
@@ -101,6 +111,7 @@ abstract class Capsule implements _i1.SerializableModel {
101111
_i3.Project? project,
102112
List<_i4.EnvironmentVariable>? environmentVariables,
103113
List<_i5.CustomDomainName>? domainNames,
114+
_i6.CapsuleResource? resourceConfig,
104115
});
105116
@override
106117
Map<String, dynamic> toJson() {
@@ -116,6 +127,7 @@ abstract class Capsule implements _i1.SerializableModel {
116127
environmentVariables?.toJson(valueToJson: (v) => v.toJson()),
117128
if (domainNames != null)
118129
'domainNames': domainNames?.toJson(valueToJson: (v) => v.toJson()),
130+
if (resourceConfig != null) 'resourceConfig': resourceConfig?.toJson(),
119131
};
120132
}
121133

@@ -137,6 +149,7 @@ class _CapsuleImpl extends Capsule {
137149
_i3.Project? project,
138150
List<_i4.EnvironmentVariable>? environmentVariables,
139151
List<_i5.CustomDomainName>? domainNames,
152+
_i6.CapsuleResource? resourceConfig,
140153
}) : super._(
141154
id: id,
142155
name: name,
@@ -146,6 +159,7 @@ class _CapsuleImpl extends Capsule {
146159
project: project,
147160
environmentVariables: environmentVariables,
148161
domainNames: domainNames,
162+
resourceConfig: resourceConfig,
149163
);
150164

151165
/// Returns a shallow copy of this [Capsule]
@@ -161,6 +175,7 @@ class _CapsuleImpl extends Capsule {
161175
Object? project = _Undefined,
162176
Object? environmentVariables = _Undefined,
163177
Object? domainNames = _Undefined,
178+
Object? resourceConfig = _Undefined,
164179
}) {
165180
return Capsule(
166181
id: id is int? ? id : this.id,
@@ -176,6 +191,9 @@ class _CapsuleImpl extends Capsule {
176191
domainNames: domainNames is List<_i5.CustomDomainName>?
177192
? domainNames
178193
: this.domainNames?.map((e0) => e0.copyWith()).toList(),
194+
resourceConfig: resourceConfig is _i6.CapsuleResource?
195+
? resourceConfig
196+
: this.resourceConfig?.copyWith(),
179197
);
180198
}
181199
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
2+
/* To generate run: "serverpod generate" */
3+
4+
// ignore_for_file: implementation_imports
5+
// ignore_for_file: library_private_types_in_public_api
6+
// ignore_for_file: non_constant_identifier_names
7+
// ignore_for_file: public_member_api_docs
8+
// ignore_for_file: type_literal_in_constant_pattern
9+
// ignore_for_file: use_super_parameters
10+
11+
// ignore_for_file: no_leading_underscores_for_library_prefixes
12+
import 'package:serverpod_client/serverpod_client.dart' as _i1;
13+
import '../../../domains/capsules/models/capsule.dart' as _i2;
14+
15+
abstract class CapsuleResource implements _i1.SerializableModel {
16+
CapsuleResource._({
17+
this.id,
18+
required this.cloudCapsuleId,
19+
this.capsule,
20+
required this.computeSize,
21+
bool? computeScalingEnabled,
22+
required this.computeResourceQuota,
23+
}) : computeScalingEnabled = computeScalingEnabled ?? false;
24+
25+
factory CapsuleResource({
26+
int? id,
27+
required int cloudCapsuleId,
28+
_i2.Capsule? capsule,
29+
required String computeSize,
30+
bool? computeScalingEnabled,
31+
required String computeResourceQuota,
32+
}) = _CapsuleResourceImpl;
33+
34+
factory CapsuleResource.fromJson(Map<String, dynamic> jsonSerialization) {
35+
return CapsuleResource(
36+
id: jsonSerialization['id'] as int?,
37+
cloudCapsuleId: jsonSerialization['cloudCapsuleId'] as int,
38+
capsule: jsonSerialization['capsule'] == null
39+
? null
40+
: _i2.Capsule.fromJson(
41+
(jsonSerialization['capsule'] as Map<String, dynamic>)),
42+
computeSize: jsonSerialization['computeSize'] as String,
43+
computeScalingEnabled: jsonSerialization['computeScalingEnabled'] as bool,
44+
computeResourceQuota: jsonSerialization['computeResourceQuota'] as String,
45+
);
46+
}
47+
48+
/// The database id, set if the object has been inserted into the
49+
/// database or if it has been fetched from the database. Otherwise,
50+
/// the id will be null.
51+
int? id;
52+
53+
/// The foreign key to the capsule.
54+
int cloudCapsuleId;
55+
56+
/// The capsule this resource config belongs to.
57+
_i2.Capsule? capsule;
58+
59+
/// The size of the capsule compute.
60+
String computeSize;
61+
62+
/// Flag to enable horizontal scaling for the capsule compute.
63+
bool computeScalingEnabled;
64+
65+
/// The resource quota for the capsule compute.
66+
String computeResourceQuota;
67+
68+
/// Returns a shallow copy of this [CapsuleResource]
69+
/// with some or all fields replaced by the given arguments.
70+
@_i1.useResult
71+
CapsuleResource copyWith({
72+
int? id,
73+
int? cloudCapsuleId,
74+
_i2.Capsule? capsule,
75+
String? computeSize,
76+
bool? computeScalingEnabled,
77+
String? computeResourceQuota,
78+
});
79+
@override
80+
Map<String, dynamic> toJson() {
81+
return {
82+
if (id != null) 'id': id,
83+
'cloudCapsuleId': cloudCapsuleId,
84+
if (capsule != null) 'capsule': capsule?.toJson(),
85+
'computeSize': computeSize,
86+
'computeScalingEnabled': computeScalingEnabled,
87+
'computeResourceQuota': computeResourceQuota,
88+
};
89+
}
90+
91+
@override
92+
String toString() {
93+
return _i1.SerializationManager.encode(this);
94+
}
95+
}
96+
97+
class _Undefined {}
98+
99+
class _CapsuleResourceImpl extends CapsuleResource {
100+
_CapsuleResourceImpl({
101+
int? id,
102+
required int cloudCapsuleId,
103+
_i2.Capsule? capsule,
104+
required String computeSize,
105+
bool? computeScalingEnabled,
106+
required String computeResourceQuota,
107+
}) : super._(
108+
id: id,
109+
cloudCapsuleId: cloudCapsuleId,
110+
capsule: capsule,
111+
computeSize: computeSize,
112+
computeScalingEnabled: computeScalingEnabled,
113+
computeResourceQuota: computeResourceQuota,
114+
);
115+
116+
/// Returns a shallow copy of this [CapsuleResource]
117+
/// with some or all fields replaced by the given arguments.
118+
@_i1.useResult
119+
@override
120+
CapsuleResource copyWith({
121+
Object? id = _Undefined,
122+
int? cloudCapsuleId,
123+
Object? capsule = _Undefined,
124+
String? computeSize,
125+
bool? computeScalingEnabled,
126+
String? computeResourceQuota,
127+
}) {
128+
return CapsuleResource(
129+
id: id is int? ? id : this.id,
130+
cloudCapsuleId: cloudCapsuleId ?? this.cloudCapsuleId,
131+
capsule: capsule is _i2.Capsule? ? capsule : this.capsule?.copyWith(),
132+
computeSize: computeSize ?? this.computeSize,
133+
computeScalingEnabled:
134+
computeScalingEnabled ?? this.computeScalingEnabled,
135+
computeResourceQuota: computeResourceQuota ?? this.computeResourceQuota,
136+
);
137+
}
138+
}

0 commit comments

Comments
 (0)