-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpid4cat_model_pydantic.py
More file actions
1602 lines (1452 loc) · 78.6 KB
/
Copy pathpid4cat_model_pydantic.py
File metadata and controls
1602 lines (1452 loc) · 78.6 KB
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
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
import re
import sys
from datetime import (
date,
datetime,
time
)
from decimal import Decimal
from enum import Enum
from typing import (
Any,
ClassVar,
Literal,
Optional,
Union
)
from pydantic import (
BaseModel,
ConfigDict,
Field,
RootModel,
SerializationInfo,
SerializerFunctionWrapHandler,
field_validator,
model_serializer
)
metamodel_version = "1.11.0"
version = "0.4.2.post32.dev0+734c1c2"
class ConfiguredBaseModel(BaseModel):
model_config = ConfigDict(
serialize_by_alias = True,
validate_by_name = True,
validate_assignment = True,
validate_default = True,
extra = "forbid",
arbitrary_types_allowed = True,
use_enum_values = True,
strict = False,
)
class LinkMLMeta(RootModel):
root: dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key:str):
return getattr(self.root, key)
def __getitem__(self, key:str):
return self.root[key]
def __setitem__(self, key:str, value):
self.root[key] = value
def __contains__(self, key:str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta({'default_prefix': 'pid4cat_model',
'default_range': 'string',
'description': 'A LinkML model for persistent identifiers for resources in '
'catalysis (pid4cat). pid4cat are handle based persistent '
'identifiers (PIDs) for digital or physical resources used in '
'the catalysis research process. PID-related metadata besides '
'the obligatory landing page URL are stored directly in the '
'handle records.\n'
'The model describes metadata for the PID itself and how to '
'access the identified resource. It does not describe the '
'resource itself with the exception of the resource category, '
'which is a high-level description of what is identified by '
'the pid4cat handle, e.g. a sample or a device.',
'id': 'https://w3id.org/nfdi4cat/pid4cat-model',
'imports': ['linkml:types', 'media_types'],
'license': 'MIT',
'name': 'pid4cat-model',
'prefixes': {'DataCite': {'prefix_prefix': 'DataCite',
'prefix_reference': 'https://purl.org/spar/datacite/'},
'dcat': {'prefix_prefix': 'dcat',
'prefix_reference': 'https://www.w3.org/ns/dcat#'},
'dcterms': {'prefix_prefix': 'dcterms',
'prefix_reference': 'https://purl.org/dc/terms/'},
'linkml': {'prefix_prefix': 'linkml',
'prefix_reference': 'https://w3id.org/linkml/'},
'mediatype': {'prefix_prefix': 'mediatype',
'prefix_reference': 'https://www.iana.org/assignments/media-types/'},
'pid4cat_model': {'prefix_prefix': 'pid4cat_model',
'prefix_reference': 'https://w3id.org/nfdi4cat/pid4cat-model/'},
'prov': {'prefix_prefix': 'prov',
'prefix_reference': 'https://www.w3.org/ns/prov#'},
'voc4cat': {'prefix_prefix': 'voc4cat',
'prefix_reference': 'https://w3id.org/nfdi4cat/voc4cat_'}},
'see_also': ['https://nfdi4cat.github.io/pid4cat-model'],
'source_file': 'src/pid4cat_model/schema/pid4cat_model.yaml',
'title': 'pid4cat-model',
'todos': ['none']} )
class MediaTypesEnum(str, Enum):
"""
IANA media types are used to specify the type of data.
"""
applicationSOLIDUSepubPLUS_SIGNzip = "application/epub+zip"
"""
For data in Electronic Publication Format (EPUB).
"""
applicationSOLIDUSjson = "application/json"
"""
For data in JavaScript Object Notation (JSON).
"""
applicationSOLIDUSldPLUS_SIGNjson = "application/ld+json"
"""
For data in Linked Data json (JSON-LD).
"""
applicationSOLIDUSoctet_stream = "application/octet-stream"
"""
For binary data.
"""
applicationSOLIDUSpdf = "application/pdf"
"""
For data in Portable Document Format (PDF).
"""
applicationSOLIDUSvndFULL_STOPelnPLUS_SIGNzip = "application/vnd.eln+zip"
"""
For data in ELN ZIP format.
"""
applicationSOLIDUSvndFULL_STOPopenxmlformats_officedocumentFULL_STOPpresentationmlFULL_STOPpresentation = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
"""
For data in PowerPoint pptx format.
"""
applicationSOLIDUSvndFULL_STOPopenxmlformats_officedocumentFULL_STOPspreadsheetmlFULL_STOPsheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
"""
For data in Excel xlsx format.
"""
applicationSOLIDUSvndFULL_STOPopenxmlformats_officedocumentFULL_STOPwordprocessingmlFULL_STOPdocument = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
"""
For data in Word docx format.
"""
applicationSOLIDUSxml = "application/xml"
"""
For generic XML data.
"""
applicationSOLIDUSyaml = "application/yaml"
"""
For YAML data.
"""
applicationSOLIDUSzip = "application/zip"
"""
For zip archives.
"""
imageSOLIDUSgif = "image/gif"
"""
For GIF images.
"""
imageSOLIDUSjpeg = "image/jpeg"
"""
For JPEG images.
"""
imageSOLIDUSpng = "image/png"
"""
For PNG images.
"""
imageSOLIDUSsvgPLUS_SIGNxml = "image/svg+xml"
"""
For SVG images.
"""
imageSOLIDUStiff = "image/tiff"
"""
For TIFF images.
"""
imageSOLIDUSwebp = "image/webp"
"""
For WebP images.
"""
textSOLIDUScsv = "text/csv"
"""
For data in comma-separated values (CSV) format.
"""
textSOLIDUShtml = "text/html"
"""
For html web pages.
"""
textSOLIDUSjavascript = "text/javascript"
"""
For JavaScript code.
"""
textSOLIDUSmarkdown = "text/markdown"
"""
For data in markdown text format.
"""
textSOLIDUSplain = "text/plain"
"""
For plain text data (default text media type).
"""
textSOLIDUStab_separated_values = "text/tab-separated-values"
"""
For data in tab-separated values (TSV) format.
"""
textSOLIDUSturtle = "text/turtle"
"""
For data in turtle format.
"""
textSOLIDUSxml = "text/xml"
"""
For XML data.
"""
videoSOLIDUSmp4 = "video/mp4"
"""
For mp4 video files.
"""
videoSOLIDUSwebm = "video/webm"
"""
For webm video files.
"""
class ResourceCategory(str, Enum):
"""
The ResourceCategory expresses for which type of resource the PID is used, e.g. if the PID is for a sample or a device.
"""
COLLECTION = "COLLECTION"
"""
A collection is a group of resources and/or other collections.
"""
SAMPLE = "SAMPLE"
"""
A representative part of a material of interest on which observations are made.
"""
MATERIAL = "MATERIAL"
"""
A material used in the research process (except samples).
"""
DEVICE = "DEVICE"
"""
A physical device used in a research or manufacturing process.
"""
DATA_OBJECT = "DATA_OBJECT"
"""
A collection of data available for access or download. A data object might be a data file, a data set, a data collection.
"""
DATA_SERVICE = "DATA_SERVICE"
"""
An organized system of operations that provide data processing functions or access to datasets.
"""
class RelationType(str, Enum):
"""
The type of relation between two resources referenced by their PIDs.
"""
IS_CITED_BY = "IS_CITED_BY"
"""
The resource is cited by another resource.
"""
CITES = "CITES"
"""
The resource cites another resource.
"""
IS_SUPPLEMENT_TO = "IS_SUPPLEMENT_TO"
"""
The resource is supplemented by another resource.
"""
IS_SUPPLEMENTED_BY = "IS_SUPPLEMENTED_BY"
"""
The resource supplements another resource.
"""
IS_CONTINUED_BY = "IS_CONTINUED_BY"
"""
The resource is continued by another resource.
"""
CONTINUES = "CONTINUES"
"""
The resource continues another resource.
"""
HAS_METADATA = "HAS_METADATA"
"""
The resource has metadata in another resource.
"""
IS_METADATA_FOR = "IS_METADATA_FOR"
"""
The resource is metadata for another resource.
"""
HAS_VERSION = "HAS_VERSION"
"""
The resource has a version. This is useful to express the relation between a abstract resource to its versioned instances, for example, "Python has_version Python 3.12".
"""
IS_VERSION_OF = "IS_VERSION_OF"
"""
The resource is a version of another resource. This is useful to refer to an abstract resource that has different versions, for example, "Python 3.12 is a version of Python".
"""
IS_NEW_VERSION_OF = "IS_NEW_VERSION_OF"
"""
The resource is a new version of another versioned resource. This is useful to refer between versioned resources, for example, "Python 3.12.1 is_new_version_of Python 3.12.0".
"""
IS_PREVIOUS_VERSION_OF = "IS_PREVIOUS_VERSION_OF"
"""
The resource is a previous version of another versioned resource. This is useful to refer between versioned resources, for example, "Python 3.12.0 is_previous_version_of Python 3.12.1".
"""
IS_PART_OF = "IS_PART_OF"
"""
The resource is part of another resource. This relation applies to container-contained type relationships. If the relation refers to publishing one resource as part of another resource, use "IS_PUBLISHED_IN" instead. If the relation refers to a versioned resource and non-versioned resource, use "IS_VERSION_OF" instead.
"""
HAS_PART = "HAS_PART"
"""
The resource has part another resource. This relation applies to container-contained type relationships. If the relation refers to publishing one resource as part of another resource, "IS_PUBLISHED_IN" instead. If the relation refers to a versioned resource and non-versioned resource, use "HAS_VERSION" instead.
"""
IS_PUBLISHED_IN = "IS_PUBLISHED_IN"
"""
The resource is published in another resource. A resource A that is_published_in a resource B is independent from other resources published in the same resource B.
"""
IS_REFERENCED_BY = "IS_REFERENCED_BY"
"""
The resource is referenced by another resource.
"""
REFERENCES = "REFERENCES"
"""
The resource references another resource.
"""
IS_DOCUMENTED_BY = "IS_DOCUMENTED_BY"
"""
The resource is documented by another resource.
"""
DOCUMENTS = "DOCUMENTS"
"""
The resource documents another resource.
"""
IS_COMPILED_BY = "IS_COMPILED_BY"
"""
The resource is compiled by another resource. Resources may be text or software. The compiler may be a computer program or a person.
"""
COMPILES = "COMPILES"
"""
The resource compiles another resource. Resources may be text or software. The compiler may be a computer program or a person.
"""
IS_VARIANT_FORM_OF = "IS_VARIANT_FORM_OF"
"""
The resource is variant form of another resource. This may be used e.g. for relating architecture-specific builds of a software program to a source-code release. It may also be used to express the relation between data in different formats (e.g. PNG, JPEG) of the same image.
"""
IS_ORIGINAL_FORM_OF = "IS_ORIGINAL_FORM_OF"
"""
The resource is original form of another resource. This may be used e.g. for relating architecture-specific builds of a software program to a source-code release. It may also be used to express the relation between data in different formats (e.g. PNG, JPEG) of the same image.
"""
IS_IDENTICAL_TO = "IS_IDENTICAL_TO"
"""
The resource is identical to another resource. May be used to indicate the relationship between an exact copy of a resource that is published at another location.
"""
IS_DERIVED_FROM = "IS_DERIVED_FROM"
"""
The resource is derived from another resource. This may be used for relating a new dataset created by data processing to its original source dataset. For samples it may express the relation between the original sample and another sample derived from it by physical or chemical treatment.
"""
IS_SOURCE_OF = "IS_SOURCE_OF"
"""
The resource is source of another resource. This may be used for example to express the relation between a source dataset and a new dataset derived from it by data processing. For samples it may express the relation between a sample processed by physical or chemical treatment and the original sample.
"""
IS_COLLECTED_BY = "IS_COLLECTED_BY"
"""
The resource is collected by another resource. May be used to indicate the relationship between a dataset and an instrument that is used to collect, measure, obtain, or observe data.
"""
COLLECTS = "COLLECTS"
"""
The resource collects another resource. May be used to indicate the relationship between an instrument and where it has been used to collect, measure, obtain, or observe data.
"""
IS_REQUIRED_BY = "IS_REQUIRED_BY"
"""
The resource is required by another resource.
"""
REQUIRES = "REQUIRES"
"""
The resource requires another resource.
"""
IS_OBSOLETED_BY = "IS_OBSOLETED_BY"
"""
The resource is obsoleted by another resource.
"""
OBSOLETES = "OBSOLETES"
"""
The resource obsoletes another resource.
"""
CONFORMS_TO = "CONFORMS_TO"
"""
An established standard to which the described resource conforms. This relation should be used to indicate the model, schema, ontology, or profile that the resource content conforms to.
"""
class Pid4CatStatus(str, Enum):
"""
The usage status of the pid4cat record.
"""
SUBMITTED = "SUBMITTED"
"""
The pid4cat handle is reserved but the resource is not yet linked.
"""
REGISTERED = "REGISTERED"
"""
The pid4cat handle is linked to a concrete resource.
"""
OBSOLETED = "OBSOLETED"
"""
The pid4cat handle is obsolete, e.g. because the resource is referenced by another pid4cat.
"""
DEPRECATED = "DEPRECATED"
"""
The pid4cat record is deprecated, e.g. because the resource can no longer be found.
"""
class Pid4CatAgentRole(str, Enum):
"""
The role of an agent relative to the resource.
"""
TRUSTEE = "TRUSTEE"
"""
The agent is the trustee of the resource.
"""
OWNER = "OWNER"
"""
The agent is the owner of the resource.
"""
class ChangeLogField(str, Enum):
"""
The field of the pid4cat record that was changed.
"""
STATUS = "STATUS"
"""
The status of the pid4cat record was changed.
"""
LANDING_PAGE = "LANDING_PAGE"
"""
The URL of the landing page in the pid4cat record was changed.
"""
RESOURCE_INFO = "RESOURCE_INFO"
"""
The resource info of the pid4cat record was changed.
"""
RELATED_IDS = "RELATED_IDS"
"""
The related identifiers of the pid4cat record were changed.
"""
CONTACT = "CONTACT"
"""
The contact information of the pid4cat record was changed.
"""
LICENSE = "LICENSE"
"""
The license of the pid4cat record was changed.
"""
SCHEMA_VER = "SCHEMA_VER"
"""
The pid4cat-model version of the pid4cat record was changed.
"""
class HandleAPIRecord(ConfiguredBaseModel):
"""
A class representing a handle record query response of the REST (json) API of a handle server.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'handle': {'name': 'handle',
'pattern': '^\\d{2}\\.T?\\d{4,}\\/.*$',
'required': True},
'values': {'name': 'values', 'required': True}}})
responseCode: Optional[int] = Field(default=None, description="""The response code of the handle API.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleAPIRecord']} })
handle: str = Field(default=..., description="""The handle of the pid4cat record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleAPIRecord']} })
values: list[Union[HandleRecord,URL,EMAIL,STATUS,SCHEMAVER,METADATALICENSE,RESOURCE,RELATED,CHANGES]] = Field(default=..., description="""The values of the pid4cat record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleAPIRecord']} })
@field_validator('handle')
def pattern_handle(cls, v):
pattern=re.compile(r"^\d{2}\.T?\d{4,}\/.*$")
if isinstance(v, list):
for element in v:
if isinstance(element, str) and not pattern.match(element):
err_msg = f"Invalid handle format: {element}"
raise ValueError(err_msg)
elif isinstance(v, str) and not pattern.match(v):
err_msg = f"Invalid handle format: {v}"
raise ValueError(err_msg)
return v
class HandleRecord(ConfiguredBaseModel):
"""
A base class for handle-data classes that represent a handle record in the same way as in the REST (json) API of a handle server.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'timestamp': {'name': 'timestamp', 'required': True},
'ttl': {'ifabsent': '86400', 'name': 'ttl'},
'type': {'description': 'The type of handledata stored in the '
'handle record.',
'designates_type': True,
'name': 'type',
'required': True}}})
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["HandleRecord"] = Field(default="HandleRecord", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class URL(HandleRecord):
"""
The data element in the handle API for the landing page URL.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'data': {'name': 'data',
'range': 'HdlDataUrl',
'required': True},
'index': {'maximum_value': 1,
'minimum_value': 1,
'name': 'index',
'required': True}}})
index: int = Field(default=..., description="""The index of the handle record.""", ge=1, le=1, json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
data: HdlDataUrl = Field(default=..., description="""The data in the handle record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["URL"] = Field(default="URL", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class HdlDataUrl(ConfiguredBaseModel):
"""
The data class for the redirect url.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'format': {'equals_string': 'string',
'ifabsent': 'string',
'name': 'format'},
'value': {'name': 'value',
'pattern': '^https?:\\/\\/.*$',
'required': True}}})
format: Optional[Literal["string"]] = Field(default="string", description="""The format of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'string',
'ifabsent': 'string'} })
value: str = Field(default=..., description="""The value of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog']} })
@field_validator('value')
def pattern_value(cls, v):
pattern=re.compile(r"^https?:\/\/.*$")
if isinstance(v, list):
for element in v:
if isinstance(element, str) and not pattern.match(element):
err_msg = f"Invalid value format: {element}"
raise ValueError(err_msg)
elif isinstance(v, str) and not pattern.match(v):
err_msg = f"Invalid value format: {v}"
raise ValueError(err_msg)
return v
class EMAIL(HandleRecord):
"""
The data element in the handle API for the contact email.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'data': {'name': 'data',
'range': 'HdlDataContact',
'required': True},
'index': {'maximum_value': 10,
'minimum_value': 10,
'name': 'index',
'required': True}}})
index: int = Field(default=..., description="""The index of the handle record.""", ge=10, le=10, json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
data: HdlDataContact = Field(default=..., description="""The data in the handle record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["EMAIL"] = Field(default="EMAIL", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class HdlDataContact(ConfiguredBaseModel):
"""
The data class for the handle-record contact email.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'format': {'equals_string': 'string',
'ifabsent': 'string',
'name': 'format'},
'value': {'name': 'value',
'pattern': '^\\S+@[\\S+\\.]+\\S+',
'required': True}}})
format: Optional[Literal["string"]] = Field(default="string", description="""The format of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'string',
'ifabsent': 'string'} })
value: str = Field(default=..., description="""The value of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog']} })
@field_validator('value')
def pattern_value(cls, v):
pattern=re.compile(r"^\S+@[\S+\.]+\S+")
if isinstance(v, list):
for element in v:
if isinstance(element, str) and not pattern.match(element):
err_msg = f"Invalid value format: {element}"
raise ValueError(err_msg)
elif isinstance(v, str) and not pattern.match(v):
err_msg = f"Invalid value format: {v}"
raise ValueError(err_msg)
return v
class STATUS(HandleRecord):
"""
The data element in the handle API for the PID status information.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'data': {'name': 'data',
'range': 'HdlDataStatus',
'required': True},
'index': {'maximum_value': 11,
'minimum_value': 11,
'name': 'index',
'required': True}}})
index: int = Field(default=..., description="""The index of the handle record.""", ge=11, le=11, json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
data: HdlDataStatus = Field(default=..., description="""The data in the handle record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["STATUS"] = Field(default="STATUS", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class HdlDataStatus(ConfiguredBaseModel):
"""
The data class for the PID status information.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'format': {'equals_string': 'string',
'ifabsent': 'string',
'name': 'format'},
'value': {'name': 'value',
'range': 'Pid4CatStatus',
'required': True}}})
format: Optional[Literal["string"]] = Field(default="string", description="""The format of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'string',
'ifabsent': 'string'} })
value: Pid4CatStatus = Field(default=..., description="""The value of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog']} })
class SCHEMAVER(HandleRecord):
"""
The data element in the handle API for the schema version.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'data': {'name': 'data',
'range': 'HdlDataSchemaVer',
'required': True},
'index': {'maximum_value': 12,
'minimum_value': 12,
'name': 'index',
'required': True}}})
index: int = Field(default=..., description="""The index of the handle record.""", ge=12, le=12, json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
data: HdlDataSchemaVer = Field(default=..., description="""The data in the handle record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["SCHEMA_VER"] = Field(default="SCHEMA_VER", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class HdlDataSchemaVer(ConfiguredBaseModel):
"""
The data class for the schema version.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'format': {'equals_string': 'string',
'ifabsent': 'string',
'name': 'format'},
'value': {'name': 'value',
'pattern': '^v\\d+\\.\\d+\\.\\d+$',
'required': True}}})
format: Optional[Literal["string"]] = Field(default="string", description="""The format of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'string',
'ifabsent': 'string'} })
value: str = Field(default=..., description="""The value of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog']} })
@field_validator('value')
def pattern_value(cls, v):
pattern=re.compile(r"^v\d+\.\d+\.\d+$")
if isinstance(v, list):
for element in v:
if isinstance(element, str) and not pattern.match(element):
err_msg = f"Invalid value format: {element}"
raise ValueError(err_msg)
elif isinstance(v, str) and not pattern.match(v):
err_msg = f"Invalid value format: {v}"
raise ValueError(err_msg)
return v
class METADATALICENSE(HandleRecord):
"""
The data element in the handle API for the PID metadata license.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'data': {'name': 'data',
'range': 'HdlDataLicense',
'required': True},
'index': {'maximum_value': 13,
'minimum_value': 13,
'name': 'index',
'required': True}}})
index: int = Field(default=..., description="""The index of the handle record.""", ge=13, le=13, json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
data: HdlDataLicense = Field(default=..., description="""The data in the handle record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["METADATA_LICENSE"] = Field(default="METADATA_LICENSE", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class HdlDataLicense(ConfiguredBaseModel):
"""
The data class for the PID metadata license.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'format': {'equals_string': 'string',
'ifabsent': 'string',
'name': 'format'},
'value': {'equals_string': 'CC0-1.0',
'name': 'value',
'required': True}}})
format: Optional[Literal["string"]] = Field(default="string", description="""The format of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'string',
'ifabsent': 'string'} })
value: Literal["CC0-1.0"] = Field(default=..., description="""The value of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'CC0-1.0'} })
class RESOURCE(HandleRecord):
"""
The data element in the handle API for the resource info.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'data': {'name': 'data',
'range': 'HdlDataResourceInfo',
'required': True},
'index': {'maximum_value': 14,
'minimum_value': 14,
'name': 'index',
'required': True}}})
index: int = Field(default=..., description="""The index of the handle record.""", ge=14, le=14, json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
data: HdlDataResourceInfo = Field(default=..., description="""The data in the handle record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["RESOURCE"] = Field(default="RESOURCE", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class HdlDataResourceInfo(ConfiguredBaseModel):
"""
The data class for the resource info.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'format': {'equals_string': 'string',
'ifabsent': 'string',
'name': 'format'},
'value': {'name': 'value',
'range': 'ResourceInfo',
'required': True}}})
format: Optional[Literal["string"]] = Field(default="string", description="""The format of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'string',
'ifabsent': 'string'} })
value: ResourceInfo = Field(default=..., description="""The value of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog']} })
class RELATED(HandleRecord):
"""
The data element in the handle API for related identifiers.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'data': {'name': 'data',
'range': 'HdlDataRelated',
'required': True},
'index': {'maximum_value': 15,
'minimum_value': 15,
'name': 'index',
'required': True}}})
index: int = Field(default=..., description="""The index of the handle record.""", ge=15, le=15, json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
data: HdlDataRelated = Field(default=..., description="""The data in the handle record.""", json_schema_extra = { "linkml_meta": {'domain_of': ['URL',
'EMAIL',
'STATUS',
'SCHEMA_VER',
'METADATA_LICENSE',
'RESOURCE',
'RELATED',
'CHANGES']} })
timestamp: datetime = Field(default=..., description="""The iso datetime for the last update of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord']} })
ttl: Optional[int] = Field(default=86400, description="""A time to live in seconds for the handle record. Typically: 86400 => 1 day""", json_schema_extra = { "linkml_meta": {'domain_of': ['HandleRecord'], 'ifabsent': '86400'} })
type: Literal["RELATED"] = Field(default="RELATED", description="""The type of handledata stored in the handle record.""", json_schema_extra = { "linkml_meta": {'designates_type': True, 'domain_of': ['HandleRecord', 'RelatedIdentifier']} })
class HdlDataRelated(ConfiguredBaseModel):
"""
The data class for related identifiers.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/nfdi4cat/pid4cat-model',
'slot_usage': {'format': {'equals_string': 'string',
'ifabsent': 'string',
'name': 'format'},
'value': {'multivalued': True,
'name': 'value',
'range': 'Pid4CatRelation'}}})
format: Optional[Literal["string"]] = Field(default="string", description="""The format of the handle data.""", json_schema_extra = { "linkml_meta": {'domain_of': ['HdlDataUrl',
'HdlDataContact',
'HdlDataStatus',
'HdlDataSchemaVer',
'HdlDataLicense',
'HdlDataResourceInfo',
'HdlDataRelated',
'HdlDataLog'],
'equals_string': 'string',