Skip to content

Схемы, связанные с неймспейсом(пространством имен)

NamespaceResponseV1

Bases: BaseModel

Namespace response.

Source code in horizon/commons/schemas/v1/namespace.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class NamespaceResponseV1(BaseModel):
    """Namespace response."""

    id: int = Field(description="Namespace id")
    name: str = Field(description="Namespace name, unique in the entire database")
    description: str = Field(description="Namespace description")
    owned_by: str = Field(description="The namespace owner")
    changed_at: datetime = Field(description="Timestamp of last change of the namespace data")
    changed_by: Optional[str] = Field(default=None, description="Latest user who changed the namespace data")

    class Config:
        if pydantic_version >= "2":
            from_attributes = True
        else:
            orm_mode = True

NamespacePaginateQueryV1

Bases: PaginateQueryV1

Query params for namespace pagination request.

Source code in horizon/commons/schemas/v1/namespace.py
40
41
42
43
class NamespacePaginateQueryV1(PaginateQueryV1):
    """Query params for namespace pagination request."""

    name: Optional[str] = Field(default=None, min_length=1, max_length=MAX_NAME_LENGTH)

NamespaceCreateRequestV1

Bases: BaseModel

Request body for namespace creation request.

Source code in horizon/commons/schemas/v1/namespace.py
48
49
50
51
52
class NamespaceCreateRequestV1(BaseModel):
    """Request body for namespace creation request."""

    name: str = Field(min_length=1, max_length=MAX_NAME_LENGTH)
    description: str = ""

NamespaceUpdateRequestV1

Bases: BaseModel

Request body for namespace update request.

If field value is not set, it will not be updated.

Source code in horizon/commons/schemas/v1/namespace.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class NamespaceUpdateRequestV1(BaseModel):
    """Request body for namespace update request.

    If field value is not set, it will not be updated.
    """

    name: str = Field(default=Unset(), min_length=1, max_length=MAX_NAME_LENGTH)  # type: ignore[assignment]
    description: str = Unset()  # type: ignore[assignment]

    class Config:
        arbitrary_types_allowed = True

    @root_validator(skip_on_failure=True)
    def _any_field_set(cls, values):  # noqa: N805
        """Validate that at least one field is set."""
        values_set = {k for k, v in values.items() if not isinstance(v, Unset)}
        if not values_set:
            msg = "At least one field must be set."
            raise ValueError(msg)
        return values