cradle.sdk.types.common
1from __future__ import annotations 2 3from datetime import datetime 4from typing import Annotated, Literal, TypeAlias 5 6from pydantic import BaseModel, Field 7 8 9class AbstractResourceResponse(BaseModel): 10 id: int = Field(description="The unique identifier of the resource") 11 created_at: datetime = Field(description="The time at which the resource was created") 12 created_by: str = Field(description="The ID of the user who created the resource") 13 14 15class ArchivableResourceMixin(BaseModel): 16 archived_at: datetime | None = Field(default=None, description="The time at which the resource was archived") 17 archived_by: str | None = Field(default=None, description="The ID of the user who archived the resource") 18 19 20class BaseListResponse(BaseModel): 21 items: list[AbstractResourceResponse] = Field(description="The listed resources.") 22 cursor: str | None = Field( 23 description="Cursor with which the next page of entries can be retrieved. If no cursor is returned, no further pages exist." 24 ) 25 26 27class ContextProject(BaseModel): 28 kind: Literal["PROJECT"] = Field(default="PROJECT") 29 project_id: int 30 31 32class ContextRound(BaseModel): 33 kind: Literal["ROUND"] = Field(default="ROUND") 34 round_id: int 35 36 37class ContextWorkspace(BaseModel): 38 kind: Literal["WORKSPACE"] = Field(default="WORKSPACE") 39 40 41class ErrorResponseMixin(BaseModel): 42 """Mixin for resources that can return errors.""" 43 44 errors: list[str] = Field(default_factory=list, description="List of error messages associated with the resource.") 45 46 47class ListOptions(BaseModel): 48 limit: int = Field(default=100, description="Maximum number of items to return") 49 cursor: str | None = Field(default=None, description="Continuation token returned by the previous page's response") 50 order: Literal["ASC", "DESC"] = Field( 51 default="ASC", description="Whether to order the result ascending or descending" 52 ) 53 54 55class ImmutableResourceResponse(AbstractResourceResponse): 56 pass 57 58 59class ResourceResponse(AbstractResourceResponse): 60 updated_at: datetime = Field(description="The time at which the resource was last updated") 61 updated_by: str = Field(description="The ID of the user who last updated the resource") 62 63 64Context: TypeAlias = Annotated[ContextWorkspace | ContextProject | ContextRound, Field(discriminator="kind")]
class
AbstractResourceResponse(pydantic.main.BaseModel):
class
ArchivableResourceMixin(pydantic.main.BaseModel):
class
BaseListResponse(pydantic.main.BaseModel):
class
ContextProject(pydantic.main.BaseModel):
class
ContextRound(pydantic.main.BaseModel):
class
ContextWorkspace(pydantic.main.BaseModel):
class
ErrorResponseMixin(pydantic.main.BaseModel):
42class ErrorResponseMixin(BaseModel): 43 """Mixin for resources that can return errors.""" 44 45 errors: list[str] = Field(default_factory=list, description="List of error messages associated with the resource.")
Mixin for resources that can return errors.
class
ListOptions(pydantic.main.BaseModel):
48class ListOptions(BaseModel): 49 limit: int = Field(default=100, description="Maximum number of items to return") 50 cursor: str | None = Field(default=None, description="Continuation token returned by the previous page's response") 51 order: Literal["ASC", "DESC"] = Field( 52 default="ASC", description="Whether to order the result ascending or descending" 53 )
Inherited Members
60class ResourceResponse(AbstractResourceResponse): 61 updated_at: datetime = Field(description="The time at which the resource was last updated") 62 updated_by: str = Field(description="The ID of the user who last updated the resource")
Inherited Members
Context: TypeAlias =
Annotated[ContextWorkspace | ContextProject | ContextRound, FieldInfo(annotation=NoneType, required=True, discriminator='kind')]