Skip to content

Response

buffy.buffyserver.api.v1.models.Response

Bases: BaseModel

Metadata object for a request response.

HINT: This is pydantic model. Every class-attribute is also a parameter

Source code in buffy/buffyserver/api/v1/models.py
class Response(BaseModel):
    """Metadata object for a request response.

    **HINT**: This is pydantic model. Every `class-attribute` is also a `parameter`
    """

    id: str = None
    request_id: str
    version: str
    """A compact date string, declarating the versions name"""
    previous_version: Optional[str] = None
    """If there is a predating version, you can find the version name here"""
    next_version: Optional[str] = None
    """If there is a newer version, you can find the version name here"""
    status: Literal["wait", "in_progress", "ready", "duplicate", "failed"]
    """State of the reponses download on Buffy-server side. 
    'wait': The request is registered by the backend, but no actions have been initiated  
    'in_progress': The backend is running the download of the response  
    'ready': The response is cached and can be picked up by a client  
    'duplicate': The response is cached but equal to the previous cached response. It will be deleted and should not be used by a client  
    'failed: The response download failed. The the 'Response.download_stats.error' field for more details."""
    content_download_path: Optional[str] = None
    """Path to downlaod the responses content from the Buffy-server API. No base domain included!"""
    cached_datetime_utc: Optional[datetime.datetime] = None
    """Moment when Buffy-server finished the download"""
    request_datetime_utc: Optional[datetime.datetime] = None
    """Moment when a client requested the file. This is not appliable to all strategies."""
    # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
    pinned: Optional[bool] = False
    """!WIP!: A pinned response will not be deleted by the garbage collector if `Request.cache_configuration.max_cached_unpinned_versions` is reached."""
    tags: List[str] = []
    """!EXPERIMENTAL!: Clients can add tags to a reponse to manage multiple versions"""
    download_stats: ResponseDownloadStats = None
    """Statistics about the downlaod by Buffy-server"""
    content_attributes: ResponseContentAttributes = None
    """Attributes the download could gather about the content. mostly based on HTTP headers"""
    content_hash_hex: str = None
    """A hex hash of the response content. The hash alg is defined in `Request.validation_hash_type`"""
    pinned_until_utc: Optional[datetime.datetime] = None
    """While handling a certain response we can prevent the server from accidantly garbage collect the reponse by providing a temporary lock to it"""

    @property
    def is_pinned(self):
        if self.pinned or (
            self.pinned_until_utc and self.pinned_until_utc > datetime.datetime.utcnow()
        ):
            return True
        else:
            return False

cached_datetime_utc: Optional[datetime.datetime] = None class-attribute

Moment when Buffy-server finished the download

content_attributes: ResponseContentAttributes = None class-attribute

Attributes the download could gather about the content. mostly based on HTTP headers

content_download_path: Optional[str] = None class-attribute

Path to downlaod the responses content from the Buffy-server API. No base domain included!

content_hash_hex: str = None class-attribute

A hex hash of the response content. The hash alg is defined in Request.validation_hash_type

download_stats: ResponseDownloadStats = None class-attribute

Statistics about the downlaod by Buffy-server

next_version: Optional[str] = None class-attribute

If there is a newer version, you can find the version name here

pinned: Optional[bool] = False class-attribute

!WIP!: A pinned response will not be deleted by the garbage collector if Request.cache_configuration.max_cached_unpinned_versions is reached.

pinned_until_utc: Optional[datetime.datetime] = None class-attribute

While handling a certain response we can prevent the server from accidantly garbage collect the reponse by providing a temporary lock to it

previous_version: Optional[str] = None class-attribute

If there is a predating version, you can find the version name here

request_datetime_utc: Optional[datetime.datetime] = None class-attribute

Moment when a client requested the file. This is not appliable to all strategies.

status: Literal['wait', 'in_progress', 'ready', 'duplicate', 'failed'] class-attribute

State of the reponses download on Buffy-server side. 'wait': The request is registered by the backend, but no actions have been initiated
'in_progress': The backend is running the download of the response
'ready': The response is cached and can be picked up by a client
'duplicate': The response is cached but equal to the previous cached response. It will be deleted and should not be used by a client
'failed: The response download failed. The the 'Response.download_stats.error' field for more details.

tags: List[str] = [] class-attribute

!EXPERIMENTAL!: Clients can add tags to a reponse to manage multiple versions

version: str class-attribute

A compact date string, declarating the versions name