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,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
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool
21
+ from typing_extensions import Self
22
+
23
+
24
+ class VerifiedData(BaseModel):
25
+ """
26
+ VerifiedData
27
+ """
28
+
29
+ valid: StrictBool = Field(description="Whether or not the data has a valid signature.")
30
+ __properties: ClassVar[List[str]] = ["valid"]
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 VerifiedData 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 VerifiedData 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({"valid": obj.get("valid")})
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 VerifyPayload(BaseModel):
25
+ """
26
+ VerifyPayload
27
+ """
28
+
29
+ data: Union[StrictBytes, StrictStr] = Field(description="The data to be verified. 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 VerifyPayload 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 VerifyPayload 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
@@ -0,0 +1,138 @@
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
+ StrictInt,
27
+ StrictStr,
28
+ field_validator,
29
+ )
30
+ from typing_extensions import Self
31
+
32
+
33
+ class Version(BaseModel):
34
+ """
35
+ Version
36
+ """
37
+
38
+ created_at: datetime = Field(
39
+ description="The date and time the creation of the key was triggered.", alias="createdAt"
40
+ )
41
+ destroy_date: Optional[datetime] = Field(
42
+ default=None,
43
+ description="The scheduled date when a version's key material will be erased completely from the backend",
44
+ alias="destroyDate",
45
+ )
46
+ disabled: Optional[StrictBool] = Field(default=False, description="States whether versions is enabled or disabled.")
47
+ key_id: StrictStr = Field(description="The unique id of the key this version is assigned to.", alias="keyId")
48
+ key_ring_id: StrictStr = Field(
49
+ description="The unique id of the key ring the key of this version is assigned to.", alias="keyRingId"
50
+ )
51
+ number: StrictInt = Field(description="A sequential number which identifies the key versions.")
52
+ public_key: Optional[StrictStr] = Field(
53
+ default=None,
54
+ description="The public key of the key version. Only present in asymmetric keys.",
55
+ alias="publicKey",
56
+ )
57
+ state: StrictStr = Field(description="The current state of the key.")
58
+ __properties: ClassVar[List[str]] = [
59
+ "createdAt",
60
+ "destroyDate",
61
+ "disabled",
62
+ "keyId",
63
+ "keyRingId",
64
+ "number",
65
+ "publicKey",
66
+ "state",
67
+ ]
68
+
69
+ @field_validator("state")
70
+ def state_validate_enum(cls, value):
71
+ """Validates the enum"""
72
+ if value not in set(["active", "key_material_not_ready", "key_material_invalid", "disabled", "destroyed"]):
73
+ raise ValueError(
74
+ "must be one of enum values ('active', 'key_material_not_ready', 'key_material_invalid', 'disabled', 'destroyed')"
75
+ )
76
+ return value
77
+
78
+ model_config = ConfigDict(
79
+ populate_by_name=True,
80
+ validate_assignment=True,
81
+ protected_namespaces=(),
82
+ )
83
+
84
+ def to_str(self) -> str:
85
+ """Returns the string representation of the model using alias"""
86
+ return pprint.pformat(self.model_dump(by_alias=True))
87
+
88
+ def to_json(self) -> str:
89
+ """Returns the JSON representation of the model using alias"""
90
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
91
+ return json.dumps(self.to_dict())
92
+
93
+ @classmethod
94
+ def from_json(cls, json_str: str) -> Optional[Self]:
95
+ """Create an instance of Version from a JSON string"""
96
+ return cls.from_dict(json.loads(json_str))
97
+
98
+ def to_dict(self) -> Dict[str, Any]:
99
+ """Return the dictionary representation of the model using alias.
100
+
101
+ This has the following differences from calling pydantic's
102
+ `self.model_dump(by_alias=True)`:
103
+
104
+ * `None` is only added to the output dict for nullable fields that
105
+ were set at model initialization. Other fields with value `None`
106
+ are ignored.
107
+ """
108
+ excluded_fields: Set[str] = set([])
109
+
110
+ _dict = self.model_dump(
111
+ by_alias=True,
112
+ exclude=excluded_fields,
113
+ exclude_none=True,
114
+ )
115
+ return _dict
116
+
117
+ @classmethod
118
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
119
+ """Create an instance of Version from a dict"""
120
+ if obj is None:
121
+ return None
122
+
123
+ if not isinstance(obj, dict):
124
+ return cls.model_validate(obj)
125
+
126
+ _obj = cls.model_validate(
127
+ {
128
+ "createdAt": obj.get("createdAt"),
129
+ "destroyDate": obj.get("destroyDate"),
130
+ "disabled": obj.get("disabled") if obj.get("disabled") is not None else False,
131
+ "keyId": obj.get("keyId"),
132
+ "keyRingId": obj.get("keyRingId"),
133
+ "number": obj.get("number"),
134
+ "publicKey": obj.get("publicKey"),
135
+ "state": obj.get("state"),
136
+ }
137
+ )
138
+ 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
21
+ from typing_extensions import Self
22
+
23
+ from stackit.kms.models.version import Version
24
+
25
+
26
+ class VersionList(BaseModel):
27
+ """
28
+ VersionList
29
+ """
30
+
31
+ versions: List[Version]
32
+ __properties: ClassVar[List[str]] = ["versions"]
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 VersionList 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 versions (list)
72
+ _items = []
73
+ if self.versions:
74
+ for _item in self.versions:
75
+ if _item:
76
+ _items.append(_item.to_dict())
77
+ _dict["versions"] = _items
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of VersionList 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
+ "versions": (
92
+ [Version.from_dict(_item) for _item in obj["versions"]] if obj.get("versions") is not None else None
93
+ )
94
+ }
95
+ )
96
+ return _obj
@@ -0,0 +1,42 @@
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 WrappingAlgorithm(str, Enum):
23
+ """
24
+ The wrapping algorithm used to wrap the key to import.
25
+ """
26
+
27
+ """
28
+ allowed enum values
29
+ """
30
+ RSA_2048_OAEP_SHA256 = "rsa_2048_oaep_sha256"
31
+ RSA_3072_OAEP_SHA256 = "rsa_3072_oaep_sha256"
32
+ RSA_4096_OAEP_SHA256 = "rsa_4096_oaep_sha256"
33
+ RSA_4096_OAEP_SHA512 = "rsa_4096_oaep_sha512"
34
+ RSA_2048_OAEP_SHA256_AES_256_KEY_WRAP = "rsa_2048_oaep_sha256_aes_256_key_wrap"
35
+ RSA_3072_OAEP_SHA256_AES_256_KEY_WRAP = "rsa_3072_oaep_sha256_aes_256_key_wrap"
36
+ RSA_4096_OAEP_SHA256_AES_256_KEY_WRAP = "rsa_4096_oaep_sha256_aes_256_key_wrap"
37
+ RSA_4096_OAEP_SHA512_AES_256_KEY_WRAP = "rsa_4096_oaep_sha512_aes_256_key_wrap"
38
+
39
+ @classmethod
40
+ def from_json(cls, json_str: str) -> Self:
41
+ """Create an instance of WrappingAlgorithm from a JSON string"""
42
+ return cls(json.loads(json_str))
@@ -0,0 +1,139 @@
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
+ from stackit.kms.models.backend import Backend
25
+ from stackit.kms.models.wrapping_algorithm import WrappingAlgorithm
26
+ from stackit.kms.models.wrapping_purpose import WrappingPurpose
27
+
28
+
29
+ class WrappingKey(BaseModel):
30
+ """
31
+ WrappingKey
32
+ """
33
+
34
+ algorithm: WrappingAlgorithm
35
+ backend: Backend
36
+ created_at: datetime = Field(
37
+ description="The date and time the creation of the wrapping key was triggered.", alias="createdAt"
38
+ )
39
+ description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(
40
+ default=None, description="A user chosen description to distinguish multiple wrapping keys."
41
+ )
42
+ display_name: Annotated[str, Field(strict=True, max_length=64)] = Field(
43
+ description="The display name to distinguish multiple wrapping keys.", alias="displayName"
44
+ )
45
+ expires_at: datetime = Field(description="The date and time the wrapping key will expire.", alias="expiresAt")
46
+ id: StrictStr = Field(description="A auto generated unique id which identifies the wrapping keys.")
47
+ key_ring_id: StrictStr = Field(
48
+ description="The unique id of the key ring this wrapping key is assigned to.", alias="keyRingId"
49
+ )
50
+ public_key: Optional[StrictStr] = Field(
51
+ default=None, description="The public key of the wrapping key.", alias="publicKey"
52
+ )
53
+ purpose: WrappingPurpose
54
+ state: StrictStr = Field(description="The current state of the wrapping key.")
55
+ __properties: ClassVar[List[str]] = [
56
+ "algorithm",
57
+ "backend",
58
+ "createdAt",
59
+ "description",
60
+ "displayName",
61
+ "expiresAt",
62
+ "id",
63
+ "keyRingId",
64
+ "publicKey",
65
+ "purpose",
66
+ "state",
67
+ ]
68
+
69
+ @field_validator("state")
70
+ def state_validate_enum(cls, value):
71
+ """Validates the enum"""
72
+ if value not in set(["active", "key_material_not_ready", "expired", "deleting"]):
73
+ raise ValueError("must be one of enum values ('active', 'key_material_not_ready', 'expired', 'deleting')")
74
+ return value
75
+
76
+ model_config = ConfigDict(
77
+ populate_by_name=True,
78
+ validate_assignment=True,
79
+ protected_namespaces=(),
80
+ )
81
+
82
+ def to_str(self) -> str:
83
+ """Returns the string representation of the model using alias"""
84
+ return pprint.pformat(self.model_dump(by_alias=True))
85
+
86
+ def to_json(self) -> str:
87
+ """Returns the JSON representation of the model using alias"""
88
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
89
+ return json.dumps(self.to_dict())
90
+
91
+ @classmethod
92
+ def from_json(cls, json_str: str) -> Optional[Self]:
93
+ """Create an instance of WrappingKey from a JSON string"""
94
+ return cls.from_dict(json.loads(json_str))
95
+
96
+ def to_dict(self) -> Dict[str, Any]:
97
+ """Return the dictionary representation of the model using alias.
98
+
99
+ This has the following differences from calling pydantic's
100
+ `self.model_dump(by_alias=True)`:
101
+
102
+ * `None` is only added to the output dict for nullable fields that
103
+ were set at model initialization. Other fields with value `None`
104
+ are ignored.
105
+ """
106
+ excluded_fields: Set[str] = set([])
107
+
108
+ _dict = self.model_dump(
109
+ by_alias=True,
110
+ exclude=excluded_fields,
111
+ exclude_none=True,
112
+ )
113
+ return _dict
114
+
115
+ @classmethod
116
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
117
+ """Create an instance of WrappingKey from a dict"""
118
+ if obj is None:
119
+ return None
120
+
121
+ if not isinstance(obj, dict):
122
+ return cls.model_validate(obj)
123
+
124
+ _obj = cls.model_validate(
125
+ {
126
+ "algorithm": obj.get("algorithm"),
127
+ "backend": obj.get("backend"),
128
+ "createdAt": obj.get("createdAt"),
129
+ "description": obj.get("description"),
130
+ "displayName": obj.get("displayName"),
131
+ "expiresAt": obj.get("expiresAt"),
132
+ "id": obj.get("id"),
133
+ "keyRingId": obj.get("keyRingId"),
134
+ "publicKey": obj.get("publicKey"),
135
+ "purpose": obj.get("purpose"),
136
+ "state": obj.get("state"),
137
+ }
138
+ )
139
+ return _obj
@@ -0,0 +1,98 @@
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.wrapping_key import WrappingKey
24
+
25
+
26
+ class WrappingKeyList(BaseModel):
27
+ """
28
+ WrappingKeyList
29
+ """
30
+
31
+ wrapping_keys: List[WrappingKey] = Field(alias="wrappingKeys")
32
+ __properties: ClassVar[List[str]] = ["wrappingKeys"]
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 WrappingKeyList 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 wrapping_keys (list)
72
+ _items = []
73
+ if self.wrapping_keys:
74
+ for _item in self.wrapping_keys:
75
+ if _item:
76
+ _items.append(_item.to_dict())
77
+ _dict["wrappingKeys"] = _items
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of WrappingKeyList 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
+ "wrappingKeys": (
92
+ [WrappingKey.from_dict(_item) for _item in obj["wrappingKeys"]]
93
+ if obj.get("wrappingKeys") is not None
94
+ else None
95
+ )
96
+ }
97
+ )
98
+ return _obj