diff --git a/gso/products/product_blocks/layer_2_circuit.py b/gso/products/product_blocks/layer_2_circuit.py index 854d58d9b77ef07ebe9ab379c1aedb3027576dce..efa14953221f136806b12d3e18dec32cf6ce9459 100644 --- a/gso/products/product_blocks/layer_2_circuit.py +++ b/gso/products/product_blocks/layer_2_circuit.py @@ -1,5 +1,6 @@ """Layer 2 Circuit product block.""" +from collections.abc import Sequence from typing import Annotated, TypeVar from annotated_types import Len @@ -51,7 +52,7 @@ Layer2CircuitSideBlockType = TypeVar( ) Layer2CircuitSides = Annotated[ - list[Layer2CircuitSideBlockType], + Sequence[Layer2CircuitSideBlockType], AfterValidator(validate_unique_list), Len(min_length=2, max_length=2), Doc("A list of two Layer 2 Circuit sides."), diff --git a/gso/workflows/l2_circuit/create_layer_2_circuit.py b/gso/workflows/l2_circuit/create_layer_2_circuit.py index f30633cf918ffc0cfa95558e87ba318926137917..27de16e4ec639eafee27a590db630c93618e47a0 100644 --- a/gso/workflows/l2_circuit/create_layer_2_circuit.py +++ b/gso/workflows/l2_circuit/create_layer_2_circuit.py @@ -52,12 +52,6 @@ def initial_input_generator(product_name: str) -> FormGenerator: class Layer2CircuitServiceSidesPage(FormPage): model_config = ConfigDict(title=f"{product_name} - Configure Edge Ports") - vlan_range_label: Label | None = Field(None, exclude=True) - vlan_range_lower_bound: VLAN_ID | None = None - vlan_range_upper_bound: VLAN_ID | None = None - - policer_bandwidth: BandwidthString | None = None - if initial_user_input.layer_2_circuit_type == Layer2CircuitType.TAGGED: vlan_range_label: Label = Field("Please set a VLAN range, bounds including.", exclude=True) vlan_range_lower_bound: VLAN_ID @@ -79,6 +73,22 @@ def initial_input_generator(product_name: str) -> FormGenerator: side_divider: Divider = Field(None, exclude=True) layer_2_circuit_side_b: Layer2CircuitSideSelection + def __init__(self, **data: Any): + """Initialize fields based on user input conditions.""" + super().__init__(**data) + if initial_user_input.layer_2_circuit_type == Layer2CircuitType.TAGGED: + self.vlan_range_label = Field("Please set a VLAN range, bounds including.", exclude=True) + self.vlan_range_lower_bound = VLAN_ID() + self.vlan_range_upper_bound = VLAN_ID() + else: + self.vlan_range_lower_bound = ReadOnlyField(None, default_type=int) + self.vlan_range_upper_bound = ReadOnlyField(None, default_type=int) + + if initial_user_input.policer_enabled: + self.policer_bandwidth = BandwidthString() + else: + self.policer_bandwidth = ReadOnlyField(None, default_type=int) + layer_2_circuit_input = yield Layer2CircuitServiceSidesPage return {"product_name": product_name} | initial_user_input.model_dump() | layer_2_circuit_input.model_dump()