aboutsummaryrefslogtreecommitdiffstats
path: root/python/sandcrawler/fileset_types.py
blob: 9fe8b0dbf030f024d21014b072e9496fc727b24a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from enum import Enum
from typing import Optional, Tuple, Any, Dict, List

from pydantic import BaseModel

class IngestStrategy(str, Enum):
    WebFile = "web-file"
    WebFileset = "web-fileset"
    WebFilesetBundled = "web-fileset-bundled"
    ArchiveorgFile = "archiveorg-file"
    ArchiveorgFileset = "archiveorg-fileset"
    ArchiveorgFilesetBundled = "archiveorg-fileset-bundled"

class FilesetManifestFile(BaseModel):
    path: str
    size: Optional[int]
    md5: Optional[str]
    sha1: Optional[str]
    sha256: Optional[str]
    mimetype: Optional[str]

    status: Optional[str]
    platform_url: Optional[str]
    terminal_url: Optional[str]
    terminal_dt: Optional[str]
    extra: Optional[Dict[str, Any]]

class DatasetPlatformItem(BaseModel):
    platform_name: str
    platform_status: str
    manifest: Optional[List[FilesetManifestFile]]

    platform_domain: Optional[str]
    platform_id: Optional[str]
    archiveorg_item_name: Optional[str]
    archiveorg_item_meta: Optional[dict]
    web_base_url: Optional[str]
    web_bundle_url: Optional[str]

class ArchiveStrategyResult(BaseModel):
    ingest_strategy: str
    status: str
    manifest: List[FilesetManifestFile]

class PlatformScopeError(Exception):
    """
    For incidents where platform helper discovers that the fileset/dataset is
    out-of-cope after already starting to process it.

    For example, attempting to ingest:

    - a 'latest version' record, when the platform has version-specific records
    - a single file within a dataset for a platform which has file-level identifiers
    """
    pass

class PlatformRestrictedError(Exception):
    """
    When datasets are not publicly available on a platform (yet)
    """
    pass