destiny_sdk 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/PKG-INFO +1 -1
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/pyproject.toml +1 -1
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/references.py +23 -1
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/LICENSE +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/README.md +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/__init__.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/auth.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/client.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/core.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/enhancements.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/identifiers.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/imports.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/py.typed +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/robots.py +0 -0
- {destiny_sdk-0.1.3 → destiny_sdk-0.1.4}/src/destiny_sdk/visibility.py +0 -0
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"""Reference classes for the Destiny SDK."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from typing import Self
|
|
4
|
+
|
|
5
|
+
from pydantic import UUID4, BaseModel, Field, TypeAdapter
|
|
4
6
|
|
|
5
7
|
from destiny_sdk.core import _JsonlFileInputMixIn
|
|
6
8
|
from destiny_sdk.enhancements import Enhancement, EnhancementFileInput
|
|
7
9
|
from destiny_sdk.identifiers import ExternalIdentifier
|
|
8
10
|
from destiny_sdk.visibility import Visibility
|
|
9
11
|
|
|
12
|
+
external_identifier_adapter = TypeAdapter(ExternalIdentifier)
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class Reference(_JsonlFileInputMixIn, BaseModel):
|
|
12
16
|
"""Core reference class."""
|
|
@@ -27,6 +31,24 @@ class Reference(_JsonlFileInputMixIn, BaseModel):
|
|
|
27
31
|
description="A list of enhancements for the reference",
|
|
28
32
|
)
|
|
29
33
|
|
|
34
|
+
@classmethod
|
|
35
|
+
def from_es(cls, es_reference: dict) -> Self:
|
|
36
|
+
"""Create a Reference from an Elasticsearch document."""
|
|
37
|
+
return cls(
|
|
38
|
+
id=es_reference["_id"],
|
|
39
|
+
visibility=Visibility(es_reference["_source"]["visibility"]),
|
|
40
|
+
identifiers=[
|
|
41
|
+
external_identifier_adapter.validate_python(identifier)
|
|
42
|
+
for identifier in es_reference["_source"].get("identifiers", [])
|
|
43
|
+
],
|
|
44
|
+
enhancements=[
|
|
45
|
+
Enhancement.model_validate(
|
|
46
|
+
enhancement | {"reference_id": es_reference["_id"]},
|
|
47
|
+
)
|
|
48
|
+
for enhancement in es_reference["_source"].get("enhancements", [])
|
|
49
|
+
],
|
|
50
|
+
)
|
|
51
|
+
|
|
30
52
|
|
|
31
53
|
class ReferenceFileInput(_JsonlFileInputMixIn, BaseModel):
|
|
32
54
|
"""Enhancement model used to marshall a file input."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|