-
Notifications
You must be signed in to change notification settings - Fork 0
/
Invenio_Record_schema.py
545 lines (388 loc) · 14.1 KB
/
Invenio_Record_schema.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# generated by datamodel-codegen:
# filename: record-v5.0.0.json
# timestamp: 2023-04-21T15:34:55+00:00
from __future__ import annotations
from datetime import date, datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Union
from pydantic import AnyUrl, BaseModel, Extra, Field, constr
class Record(Enum):
public = 'public'
restricted = 'restricted'
class Files(Enum):
public = 'public'
restricted = 'restricted'
class Embargo(BaseModel):
class Config:
extra = Extra.forbid
active: Optional[bool] = Field(
None, description='Whether or not the embargo is (still) active.'
)
until: Optional[date] = Field(
None,
description='Embargo date of record (ISO8601 formatted date time in UTC). At this time both metadata and files will be made public.',
)
reason: Optional[str] = Field(
None, description='The reason why the record is under embargo.'
)
class Access(BaseModel):
class Config:
extra = Extra.forbid
record: Optional[Record] = Field(
None, description='Record visibility (public or restricted)'
)
files: Optional[Files] = Field(
None, description='Files visibility (public or restricted)'
)
embargo: Optional[Embargo] = Field(
None, description='Description of the embargo on the record.'
)
class FieldSchema(BaseModel):
__root__: Any
class Identifier(BaseModel):
__root__: str = Field(..., description='An identifier.')
class Status(Enum):
N = 'N'
K = 'K'
R = 'R'
M = 'M'
D = 'D'
class InternalPid(BaseModel):
class Config:
extra = Extra.forbid
pk: int = Field(..., description='Primary key of the PID object.')
status: Status = Field(
..., description='The status of the PID (from Invenio-PIDStore).'
)
pid_type: Optional[str] = Field(
None, description='The type of the persistent identifier.'
)
obj_type: Optional[str] = Field(
None, description='The type of the associated object.'
)
class ExternalPid(BaseModel):
class Config:
extra = Extra.forbid
identifier: Optional[Identifier] = None
provider: Optional[str] = Field(
None, description='The provider of the persistent identifier.'
)
client: Optional[str] = Field(
None, description='Client identifier for the specific PID.'
)
class ResourceType(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
class Scheme(BaseModel):
__root__: str = Field(..., description='A scheme.')
class NameType(Enum):
personal = 'personal'
organizational = 'organizational'
class Role(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
class Affiliation(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
name: Optional[str] = None
class TitleType(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
class Language(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
class Subject(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
subject: Optional[str] = None
class DateType(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
class RelationType(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
class DescriptionType(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[str] = None
class Type(Enum):
Point = 'Point'
class GeoJSONGeometryItem(BaseModel):
type: Type
coordinates: List[float] = Field(..., min_items=2)
bbox: Optional[List[float]] = Field(None, min_items=4)
class Type1(Enum):
LineString = 'LineString'
class Coordinate(BaseModel):
__root__: List[Any]
class GeoJSONGeometryItem1(BaseModel):
type: Type1
coordinates: List[Coordinate] = Field(..., min_items=2)
bbox: Optional[List[float]] = Field(None, min_items=4)
class Type2(Enum):
Polygon = 'Polygon'
class GeoJSONGeometryItem2(BaseModel):
type: Type2
coordinates: List[List[Coordinate]]
bbox: Optional[List[float]] = Field(None, min_items=4)
class Type3(Enum):
MultiPoint = 'MultiPoint'
class GeoJSONGeometryItem3(BaseModel):
type: Type3
coordinates: List[List[float]]
bbox: Optional[List[float]] = Field(None, min_items=4)
class Type4(Enum):
MultiLineString = 'MultiLineString'
class GeoJSONGeometryItem4(BaseModel):
type: Type4
coordinates: List[List[Coordinate]]
bbox: Optional[List[float]] = Field(None, min_items=4)
class Type5(Enum):
MultiPolygon = 'MultiPolygon'
class GeoJSONGeometryItem5(BaseModel):
type: Type5
coordinates: List[List[List[Coordinate]]]
bbox: Optional[List[float]] = Field(None, min_items=4)
class GeoJSONGeometry(BaseModel):
__root__: Union[
GeoJSONGeometryItem,
GeoJSONGeometryItem1,
GeoJSONGeometryItem2,
GeoJSONGeometryItem3,
GeoJSONGeometryItem4,
GeoJSONGeometryItem5,
] = Field(..., title='GeoJSON Geometry')
class User(BaseModel):
class Config:
extra = Extra.forbid
user: Optional[int] = None
class File(BaseModel):
class Config:
extra = Extra.forbid
version_id: Optional[str] = Field(None, description='Object version ID.')
bucket_id: Optional[str] = Field(None, description='Object verison bucket ID.')
mimetype: Optional[str] = Field(None, description='File MIMEType.')
uri: Optional[str] = Field(None, description='File URI.')
storage_class: Optional[str] = Field(None, description='File storage class.')
checksum: Optional[str] = Field(None, description='Checksum of the file.')
size: Optional[float] = Field(None, description='Size of the file in bytes.')
key: Optional[str] = Field(None, description='Key (filename) of the file.')
file_id: Optional[Identifier] = None
class AdditionalTitle(BaseModel):
class Config:
extra = Extra.forbid
title: Optional[str] = Field(None, description='Additional title of the record.')
type: Optional[TitleType] = None
lang: Optional[Language] = None
class Date(BaseModel):
class Config:
extra = Extra.forbid
date: Optional[str] = Field(
None, description='Date or date interval in EDTF level 0 format'
)
type: Optional[DateType] = None
description: Optional[str] = Field(
None,
description="Description of the date or date interval e.g. 'Accepted' or 'Available' (CV).",
)
class RelatedIdentifier(BaseModel):
class Config:
extra = Extra.forbid
identifier: Optional[Identifier] = None
scheme: Optional[Scheme] = None
relation_type: Optional[RelationType] = None
resource_type: Optional[ResourceType] = None
class Right(BaseModel):
class Config:
extra = Extra.forbid
id: Optional[Identifier] = None
title: Optional[Dict[str, Any]] = Field(
None, description='The license name or license itself. Free text.'
)
description: Optional[Dict[str, Any]] = Field(
None, description='The license description Free text.'
)
link: Optional[AnyUrl] = None
class AdditionalDescription(BaseModel):
class Config:
extra = Extra.forbid
description: Optional[str] = Field(None, description='Description for record.')
type: Optional[DescriptionType] = None
lang: Optional[Language] = None
class Geometry(BaseModel):
type: Optional[Any] = None
coordinates: Optional[Any] = None
class Funder(BaseModel):
class Config:
extra = Extra.forbid
name: Optional[str] = None
id: Optional[Identifier] = None
class Reference(BaseModel):
class Config:
extra = Extra.forbid
reference: Optional[str] = Field(None, description='A reference string.')
identifier: Optional[Identifier] = None
scheme: Optional[Scheme] = None
class Files1(BaseModel):
class Config:
extra = Extra.forbid
enabled: Optional[bool] = Field(
None, description='Set to false for metadata only records.'
)
default_preview: Optional[str] = Field(
None, description='Key of the default previewed file.'
)
order: Optional[List[str]] = None
entries: Optional[Dict[str, File]] = None
meta: Optional[Dict[str, Dict[str, Any]]] = None
class IdentifiersWithScheme(BaseModel):
class Config:
extra = Extra.forbid
identifier: Optional[Identifier] = None
scheme: Optional[Scheme] = None
class Affiliations(BaseModel):
__root__: List[Affiliation] = Field(..., unique_items=True)
class Subjects(BaseModel):
__root__: List[Subject] = Field(..., unique_items=True)
class Agent(BaseModel):
__root__: User = Field(
..., description='An agent (user, software process, community, ...).'
)
class Feature(BaseModel):
geometry: Optional[Geometry] = None
identifiers: Optional[List[IdentifiersWithScheme]] = Field(None, unique_items=True)
place: Optional[constr(min_length=1)] = Field(
None, description='Place of the location'
)
description: Optional[constr(min_length=1)] = Field(
None, description='Description of the location'
)
class Locations(BaseModel):
class Config:
extra = Extra.forbid
features: Optional[List[Feature]] = Field(None, min_items=1)
class Award(BaseModel):
class Config:
extra = Extra.forbid
title: Optional[Dict[str, Any]] = None
number: Optional[str] = None
id: Optional[Identifier] = None
identifiers: Optional[List[IdentifiersWithScheme]] = None
class FundingItem(BaseModel):
class Config:
extra = Extra.forbid
funder: Optional[Funder] = None
award: Optional[Award] = None
class Tombstone(BaseModel):
class Config:
extra = Extra.forbid
reason: Optional[str] = Field(None, description='Reason for removal.')
category: Optional[str] = Field(None, description='Category for the removal.')
removed_by: Optional[Agent] = None
timestamp: Optional[datetime] = Field(
None, description='ISO8601 formatted timestamp in UTC.'
)
class Provenance(BaseModel):
class Config:
extra = Extra.forbid
created_by: Optional[Agent] = None
on_behalf_of: Optional[Agent] = None
class PersonOrOrg(BaseModel):
class Config:
extra = Extra.forbid
name: Optional[str] = None
type: Optional[NameType] = None
given_name: Optional[str] = None
family_name: Optional[str] = None
identifiers: Optional[List[IdentifiersWithScheme]] = Field(None, unique_items=True)
class Creator(BaseModel):
class Config:
extra = Extra.forbid
person_or_org: Optional[PersonOrOrg] = None
role: Optional[Role] = None
affiliations: Optional[Affiliations] = None
class Contributor(BaseModel):
class Config:
extra = Extra.forbid
person_or_org: Optional[PersonOrOrg] = None
role: Optional[Role] = None
affiliations: Optional[Affiliations] = None
class Metadata(BaseModel):
class Config:
extra = Extra.forbid
resource_type: Optional[ResourceType] = None
creators: Optional[List[Creator]] = Field(
None, description='Creators of the resource.'
)
title: Optional[str] = Field(None, description='Primary title of the record.')
additional_titles: Optional[List[AdditionalTitle]] = Field(
None, description='Additional record titles.'
)
publisher: Optional[str] = None
publication_date: Optional[str] = Field(
None, description='Record publication date (EDTF level 0 format).'
)
subjects: Optional[Subjects] = None
contributors: Optional[List[Contributor]] = Field(
None, description='Contributors in order of importance.'
)
dates: Optional[List[Date]] = Field(None, description='Date or date interval.')
languages: Optional[List[Language]] = Field(
None,
description='The primary languages of the resource. ISO 639-3 language code.',
unique_items=True,
)
identifiers: Optional[List[IdentifiersWithScheme]] = Field(
None, description='Alternate identifiers for the record.', unique_items=True
)
related_identifiers: Optional[List[RelatedIdentifier]] = Field(
None, unique_items=True
)
sizes: Optional[List[str]] = None
formats: Optional[List[str]] = None
version: Optional[str] = Field(None, description='Record version tag.')
rights: Optional[List[Right]] = Field(
None, description='Any license or copyright information for this resource.'
)
description: Optional[str] = Field(
None, description='Description for record (may contain HTML).'
)
additional_descriptions: Optional[List[AdditionalDescription]] = None
locations: Optional[Locations] = Field(
None, description='Geographical locations relevant to this record.'
)
funding: Optional[List[FundingItem]] = None
references: Optional[List[Reference]] = Field(None, min_items=0)
class InveniordmRecordSchemaV500(BaseModel):
class Config:
extra = Extra.forbid
field_schema: Optional[FieldSchema] = Field(None, alias='$schema')
id: Optional[Identifier] = None
pid: Optional[InternalPid] = None
pids: Optional[Dict[str, ExternalPid]] = Field(
None,
description='External persistent identifiers for a record including e.g. OAI-PMH identifier, minted DOIs and more. PIDs are registered in the PIDStore.',
)
metadata: Optional[Metadata] = Field(None, description='Resource metadata.')
custom_fields: Optional[Dict[str, Any]] = Field(
None, description='Configured additional metadata'
)
tombstone: Optional[Tombstone] = Field(
None, description='Tombstone for the record.'
)
provenance: Optional[Provenance] = Field(None, description='Record provenance.')
access: Optional[Access] = Field(
None, description='Record access control and ownership.'
)
files: Optional[Files1] = Field(
None, description='Files associated with the record'
)
notes: Optional[List[str]] = None