# This file is part of the Open Parts Database software # Copyright (C) 2022 Valentin Lorentz # # This program is free software: you can redistribute it and/or modify it under the # terms of the GNU Affero General Public License version 3, as published by the # Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License along with # this program. If not, see . """ Classes representing objects in the postgresql database """ import dataclasses import datetime import typing from .orm import BaseModel as _BaseModel @dataclasses.dataclass(frozen=True) class WebPageSnapshot(_BaseModel): """Local cache of a live webpage""" TABLE = "web_page_snapshot" PK = ("url", "snapshot_date") url: str """IRI of the page""" snapshot_date: datetime.datetime """Moment the snapshot was taken from the live website""" snapshot_url: typing.Optional[str] """IRI where the page was downloaded from (:const:`None` unless the snapshot was downloaded from a proxy).""" retrieved_at: datetime.datetime """Moment the snapshot was downloaded by opdb and inserted in the DB (differs from :attr:`snapshot_date` if the snapshot was taken by a proxy).""" response_headers: dict[str, str] """Response headers of the webpage""" content: bytes """Content of the webpage."""