36
36
]
37
37
38
38
39
- class PydanticModel (BaseModel ):
39
+ class PydanticRequestBaseModel (BaseModel ):
40
+ """Base model representing IIB request."""
41
+
40
42
@classmethod
41
43
def _get_all_keys_to_check_in_db (cls ):
42
44
"""Class that returns request specific keys to check."""
43
45
raise NotImplementedError ("Not implemented" )
44
46
45
47
def get_keys_to_check_in_db (self ):
46
- """Filter keys, which need to be checked in db. Return only a keys that are set to values."""
48
+ """
49
+ Filter keys, which need to be checked in db.
50
+
51
+ Return only a keys that are set to values.
52
+ """
47
53
return [k for k in self ._get_all_keys_to_check_in_db () if getattr (self , k , None )]
48
54
49
55
50
- class AddPydanticModel (PydanticModel ):
56
+ class AddPydanticModel (PydanticRequestBaseModel ):
51
57
"""Datastructure of the request to /builds/add API point."""
52
58
53
59
add_arches : Optional [List [str ]] = None
@@ -76,18 +82,22 @@ class AddPydanticModel(PydanticModel):
76
82
BeforeValidator (distribution_scope_lower ),
77
83
] = None
78
84
force_backport : Optional [bool ] = False # deprecated
79
- from_index : Annotated [str , AfterValidator (image_format_check )]
85
+ from_index : Annotated [Optional [ str ] , AfterValidator (image_format_check )] = None
80
86
graph_update_mode : Optional [GRAPH_MODE_LITERAL ] = None
81
87
organization : Optional [str ] = None # deprecated
82
88
overwrite_from_index : Optional [bool ] = False
83
89
overwrite_from_index_token : Optional [SecretStr ] = None
84
90
85
- _from_index_add_arches_check = model_validator (mode = 'after' )(from_index_add_arches )
91
+ @model_validator (mode = 'after' )
92
+ def verify_from_index_add_arches_combination (self ) -> 'AddPydanticModel' :
93
+ """Check the 'overwrite_from_index' parameter with 'overwrite_from_index_token' param."""
94
+ from_index_add_arches (self .from_index , self .add_arches )
95
+ return self
86
96
87
97
# TODO remove this comment -> Validator from RequestIndexImageMixin class
88
98
@model_validator (mode = 'after' )
89
99
def verify_overwrite_from_index_token (self ) -> 'AddPydanticModel' :
90
- """Check the 'overwrite_from_index' parameter in combination with 'overwrite_from_index_token' parameter ."""
100
+ """Check the 'overwrite_from_index' parameter with 'overwrite_from_index_token' param ."""
91
101
validate_overwrite_params (self .overwrite_from_index , self .overwrite_from_index_token )
92
102
return self
93
103
@@ -138,7 +148,7 @@ def _get_all_keys_to_check_in_db(self):
138
148
return ["binary_image" , "bundles" , "deprecation_list" , "from_index" ]
139
149
140
150
141
- class RmPydanticModel (PydanticModel ):
151
+ class RmPydanticModel (PydanticRequestBaseModel ):
142
152
"""Datastructure of the request to /builds/rm API point."""
143
153
144
154
add_arches : Optional [List [str ]] = None
@@ -151,16 +161,24 @@ class RmPydanticModel(PydanticModel):
151
161
Optional [DISTRIBUTION_SCOPE_LITERAL ],
152
162
BeforeValidator (distribution_scope_lower ),
153
163
] = None
154
- from_index : Annotated [str , AfterValidator (image_format_check )]
164
+ from_index : Annotated [Optional [ str ] , AfterValidator (image_format_check )] = None
155
165
operators : Annotated [List [str ], AfterValidator (length_validator )]
156
166
overwrite_from_index : Optional [bool ] = False
157
167
overwrite_from_index_token : Optional [SecretStr ] = None
158
168
159
- _from_index_add_arches_check = model_validator (mode = 'after' )(from_index_add_arches )
169
+ @model_validator (mode = 'after' )
170
+ def verify_from_index_add_arches_combination (self ) -> 'AddPydanticModel' :
171
+ """Check the 'overwrite_from_index' parameter with 'overwrite_from_index_token' param."""
172
+ from_index_add_arches (self .from_index , self .add_arches )
173
+ return self
160
174
161
175
@model_validator (mode = 'after' )
162
176
def verify_overwrite_from_index_token (self ) -> 'RmPydanticModel' :
163
- validate_overwrite_params (self .overwrite_from_index , self .overwrite_from_index_token )
177
+ """Validate overwrite_from_index and overwrite_from_index_token param combination."""
178
+ validate_overwrite_params (
179
+ self .overwrite_from_index ,
180
+ self .overwrite_from_index_token ,
181
+ )
164
182
return self
165
183
166
184
def get_json_for_request (self ):
@@ -180,19 +198,30 @@ def _get_all_keys_to_check_in_db(self):
180
198
181
199
182
200
class AddRmBatchPydanticModel (BaseModel ):
201
+ """Datastructure of the request to /builds/add-rm-batch API point."""
202
+
183
203
annotations : Dict [str , Any ]
184
204
build_requests : List [Union [AddPydanticModel , RmPydanticModel ]]
185
205
186
206
187
207
class RegistryAuth (BaseModel ):
208
+ """Datastructure representing private registry token."""
209
+
188
210
auth : SecretStr
189
211
190
212
191
- class RegistryAuths (BaseModel ): # is {"auths":{}} allowed?
213
+ class RegistryAuths (BaseModel ):
214
+ """
215
+ Datastructure used within recursive-related-bundles.
216
+
217
+ Provide the dockerconfig.json for authentication to private registries.
218
+ Non-auth information in the dockerconfig.json is not allowed.
219
+ """
220
+
192
221
auths : Annotated [Dict [SecretStr , RegistryAuth ], AfterValidator (length_validator )]
193
222
194
223
195
- class RegenerateBundlePydanticModel (PydanticModel ):
224
+ class RegenerateBundlePydanticModel (PydanticRequestBaseModel ):
196
225
"""Datastructure of the request to /builds/regenerate-bundle API point."""
197
226
198
227
# BUNDLE_IMAGE, from_bundle_image_resolved, build_tags?
@@ -213,12 +242,14 @@ def _get_all_keys_to_check_in_db(self):
213
242
214
243
215
244
class RegenerateBundleBatchPydanticModel (BaseModel ):
245
+ """Datastructure of the request to /builds/regenerate-bundle-batch API point."""
246
+
216
247
build_requests : List [RegenerateBundlePydanticModel ]
217
248
annotations : Dict [str , Any ]
218
249
219
250
220
- class MergeIndexImagePydanticModel (PydanticModel ):
221
- """Datastructure of the request to /builds/regenerate-bundle API point."""
251
+ class MergeIndexImagePydanticModel (PydanticRequestBaseModel ):
252
+ """Datastructure of the request to /builds/merge-index-image API point."""
222
253
223
254
binary_image : Annotated [
224
255
Optional [str ],
@@ -245,11 +276,13 @@ class MergeIndexImagePydanticModel(PydanticModel):
245
276
246
277
@model_validator (mode = 'after' )
247
278
def verify_graph_update_mode_with_target_index (self ) -> 'MergeIndexImagePydanticModel' :
279
+ """Validate graph_update_mode with target_index param combination."""
248
280
validate_graph_mode_index_image (self .graph_update_mode , self .target_index )
249
281
return self
250
282
251
283
@model_validator (mode = 'after' )
252
284
def verify_overwrite_from_index_token (self ) -> 'MergeIndexImagePydanticModel' :
285
+ """Validate overwrite_target_index with overwrite_target_index_token param combination."""
253
286
validate_overwrite_params (
254
287
self .overwrite_target_index ,
255
288
self .overwrite_target_index_token ,
@@ -274,8 +307,8 @@ def _get_all_keys_to_check_in_db(self):
274
307
]
275
308
276
309
277
- class CreateEmptyIndexPydanticModel (PydanticModel ):
278
- """Datastructure of the request to /builds/regenerate-bundle API point."""
310
+ class CreateEmptyIndexPydanticModel (PydanticRequestBaseModel ):
311
+ """Datastructure of the request to /builds/create-empty-index API point."""
279
312
280
313
binary_image : Annotated [
281
314
Optional [str ],
@@ -302,7 +335,9 @@ def _get_all_keys_to_check_in_db(self):
302
335
return ["binary_image" , "from_index" ]
303
336
304
337
305
- class RecursiveRelatedBundlesPydanticModel (PydanticModel ):
338
+ class RecursiveRelatedBundlesPydanticModel (PydanticRequestBaseModel ):
339
+ """Datastructure of the request to /builds/recursive-related-bundles API point."""
340
+
306
341
organization : Optional [str ] = None
307
342
parent_bundle_image : Annotated [
308
343
str ,
@@ -322,7 +357,9 @@ def _get_all_keys_to_check_in_db(self):
322
357
return ["parent_bundle_image" ]
323
358
324
359
325
- class FbcOperationsPydanticModel (PydanticModel ):
360
+ class FbcOperationsPydanticModel (PydanticRequestBaseModel ):
361
+ """Datastructure of the request to /builds/fbc-operations API point."""
362
+
326
363
add_arches : Optional [List [str ]] = []
327
364
binary_image : Annotated [
328
365
Optional [str ],
@@ -357,6 +394,7 @@ class FbcOperationsPydanticModel(PydanticModel):
357
394
358
395
@model_validator (mode = 'after' )
359
396
def verify_overwrite_from_index_token (self ) -> 'FbcOperationsPydanticModel' :
397
+ """Validate overwrite_from_index and overwrite_from_index_token param combination."""
360
398
validate_overwrite_params (self .overwrite_from_index , self .overwrite_from_index_token )
361
399
return self
362
400
0 commit comments