destiny_sdk 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl

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/references.py CHANGED
@@ -1,12 +1,16 @@
1
1
  """Reference classes for the Destiny SDK."""
2
2
 
3
- from pydantic import UUID4, BaseModel, Field
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."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: destiny_sdk
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A software development kit (sdk) to support interaction with the DESTINY repository
5
5
  License: Apache 2.0
6
6
  Author: Adam Hamilton
@@ -6,10 +6,10 @@ destiny_sdk/enhancements.py,sha256=2bAFVMVWc-9-82sDnzd0Wujz8CeNm1C5ZtveuSX0JKU,1
6
6
  destiny_sdk/identifiers.py,sha256=JHxu-wM3T8kKtAYuk5dMec35Ay73KxYP7gthbSvOhuI,3480
7
7
  destiny_sdk/imports.py,sha256=mfC1QXbAU27iD3hO9OFTRQes352F6DS1U4fSMw26-8w,8243
8
8
  destiny_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- destiny_sdk/references.py,sha256=Tt9sVgw6WIXIhXGrlgGdRgIrIgQL0yr3Aqb0nr0WfK0,1493
9
+ destiny_sdk/references.py,sha256=Dx-WKcv9gNJkKU9n52AYoEey7siTHR5_wBVBKSHND6Q,2321
10
10
  destiny_sdk/robots.py,sha256=wBXDqD7WGG7fEGUsfQN9T9ZRDCE9jmGPfBwQHH0zO3g,12806
11
11
  destiny_sdk/visibility.py,sha256=nDLqnWuSZSk0vG3ynzDpHAvaALsbk8cuEZujTsqf6no,684
12
- destiny_sdk-0.1.3.dist-info/LICENSE,sha256=6QURU4gvvTjVZ5rfp5amZ6FtFvcpPhAGUjxF5WSZAHI,9138
13
- destiny_sdk-0.1.3.dist-info/METADATA,sha256=fPQsKE7jBjy1vo6-kOvbpxMszEqx-m5OlaaQhMxINsc,2543
14
- destiny_sdk-0.1.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
15
- destiny_sdk-0.1.3.dist-info/RECORD,,
12
+ destiny_sdk-0.1.4.dist-info/LICENSE,sha256=6QURU4gvvTjVZ5rfp5amZ6FtFvcpPhAGUjxF5WSZAHI,9138
13
+ destiny_sdk-0.1.4.dist-info/METADATA,sha256=awSdHvKum39gNkTsC728JSAH6m4qOb4_pV0sa2_GYGA,2543
14
+ destiny_sdk-0.1.4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
15
+ destiny_sdk-0.1.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any