3636]
3737
3838
39- class PydanticModel (BaseModel ):
39+ class PydanticRequestBaseModel (BaseModel ):
40+ """Base model representing IIB request."""
41+
4042 @classmethod
4143 def _get_all_keys_to_check_in_db (cls ):
4244 """Class that returns request specific keys to check."""
4345 raise NotImplementedError ("Not implemented" )
4446
4547 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+ """
4753 return [k for k in self ._get_all_keys_to_check_in_db () if getattr (self , k , None )]
4854
4955
50- class AddPydanticModel (PydanticModel ):
56+ class AddPydanticModel (PydanticRequestBaseModel ):
5157 """Datastructure of the request to /builds/add API point."""
5258
5359 add_arches : Optional [List [str ]] = None
@@ -76,18 +82,22 @@ class AddPydanticModel(PydanticModel):
7682 BeforeValidator (distribution_scope_lower ),
7783 ] = None
7884 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
8086 graph_update_mode : Optional [GRAPH_MODE_LITERAL ] = None
8187 organization : Optional [str ] = None # deprecated
8288 overwrite_from_index : Optional [bool ] = False
8389 overwrite_from_index_token : Optional [SecretStr ] = None
8490
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
8696
8797 # TODO remove this comment -> Validator from RequestIndexImageMixin class
8898 @model_validator (mode = 'after' )
8999 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 ."""
91101 validate_overwrite_params (self .overwrite_from_index , self .overwrite_from_index_token )
92102 return self
93103
@@ -138,7 +148,7 @@ def _get_all_keys_to_check_in_db(self):
138148 return ["binary_image" , "bundles" , "deprecation_list" , "from_index" ]
139149
140150
141- class RmPydanticModel (PydanticModel ):
151+ class RmPydanticModel (PydanticRequestBaseModel ):
142152 """Datastructure of the request to /builds/rm API point."""
143153
144154 add_arches : Optional [List [str ]] = None
@@ -151,16 +161,24 @@ class RmPydanticModel(PydanticModel):
151161 Optional [DISTRIBUTION_SCOPE_LITERAL ],
152162 BeforeValidator (distribution_scope_lower ),
153163 ] = None
154- from_index : Annotated [str , AfterValidator (image_format_check )]
164+ from_index : Annotated [Optional [ str ] , AfterValidator (image_format_check )] = None
155165 operators : Annotated [List [str ], AfterValidator (length_validator )]
156166 overwrite_from_index : Optional [bool ] = False
157167 overwrite_from_index_token : Optional [SecretStr ] = None
158168
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
160174
161175 @model_validator (mode = 'after' )
162176 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+ )
164182 return self
165183
166184 def get_json_for_request (self ):
@@ -180,19 +198,30 @@ def _get_all_keys_to_check_in_db(self):
180198
181199
182200class AddRmBatchPydanticModel (BaseModel ):
201+ """Datastructure of the request to /builds/add-rm-batch API point."""
202+
183203 annotations : Dict [str , Any ]
184204 build_requests : List [Union [AddPydanticModel , RmPydanticModel ]]
185205
186206
187207class RegistryAuth (BaseModel ):
208+ """Datastructure representing private registry token."""
209+
188210 auth : SecretStr
189211
190212
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+
192221 auths : Annotated [Dict [SecretStr , RegistryAuth ], AfterValidator (length_validator )]
193222
194223
195- class RegenerateBundlePydanticModel (PydanticModel ):
224+ class RegenerateBundlePydanticModel (PydanticRequestBaseModel ):
196225 """Datastructure of the request to /builds/regenerate-bundle API point."""
197226
198227 # BUNDLE_IMAGE, from_bundle_image_resolved, build_tags?
@@ -213,12 +242,14 @@ def _get_all_keys_to_check_in_db(self):
213242
214243
215244class RegenerateBundleBatchPydanticModel (BaseModel ):
245+ """Datastructure of the request to /builds/regenerate-bundle-batch API point."""
246+
216247 build_requests : List [RegenerateBundlePydanticModel ]
217248 annotations : Dict [str , Any ]
218249
219250
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."""
222253
223254 binary_image : Annotated [
224255 Optional [str ],
@@ -245,11 +276,13 @@ class MergeIndexImagePydanticModel(PydanticModel):
245276
246277 @model_validator (mode = 'after' )
247278 def verify_graph_update_mode_with_target_index (self ) -> 'MergeIndexImagePydanticModel' :
279+ """Validate graph_update_mode with target_index param combination."""
248280 validate_graph_mode_index_image (self .graph_update_mode , self .target_index )
249281 return self
250282
251283 @model_validator (mode = 'after' )
252284 def verify_overwrite_from_index_token (self ) -> 'MergeIndexImagePydanticModel' :
285+ """Validate overwrite_target_index with overwrite_target_index_token param combination."""
253286 validate_overwrite_params (
254287 self .overwrite_target_index ,
255288 self .overwrite_target_index_token ,
@@ -274,8 +307,8 @@ def _get_all_keys_to_check_in_db(self):
274307 ]
275308
276309
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."""
279312
280313 binary_image : Annotated [
281314 Optional [str ],
@@ -302,7 +335,9 @@ def _get_all_keys_to_check_in_db(self):
302335 return ["binary_image" , "from_index" ]
303336
304337
305- class RecursiveRelatedBundlesPydanticModel (PydanticModel ):
338+ class RecursiveRelatedBundlesPydanticModel (PydanticRequestBaseModel ):
339+ """Datastructure of the request to /builds/recursive-related-bundles API point."""
340+
306341 organization : Optional [str ] = None
307342 parent_bundle_image : Annotated [
308343 str ,
@@ -322,7 +357,9 @@ def _get_all_keys_to_check_in_db(self):
322357 return ["parent_bundle_image" ]
323358
324359
325- class FbcOperationsPydanticModel (PydanticModel ):
360+ class FbcOperationsPydanticModel (PydanticRequestBaseModel ):
361+ """Datastructure of the request to /builds/fbc-operations API point."""
362+
326363 add_arches : Optional [List [str ]] = []
327364 binary_image : Annotated [
328365 Optional [str ],
@@ -357,6 +394,7 @@ class FbcOperationsPydanticModel(PydanticModel):
357394
358395 @model_validator (mode = 'after' )
359396 def verify_overwrite_from_index_token (self ) -> 'FbcOperationsPydanticModel' :
397+ """Validate overwrite_from_index and overwrite_from_index_token param combination."""
360398 validate_overwrite_params (self .overwrite_from_index , self .overwrite_from_index_token )
361399 return self
362400
0 commit comments