Skip to content
Snippets Groups Projects

correct typing and fix a bug

Merged Mohammad Torkashvand requested to merge refactor/improve-lat-lon-validation into develop
All threads resolved!
Files
5
"""The product block that describes a site subscription."""
"""The product block that describes a site subscription."""
import re
from typing import Optional
from typing import Optional
from orchestrator.domain.base import ProductBlockModel
from orchestrator.domain.base import ProductBlockModel
from orchestrator.types import SubscriptionLifecycle, strEnum
from orchestrator.types import SubscriptionLifecycle, strEnum
from pydantic import ConstrainedStr
 
from gso.schemas.types import LatitudeCoordinate, LongitudeCoordinate
class SiteTier(strEnum):
class SiteTier(strEnum):
@@ -20,15 +20,6 @@ class SiteTier(strEnum):
@@ -20,15 +20,6 @@ class SiteTier(strEnum):
TIER4 = 4
TIER4 = 4
class SnmpCoordinate(ConstrainedStr):
"""An {term}`SNMP` coordinate, modeled as a constrained string.
The coordinate must match the format of `1.35`, `-123.456`, etc.
"""
regex = re.compile(r"^-?\d{1,3}\.\d+$")
class SiteBlockInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INITIAL], product_block_name="SiteBlock"):
class SiteBlockInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INITIAL], product_block_name="SiteBlock"):
"""A site that's currently inactive, see {class}`SiteBlock`."""
"""A site that's currently inactive, see {class}`SiteBlock`."""
@@ -36,8 +27,8 @@ class SiteBlockInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INIT
@@ -36,8 +27,8 @@ class SiteBlockInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INIT
site_city: Optional[str] = None
site_city: Optional[str] = None
site_country: Optional[str] = None
site_country: Optional[str] = None
site_country_code: Optional[str] = None
site_country_code: Optional[str] = None
site_latitude: Optional[SnmpCoordinate] = None
site_latitude: Optional[LatitudeCoordinate] = None
site_longitude: Optional[SnmpCoordinate] = None
site_longitude: Optional[LongitudeCoordinate] = None
site_internal_id: Optional[int] = None
site_internal_id: Optional[int] = None
site_bgp_community_id: Optional[int] = None
site_bgp_community_id: Optional[int] = None
site_tier: Optional[SiteTier] = None
site_tier: Optional[SiteTier] = None
@@ -51,8 +42,8 @@ class SiteBlockProvisioning(SiteBlockInactive, lifecycle=[SubscriptionLifecycle.
@@ -51,8 +42,8 @@ class SiteBlockProvisioning(SiteBlockInactive, lifecycle=[SubscriptionLifecycle.
site_city: Optional[str] = None
site_city: Optional[str] = None
site_country: Optional[str] = None
site_country: Optional[str] = None
site_country_code: Optional[str] = None
site_country_code: Optional[str] = None
site_latitude: Optional[SnmpCoordinate] = None
site_latitude: Optional[LatitudeCoordinate] = None
site_longitude: Optional[SnmpCoordinate] = None
site_longitude: Optional[LongitudeCoordinate] = None
site_internal_id: Optional[int] = None
site_internal_id: Optional[int] = None
site_bgp_community_id: Optional[int] = None
site_bgp_community_id: Optional[int] = None
site_tier: Optional[SiteTier] = None
site_tier: Optional[SiteTier] = None
@@ -72,9 +63,9 @@ class SiteBlock(SiteBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE])
@@ -72,9 +63,9 @@ class SiteBlock(SiteBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE])
site_country_code: str
site_country_code: str
"""The code of the corresponding country. This is also used for the {term}`FQDN`, following the example given for
"""The code of the corresponding country. This is also used for the {term}`FQDN`, following the example given for
the site name, the country code would end up in the Y position."""
the site name, the country code would end up in the Y position."""
site_latitude: SnmpCoordinate
site_latitude: LatitudeCoordinate
"""The latitude of the site, used for {term}`SNMP` purposes."""
"""The latitude of the site, used for {term}`SNMP` purposes."""
site_longitude: SnmpCoordinate
site_longitude: LongitudeCoordinate
"""Similar to the latitude, the longitude of a site."""
"""Similar to the latitude, the longitude of a site."""
site_internal_id: int
site_internal_id: int
"""The internal ID used within GÉANT to denote a site."""
"""The internal ID used within GÉANT to denote a site."""
Loading