stackit-kms 0.0.1__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.
Files changed (40) hide show
  1. stackit/kms/__init__.py +61 -0
  2. stackit/kms/api/__init__.py +4 -0
  3. stackit/kms/api/default_api.py +7038 -0
  4. stackit/kms/api_client.py +626 -0
  5. stackit/kms/api_response.py +23 -0
  6. stackit/kms/configuration.py +138 -0
  7. stackit/kms/exceptions.py +198 -0
  8. stackit/kms/models/__init__.py +42 -0
  9. stackit/kms/models/algorithm.py +45 -0
  10. stackit/kms/models/backend.py +35 -0
  11. stackit/kms/models/create_key_payload.py +105 -0
  12. stackit/kms/models/create_key_ring_payload.py +86 -0
  13. stackit/kms/models/create_wrapping_key_payload.py +101 -0
  14. stackit/kms/models/decrypt_payload.py +81 -0
  15. stackit/kms/models/decrypted_data.py +81 -0
  16. stackit/kms/models/encrypt_payload.py +81 -0
  17. stackit/kms/models/encrypted_data.py +81 -0
  18. stackit/kms/models/http_error.py +81 -0
  19. stackit/kms/models/import_key_payload.py +86 -0
  20. stackit/kms/models/key.py +150 -0
  21. stackit/kms/models/key_list.py +92 -0
  22. stackit/kms/models/key_ring.py +107 -0
  23. stackit/kms/models/key_ring_list.py +96 -0
  24. stackit/kms/models/purpose.py +38 -0
  25. stackit/kms/models/sign_payload.py +81 -0
  26. stackit/kms/models/signed_data.py +82 -0
  27. stackit/kms/models/verified_data.py +81 -0
  28. stackit/kms/models/verify_payload.py +82 -0
  29. stackit/kms/models/version.py +138 -0
  30. stackit/kms/models/version_list.py +96 -0
  31. stackit/kms/models/wrapping_algorithm.py +42 -0
  32. stackit/kms/models/wrapping_key.py +139 -0
  33. stackit/kms/models/wrapping_key_list.py +98 -0
  34. stackit/kms/models/wrapping_purpose.py +36 -0
  35. stackit/kms/py.typed +0 -0
  36. stackit/kms/rest.py +148 -0
  37. stackit_kms-0.0.1.dist-info/LICENSE.md +201 -0
  38. stackit_kms-0.0.1.dist-info/METADATA +45 -0
  39. stackit_kms-0.0.1.dist-info/RECORD +40 -0
  40. stackit_kms-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,150 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Key Management Service API
5
+
6
+ This API provides endpoints for managing keys and key rings.
7
+
8
+ The version of the OpenAPI document: 1beta.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from datetime import datetime
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import (
22
+ BaseModel,
23
+ ConfigDict,
24
+ Field,
25
+ StrictBool,
26
+ StrictStr,
27
+ field_validator,
28
+ )
29
+ from typing_extensions import Annotated, Self
30
+
31
+ from stackit.kms.models.algorithm import Algorithm
32
+ from stackit.kms.models.backend import Backend
33
+ from stackit.kms.models.purpose import Purpose
34
+
35
+
36
+ class Key(BaseModel):
37
+ """
38
+ Key
39
+ """
40
+
41
+ algorithm: Algorithm
42
+ backend: Backend
43
+ created_at: datetime = Field(
44
+ description="The date and time the creation of the key was triggered.", alias="createdAt"
45
+ )
46
+ deletion_date: Optional[datetime] = Field(
47
+ default=None,
48
+ description="This date is set when a key is pending deletion and refers to the scheduled date of deletion",
49
+ alias="deletionDate",
50
+ )
51
+ description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(
52
+ default=None, description="A user chosen description to distinguish multiple keys."
53
+ )
54
+ display_name: Annotated[str, Field(strict=True, max_length=64)] = Field(
55
+ description="The display name to distinguish multiple keys.", alias="displayName"
56
+ )
57
+ id: StrictStr = Field(description="A auto generated unique id which identifies the keys.")
58
+ import_only: Optional[StrictBool] = Field(
59
+ default=False, description="States whether versions can be created or only imported.", alias="importOnly"
60
+ )
61
+ key_ring_id: StrictStr = Field(
62
+ description="The unique id of the key ring this key is assigned to.", alias="keyRingId"
63
+ )
64
+ purpose: Purpose
65
+ state: StrictStr = Field(description="The current state of the key.")
66
+ __properties: ClassVar[List[str]] = [
67
+ "algorithm",
68
+ "backend",
69
+ "createdAt",
70
+ "deletionDate",
71
+ "description",
72
+ "displayName",
73
+ "id",
74
+ "importOnly",
75
+ "keyRingId",
76
+ "purpose",
77
+ "state",
78
+ ]
79
+
80
+ @field_validator("state")
81
+ def state_validate_enum(cls, value):
82
+ """Validates the enum"""
83
+ if value not in set(["active", "version_not_ready", "deleted"]):
84
+ raise ValueError("must be one of enum values ('active', 'version_not_ready', 'deleted')")
85
+ return value
86
+
87
+ model_config = ConfigDict(
88
+ populate_by_name=True,
89
+ validate_assignment=True,
90
+ protected_namespaces=(),
91
+ )
92
+
93
+ def to_str(self) -> str:
94
+ """Returns the string representation of the model using alias"""
95
+ return pprint.pformat(self.model_dump(by_alias=True))
96
+
97
+ def to_json(self) -> str:
98
+ """Returns the JSON representation of the model using alias"""
99
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
100
+ return json.dumps(self.to_dict())
101
+
102
+ @classmethod
103
+ def from_json(cls, json_str: str) -> Optional[Self]:
104
+ """Create an instance of Key from a JSON string"""
105
+ return cls.from_dict(json.loads(json_str))
106
+
107
+ def to_dict(self) -> Dict[str, Any]:
108
+ """Return the dictionary representation of the model using alias.
109
+
110
+ This has the following differences from calling pydantic's
111
+ `self.model_dump(by_alias=True)`:
112
+
113
+ * `None` is only added to the output dict for nullable fields that
114
+ were set at model initialization. Other fields with value `None`
115
+ are ignored.
116
+ """
117
+ excluded_fields: Set[str] = set([])
118
+
119
+ _dict = self.model_dump(
120
+ by_alias=True,
121
+ exclude=excluded_fields,
122
+ exclude_none=True,
123
+ )
124
+ return _dict
125
+
126
+ @classmethod
127
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
128
+ """Create an instance of Key from a dict"""
129
+ if obj is None:
130
+ return None
131
+
132
+ if not isinstance(obj, dict):
133
+ return cls.model_validate(obj)
134
+
135
+ _obj = cls.model_validate(
136
+ {
137
+ "algorithm": obj.get("algorithm"),
138
+ "backend": obj.get("backend"),
139
+ "createdAt": obj.get("createdAt"),
140
+ "deletionDate": obj.get("deletionDate"),
141
+ "description": obj.get("description"),
142
+ "displayName": obj.get("displayName"),
143
+ "id": obj.get("id"),
144
+ "importOnly": obj.get("importOnly") if obj.get("importOnly") is not None else False,
145
+ "keyRingId": obj.get("keyRingId"),
146
+ "purpose": obj.get("purpose"),
147
+ "state": obj.get("state"),
148
+ }
149
+ )
150
+ return _obj
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Key Management Service API
5
+
6
+ This API provides endpoints for managing keys and key rings.
7
+
8
+ The version of the OpenAPI document: 1beta.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict
21
+ from typing_extensions import Self
22
+
23
+ from stackit.kms.models.key import Key
24
+
25
+
26
+ class KeyList(BaseModel):
27
+ """
28
+ KeyList
29
+ """
30
+
31
+ keys: List[Key]
32
+ __properties: ClassVar[List[str]] = ["keys"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of KeyList from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([])
65
+
66
+ _dict = self.model_dump(
67
+ by_alias=True,
68
+ exclude=excluded_fields,
69
+ exclude_none=True,
70
+ )
71
+ # override the default output from pydantic by calling `to_dict()` of each item in keys (list)
72
+ _items = []
73
+ if self.keys:
74
+ for _item in self.keys:
75
+ if _item:
76
+ _items.append(_item.to_dict())
77
+ _dict["keys"] = _items
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of KeyList from a dict"""
83
+ if obj is None:
84
+ return None
85
+
86
+ if not isinstance(obj, dict):
87
+ return cls.model_validate(obj)
88
+
89
+ _obj = cls.model_validate(
90
+ {"keys": [Key.from_dict(_item) for _item in obj["keys"]] if obj.get("keys") is not None else None}
91
+ )
92
+ return _obj
@@ -0,0 +1,107 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Key Management Service API
5
+
6
+ This API provides endpoints for managing keys and key rings.
7
+
8
+ The version of the OpenAPI document: 1beta.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from datetime import datetime
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
22
+ from typing_extensions import Annotated, Self
23
+
24
+
25
+ class KeyRing(BaseModel):
26
+ """
27
+ KeyRing
28
+ """
29
+
30
+ created_at: datetime = Field(
31
+ description="The date and time the creation of the key ring was triggered.", alias="createdAt"
32
+ )
33
+ description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(
34
+ default=None, description="A user chosen description to distinguish multiple key rings."
35
+ )
36
+ display_name: Annotated[str, Field(strict=True, max_length=64)] = Field(
37
+ description="The display name to distinguish multiple key rings.", alias="displayName"
38
+ )
39
+ id: StrictStr = Field(description="A auto generated unique id which identifies the key ring.")
40
+ state: StrictStr = Field(description="The current state of the key ring.")
41
+ __properties: ClassVar[List[str]] = ["createdAt", "description", "displayName", "id", "state"]
42
+
43
+ @field_validator("state")
44
+ def state_validate_enum(cls, value):
45
+ """Validates the enum"""
46
+ if value not in set(["active", "deleted"]):
47
+ raise ValueError("must be one of enum values ('active', 'deleted')")
48
+ return value
49
+
50
+ model_config = ConfigDict(
51
+ populate_by_name=True,
52
+ validate_assignment=True,
53
+ protected_namespaces=(),
54
+ )
55
+
56
+ def to_str(self) -> str:
57
+ """Returns the string representation of the model using alias"""
58
+ return pprint.pformat(self.model_dump(by_alias=True))
59
+
60
+ def to_json(self) -> str:
61
+ """Returns the JSON representation of the model using alias"""
62
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
63
+ return json.dumps(self.to_dict())
64
+
65
+ @classmethod
66
+ def from_json(cls, json_str: str) -> Optional[Self]:
67
+ """Create an instance of KeyRing from a JSON string"""
68
+ return cls.from_dict(json.loads(json_str))
69
+
70
+ def to_dict(self) -> Dict[str, Any]:
71
+ """Return the dictionary representation of the model using alias.
72
+
73
+ This has the following differences from calling pydantic's
74
+ `self.model_dump(by_alias=True)`:
75
+
76
+ * `None` is only added to the output dict for nullable fields that
77
+ were set at model initialization. Other fields with value `None`
78
+ are ignored.
79
+ """
80
+ excluded_fields: Set[str] = set([])
81
+
82
+ _dict = self.model_dump(
83
+ by_alias=True,
84
+ exclude=excluded_fields,
85
+ exclude_none=True,
86
+ )
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of KeyRing from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate(
99
+ {
100
+ "createdAt": obj.get("createdAt"),
101
+ "description": obj.get("description"),
102
+ "displayName": obj.get("displayName"),
103
+ "id": obj.get("id"),
104
+ "state": obj.get("state"),
105
+ }
106
+ )
107
+ return _obj
@@ -0,0 +1,96 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Key Management Service API
5
+
6
+ This API provides endpoints for managing keys and key rings.
7
+
8
+ The version of the OpenAPI document: 1beta.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field
21
+ from typing_extensions import Self
22
+
23
+ from stackit.kms.models.key_ring import KeyRing
24
+
25
+
26
+ class KeyRingList(BaseModel):
27
+ """
28
+ KeyRingList
29
+ """
30
+
31
+ key_rings: List[KeyRing] = Field(alias="keyRings")
32
+ __properties: ClassVar[List[str]] = ["keyRings"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of KeyRingList from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([])
65
+
66
+ _dict = self.model_dump(
67
+ by_alias=True,
68
+ exclude=excluded_fields,
69
+ exclude_none=True,
70
+ )
71
+ # override the default output from pydantic by calling `to_dict()` of each item in key_rings (list)
72
+ _items = []
73
+ if self.key_rings:
74
+ for _item in self.key_rings:
75
+ if _item:
76
+ _items.append(_item.to_dict())
77
+ _dict["keyRings"] = _items
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of KeyRingList from a dict"""
83
+ if obj is None:
84
+ return None
85
+
86
+ if not isinstance(obj, dict):
87
+ return cls.model_validate(obj)
88
+
89
+ _obj = cls.model_validate(
90
+ {
91
+ "keyRings": (
92
+ [KeyRing.from_dict(_item) for _item in obj["keyRings"]] if obj.get("keyRings") is not None else None
93
+ )
94
+ }
95
+ )
96
+ return _obj
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Key Management Service API
5
+
6
+ This API provides endpoints for managing keys and key rings.
7
+
8
+ The version of the OpenAPI document: 1beta.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ from enum import Enum
18
+
19
+ from typing_extensions import Self
20
+
21
+
22
+ class Purpose(str, Enum):
23
+ """
24
+ The purpose of the key.
25
+ """
26
+
27
+ """
28
+ allowed enum values
29
+ """
30
+ SYMMETRIC_ENCRYPT_DECRYPT = "symmetric_encrypt_decrypt"
31
+ ASYMMETRIC_ENCRYPT_DECRYPT = "asymmetric_encrypt_decrypt"
32
+ MESSAGE_AUTHENTICATION_CODE = "message_authentication_code"
33
+ ASYMMETRIC_SIGN_VERIFY = "asymmetric_sign_verify"
34
+
35
+ @classmethod
36
+ def from_json(cls, json_str: str) -> Self:
37
+ """Create an instance of Purpose from a JSON string"""
38
+ return cls(json.loads(json_str))
@@ -0,0 +1,81 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Key Management Service API
5
+
6
+ This API provides endpoints for managing keys and key rings.
7
+
8
+ The version of the OpenAPI document: 1beta.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set, Union
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
21
+ from typing_extensions import Self
22
+
23
+
24
+ class SignPayload(BaseModel):
25
+ """
26
+ SignPayload
27
+ """
28
+
29
+ data: Union[StrictBytes, StrictStr] = Field(description="The data that has to be signed. Encoded in base64.")
30
+ __properties: ClassVar[List[str]] = ["data"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+ def to_str(self) -> str:
39
+ """Returns the string representation of the model using alias"""
40
+ return pprint.pformat(self.model_dump(by_alias=True))
41
+
42
+ def to_json(self) -> str:
43
+ """Returns the JSON representation of the model using alias"""
44
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
+ return json.dumps(self.to_dict())
46
+
47
+ @classmethod
48
+ def from_json(cls, json_str: str) -> Optional[Self]:
49
+ """Create an instance of SignPayload from a JSON string"""
50
+ return cls.from_dict(json.loads(json_str))
51
+
52
+ def to_dict(self) -> Dict[str, Any]:
53
+ """Return the dictionary representation of the model using alias.
54
+
55
+ This has the following differences from calling pydantic's
56
+ `self.model_dump(by_alias=True)`:
57
+
58
+ * `None` is only added to the output dict for nullable fields that
59
+ were set at model initialization. Other fields with value `None`
60
+ are ignored.
61
+ """
62
+ excluded_fields: Set[str] = set([])
63
+
64
+ _dict = self.model_dump(
65
+ by_alias=True,
66
+ exclude=excluded_fields,
67
+ exclude_none=True,
68
+ )
69
+ return _dict
70
+
71
+ @classmethod
72
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
73
+ """Create an instance of SignPayload from a dict"""
74
+ if obj is None:
75
+ return None
76
+
77
+ if not isinstance(obj, dict):
78
+ return cls.model_validate(obj)
79
+
80
+ _obj = cls.model_validate({"data": obj.get("data")})
81
+ return _obj
@@ -0,0 +1,82 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Key Management Service API
5
+
6
+ This API provides endpoints for managing keys and key rings.
7
+
8
+ The version of the OpenAPI document: 1beta.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set, Union
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr
21
+ from typing_extensions import Self
22
+
23
+
24
+ class SignedData(BaseModel):
25
+ """
26
+ SignedData
27
+ """
28
+
29
+ data: Union[StrictBytes, StrictStr] = Field(description="The data that was signed. Encoded in base64.")
30
+ signature: Union[StrictBytes, StrictStr] = Field(description="The signature of the data. Encoded in base64.")
31
+ __properties: ClassVar[List[str]] = ["data", "signature"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+ def to_str(self) -> str:
40
+ """Returns the string representation of the model using alias"""
41
+ return pprint.pformat(self.model_dump(by_alias=True))
42
+
43
+ def to_json(self) -> str:
44
+ """Returns the JSON representation of the model using alias"""
45
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46
+ return json.dumps(self.to_dict())
47
+
48
+ @classmethod
49
+ def from_json(cls, json_str: str) -> Optional[Self]:
50
+ """Create an instance of SignedData from a JSON string"""
51
+ return cls.from_dict(json.loads(json_str))
52
+
53
+ def to_dict(self) -> Dict[str, Any]:
54
+ """Return the dictionary representation of the model using alias.
55
+
56
+ This has the following differences from calling pydantic's
57
+ `self.model_dump(by_alias=True)`:
58
+
59
+ * `None` is only added to the output dict for nullable fields that
60
+ were set at model initialization. Other fields with value `None`
61
+ are ignored.
62
+ """
63
+ excluded_fields: Set[str] = set([])
64
+
65
+ _dict = self.model_dump(
66
+ by_alias=True,
67
+ exclude=excluded_fields,
68
+ exclude_none=True,
69
+ )
70
+ return _dict
71
+
72
+ @classmethod
73
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
74
+ """Create an instance of SignedData from a dict"""
75
+ if obj is None:
76
+ return None
77
+
78
+ if not isinstance(obj, dict):
79
+ return cls.model_validate(obj)
80
+
81
+ _obj = cls.model_validate({"data": obj.get("data"), "signature": obj.get("signature")})
82
+ return _obj