Skip to content

Locator

sereto.models.locator

DomainLocatorModel

Bases: SeretoBaseModel

Model representing a domain locator.

Attributes:

Name Type Description
type Literal['domain']

The discriminator for the locator type, which is always "domain".

value str

The domain of the locator.

description str | None

Optional description of the domain locator.

Source code in sereto/models/locator.py
37
38
39
40
41
42
43
44
45
46
47
48
class DomainLocatorModel(SeretoBaseModel):
    """Model representing a domain locator.

    Attributes:
        type: The discriminator for the locator type, which is always "domain".
        value: The domain of the locator.
        description: Optional description of the domain locator.
    """

    type: Literal["domain"] = "domain"
    value: str  # Domain as a string
    description: str | None = None

FileLocatorModel

Bases: SeretoBaseModel

Model representing a file locator.

Attributes:

Name Type Description
type Literal['file']

The discriminator for the locator type, which is always "file".

value str

The path to the file, may contain specific line.

description str | None

Optional description of the file locator.

Source code in sereto/models/locator.py
65
66
67
68
69
70
71
72
73
74
75
76
class FileLocatorModel(SeretoBaseModel):
    """Model representing a file locator.

    Attributes:
        type: The discriminator for the locator type, which is always "file".
        value: The path to the file, may contain specific line.
        description: Optional description of the file locator.
    """

    type: Literal["file"] = "file"
    value: str  # Path to the file
    description: str | None = None

HostnameLocatorModel

Bases: SeretoBaseModel

Model representing a hostname locator.

Attributes:

Name Type Description
type Literal['hostname']

The discriminator for the locator type, which is always "hostname".

value str

The hostname of the locator.

description str | None

Optional description of the hostname locator.

Source code in sereto/models/locator.py
23
24
25
26
27
28
29
30
31
32
33
34
class HostnameLocatorModel(SeretoBaseModel):
    """Model representing a hostname locator.

    Attributes:
        type: The discriminator for the locator type, which is always "hostname".
        value: The hostname of the locator.
        description: Optional description of the hostname locator.
    """

    type: Literal["hostname"] = "hostname"
    value: str  # Hostname as a string
    description: str | None = None

IpLocatorModel

Bases: SeretoBaseModel

Model representing an IP locator.

Attributes:

Name Type Description
type Literal['ip']

The discriminator for the locator type, which is always "ip".

value IPvAnyAddress | IPvAnyNetwork

The IP address or network of the locator.

description str | None

Optional description of the IP locator.

Source code in sereto/models/locator.py
51
52
53
54
55
56
57
58
59
60
61
62
class IpLocatorModel(SeretoBaseModel):
    """Model representing an IP locator.

    Attributes:
        type: The discriminator for the locator type, which is always "ip".
        value: The IP address or network of the locator.
        description: Optional description of the IP locator.
    """

    type: Literal["ip"] = "ip"
    value: IPvAnyAddress | IPvAnyNetwork
    description: str | None = None

UrlLocatorModel

Bases: SeretoBaseModel

Model representing a URL locator.

Attributes:

Name Type Description
type Literal['url']

The discriminator for the locator type, which is always "url".

value AnyUrl

The URL of the locator.

description str | None

Optional description of the URL locator.

Source code in sereto/models/locator.py
 9
10
11
12
13
14
15
16
17
18
19
20
class UrlLocatorModel(SeretoBaseModel):
    """Model representing a URL locator.

    Attributes:
        type: The discriminator for the locator type, which is always "url".
        value: The URL of the locator.
        description: Optional description of the URL locator.
    """

    type: Literal["url"] = "url"
    value: AnyUrl
    description: str | None = None

dump_locators_to_toml(locators)

Dump locators to a TOML string.

Parameters:

Name Type Description Default
locators Iterable[LocatorModel]

An iterable of LocatorModel instances.

required

Returns:

Type Description
str

A TOML formatted string representing the locators.

Source code in sereto/models/locator.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
@validate_call
def dump_locators_to_toml(locators: Iterable[LocatorModel]) -> str:
    """Dump locators to a TOML string.

    Args:
        locators: An iterable of LocatorModel instances.

    Returns:
        A TOML formatted string representing the locators.
    """
    if len(loc_list := list(locators)) == 0:
        return "[]"

    lines: list[str] = []
    for loc in loc_list:
        desc = f', description="{loc.description}"' if loc.description else ""
        lines.append(f'{{type="{loc.type}", value="{loc.value}"{desc}}},')
    return "[\n    " + "\n    ".join(lines) + "\n]"