Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
add missing builder methods to traffic-policy parcel
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Oct 9, 2024
1 parent 665959d commit 1851017
Showing 1 changed file with 55 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,36 @@ class SlaClassAction(BaseModel):
default=None, validation_alias="slaClass", serialization_alias="slaClass", description="slaClass"
)

@staticmethod
def from_params(
sla_name: Optional[UUID] = None,
preferred_color: Optional[List[TLOCColor]] = None,
preferred_color_group: Optional[UUID] = None,
preferred_remote_color: Optional[List[TLOCColor]] = None,
remote_color_restrict: Optional[bool] = None,
strict: Optional[bool] = None,
fallback_to_best_path: Optional[bool] = None,
) -> "SlaClassAction":
action = SlaClassAction()
action.sla_class = []
if sla_name is not None:
action.sla_class.append(SlaClass(sla_name=RefIdItem.from_uuid(sla_name)))
if preferred_color:
action.sla_class.append(SlaClass(preferred_color=Global[List[TLOCColor]](value=preferred_color)))
if preferred_color_group is not None:
action.sla_class.append(SlaClass(preferred_color_group=RefIdItem.from_uuid(preferred_color_group)))
if preferred_remote_color is not None:
action.sla_class.append(
SlaClass(preferred_remote_color=Global[List[TLOCColor]](value=preferred_remote_color))
)
if remote_color_restrict is not None:
action.sla_class.append(SlaClass(remote_color_restrict=Global[bool](value=remote_color_restrict)))
if strict is not None:
action.sla_class.append(SlaClass(strict=Global[bool](value=strict)))
if fallback_to_best_path is not None:
action.sla_class.append(SlaClass(fallback_to_best_path=Global[bool](value=fallback_to_best_path)))
return action


class BackupSlaPreferredColorAction(BaseModel):
model_config = ConfigDict(populate_by_name=True, extra="forbid")
Expand Down Expand Up @@ -952,8 +982,10 @@ def associate_appqoe_optimization_action(
action = AppqoeOptimizationAction(appqoe_optimization=appqoe_optimization)
self._insert_action(action)

def associate_backup_sla_preferred_color_action(self) -> None:
pass # TODO
def associate_backup_sla_preferred_color_action(self, tloc_colors: List[TLOCColor]) -> None:
self._insert_action(
BackupSlaPreferredColorAction(backup_sla_preferred_color=Global[List[TLOCColor]](value=tloc_colors))
)

def associate_cflowd_action(self, cflowd: bool) -> None:
self._insert_action(CflowdAction(cflowd=as_global(cflowd)))
Expand All @@ -962,7 +994,7 @@ def associate_cloud_probe_action(self) -> None:
pass # TODO

def associate_cloud_saas_action(self) -> None:
pass # TODO
self._insert_action(CloudSaasAction(cloud_saas=as_global(True)))

def associate_count_action(self, count: str) -> None:
self._insert_action(CountAction(count=as_global(count)))
Expand Down Expand Up @@ -1006,8 +1038,26 @@ def associate_set_action(self) -> None:
def associate_sig_action(self) -> None:
self._insert_action(SigAction(sig=as_global(True)))

def associate_sla_class_action(self) -> None:
pass # TODO
def associate_sla_class_action(
self,
sla_name: Optional[UUID] = None,
preferred_color: Optional[List[TLOCColor]] = None,
preferred_color_group: Optional[UUID] = None,
preferred_remote_color: Optional[List[TLOCColor]] = None,
remote_color_restrict: Optional[bool] = None,
strict: Optional[bool] = None,
fallback_to_best_path: Optional[bool] = None,
) -> None:
action = SlaClassAction.from_params(
sla_name=sla_name,
preferred_color=preferred_color,
preferred_color_group=preferred_color_group,
preferred_remote_color=preferred_remote_color,
remote_color_restrict=remote_color_restrict,
strict=strict,
fallback_to_best_path=fallback_to_best_path,
)
self._insert_action(action)

def associate_sse_action(self) -> None:
pass # TODO
Expand Down

0 comments on commit 1851017

Please sign in to comment.