Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting work on downgrading schema #178

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 78 additions & 53 deletions iiif_prezi3/skeleton.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: iiif_3_0.json
# timestamp: 2023-02-17T13:09:25+00:00
# timestamp: 2023-03-14T00:28:59+00:00

from __future__ import annotations

Expand Down Expand Up @@ -55,8 +55,12 @@ class ViewingDirection(Base):
]


class Context(Base):
__root__: Union[str, List[AnyUrl]]


class Id(Base):
__root__: AnyUrl = Field(..., title='Id must be presesnt and must be a URI')
__root__: AnyUrl = Field(..., title='Id must be present and must be a URI')


class LngString(Base):
Expand Down Expand Up @@ -94,13 +98,33 @@ class Format(Base):
__root__: constr(regex=r'^[a-z][a-z]*/.*$')


class AnnoSelectorItem(Base):
type: str
t: Optional[Duration] = None
class SelectorItem(Base):
type: constr(regex=r'^PointSelector$') = 'PointSelector'
t: Duration


class SelectorItem1(Base):
type: constr(regex=r'^FragmentSelector$') = 'FragmentSelector'
conformsTo: AnyUrl = 'http://www.w3.org/TR/media-frags/'
value: Any


class SelectorItem2(Base):
type: constr(regex=r'^SvgSelector$') = 'SvgSelector'
value: Any

class AnnoSelector(Base):
__root__: Union[AnyUrl, AnnoSelectorItem]

class SelectorItem3(Base):
type: constr(regex=r'^ImageApiSelector$') = 'ImageApiSelector'
region: Optional[Any] = None
size: Optional[Any] = None
rotation: Optional[Any] = None
quality: Optional[Any] = None
format: Optional[Any] = None


class Selector(Base):
__root__: Union[AnyUrl, SelectorItem, SelectorItem1, SelectorItem2, SelectorItem3]


class NavPlace(Base):
Expand All @@ -109,7 +133,7 @@ class NavPlace(Base):
features: Optional[List[Dict[str, Any]]] = None


class ResourceItem1(Base):
class ResourceItem(Base):
id: Optional[Id] = None
type: constr(regex=r'^TextualBody$') = 'TextualBody'
value: str
Expand Down Expand Up @@ -142,8 +166,8 @@ class SpecificResource(Base):
type: constr(regex=r'^SpecificResource$') = 'SpecificResource'
format: Optional[Format] = None
accessibility: Optional[str] = None
source: Id
selector: Union[AnnoSelector, List[AnnoSelector]]
source: Union[Id, Class]
selector: Optional[Union[Selector, List[Selector]]] = None


class HomepageItem(Class):
Expand All @@ -163,10 +187,6 @@ class PartOf(Base):
__root__: List[Class]


class Item(Class):
type: constr(regex=r'^Canvas$') = 'Canvas'


class SeeAlso(Base):
__root__: External

Expand All @@ -179,18 +199,15 @@ class Model(Base):
__root__: Union[Manifest, Collection, AnnotationPage]


class AnnotationPage(Base):
class Config:
extra = Extra.forbid

context: Optional[Any] = Field(None, alias='@context')
class AnnotationPage(Class):
context: Optional[Context] = Field(None, alias='@context')
id: Id
type: constr(regex=r'^AnnotationPage$') = 'AnnotationPage'
rendering: Optional[External] = None
label: Optional[LngString] = None
service: Optional[Service] = None
rendering: Optional[External] = None
thumbnail: Optional[List[Resource]] = None
items: Optional[List[Annotation]] = None
items: List[Annotation]


class Collection(Class):
Expand All @@ -217,11 +234,11 @@ class Collection(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: Optional[List[Union[ManifestRef, CollectionRef, Collection]]] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[AnnotationsLink] = None


class Manifest(Class):
context: Optional[Union[List[AnyUrl], str]] = Field(None, alias='@context')
context: Optional[Context] = Field(None, alias='@context')
id: Id
label: LngString
type: constr(regex=r'^Manifest') = 'Manifest'
Expand All @@ -246,7 +263,7 @@ class Manifest(Class):
partOf: Optional[PartOf] = None
items: Optional[List[Canvas]] = None
structures: Optional[List[Range]] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[AnnotationsLink] = None


class AccompanyingCanvas(Class):
Expand All @@ -269,20 +286,16 @@ class AccompanyingCanvas(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: List[AnnotationPage]
annotations: Optional[List[AnnotationPage]] = None


class BodyItem(Choice):
items: List[Resource]
annotations: Optional[AnnotationsLink] = None


class Annotation(Class):
type: constr(regex=r'^Annotation$') = 'Annotation'
service: Optional[Service] = None
rendering: Optional[External] = None
thumbnail: Optional[List[Resource]] = None
motivation: Optional[Union[str, List[str]]] = None
body: Optional[Union[Resource, BodyItem, List[Dict[str, Any]]]] = None
motivation: Optional[Union[List[str], str]] = None
body: Optional[Union[Choice, Resource, List[Resource]]] = None
target: Union[AnnoTarget, List[AnnoTarget]]


Expand All @@ -308,7 +321,7 @@ class Canvas(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: List[AnnotationPage]
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[AnnotationsLink] = None


class PlaceholderCanvas(Class):
Expand All @@ -331,7 +344,7 @@ class PlaceholderCanvas(Class):
behavior: Optional[Behavior] = None
partOf: Optional[PartOf] = None
items: List[AnnotationPage]
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[AnnotationsLink] = None


class ProviderItem(Class):
Expand All @@ -352,12 +365,12 @@ class Range(Class):
service: Optional[Service] = None
placeholderCanvas: Optional[PlaceholderCanvas] = None
accompanyingCanvas: Optional[AccompanyingCanvas] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[AnnotationsLink] = None
thumbnail: Optional[List[Resource]] = None
items: List[Union[SpecificResource, Item, Range, CanvasRef, RangeRef]]
items: List[Union[SpecificResource, Range, Canvas, CanvasRef]]


class ResourceItem(Base):
class ResourceItem1(Base):
id: Id
type: str
height: Optional[Dimension] = None
Expand All @@ -369,44 +382,57 @@ class ResourceItem(Base):
format: Optional[Format] = None
label: Optional[LngString] = None
thumbnail: Optional[List[Resource]] = None
annotations: Optional[List[AnnotationPage]] = None
annotations: Optional[AnnotationsLink] = None


class Resource(Base):
__root__: Union[ResourceItem, ResourceItem1]
__root__: Union[ResourceItem, SpecificResource, ResourceItem1] = Field(
..., title='ContentResource'
)


class ServiceItem(Class):
class ServiceItem(Base):
id: Id = Field(..., alias='@id')
type: str = Field(..., alias='@type')
profile: Optional[str] = None
service: Optional[Service] = None


class ServiceItem1(Base):
id: Id = Field(..., alias='@id')
type: str = Field(..., alias='@type')
class ServiceItem1(Class):
profile: Optional[str] = None
service: Optional[Service] = None


class Service(Base):
__root__: List[Union[ServiceItem, ServiceItem1]]
__root__: List[Union[ServiceItem, ServiceItem1]] = Field(
...,
description='must be an array and have an id and type or @id and @type',
title='Service',
)


class AnnotationsLink(Base):
__root__: List[Union[AnnotationPage, AnnotationPageRef]]


class AnnotationCollection(Class):
type: constr(regex=r'^AnnotationCollection$') = 'AnnotationCollection'
rendering: Optional[External] = None
partOf: Optional[PartOf] = None
next: Optional[AnnotationPage] = None
first: Optional[AnnotationPage] = None
last: Optional[AnnotationPage] = None
next: Optional[AnnotationPageRef] = None
first: Optional[AnnotationPageRef] = None
last: Optional[AnnotationPageRef] = None
service: Optional[Service] = None
thumbnail: Optional[List[Resource]] = None
items: Optional[List[Annotation]] = None


class Reference(Base):
class Config:
extra = Extra.allow

id: Id
label: LngString
label: Optional[LngString] = None
type: constr(
regex=r'^Manifest$|^AnnotationPage$|^Collection$|^AnnotationCollection$|^Canvas$|^Range$'
)
Expand All @@ -415,6 +441,7 @@ class Reference(Base):

class CollectionRef(Reference):
type: Optional[constr(regex=r'^Collection$')] = None
label: LngString


class ManifestRef(Reference):
Expand All @@ -426,23 +453,21 @@ class Config:

class CanvasRef(Reference):
type: Optional[constr(regex=r'^Canvas$')] = None


class RangeRef(Reference):
type: Optional[constr(regex=r'^Range$')] = None
label: Optional[LngString] = None


Model.update_forward_refs()
AnnotationPage.update_forward_refs()
Collection.update_forward_refs()
Manifest.update_forward_refs()
AccompanyingCanvas.update_forward_refs()
BodyItem.update_forward_refs()
Annotation.update_forward_refs()
Canvas.update_forward_refs()
PlaceholderCanvas.update_forward_refs()
ProviderItem.update_forward_refs()
Range.update_forward_refs()
ResourceItem.update_forward_refs()
ResourceItem1.update_forward_refs()
ServiceItem.update_forward_refs()
ServiceItem1.update_forward_refs()
AnnotationsLink.update_forward_refs()
AnnotationCollection.update_forward_refs()
Loading