@@ -230,12 +230,6 @@ def _print_log(message: str, prefix: str = '', color: str = '', output: str = ''
230230print_warning = lambda msg , output = '' , duration = '' : _print_log (msg , '⚠️ ' , BOLD_Y , output , duration , True )
231231print_val = lambda name , value , val_below = False : _print_log (f"{ name :<25} :{ '\n ' if val_below else ' ' } { value } " , '👉🏽 ' , BOLD_B )
232232
233- # Validation functions will raise ValueError if the value is not valid
234-
235- validate_http_verb = lambda val : HTTP_VERB (val )
236- validate_infrastructure = lambda val : INFRASTRUCTURE (val )
237- validate_sku = lambda val : APIM_SKU (val )
238-
239233def create_bicep_deployment_group (rg_name : str , rg_location : str , deployment : str | INFRASTRUCTURE , bicep_parameters : dict , bicep_parameters_file : str = 'params.json' ) -> Output :
240234 """
241235 Create a Bicep deployment in a resource group, writing parameters to a file and running the deployment.
@@ -355,7 +349,6 @@ def cleanup_infra_deployments(deployment: INFRASTRUCTURE, indexes: int | list[in
355349 deployment (INFRASTRUCTURE): The infrastructure deployment enum value.
356350 indexes (int | list[int] | None): A single index, a list of indexes, or None for no index.
357351 """
358- validate_infrastructure (deployment )
359352
360353 if indexes is None :
361354 indexes_list = [None ]
@@ -540,8 +533,6 @@ def get_infra_rg_name(deployment_name: INFRASTRUCTURE, index: int | None = None)
540533 str: The generated resource group name.
541534 """
542535
543- validate_infrastructure (deployment_name )
544-
545536 rg_name = f"apim-infra-{ deployment_name .value } "
546537
547538 if index is not None :
@@ -633,3 +624,23 @@ def run(command: str, ok_message: str = '', error_message: str = '', print_outpu
633624 print_message (ok_message if success else error_message , output_text if not success or print_output else "" , f"[{ int (minutes )} m:{ int (seconds )} s]" )
634625
635626 return Output (success , output_text )
627+
628+ # Validation functions will raise ValueError if the value is not valid
629+
630+ validate_http_verb = lambda val : HTTP_VERB (val )
631+ validate_sku = lambda val : APIM_SKU (val )
632+
633+ def validate_infrastructure (infra : INFRASTRUCTURE , supported_infras : list [INFRASTRUCTURE ]) -> bool :
634+ """
635+ Validate that the provided infrastructure is a supported infrastructure.
636+
637+ Args:
638+ infra (INFRASTRUCTURE): The infrastructure deployment enum value.
639+ supported_infras (list[INFRASTRUCTURE]): List of supported infrastructures.
640+
641+ Raises:
642+ ValueError: If the infrastructure is not supported.
643+ """
644+
645+ if infra not in supported_infras :
646+ raise ValueError (f"Unsupported infrastructure: { infra } . Supported infrastructures are: { ', ' .join ([i .value for i in supported_infras ])} " )
0 commit comments