pangea-sdk 4.4.0__py3-none-any.whl → 5.1.0__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.
- pangea/__init__.py +1 -1
- pangea/asyncio/request.py +19 -9
- pangea/asyncio/services/__init__.py +1 -0
- pangea/asyncio/services/share.py +621 -0
- pangea/asyncio/services/vault.py +1571 -787
- pangea/crypto/rsa.py +88 -0
- pangea/request.py +46 -41
- pangea/response.py +12 -0
- pangea/services/__init__.py +1 -0
- pangea/services/audit/signing.py +5 -4
- pangea/services/share/file_format.py +170 -0
- pangea/services/share/share.py +1256 -0
- pangea/services/vault/models/asymmetric.py +120 -20
- pangea/services/vault/models/common.py +293 -171
- pangea/services/vault/models/keys.py +94 -0
- pangea/services/vault/models/secret.py +27 -3
- pangea/services/vault/models/symmetric.py +66 -24
- pangea/services/vault/vault.py +1551 -782
- pangea/tools.py +6 -7
- pangea/utils.py +92 -18
- pangea/verify_audit.py +4 -4
- {pangea_sdk-4.4.0.dist-info → pangea_sdk-5.1.0.dist-info}/METADATA +3 -4
- {pangea_sdk-4.4.0.dist-info → pangea_sdk-5.1.0.dist-info}/RECORD +24 -20
- {pangea_sdk-4.4.0.dist-info → pangea_sdk-5.1.0.dist-info}/WHEEL +0 -0
pangea/asyncio/services/vault.py
CHANGED
@@ -2,31 +2,35 @@
|
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
|
-
import
|
6
|
-
from typing import
|
5
|
+
from collections.abc import Mapping
|
6
|
+
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union, cast, overload
|
7
|
+
|
8
|
+
from pydantic import Field, TypeAdapter
|
9
|
+
from typing_extensions import Annotated
|
7
10
|
|
8
11
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
9
12
|
from pangea.config import PangeaConfig
|
10
|
-
from pangea.response import PangeaResponse
|
13
|
+
from pangea.response import PangeaResponse, PangeaResponseResult
|
11
14
|
from pangea.services.vault.models.asymmetric import (
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
AsymmetricKey,
|
16
|
+
AsymmetricKeyAlgorithm,
|
17
|
+
AsymmetricKeyEncryptionAlgorithm,
|
18
|
+
AsymmetricKeyJwtAlgorithm,
|
19
|
+
AsymmetricKeyPkiAlgorithm,
|
20
|
+
AsymmetricKeyPurpose,
|
21
|
+
AsymmetricKeySigningAlgorithm,
|
16
22
|
SignRequest,
|
17
23
|
SignResult,
|
18
24
|
VerifyRequest,
|
19
25
|
VerifyResult,
|
20
26
|
)
|
21
27
|
from pangea.services.vault.models.common import (
|
22
|
-
|
28
|
+
ClientSecret,
|
29
|
+
ClientSecretRotateRequest,
|
23
30
|
DecryptTransformRequest,
|
24
31
|
DecryptTransformResult,
|
25
32
|
DeleteRequest,
|
26
33
|
DeleteResult,
|
27
|
-
EncodedPrivateKey,
|
28
|
-
EncodedPublicKey,
|
29
|
-
EncodedSymmetricKey,
|
30
34
|
EncryptStructuredRequest,
|
31
35
|
EncryptStructuredResult,
|
32
36
|
EncryptTransformRequest,
|
@@ -34,13 +38,13 @@ from pangea.services.vault.models.common import (
|
|
34
38
|
ExportEncryptionAlgorithm,
|
35
39
|
ExportRequest,
|
36
40
|
ExportResult,
|
41
|
+
Folder,
|
37
42
|
FolderCreateRequest,
|
38
43
|
FolderCreateResult,
|
44
|
+
GetBulkRequest,
|
39
45
|
GetRequest,
|
40
|
-
GetResult,
|
41
46
|
ItemOrder,
|
42
47
|
ItemOrderBy,
|
43
|
-
ItemState,
|
44
48
|
ItemType,
|
45
49
|
ItemVersionState,
|
46
50
|
JWKGetRequest,
|
@@ -49,38 +53,53 @@ from pangea.services.vault.models.common import (
|
|
49
53
|
JWTSignResult,
|
50
54
|
JWTVerifyRequest,
|
51
55
|
JWTVerifyResult,
|
52
|
-
KeyPurpose,
|
53
|
-
KeyRotateRequest,
|
54
|
-
KeyRotateResult,
|
55
56
|
ListRequest,
|
56
57
|
ListResult,
|
57
58
|
Metadata,
|
59
|
+
PangeaToken,
|
60
|
+
PangeaTokenRotateRequest,
|
61
|
+
RequestManualRotationState,
|
62
|
+
RequestRotationState,
|
63
|
+
RotationState,
|
64
|
+
Secret,
|
58
65
|
StateChangeRequest,
|
59
|
-
StateChangeResult,
|
60
|
-
SymmetricAlgorithm,
|
61
66
|
Tags,
|
62
67
|
TDict,
|
63
68
|
TransformAlphabet,
|
64
69
|
UpdateRequest,
|
65
70
|
UpdateResult,
|
66
71
|
)
|
67
|
-
from pangea.services.vault.models.
|
68
|
-
|
69
|
-
SecretRotateResult,
|
70
|
-
SecretStoreRequest,
|
71
|
-
SecretStoreResult,
|
72
|
-
)
|
72
|
+
from pangea.services.vault.models.keys import CommonGenerateRequest, KeyRotateRequest, KeyStoreRequest
|
73
|
+
from pangea.services.vault.models.secret import SecretRotateRequest, SecretStoreRequest, SecretStoreResult
|
73
74
|
from pangea.services.vault.models.symmetric import (
|
74
75
|
DecryptRequest,
|
75
76
|
DecryptResult,
|
76
77
|
EncryptRequest,
|
77
78
|
EncryptResult,
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
SymmetricKey,
|
80
|
+
SymmetricKeyAlgorithm,
|
81
|
+
SymmetricKeyEncryptionAlgorithm,
|
82
|
+
SymmetricKeyFpeAlgorithm,
|
83
|
+
SymmetricKeyJwtAlgorithm,
|
84
|
+
SymmetricKeyPurpose,
|
82
85
|
)
|
83
86
|
|
87
|
+
if TYPE_CHECKING:
|
88
|
+
import datetime
|
89
|
+
from collections.abc import Mapping
|
90
|
+
|
91
|
+
from pangea.config import PangeaConfig
|
92
|
+
from pangea.request import TResult
|
93
|
+
|
94
|
+
VaultItem = Annotated[
|
95
|
+
Union[AsymmetricKey, SymmetricKey, Secret, ClientSecret, Folder, PangeaToken], Field(discriminator="type")
|
96
|
+
]
|
97
|
+
vault_item_adapter: TypeAdapter[VaultItem] = TypeAdapter(VaultItem)
|
98
|
+
|
99
|
+
|
100
|
+
class GetBulkResponse(PangeaResponseResult):
|
101
|
+
items: List[VaultItem]
|
102
|
+
|
84
103
|
|
85
104
|
class VaultAsync(ServiceBaseAsync):
|
86
105
|
"""Vault service client.
|
@@ -95,14 +114,14 @@ class VaultAsync(ServiceBaseAsync):
|
|
95
114
|
import os
|
96
115
|
|
97
116
|
# Pangea SDK
|
117
|
+
from pangea.asyncio.services import VaultAsync
|
98
118
|
from pangea.config import PangeaConfig
|
99
|
-
from pangea.services.vault import Vault
|
100
119
|
|
101
120
|
PANGEA_VAULT_TOKEN = os.getenv("PANGEA_VAULT_TOKEN")
|
102
121
|
vault_config = PangeaConfig(domain="pangea.cloud")
|
103
122
|
|
104
123
|
# Setup Pangea Vault service
|
105
|
-
vault =
|
124
|
+
vault = VaultAsync(token=PANGEA_VAULT_TOKEN, config=vault_config)
|
106
125
|
"""
|
107
126
|
|
108
127
|
service_name = "vault"
|
@@ -129,120 +148,148 @@ class VaultAsync(ServiceBaseAsync):
|
|
129
148
|
"""
|
130
149
|
super().__init__(token, config, logger_name)
|
131
150
|
|
132
|
-
|
133
|
-
async def delete(self, id: str) -> PangeaResponse[DeleteResult]:
|
151
|
+
async def delete(self, item_id: str, *, recursive: bool = False) -> PangeaResponse[DeleteResult]:
|
134
152
|
"""
|
135
153
|
Delete
|
136
154
|
|
137
155
|
Delete a secret or key
|
138
156
|
|
139
|
-
OperationId:
|
157
|
+
OperationId: vault_post_v2_delete
|
140
158
|
|
141
159
|
Args:
|
142
|
-
|
143
|
-
|
144
|
-
|
160
|
+
item_id: The item ID.
|
161
|
+
recursive: Whether to delete the item and all its children
|
162
|
+
recursively. Only applicable to folders.
|
145
163
|
|
146
164
|
Returns:
|
147
165
|
A PangeaResponse where the id of the deleted secret or key
|
148
166
|
is returned in the response.result field.
|
149
167
|
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#delete).
|
150
168
|
|
169
|
+
Raises:
|
170
|
+
PangeaAPIException: If an API Error happens
|
171
|
+
|
151
172
|
Examples:
|
152
|
-
vault.delete(id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5")
|
173
|
+
await vault.delete(id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5")
|
153
174
|
"""
|
154
|
-
|
155
|
-
id=id,
|
156
|
-
)
|
157
|
-
return await self.request.post("v1/delete", DeleteResult, data=input.model_dump(exclude_none=True))
|
175
|
+
return await self.request.post("v2/delete", DeleteResult, data=DeleteRequest(id=item_id, recursive=recursive))
|
158
176
|
|
159
|
-
# Get endpoint
|
160
177
|
async def get(
|
161
178
|
self,
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
) -> PangeaResponse[GetResult]:
|
179
|
+
item_id: str,
|
180
|
+
*,
|
181
|
+
version: Union[Literal["all"], int, None] = None,
|
182
|
+
) -> PangeaResponse[VaultItem]:
|
167
183
|
"""
|
168
184
|
Retrieve
|
169
185
|
|
170
|
-
Retrieve a secret or
|
186
|
+
Retrieve a secret, key or folder, and any associated information.
|
171
187
|
|
172
|
-
OperationId:
|
188
|
+
OperationId: vault_post_v2_get
|
173
189
|
|
174
190
|
Args:
|
175
|
-
|
176
|
-
version
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
version_state (ItemVersionState, optional): The state of the item version
|
181
|
-
verbose (bool, optional): Return metadata and extra fields. Default is `False`.
|
182
|
-
Raises:
|
183
|
-
PangeaAPIException: If an API Error happens
|
191
|
+
item_id: The item ID
|
192
|
+
version: The key version(s).
|
193
|
+
- `all` for all versions
|
194
|
+
- `num` for a specific version
|
195
|
+
- `-num` for the `num` latest versions
|
184
196
|
|
185
197
|
Returns:
|
186
198
|
A PangeaResponse where the secret or key
|
187
199
|
is returned in the response.result field.
|
188
200
|
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#retrieve).
|
189
201
|
|
202
|
+
Raises:
|
203
|
+
PangeaAPIException: If an API Error happens
|
204
|
+
|
190
205
|
Examples:
|
191
|
-
response = vault.get(
|
206
|
+
response = await vault.get(
|
192
207
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
193
208
|
version=1,
|
194
|
-
version_state=ItemVersionState.ACTIVE,
|
195
|
-
verbose=True,
|
196
209
|
)
|
197
210
|
"""
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
211
|
+
response = await self.request.post("v2/get", PangeaResponseResult, data=GetRequest(id=item_id, version=version))
|
212
|
+
response.result = vault_item_adapter.validate_python(response.json["result"])
|
213
|
+
return cast(PangeaResponse[VaultItem], response)
|
214
|
+
|
215
|
+
async def get_bulk(
|
216
|
+
self,
|
217
|
+
filter_: Mapping[str, str],
|
218
|
+
*,
|
219
|
+
size: int | None = None,
|
220
|
+
order: ItemOrder | None = None,
|
221
|
+
order_by: ItemOrderBy | None = None,
|
222
|
+
last: str | None = None,
|
223
|
+
) -> PangeaResponse[GetBulkResponse]:
|
224
|
+
"""
|
225
|
+
Get bulk
|
226
|
+
|
227
|
+
Retrieve details for multiple Vault items, including keys, secrets,
|
228
|
+
tokens, or folders, that match a given filter specification.
|
229
|
+
|
230
|
+
OperationId: vault_post_v2_get_bulk
|
231
|
+
|
232
|
+
Args:
|
233
|
+
filter: Filters to customize your search.
|
234
|
+
size: Maximum number of items in the response.
|
235
|
+
order: Direction for ordering the results.
|
236
|
+
order_by: Property by which to order the results.
|
237
|
+
last: Internal ID returned in the previous look up response. Used
|
238
|
+
for pagination.
|
239
|
+
|
240
|
+
Examples:
|
241
|
+
response = await vault.get_bulk({"id": "pvi_..."})
|
242
|
+
"""
|
243
|
+
return await self.request.post(
|
244
|
+
"v2/get_bulk",
|
245
|
+
GetBulkResponse,
|
246
|
+
data=GetBulkRequest(filter=filter_, size=size, order=order, order_by=order_by, last=last),
|
203
247
|
)
|
204
|
-
return await self.request.post("v1/get", GetResult, data=input.model_dump(exclude_none=True))
|
205
248
|
|
206
|
-
# List endpoint
|
207
249
|
async def list(
|
208
250
|
self,
|
209
|
-
|
210
|
-
|
251
|
+
*,
|
252
|
+
filter: Optional[Mapping[str, str]] = None,
|
253
|
+
size: int = 50,
|
211
254
|
order: Optional[ItemOrder] = None,
|
212
|
-
order_by:
|
213
|
-
|
255
|
+
order_by: ItemOrderBy | None = None,
|
256
|
+
last: str | None = None,
|
214
257
|
) -> PangeaResponse[ListResult]:
|
215
258
|
"""
|
216
259
|
List
|
217
260
|
|
218
|
-
|
261
|
+
Retrieve a list of secrets, keys and folders, and their associated information.
|
219
262
|
|
220
|
-
OperationId:
|
263
|
+
OperationId: vault_post_v2_list
|
221
264
|
|
222
265
|
Args:
|
223
|
-
filter
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
266
|
+
filter: A set of filters to help you customize your search.
|
267
|
+
|
268
|
+
Examples:
|
269
|
+
- "folder": "/tmp"
|
270
|
+
- "tags": "personal"
|
271
|
+
- "name__contains": "xxx"
|
272
|
+
- "created_at__gt": "2020-02-05T10:00:00Z"
|
273
|
+
|
274
|
+
For metadata, use: "metadata_{key}": "{value}"
|
275
|
+
size: Maximum number of items in the response. Default is `50`.
|
276
|
+
order: Ordering direction: `asc` or `desc`
|
277
|
+
order_by: Property used to order the results. Supported properties: `id`,
|
233
278
|
`type`, `created_at`, `algorithm`, `purpose`, `expiration`, `last_rotated`, `next_rotation`,
|
234
279
|
`name`, `folder`, `item_state`.
|
235
|
-
|
236
|
-
|
237
|
-
PangeaAPIException: If an API Error happens
|
280
|
+
last: Internal ID returned in the previous look up response. Used
|
281
|
+
for pagination.
|
238
282
|
|
239
283
|
Returns:
|
240
284
|
A PangeaResponse where a list of secrets or keys
|
241
285
|
is returned in the response.result field.
|
242
286
|
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#list).
|
243
287
|
|
288
|
+
Raises:
|
289
|
+
PangeaAPIException: If an API Error happens
|
290
|
+
|
244
291
|
Examples:
|
245
|
-
response = vault.list(
|
292
|
+
response = await vault.list(
|
246
293
|
filter={
|
247
294
|
"folder": "/",
|
248
295
|
"type": "asymmetric_key",
|
@@ -256,58 +303,55 @@ class VaultAsync(ServiceBaseAsync):
|
|
256
303
|
size=20,
|
257
304
|
)
|
258
305
|
"""
|
259
|
-
|
260
|
-
|
306
|
+
return await self.request.post(
|
307
|
+
"v2/list",
|
308
|
+
ListResult,
|
309
|
+
data=ListRequest(filter=filter, size=size, order=order, order_by=order_by, last=last),
|
310
|
+
)
|
261
311
|
|
262
|
-
# Update endpoint
|
263
312
|
async def update(
|
264
313
|
self,
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
314
|
+
item_id: str,
|
315
|
+
*,
|
316
|
+
name: str | None = None,
|
317
|
+
folder: str | None = None,
|
318
|
+
metadata: Metadata | None = None,
|
319
|
+
tags: Tags | None = None,
|
320
|
+
disabled_at: str | None = None,
|
321
|
+
enabled: bool | None = None,
|
322
|
+
rotation_frequency: str | None = None,
|
323
|
+
rotation_state: RequestRotationState = RequestRotationState.INHERITED,
|
324
|
+
rotation_grace_period: str | None = None,
|
275
325
|
) -> PangeaResponse[UpdateResult]:
|
276
326
|
"""
|
277
327
|
Update
|
278
328
|
|
279
|
-
Update information associated with a secret or
|
329
|
+
Update information associated with a secret, key or folder.
|
280
330
|
|
281
|
-
OperationId:
|
331
|
+
OperationId: vault_post_v2_update
|
282
332
|
|
283
333
|
Args:
|
284
|
-
|
285
|
-
name
|
286
|
-
folder
|
287
|
-
metadata
|
288
|
-
tags
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
Default is `deactivated`.
|
296
|
-
rotation_grace_period (str, optional): Grace period for the previous version of the Pangea Token
|
297
|
-
expiration (str, optional): Expiration timestamp
|
298
|
-
item_state (ItemState, optional): The new state of the item. Supported options:
|
299
|
-
- `enabled`
|
300
|
-
- `disabled`
|
301
|
-
Raises:
|
302
|
-
PangeaAPIException: If an API Error happens
|
334
|
+
item_id: The item ID.
|
335
|
+
name: The name of this item
|
336
|
+
folder: The folder where this item is stored.
|
337
|
+
metadata: User-provided metadata.
|
338
|
+
tags: A list of user-defined tags.
|
339
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
340
|
+
enabled: True if the item is enabled.
|
341
|
+
rotation_frequency: Period of time between item rotations.
|
342
|
+
rotation_state: State to which the previous version should transition upon rotation.
|
343
|
+
rotation_grace_period: Grace period for the previous version of the Pangea Token.
|
303
344
|
|
304
345
|
Returns:
|
305
|
-
A PangeaResponse where the item ID
|
306
|
-
|
307
|
-
|
346
|
+
A PangeaResponse where the item ID is returned in the
|
347
|
+
response.result field. Available response fields can be found in our
|
348
|
+
[API documentation](https://pangea.cloud/docs/api/vault#update).
|
349
|
+
|
350
|
+
Raises:
|
351
|
+
PangeaAPIException: If an API Error happens
|
308
352
|
|
309
353
|
Examples:
|
310
|
-
response = vault.update(
|
354
|
+
response = await vault.update(
|
311
355
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
312
356
|
name="my-very-secret-secret",
|
313
357
|
folder="/personal",
|
@@ -321,719 +365,1422 @@ class VaultAsync(ServiceBaseAsync):
|
|
321
365
|
],
|
322
366
|
rotation_frequency="10d",
|
323
367
|
rotation_state=ItemVersionState.DEACTIVATED,
|
324
|
-
rotation_grace_period="1d",
|
325
|
-
expiration="2025-01-01T10:00:00Z",
|
326
|
-
item_state=ItemState.DISABLED,
|
327
368
|
)
|
328
369
|
"""
|
329
|
-
|
330
|
-
|
370
|
+
return await self.request.post(
|
371
|
+
"v2/update",
|
372
|
+
UpdateResult,
|
373
|
+
data=UpdateRequest(
|
374
|
+
id=item_id,
|
375
|
+
name=name,
|
376
|
+
folder=folder,
|
377
|
+
metadata=metadata,
|
378
|
+
tags=tags,
|
379
|
+
disabled_at=disabled_at,
|
380
|
+
enabled=enabled,
|
381
|
+
rotation_frequency=rotation_frequency,
|
382
|
+
rotation_state=rotation_state,
|
383
|
+
rotation_grace_period=rotation_grace_period,
|
384
|
+
),
|
385
|
+
)
|
386
|
+
|
387
|
+
async def _secret_store(
|
388
|
+
self,
|
389
|
+
*,
|
390
|
+
item_type: Literal["secret", "pangea_token", "pangea_client_secret"] = "secret",
|
391
|
+
result_class: type[TResult] = SecretStoreResult, # type: ignore[assignment]
|
392
|
+
name: str | None = None,
|
393
|
+
folder: str | None = None,
|
394
|
+
metadata: Metadata | None = None,
|
395
|
+
tags: Tags | None = None,
|
396
|
+
disabled_at: datetime.datetime | None = None,
|
397
|
+
**kwargs: Any,
|
398
|
+
) -> PangeaResponse[TResult]:
|
399
|
+
return await self.request.post(
|
400
|
+
"v2/secret/store",
|
401
|
+
result_class,
|
402
|
+
data=SecretStoreRequest(
|
403
|
+
type=item_type,
|
404
|
+
name=name,
|
405
|
+
folder=folder,
|
406
|
+
metadata=metadata,
|
407
|
+
tags=tags,
|
408
|
+
disabled_at=disabled_at,
|
409
|
+
**kwargs,
|
410
|
+
),
|
411
|
+
)
|
412
|
+
|
413
|
+
async def store_secret(
|
414
|
+
self,
|
415
|
+
secret: str,
|
416
|
+
*,
|
417
|
+
name: str | None = None,
|
418
|
+
folder: str | None = None,
|
419
|
+
metadata: Metadata | None = None,
|
420
|
+
tags: Tags | None = None,
|
421
|
+
disabled_at: datetime.datetime | None = None,
|
422
|
+
) -> PangeaResponse[Secret]:
|
423
|
+
"""
|
424
|
+
Store secret
|
425
|
+
|
426
|
+
Store a secret.
|
427
|
+
|
428
|
+
Args:
|
429
|
+
secret: The secret value.
|
430
|
+
name: The name of this item.
|
431
|
+
folder: The folder where this item is stored.
|
432
|
+
metadata: User-provided metadata.
|
433
|
+
tags: A list of user-defined tags.
|
434
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
435
|
+
|
436
|
+
Raises:
|
437
|
+
PangeaAPIException: If an API Error happens
|
438
|
+
|
439
|
+
Examples:
|
440
|
+
response = await vault.store_secret(secret="foobar")
|
441
|
+
"""
|
442
|
+
|
443
|
+
return await self._secret_store(
|
444
|
+
item_type="secret",
|
445
|
+
result_class=Secret,
|
446
|
+
secret=secret,
|
331
447
|
name=name,
|
332
448
|
folder=folder,
|
333
449
|
metadata=metadata,
|
334
450
|
tags=tags,
|
335
|
-
|
336
|
-
rotation_state=rotation_state,
|
337
|
-
rotation_grace_period=rotation_grace_period,
|
338
|
-
expiration=expiration,
|
339
|
-
item_state=item_state,
|
451
|
+
disabled_at=disabled_at,
|
340
452
|
)
|
341
|
-
return await self.request.post("v1/update", UpdateResult, data=input.model_dump(exclude_none=True))
|
342
453
|
|
343
|
-
async def
|
454
|
+
async def store_pangea_token(
|
344
455
|
self,
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
456
|
+
token: str,
|
457
|
+
*,
|
458
|
+
name: str | None = None,
|
459
|
+
folder: str | None = None,
|
460
|
+
metadata: Metadata | None = None,
|
461
|
+
tags: Tags | None = None,
|
462
|
+
disabled_at: datetime.datetime | None = None,
|
463
|
+
rotation_frequency: str | None = None,
|
464
|
+
rotation_state: RotationState | None = None,
|
465
|
+
rotation_grace_period: str | None = None,
|
466
|
+
) -> PangeaResponse[PangeaToken]:
|
354
467
|
"""
|
355
|
-
|
356
|
-
|
357
|
-
Import a secret
|
468
|
+
Store secret
|
358
469
|
|
359
|
-
|
470
|
+
Store a Pangea token.
|
360
471
|
|
361
472
|
Args:
|
362
|
-
|
363
|
-
name
|
364
|
-
folder
|
365
|
-
metadata
|
366
|
-
tags
|
367
|
-
|
368
|
-
rotation_state (ItemVersionState, optional): State to which the previous version should transition upon rotation.
|
369
|
-
Supported options:
|
370
|
-
- `deactivated`
|
371
|
-
- `destroyed`
|
372
|
-
expiration (str, optional): Expiration timestamp
|
473
|
+
token: The Pangea token value.
|
474
|
+
name: The name of this item.
|
475
|
+
folder: The folder where this item is stored.
|
476
|
+
metadata: User-provided metadata.
|
477
|
+
tags: A list of user-defined tags.
|
478
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
373
479
|
|
374
480
|
Raises:
|
375
481
|
PangeaAPIException: If an API Error happens
|
376
482
|
|
377
|
-
Returns:
|
378
|
-
A PangeaResponse where the secret
|
379
|
-
is returned in the response.result field.
|
380
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#import-a-secret).
|
381
|
-
|
382
483
|
Examples:
|
383
|
-
response = vault.
|
384
|
-
secret="12sdfgs4543qv@#%$casd",
|
385
|
-
name="my-very-secret-secret",
|
386
|
-
folder="/personal",
|
387
|
-
metadata={
|
388
|
-
"created_by": "John Doe",
|
389
|
-
"used_in": "Google products"
|
390
|
-
},
|
391
|
-
tags=[
|
392
|
-
"irs_2023",
|
393
|
-
"personal"
|
394
|
-
],
|
395
|
-
rotation_frequency="10d",
|
396
|
-
rotation_state=ItemVersionState.DEACTIVATED,
|
397
|
-
expiration="2025-01-01T10:00:00Z",
|
398
|
-
)
|
484
|
+
response = await vault.store_pangea_token(token="foobar")
|
399
485
|
"""
|
400
|
-
|
401
|
-
|
402
|
-
|
486
|
+
|
487
|
+
return await self._secret_store(
|
488
|
+
item_type="pangea_token",
|
489
|
+
result_class=PangeaToken,
|
490
|
+
token=token,
|
403
491
|
name=name,
|
404
492
|
folder=folder,
|
405
493
|
metadata=metadata,
|
406
494
|
tags=tags,
|
495
|
+
disabled_at=disabled_at,
|
407
496
|
rotation_frequency=rotation_frequency,
|
408
497
|
rotation_state=rotation_state,
|
409
|
-
|
498
|
+
rotation_grace_period=rotation_grace_period,
|
410
499
|
)
|
411
|
-
return await self.request.post("v1/secret/store", SecretStoreResult, data=input.model_dump(exclude_none=True))
|
412
500
|
|
413
|
-
async def
|
501
|
+
async def store_pangea_client_secret(
|
414
502
|
self,
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
503
|
+
client_secret: str,
|
504
|
+
client_id: str,
|
505
|
+
client_secret_id: str,
|
506
|
+
*,
|
507
|
+
name: str | None = None,
|
508
|
+
folder: str | None = None,
|
509
|
+
metadata: Metadata | None = None,
|
510
|
+
tags: Tags | None = None,
|
511
|
+
disabled_at: datetime.datetime | None = None,
|
512
|
+
rotation_frequency: str | None = None,
|
513
|
+
rotation_state: RotationState | None = None,
|
514
|
+
rotation_grace_period: str | None = None,
|
515
|
+
) -> PangeaResponse[ClientSecret]:
|
424
516
|
"""
|
425
|
-
|
517
|
+
Store secret
|
426
518
|
|
427
|
-
|
428
|
-
|
429
|
-
OperationId: vault_post_v1_secret_store 2
|
519
|
+
Store a Pangea client secret.
|
430
520
|
|
431
521
|
Args:
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
522
|
+
client_secret: The oauth client secret.
|
523
|
+
client_id: The oauth client ID.
|
524
|
+
client_secret_id: The oauth client secret ID.
|
525
|
+
name: The name of this item.
|
526
|
+
folder: The folder where this item is stored.
|
527
|
+
metadata: User-provided metadata.
|
528
|
+
tags: A list of user-defined tags.
|
529
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
530
|
+
rotation_frequency: Period of time between item rotations.
|
531
|
+
rotation_state: State to which the previous version should
|
532
|
+
transition upon rotation.
|
533
|
+
rotation_grace_period: Grace period for the previous version of the
|
534
|
+
Pangea Token.
|
443
535
|
|
444
536
|
Raises:
|
445
537
|
PangeaAPIException: If an API Error happens
|
446
538
|
|
447
|
-
Returns:
|
448
|
-
A PangeaResponse where the token
|
449
|
-
is returned in the response.result field.
|
450
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#import-a-secret).
|
451
|
-
|
452
539
|
Examples:
|
453
|
-
response = vault.
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
metadata={
|
458
|
-
"created_by": "John Doe",
|
459
|
-
"used_in": "Google products"
|
460
|
-
},
|
461
|
-
tags=[
|
462
|
-
"irs_2023",
|
463
|
-
"personal"
|
464
|
-
],
|
465
|
-
rotation_frequency="10d",
|
466
|
-
rotation_state=ItemVersionState.DEACTIVATED,
|
467
|
-
expiration="2025-01-01T10:00:00Z",
|
540
|
+
response = await vault.store_pangea_client_secret(
|
541
|
+
client_secret="foo",
|
542
|
+
client_id="bar",
|
543
|
+
client_secret_id="baz",
|
468
544
|
)
|
469
545
|
"""
|
470
|
-
|
471
|
-
|
472
|
-
|
546
|
+
|
547
|
+
return await self._secret_store(
|
548
|
+
item_type="pangea_client_secret",
|
549
|
+
result_class=ClientSecret,
|
550
|
+
client_secret=client_secret,
|
551
|
+
client_id=client_id,
|
552
|
+
client_secret_id=client_secret_id,
|
473
553
|
name=name,
|
474
554
|
folder=folder,
|
475
555
|
metadata=metadata,
|
476
556
|
tags=tags,
|
557
|
+
disabled_at=disabled_at,
|
477
558
|
rotation_frequency=rotation_frequency,
|
478
559
|
rotation_state=rotation_state,
|
479
|
-
|
560
|
+
rotation_grace_period=rotation_grace_period,
|
480
561
|
)
|
481
|
-
return await self.request.post("v1/secret/store", SecretStoreResult, data=input.model_dump(exclude_none=True))
|
482
562
|
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
563
|
+
async def rotate_secret(
|
564
|
+
self,
|
565
|
+
item_id: str,
|
566
|
+
secret: str,
|
567
|
+
*,
|
568
|
+
rotation_state: RequestManualRotationState = RequestManualRotationState.DEACTIVATED,
|
569
|
+
) -> PangeaResponse[Secret]:
|
487
570
|
"""
|
488
|
-
|
571
|
+
Rotate secret
|
572
|
+
|
573
|
+
Rotate a secret.
|
574
|
+
|
575
|
+
Args:
|
576
|
+
item_id: The item ID.
|
577
|
+
secret: The secret value.
|
578
|
+
rotation_state: State to which the previous version should
|
579
|
+
transition upon rotation.
|
489
580
|
|
490
|
-
|
581
|
+
Raises:
|
582
|
+
PangeaAPIException: If an API Error happens
|
583
|
+
|
584
|
+
Examples:
|
585
|
+
response = await vault.rotate_secret(item_id="foo", secret="bar")
|
586
|
+
"""
|
587
|
+
|
588
|
+
return await self.request.post(
|
589
|
+
"v2/secret/rotate",
|
590
|
+
Secret,
|
591
|
+
data=SecretRotateRequest(id=item_id, secret=secret, rotation_state=rotation_state),
|
592
|
+
)
|
593
|
+
|
594
|
+
async def rotate_pangea_token(
|
595
|
+
self,
|
596
|
+
item_id: str,
|
597
|
+
*,
|
598
|
+
rotation_grace_period: str | None = None,
|
599
|
+
rotation_state: RequestManualRotationState = RequestManualRotationState.DEACTIVATED,
|
600
|
+
) -> PangeaResponse[PangeaToken]:
|
601
|
+
"""
|
602
|
+
Rotate secret
|
491
603
|
|
492
|
-
|
604
|
+
Rotate a Pangea token.
|
493
605
|
|
494
606
|
Args:
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
- `suspended`
|
501
|
-
- `destroyed`
|
607
|
+
item_id: The item ID.
|
608
|
+
rotation_grace_period: Grace period for the previous version of the
|
609
|
+
Pangea Token.
|
610
|
+
rotation_state: State to which the previous version should
|
611
|
+
transition upon rotation.
|
502
612
|
|
503
|
-
|
613
|
+
Raises:
|
614
|
+
PangeaAPIException: If an API Error happens.
|
615
|
+
|
616
|
+
Examples:
|
617
|
+
response = await vault.rotate_pangea_token(item_id="foo")
|
618
|
+
"""
|
619
|
+
|
620
|
+
return await self.request.post(
|
621
|
+
"v2/secret/rotate",
|
622
|
+
PangeaToken,
|
623
|
+
data=PangeaTokenRotateRequest(
|
624
|
+
id=item_id, rotation_grace_period=rotation_grace_period, rotation_state=rotation_state
|
625
|
+
),
|
626
|
+
)
|
627
|
+
|
628
|
+
async def rotate_client_secret(
|
629
|
+
self,
|
630
|
+
item_id: str,
|
631
|
+
*,
|
632
|
+
rotation_grace_period: str | None = None,
|
633
|
+
rotation_state: RequestManualRotationState = RequestManualRotationState.DEACTIVATED,
|
634
|
+
) -> PangeaResponse[ClientSecret]:
|
635
|
+
"""
|
636
|
+
Rotate secret
|
637
|
+
|
638
|
+
Rotate a client secret.
|
639
|
+
|
640
|
+
Args:
|
641
|
+
item_id: The item ID.
|
642
|
+
rotation_grace_period: Grace period for the previous version of the
|
643
|
+
Pangea Token.
|
644
|
+
rotation_state: State to which the previous version should
|
645
|
+
transition upon rotation.
|
504
646
|
|
505
647
|
Raises:
|
506
|
-
PangeaAPIException: If an API Error happens
|
648
|
+
PangeaAPIException: If an API Error happens.
|
507
649
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
650
|
+
Examples:
|
651
|
+
response = await vault.rotate_client_secret(item_id="foo")
|
652
|
+
"""
|
653
|
+
|
654
|
+
return await self.request.post(
|
655
|
+
"v2/secret/rotate",
|
656
|
+
ClientSecret,
|
657
|
+
data=ClientSecretRotateRequest(
|
658
|
+
id=item_id, rotation_grace_period=rotation_grace_period, rotation_state=rotation_state
|
659
|
+
),
|
660
|
+
)
|
661
|
+
|
662
|
+
@overload
|
663
|
+
async def generate_key(
|
664
|
+
self,
|
665
|
+
*,
|
666
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
667
|
+
purpose: Literal[AsymmetricKeyPurpose.SIGNING],
|
668
|
+
algorithm: AsymmetricKeySigningAlgorithm,
|
669
|
+
name: str | None = None,
|
670
|
+
folder: str | None = None,
|
671
|
+
metadata: Metadata | None = None,
|
672
|
+
tags: Tags | None = None,
|
673
|
+
rotation_frequency: str | None = None,
|
674
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
675
|
+
disabled_at: datetime.datetime | None = None,
|
676
|
+
exportable: bool = False,
|
677
|
+
) -> PangeaResponse[AsymmetricKey]:
|
678
|
+
"""
|
679
|
+
Generate key
|
680
|
+
|
681
|
+
Generate an asymmetric signing key.
|
682
|
+
|
683
|
+
Args:
|
684
|
+
key_type: Key type.
|
685
|
+
purpose: The purpose of this key.
|
686
|
+
algorithm: The algorithm of the key.
|
687
|
+
name: The name of this item.
|
688
|
+
folder: The folder where this item is stored.
|
689
|
+
metadata: User-provided metadata.
|
690
|
+
tags: A list of user-defined tags.
|
691
|
+
rotation_frequency: Period of time between item rotations.
|
692
|
+
rotation_state: State to which the previous version should
|
693
|
+
transition upon rotation.
|
694
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
695
|
+
exportable: Whether the key is exportable or not.
|
696
|
+
|
697
|
+
Raises:
|
698
|
+
PangeaAPIException: If an API Error happens.
|
512
699
|
|
513
700
|
Examples:
|
514
|
-
response = vault.
|
515
|
-
|
516
|
-
|
517
|
-
|
701
|
+
response = await vault.generate_key(
|
702
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
703
|
+
purpose=AsymmetricKeyPurpose.SIGNING,
|
704
|
+
algorithm=AsymmetricKeySigningAlgorithm.ED25519,
|
518
705
|
)
|
519
706
|
"""
|
520
|
-
input = SecretRotateRequest(id=id, secret=secret, rotation_state=rotation_state)
|
521
|
-
return await self.request.post("v1/secret/rotate", SecretRotateResult, data=input.model_dump(exclude_none=True))
|
522
707
|
|
523
|
-
|
524
|
-
async def
|
708
|
+
@overload
|
709
|
+
async def generate_key(
|
710
|
+
self,
|
711
|
+
*,
|
712
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
713
|
+
purpose: Literal[AsymmetricKeyPurpose.ENCRYPTION],
|
714
|
+
algorithm: AsymmetricKeyEncryptionAlgorithm,
|
715
|
+
name: str | None = None,
|
716
|
+
folder: str | None = None,
|
717
|
+
metadata: Metadata | None = None,
|
718
|
+
tags: Tags | None = None,
|
719
|
+
rotation_frequency: str | None = None,
|
720
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
721
|
+
disabled_at: datetime.datetime | None = None,
|
722
|
+
exportable: bool = False,
|
723
|
+
) -> PangeaResponse[AsymmetricKey]:
|
724
|
+
"""
|
725
|
+
Generate key
|
726
|
+
|
727
|
+
Generate an asymmetric encryption key.
|
728
|
+
|
729
|
+
Args:
|
730
|
+
key_type: Key type.
|
731
|
+
purpose: The purpose of this key.
|
732
|
+
algorithm: The algorithm of the key.
|
733
|
+
name: The name of this item.
|
734
|
+
folder: The folder where this item is stored.
|
735
|
+
metadata: User-provided metadata.
|
736
|
+
tags: A list of user-defined tags.
|
737
|
+
rotation_frequency: Period of time between item rotations.
|
738
|
+
rotation_state: State to which the previous version should
|
739
|
+
transition upon rotation.
|
740
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
741
|
+
exportable: Whether the key is exportable or not.
|
742
|
+
|
743
|
+
Raises:
|
744
|
+
PangeaAPIException: If an API Error happens.
|
745
|
+
|
746
|
+
Examples:
|
747
|
+
response = await vault.generate_key(
|
748
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
749
|
+
purpose=AsymmetricKeyPurpose.ENCRYPTION,
|
750
|
+
algorithm=AsymmetricKeyEncryptionAlgorithm.RSA_OAEP_2048_SHA1,
|
751
|
+
)
|
525
752
|
"""
|
526
|
-
Token rotate
|
527
753
|
|
528
|
-
|
754
|
+
@overload
|
755
|
+
async def generate_key(
|
756
|
+
self,
|
757
|
+
*,
|
758
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
759
|
+
purpose: Literal[AsymmetricKeyPurpose.JWT],
|
760
|
+
algorithm: AsymmetricKeyJwtAlgorithm,
|
761
|
+
name: str | None = None,
|
762
|
+
folder: str | None = None,
|
763
|
+
metadata: Metadata | None = None,
|
764
|
+
tags: Tags | None = None,
|
765
|
+
rotation_frequency: str | None = None,
|
766
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
767
|
+
disabled_at: datetime.datetime | None = None,
|
768
|
+
exportable: bool = False,
|
769
|
+
) -> PangeaResponse[AsymmetricKey]:
|
770
|
+
"""
|
771
|
+
Generate key
|
529
772
|
|
530
|
-
|
773
|
+
Generate an asymmetric JWT key.
|
531
774
|
|
532
775
|
Args:
|
533
|
-
|
776
|
+
key_type: Key type.
|
777
|
+
purpose: The purpose of this key.
|
778
|
+
algorithm: The algorithm of the key.
|
779
|
+
name: The name of this item.
|
780
|
+
folder: The folder where this item is stored.
|
781
|
+
metadata: User-provided metadata.
|
782
|
+
tags: A list of user-defined tags.
|
783
|
+
rotation_frequency: Period of time between item rotations.
|
784
|
+
rotation_state: State to which the previous version should
|
785
|
+
transition upon rotation.
|
786
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
787
|
+
exportable: Whether the key is exportable or not.
|
534
788
|
|
535
789
|
Raises:
|
536
|
-
PangeaAPIException: If an API Error happens
|
790
|
+
PangeaAPIException: If an API Error happens.
|
537
791
|
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
792
|
+
Examples:
|
793
|
+
response = await vault.generate_key(
|
794
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
795
|
+
purpose=AsymmetricKeyPurpose.JWT,
|
796
|
+
algorithm=AsymmetricKeyJwtAlgorithm.ES512,
|
797
|
+
)
|
798
|
+
"""
|
799
|
+
|
800
|
+
@overload
|
801
|
+
async def generate_key(
|
802
|
+
self,
|
803
|
+
*,
|
804
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
805
|
+
purpose: Literal[AsymmetricKeyPurpose.PKI],
|
806
|
+
algorithm: AsymmetricKeyPkiAlgorithm,
|
807
|
+
name: str | None = None,
|
808
|
+
folder: str | None = None,
|
809
|
+
metadata: Metadata | None = None,
|
810
|
+
tags: Tags | None = None,
|
811
|
+
rotation_frequency: str | None = None,
|
812
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
813
|
+
disabled_at: datetime.datetime | None = None,
|
814
|
+
exportable: bool = False,
|
815
|
+
) -> PangeaResponse[AsymmetricKey]:
|
816
|
+
"""
|
817
|
+
Generate key
|
818
|
+
|
819
|
+
Generate an asymmetric PKI key.
|
820
|
+
|
821
|
+
Args:
|
822
|
+
key_type: Key type.
|
823
|
+
purpose: The purpose of this key.
|
824
|
+
algorithm: The algorithm of the key.
|
825
|
+
name: The name of this item.
|
826
|
+
folder: The folder where this item is stored.
|
827
|
+
metadata: User-provided metadata.
|
828
|
+
tags: A list of user-defined tags.
|
829
|
+
rotation_frequency: Period of time between item rotations.
|
830
|
+
rotation_state: State to which the previous version should
|
831
|
+
transition upon rotation.
|
832
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
833
|
+
exportable: Whether the key is exportable or not.
|
834
|
+
|
835
|
+
Raises:
|
836
|
+
PangeaAPIException: If an API Error happens.
|
542
837
|
|
543
838
|
Examples:
|
544
|
-
response = vault.
|
545
|
-
|
839
|
+
response = await vault.generate_key(
|
840
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
841
|
+
purpose=AsymmetricKeyPurpose.PKI,
|
842
|
+
algorithm=AsymmetricKeyPkiAlgorithm.ED25519,
|
546
843
|
)
|
547
844
|
"""
|
548
|
-
input = SecretRotateRequest(id=id) # type: ignore[call-arg]
|
549
|
-
return await self.request.post("v1/secret/rotate", SecretRotateResult, data=input.model_dump(exclude_none=True))
|
550
845
|
|
551
|
-
|
846
|
+
@overload
|
847
|
+
async def generate_key(
|
552
848
|
self,
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
849
|
+
*,
|
850
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
851
|
+
purpose: AsymmetricKeyPurpose,
|
852
|
+
algorithm: AsymmetricKeyAlgorithm,
|
853
|
+
name: str | None = None,
|
854
|
+
folder: str | None = None,
|
855
|
+
metadata: Metadata | None = None,
|
856
|
+
tags: Tags | None = None,
|
857
|
+
rotation_frequency: str | None = None,
|
858
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
859
|
+
disabled_at: datetime.datetime | None = None,
|
860
|
+
exportable: bool = False,
|
861
|
+
) -> PangeaResponse[AsymmetricKey]:
|
862
|
+
"""
|
863
|
+
Generate key
|
864
|
+
|
865
|
+
Generate an asymmetric key.
|
866
|
+
|
867
|
+
Args:
|
868
|
+
key_type: Key type.
|
869
|
+
purpose: The purpose of this key.
|
870
|
+
algorithm: The algorithm of the key.
|
871
|
+
name: The name of this item.
|
872
|
+
folder: The folder where this item is stored.
|
873
|
+
metadata: User-provided metadata.
|
874
|
+
tags: A list of user-defined tags.
|
875
|
+
rotation_frequency: Period of time between item rotations.
|
876
|
+
rotation_state: State to which the previous version should
|
877
|
+
transition upon rotation.
|
878
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
879
|
+
exportable: Whether the key is exportable or not.
|
880
|
+
|
881
|
+
Raises:
|
882
|
+
PangeaAPIException: If an API Error happens.
|
883
|
+
|
884
|
+
Examples:
|
885
|
+
response = await vault.generate_key(
|
886
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
887
|
+
purpose=AsymmetricKeyPurpose.PKI,
|
888
|
+
algorithm=AsymmetricKeyPkiAlgorithm.ED25519,
|
889
|
+
)
|
564
890
|
"""
|
565
|
-
Symmetric generate
|
566
891
|
|
567
|
-
|
892
|
+
@overload
|
893
|
+
async def generate_key(
|
894
|
+
self,
|
895
|
+
*,
|
896
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
897
|
+
purpose: Literal[SymmetricKeyPurpose.ENCRYPTION],
|
898
|
+
algorithm: SymmetricKeyEncryptionAlgorithm,
|
899
|
+
name: str | None = None,
|
900
|
+
folder: str | None = None,
|
901
|
+
metadata: Metadata | None = None,
|
902
|
+
tags: Tags | None = None,
|
903
|
+
rotation_frequency: str | None = None,
|
904
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
905
|
+
disabled_at: datetime.datetime | None = None,
|
906
|
+
exportable: bool = False,
|
907
|
+
) -> PangeaResponse[SymmetricKey]:
|
908
|
+
"""
|
909
|
+
Generate key
|
568
910
|
|
569
|
-
|
911
|
+
Generate a symmetric encryption key.
|
570
912
|
|
571
913
|
Args:
|
572
|
-
|
573
|
-
purpose
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
exportable (bool, optional): Whether the key is exportable or not
|
914
|
+
key_type: Key type.
|
915
|
+
purpose: The purpose of this key.
|
916
|
+
algorithm: The algorithm of the key.
|
917
|
+
name: The name of this item.
|
918
|
+
folder: The folder where this item is stored.
|
919
|
+
metadata: User-provided metadata.
|
920
|
+
tags: A list of user-defined tags.
|
921
|
+
rotation_frequency: Period of time between item rotations.
|
922
|
+
rotation_state: State to which the previous version should
|
923
|
+
transition upon rotation.
|
924
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
925
|
+
exportable: Whether the key is exportable or not.
|
585
926
|
|
586
927
|
Raises:
|
587
|
-
PangeaAPIException: If an API Error happens
|
928
|
+
PangeaAPIException: If an API Error happens.
|
588
929
|
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
930
|
+
Examples:
|
931
|
+
response = await vault.generate_key(
|
932
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
933
|
+
purpose=SymmetricKeyPurpose.ENCRYPTION,
|
934
|
+
algorithm=SymmetricKeyEncryptionAlgorithm.AES_CFB_128,
|
935
|
+
)
|
936
|
+
"""
|
937
|
+
|
938
|
+
@overload
|
939
|
+
async def generate_key(
|
940
|
+
self,
|
941
|
+
*,
|
942
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
943
|
+
purpose: Literal[SymmetricKeyPurpose.JWT],
|
944
|
+
algorithm: SymmetricKeyJwtAlgorithm,
|
945
|
+
name: str | None = None,
|
946
|
+
folder: str | None = None,
|
947
|
+
metadata: Metadata | None = None,
|
948
|
+
tags: Tags | None = None,
|
949
|
+
rotation_frequency: str | None = None,
|
950
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
951
|
+
disabled_at: datetime.datetime | None = None,
|
952
|
+
exportable: bool = False,
|
953
|
+
) -> PangeaResponse[SymmetricKey]:
|
954
|
+
"""
|
955
|
+
Generate key
|
956
|
+
|
957
|
+
Generate a symmetric JWT key.
|
958
|
+
|
959
|
+
Args:
|
960
|
+
key_type: Key type.
|
961
|
+
purpose: The purpose of this key.
|
962
|
+
algorithm: The algorithm of the key.
|
963
|
+
name: The name of this item.
|
964
|
+
folder: The folder where this item is stored.
|
965
|
+
metadata: User-provided metadata.
|
966
|
+
tags: A list of user-defined tags.
|
967
|
+
rotation_frequency: Period of time between item rotations.
|
968
|
+
rotation_state: State to which the previous version should
|
969
|
+
transition upon rotation.
|
970
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
971
|
+
exportable: Whether the key is exportable or not.
|
972
|
+
|
973
|
+
Raises:
|
974
|
+
PangeaAPIException: If an API Error happens.
|
593
975
|
|
594
976
|
Examples:
|
595
|
-
response = vault.
|
596
|
-
|
597
|
-
purpose=
|
598
|
-
|
599
|
-
folder="/personal",
|
600
|
-
metadata={
|
601
|
-
"created_by": "John Doe",
|
602
|
-
"used_in": "Google products"
|
603
|
-
},
|
604
|
-
tags=[
|
605
|
-
"irs_2023",
|
606
|
-
"personal"
|
607
|
-
],
|
608
|
-
rotation_frequency="10d",
|
609
|
-
rotation_state=ItemVersionState.DEACTIVATED,
|
610
|
-
expiration="2025-01-01T10:00:00Z",
|
977
|
+
response = await vault.generate_key(
|
978
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
979
|
+
purpose=SymmetricKeyPurpose.JWT,
|
980
|
+
algorithm=SymmetricKeyJwtAlgorithm.HS512,
|
611
981
|
)
|
612
982
|
"""
|
613
|
-
input = SymmetricGenerateRequest(
|
614
|
-
type=ItemType.SYMMETRIC_KEY,
|
615
|
-
algorithm=algorithm,
|
616
|
-
purpose=purpose,
|
617
|
-
name=name, # type: ignore[arg-type]
|
618
|
-
folder=folder,
|
619
|
-
metadata=metadata,
|
620
|
-
tags=tags,
|
621
|
-
rotation_frequency=rotation_frequency,
|
622
|
-
rotation_state=rotation_state,
|
623
|
-
expiration=expiration,
|
624
|
-
exportable=exportable,
|
625
|
-
)
|
626
|
-
return await self.request.post(
|
627
|
-
"v1/key/generate", SymmetricGenerateResult, data=input.model_dump(exclude_none=True)
|
628
|
-
)
|
629
983
|
|
630
|
-
|
984
|
+
@overload
|
985
|
+
async def generate_key(
|
631
986
|
self,
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
987
|
+
*,
|
988
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
989
|
+
purpose: Literal[SymmetricKeyPurpose.FPE],
|
990
|
+
algorithm: SymmetricKeyFpeAlgorithm,
|
991
|
+
name: str | None = None,
|
992
|
+
folder: str | None = None,
|
993
|
+
metadata: Metadata | None = None,
|
994
|
+
tags: Tags | None = None,
|
995
|
+
rotation_frequency: str | None = None,
|
996
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
997
|
+
disabled_at: datetime.datetime | None = None,
|
998
|
+
exportable: bool = False,
|
999
|
+
) -> PangeaResponse[SymmetricKey]:
|
643
1000
|
"""
|
644
|
-
|
1001
|
+
Generate key
|
645
1002
|
|
646
|
-
Generate
|
1003
|
+
Generate a symmetric FPE key.
|
1004
|
+
|
1005
|
+
Args:
|
1006
|
+
key_type: Key type.
|
1007
|
+
purpose: The purpose of this key.
|
1008
|
+
algorithm: The algorithm of the key.
|
1009
|
+
name: The name of this item.
|
1010
|
+
folder: The folder where this item is stored.
|
1011
|
+
metadata: User-provided metadata.
|
1012
|
+
tags: A list of user-defined tags.
|
1013
|
+
rotation_frequency: Period of time between item rotations.
|
1014
|
+
rotation_state: State to which the previous version should
|
1015
|
+
transition upon rotation.
|
1016
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1017
|
+
exportable: Whether the key is exportable or not.
|
647
1018
|
|
648
|
-
|
1019
|
+
Raises:
|
1020
|
+
PangeaAPIException: If an API Error happens.
|
1021
|
+
|
1022
|
+
Examples:
|
1023
|
+
response = await vault.generate_key(
|
1024
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
1025
|
+
purpose=SymmetricKeyPurpose.FPE,
|
1026
|
+
algorithm=SymmetricKeyFpeAlgorithm.AES_FF3_1_256_BETA,
|
1027
|
+
)
|
1028
|
+
"""
|
1029
|
+
|
1030
|
+
@overload
|
1031
|
+
async def generate_key(
|
1032
|
+
self,
|
1033
|
+
*,
|
1034
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
1035
|
+
purpose: SymmetricKeyPurpose,
|
1036
|
+
algorithm: SymmetricKeyAlgorithm,
|
1037
|
+
name: str | None = None,
|
1038
|
+
folder: str | None = None,
|
1039
|
+
metadata: Metadata | None = None,
|
1040
|
+
tags: Tags | None = None,
|
1041
|
+
rotation_frequency: str | None = None,
|
1042
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1043
|
+
disabled_at: datetime.datetime | None = None,
|
1044
|
+
exportable: bool = False,
|
1045
|
+
) -> PangeaResponse[SymmetricKey]:
|
1046
|
+
"""
|
1047
|
+
Generate key
|
1048
|
+
|
1049
|
+
Generate a symmetric key.
|
649
1050
|
|
650
1051
|
Args:
|
651
|
-
|
652
|
-
purpose
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
exportable (bool, optional): Whether the key is exportable or not
|
1052
|
+
key_type: Key type.
|
1053
|
+
purpose: The purpose of this key.
|
1054
|
+
algorithm: The algorithm of the key.
|
1055
|
+
name: The name of this item.
|
1056
|
+
folder: The folder where this item is stored.
|
1057
|
+
metadata: User-provided metadata.
|
1058
|
+
tags: A list of user-defined tags.
|
1059
|
+
rotation_frequency: Period of time between item rotations.
|
1060
|
+
rotation_state: State to which the previous version should
|
1061
|
+
transition upon rotation.
|
1062
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1063
|
+
exportable: Whether the key is exportable or not.
|
664
1064
|
|
665
1065
|
Raises:
|
666
|
-
PangeaAPIException: If an API Error happens
|
1066
|
+
PangeaAPIException: If an API Error happens.
|
667
1067
|
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
1068
|
+
Examples:
|
1069
|
+
response = await vault.generate_key(
|
1070
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
1071
|
+
purpose=SymmetricKeyPurpose.FPE,
|
1072
|
+
algorithm=SymmetricKeyFpeAlgorithm.AES_FF3_1_256_BETA,
|
1073
|
+
)
|
1074
|
+
"""
|
1075
|
+
|
1076
|
+
async def generate_key(
|
1077
|
+
self,
|
1078
|
+
*,
|
1079
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY, ItemType.SYMMETRIC_KEY],
|
1080
|
+
purpose: SymmetricKeyPurpose | AsymmetricKeyPurpose,
|
1081
|
+
algorithm: AsymmetricKeyAlgorithm | SymmetricKeyAlgorithm,
|
1082
|
+
name: str | None = None,
|
1083
|
+
folder: str | None = None,
|
1084
|
+
metadata: Metadata | None = None,
|
1085
|
+
tags: Tags | None = None,
|
1086
|
+
rotation_frequency: str | None = None,
|
1087
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1088
|
+
disabled_at: datetime.datetime | None = None,
|
1089
|
+
exportable: bool = False,
|
1090
|
+
) -> PangeaResponse[Any]:
|
1091
|
+
"""
|
1092
|
+
Generate key
|
1093
|
+
|
1094
|
+
Generate a key.
|
1095
|
+
|
1096
|
+
Args:
|
1097
|
+
key_type: Key type.
|
1098
|
+
purpose: The purpose of this key.
|
1099
|
+
algorithm: The algorithm of the key.
|
1100
|
+
name: The name of this item.
|
1101
|
+
folder: The folder where this item is stored.
|
1102
|
+
metadata: User-provided metadata.
|
1103
|
+
tags: A list of user-defined tags.
|
1104
|
+
rotation_frequency: Period of time between item rotations.
|
1105
|
+
rotation_state: State to which the previous version should
|
1106
|
+
transition upon rotation.
|
1107
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1108
|
+
exportable: Whether the key is exportable or not.
|
1109
|
+
|
1110
|
+
Raises:
|
1111
|
+
PangeaAPIException: If an API Error happens.
|
672
1112
|
|
673
1113
|
Examples:
|
674
|
-
response = vault.
|
675
|
-
|
676
|
-
purpose=
|
677
|
-
|
678
|
-
folder="/personal",
|
679
|
-
metadata={
|
680
|
-
"created_by": "John Doe",
|
681
|
-
"used_in": "Google products"
|
682
|
-
},
|
683
|
-
tags=[
|
684
|
-
"irs_2023",
|
685
|
-
"personal"
|
686
|
-
],
|
687
|
-
rotation_frequency="10d",
|
688
|
-
rotation_state=ItemVersionState.DEACTIVATED,
|
689
|
-
expiration="2025-01-01T10:00:00Z",
|
1114
|
+
response = await vault.generate_key(
|
1115
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
1116
|
+
purpose=SymmetricKeyPurpose.FPE,
|
1117
|
+
algorithm=SymmetricKeyFpeAlgorithm.AES_FF3_1_256_BETA,
|
690
1118
|
)
|
691
1119
|
"""
|
692
|
-
|
693
|
-
type=ItemType.ASYMMETRIC_KEY,
|
694
|
-
algorithm=algorithm,
|
695
|
-
purpose=purpose,
|
696
|
-
name=name, # type: ignore[arg-type]
|
697
|
-
folder=folder,
|
698
|
-
metadata=metadata,
|
699
|
-
tags=tags,
|
700
|
-
rotation_frequency=rotation_frequency,
|
701
|
-
rotation_state=rotation_state,
|
702
|
-
expiration=expiration,
|
703
|
-
exportable=exportable,
|
704
|
-
)
|
1120
|
+
|
705
1121
|
return await self.request.post(
|
706
|
-
"
|
1122
|
+
"v2/key/generate",
|
1123
|
+
AsymmetricKey if key_type == ItemType.ASYMMETRIC_KEY else SymmetricKey,
|
1124
|
+
data=CommonGenerateRequest(
|
1125
|
+
type=key_type,
|
1126
|
+
purpose=purpose,
|
1127
|
+
algorithm=algorithm,
|
1128
|
+
name=name,
|
1129
|
+
folder=folder,
|
1130
|
+
metadata=metadata,
|
1131
|
+
tags=tags,
|
1132
|
+
rotation_frequency=rotation_frequency,
|
1133
|
+
rotation_state=rotation_state,
|
1134
|
+
disabled_at=disabled_at,
|
1135
|
+
exportable=exportable,
|
1136
|
+
),
|
707
1137
|
)
|
708
1138
|
|
709
|
-
|
710
|
-
async def
|
1139
|
+
@overload
|
1140
|
+
async def store_key(
|
711
1141
|
self,
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
1142
|
+
*,
|
1143
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
1144
|
+
purpose: Literal[AsymmetricKeyPurpose.SIGNING],
|
1145
|
+
algorithm: AsymmetricKeySigningAlgorithm,
|
1146
|
+
public_key: str,
|
1147
|
+
private_key: str,
|
1148
|
+
name: str | None = None,
|
1149
|
+
folder: str | None = None,
|
1150
|
+
metadata: Metadata | None = None,
|
1151
|
+
tags: Tags | None = None,
|
1152
|
+
rotation_frequency: str | None = None,
|
1153
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1154
|
+
disabled_at: datetime.datetime | None = None,
|
1155
|
+
exportable: bool = False,
|
1156
|
+
) -> PangeaResponse[AsymmetricKey]:
|
1157
|
+
"""
|
1158
|
+
Store key
|
1159
|
+
|
1160
|
+
Import an asymmetric signing key.
|
1161
|
+
|
1162
|
+
Args:
|
1163
|
+
key_type: Key type.
|
1164
|
+
purpose: The purpose of this key.
|
1165
|
+
algorithm: The algorithm of the key.
|
1166
|
+
public_key: The public key (in PEM format).
|
1167
|
+
private_key: The private key (in PEM format).
|
1168
|
+
name: The name of this item.
|
1169
|
+
folder: The folder where this item is stored.
|
1170
|
+
metadata: User-provided metadata.
|
1171
|
+
tags: A list of user-defined tags.
|
1172
|
+
rotation_frequency: Period of time between item rotations.
|
1173
|
+
rotation_state: State to which the previous version should
|
1174
|
+
transition upon rotation.
|
1175
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1176
|
+
exportable: Whether the key is exportable or not.
|
1177
|
+
|
1178
|
+
Raises:
|
1179
|
+
PangeaAPIException: If an API Error happens.
|
1180
|
+
|
1181
|
+
Examples:
|
1182
|
+
response = await vault.store_key(
|
1183
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
1184
|
+
purpose=AsymmetricKeyPurpose.SIGNING,
|
1185
|
+
algorithm=AsymmetricKeySigningAlgorithm.ED25519,
|
1186
|
+
)
|
725
1187
|
"""
|
726
|
-
Asymmetric store
|
727
1188
|
|
728
|
-
|
1189
|
+
@overload
|
1190
|
+
async def store_key(
|
1191
|
+
self,
|
1192
|
+
*,
|
1193
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
1194
|
+
purpose: Literal[AsymmetricKeyPurpose.ENCRYPTION],
|
1195
|
+
algorithm: AsymmetricKeyEncryptionAlgorithm,
|
1196
|
+
public_key: str,
|
1197
|
+
private_key: str,
|
1198
|
+
name: str | None = None,
|
1199
|
+
folder: str | None = None,
|
1200
|
+
metadata: Metadata | None = None,
|
1201
|
+
tags: Tags | None = None,
|
1202
|
+
rotation_frequency: str | None = None,
|
1203
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1204
|
+
disabled_at: datetime.datetime | None = None,
|
1205
|
+
exportable: bool = False,
|
1206
|
+
) -> PangeaResponse[AsymmetricKey]:
|
1207
|
+
"""
|
1208
|
+
Store key
|
729
1209
|
|
730
|
-
|
1210
|
+
Import an asymmetric encryption key.
|
731
1211
|
|
732
1212
|
Args:
|
733
|
-
|
734
|
-
|
735
|
-
algorithm
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
exportable (bool, optional): Whether the key is exportable or not
|
1213
|
+
key_type: Key type.
|
1214
|
+
purpose: The purpose of this key.
|
1215
|
+
algorithm: The algorithm of the key.
|
1216
|
+
public_key: The public key (in PEM format).
|
1217
|
+
private_key: The private key (in PEM format).
|
1218
|
+
name: The name of this item.
|
1219
|
+
folder: The folder where this item is stored.
|
1220
|
+
metadata: User-provided metadata.
|
1221
|
+
tags: A list of user-defined tags.
|
1222
|
+
rotation_frequency: Period of time between item rotations.
|
1223
|
+
rotation_state: State to which the previous version should
|
1224
|
+
transition upon rotation.
|
1225
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1226
|
+
exportable: Whether the key is exportable or not.
|
748
1227
|
|
749
1228
|
Raises:
|
750
|
-
PangeaAPIException: If an API Error happens
|
1229
|
+
PangeaAPIException: If an API Error happens.
|
751
1230
|
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
1231
|
+
Examples:
|
1232
|
+
response = await vault.store_key(
|
1233
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
1234
|
+
purpose=AsymmetricKeyPurpose.ENCRYPTION,
|
1235
|
+
algorithm=AsymmetricKeyEncryptionAlgorithm.RSA_OAEP_2048_SHA1,
|
1236
|
+
)
|
1237
|
+
"""
|
1238
|
+
|
1239
|
+
@overload
|
1240
|
+
async def store_key(
|
1241
|
+
self,
|
1242
|
+
*,
|
1243
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
1244
|
+
purpose: Literal[AsymmetricKeyPurpose.JWT],
|
1245
|
+
algorithm: AsymmetricKeyJwtAlgorithm,
|
1246
|
+
public_key: str,
|
1247
|
+
private_key: str,
|
1248
|
+
name: str | None = None,
|
1249
|
+
folder: str | None = None,
|
1250
|
+
metadata: Metadata | None = None,
|
1251
|
+
tags: Tags | None = None,
|
1252
|
+
rotation_frequency: str | None = None,
|
1253
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1254
|
+
disabled_at: datetime.datetime | None = None,
|
1255
|
+
exportable: bool = False,
|
1256
|
+
) -> PangeaResponse[AsymmetricKey]:
|
1257
|
+
"""
|
1258
|
+
Store key
|
1259
|
+
|
1260
|
+
Import an asymmetric JWT key.
|
1261
|
+
|
1262
|
+
Args:
|
1263
|
+
key_type: Key type.
|
1264
|
+
purpose: The purpose of this key.
|
1265
|
+
algorithm: The algorithm of the key.
|
1266
|
+
public_key: The public key (in PEM format).
|
1267
|
+
private_key: The private key (in PEM format).
|
1268
|
+
name: The name of this item.
|
1269
|
+
folder: The folder where this item is stored.
|
1270
|
+
metadata: User-provided metadata.
|
1271
|
+
tags: A list of user-defined tags.
|
1272
|
+
rotation_frequency: Period of time between item rotations.
|
1273
|
+
rotation_state: State to which the previous version should
|
1274
|
+
transition upon rotation.
|
1275
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1276
|
+
exportable: Whether the key is exportable or not.
|
1277
|
+
|
1278
|
+
Raises:
|
1279
|
+
PangeaAPIException: If an API Error happens.
|
756
1280
|
|
757
1281
|
Examples:
|
758
|
-
response = vault.
|
759
|
-
|
760
|
-
|
761
|
-
algorithm=
|
762
|
-
purpose=KeyPurpose.SIGNING,
|
763
|
-
name="my-very-secret-secret",
|
764
|
-
folder="/personal",
|
765
|
-
metadata={
|
766
|
-
"created_by": "John Doe",
|
767
|
-
"used_in": "Google products"
|
768
|
-
},
|
769
|
-
tags=[
|
770
|
-
"irs_2023",
|
771
|
-
"personal"
|
772
|
-
],
|
773
|
-
rotation_frequency="10d",
|
774
|
-
rotation_state=ItemVersionState.DEACTIVATED,
|
775
|
-
expiration="2025-01-01T10:00:00Z",
|
1282
|
+
response = await vault.store_key(
|
1283
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
1284
|
+
purpose=AsymmetricKeyPurpose.JWT,
|
1285
|
+
algorithm=AsymmetricKeyJwtAlgorithm.ES512,
|
776
1286
|
)
|
777
1287
|
"""
|
778
|
-
input = AsymmetricStoreRequest(
|
779
|
-
type=ItemType.ASYMMETRIC_KEY,
|
780
|
-
algorithm=algorithm,
|
781
|
-
purpose=purpose,
|
782
|
-
public_key=public_key,
|
783
|
-
private_key=private_key,
|
784
|
-
name=name,
|
785
|
-
folder=folder,
|
786
|
-
metadata=metadata,
|
787
|
-
tags=tags,
|
788
|
-
rotation_frequency=rotation_frequency,
|
789
|
-
rotation_state=rotation_state,
|
790
|
-
expiration=expiration,
|
791
|
-
exportable=exportable,
|
792
|
-
)
|
793
|
-
return await self.request.post("v1/key/store", AsymmetricStoreResult, data=input.model_dump(exclude_none=True))
|
794
1288
|
|
795
|
-
|
1289
|
+
@overload
|
1290
|
+
async def store_key(
|
796
1291
|
self,
|
1292
|
+
*,
|
1293
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
1294
|
+
purpose: Literal[AsymmetricKeyPurpose.PKI],
|
1295
|
+
algorithm: AsymmetricKeyPkiAlgorithm,
|
1296
|
+
public_key: str,
|
1297
|
+
private_key: str,
|
1298
|
+
name: str | None = None,
|
1299
|
+
folder: str | None = None,
|
1300
|
+
metadata: Metadata | None = None,
|
1301
|
+
tags: Tags | None = None,
|
1302
|
+
rotation_frequency: str | None = None,
|
1303
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1304
|
+
disabled_at: datetime.datetime | None = None,
|
1305
|
+
exportable: bool = False,
|
1306
|
+
) -> PangeaResponse[AsymmetricKey]:
|
1307
|
+
"""
|
1308
|
+
Store key
|
1309
|
+
|
1310
|
+
Import an asymmetric PKI key.
|
1311
|
+
|
1312
|
+
Args:
|
1313
|
+
key_type: Key type.
|
1314
|
+
purpose: The purpose of this key.
|
1315
|
+
algorithm: The algorithm of the key.
|
1316
|
+
public_key: The public key (in PEM format).
|
1317
|
+
private_key: The private key (in PEM format).
|
1318
|
+
name: The name of this item.
|
1319
|
+
folder: The folder where this item is stored.
|
1320
|
+
metadata: User-provided metadata.
|
1321
|
+
tags: A list of user-defined tags.
|
1322
|
+
rotation_frequency: Period of time between item rotations.
|
1323
|
+
rotation_state: State to which the previous version should
|
1324
|
+
transition upon rotation.
|
1325
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1326
|
+
exportable: Whether the key is exportable or not.
|
1327
|
+
|
1328
|
+
Raises:
|
1329
|
+
PangeaAPIException: If an API Error happens.
|
1330
|
+
|
1331
|
+
Examples:
|
1332
|
+
response = await vault.store_key(
|
1333
|
+
key_type=ItemType.ASYMMETRIC_KEY,
|
1334
|
+
purpose=AsymmetricKeyPurpose.PKI,
|
1335
|
+
algorithm=AsymmetricKeyPkiAlgorithm.ED25519,
|
1336
|
+
)
|
1337
|
+
"""
|
1338
|
+
|
1339
|
+
@overload
|
1340
|
+
async def store_key(
|
1341
|
+
self,
|
1342
|
+
*,
|
1343
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
1344
|
+
purpose: Literal[SymmetricKeyPurpose.ENCRYPTION],
|
1345
|
+
algorithm: SymmetricKeyEncryptionAlgorithm,
|
797
1346
|
key: str,
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
exportable: Optional[bool] = None,
|
808
|
-
) -> PangeaResponse[SymmetricStoreResult]:
|
1347
|
+
name: str | None = None,
|
1348
|
+
folder: str | None = None,
|
1349
|
+
metadata: Metadata | None = None,
|
1350
|
+
tags: Tags | None = None,
|
1351
|
+
rotation_frequency: str | None = None,
|
1352
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1353
|
+
disabled_at: datetime.datetime | None = None,
|
1354
|
+
exportable: bool = False,
|
1355
|
+
) -> PangeaResponse[SymmetricKey]:
|
809
1356
|
"""
|
810
|
-
|
1357
|
+
Store key
|
1358
|
+
|
1359
|
+
Import a symmetric encryption key.
|
1360
|
+
|
1361
|
+
Args:
|
1362
|
+
key_type: Key type.
|
1363
|
+
purpose: The purpose of this key.
|
1364
|
+
algorithm: The algorithm of the key.
|
1365
|
+
key: The key material.
|
1366
|
+
name: The name of this item.
|
1367
|
+
folder: The folder where this item is stored.
|
1368
|
+
metadata: User-provided metadata.
|
1369
|
+
tags: A list of user-defined tags.
|
1370
|
+
rotation_frequency: Period of time between item rotations.
|
1371
|
+
rotation_state: State to which the previous version should
|
1372
|
+
transition upon rotation.
|
1373
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1374
|
+
exportable: Whether the key is exportable or not.
|
1375
|
+
|
1376
|
+
Raises:
|
1377
|
+
PangeaAPIException: If an API Error happens.
|
811
1378
|
|
812
|
-
|
1379
|
+
Examples:
|
1380
|
+
response = await vault.store_key(
|
1381
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
1382
|
+
purpose=SymmetricKeyPurpose.ENCRYPTION,
|
1383
|
+
algorithm=SymmetricKeyEncryptionAlgorithm.AES_CFB_128,
|
1384
|
+
)
|
1385
|
+
"""
|
1386
|
+
|
1387
|
+
@overload
|
1388
|
+
async def store_key(
|
1389
|
+
self,
|
1390
|
+
*,
|
1391
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
1392
|
+
purpose: Literal[SymmetricKeyPurpose.JWT],
|
1393
|
+
algorithm: SymmetricKeyJwtAlgorithm,
|
1394
|
+
key: str,
|
1395
|
+
name: str | None = None,
|
1396
|
+
folder: str | None = None,
|
1397
|
+
metadata: Metadata | None = None,
|
1398
|
+
tags: Tags | None = None,
|
1399
|
+
rotation_frequency: str | None = None,
|
1400
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1401
|
+
disabled_at: datetime.datetime | None = None,
|
1402
|
+
exportable: bool = False,
|
1403
|
+
) -> PangeaResponse[SymmetricKey]:
|
1404
|
+
"""
|
1405
|
+
Store key
|
813
1406
|
|
814
|
-
|
1407
|
+
Import a symmetric JWT key.
|
815
1408
|
|
816
1409
|
Args:
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
exportable (bool, optional): Whether the key is exportable or not
|
1410
|
+
key_type: Key type.
|
1411
|
+
purpose: The purpose of this key.
|
1412
|
+
algorithm: The algorithm of the key.
|
1413
|
+
key: The key material.
|
1414
|
+
name: The name of this item.
|
1415
|
+
folder: The folder where this item is stored.
|
1416
|
+
metadata: User-provided metadata.
|
1417
|
+
tags: A list of user-defined tags.
|
1418
|
+
rotation_frequency: Period of time between item rotations.
|
1419
|
+
rotation_state: State to which the previous version should
|
1420
|
+
transition upon rotation.
|
1421
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1422
|
+
exportable: Whether the key is exportable or not.
|
831
1423
|
|
832
1424
|
Raises:
|
833
|
-
PangeaAPIException: If an API Error happens
|
1425
|
+
PangeaAPIException: If an API Error happens.
|
834
1426
|
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
1427
|
+
Examples:
|
1428
|
+
response = await vault.store_key(
|
1429
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
1430
|
+
purpose=SymmetricKeyPurpose.JWT,
|
1431
|
+
algorithm=SymmetricKeyJwtAlgorithm.HS512,
|
1432
|
+
)
|
1433
|
+
"""
|
1434
|
+
|
1435
|
+
@overload
|
1436
|
+
async def store_key(
|
1437
|
+
self,
|
1438
|
+
*,
|
1439
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
1440
|
+
purpose: Literal[SymmetricKeyPurpose.FPE],
|
1441
|
+
algorithm: SymmetricKeyFpeAlgorithm,
|
1442
|
+
key: str,
|
1443
|
+
name: str | None = None,
|
1444
|
+
folder: str | None = None,
|
1445
|
+
metadata: Metadata | None = None,
|
1446
|
+
tags: Tags | None = None,
|
1447
|
+
rotation_frequency: str | None = None,
|
1448
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1449
|
+
disabled_at: datetime.datetime | None = None,
|
1450
|
+
exportable: bool = False,
|
1451
|
+
) -> PangeaResponse[SymmetricKey]:
|
1452
|
+
"""
|
1453
|
+
Store key
|
1454
|
+
|
1455
|
+
Import a symmetric FPE key.
|
1456
|
+
|
1457
|
+
Args:
|
1458
|
+
key_type: Key type.
|
1459
|
+
purpose: The purpose of this key.
|
1460
|
+
algorithm: The algorithm of the key.
|
1461
|
+
key: The key material.
|
1462
|
+
name: The name of this item.
|
1463
|
+
folder: The folder where this item is stored.
|
1464
|
+
metadata: User-provided metadata.
|
1465
|
+
tags: A list of user-defined tags.
|
1466
|
+
rotation_frequency: Period of time between item rotations.
|
1467
|
+
rotation_state: State to which the previous version should
|
1468
|
+
transition upon rotation.
|
1469
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1470
|
+
exportable: Whether the key is exportable or not.
|
1471
|
+
|
1472
|
+
Raises:
|
1473
|
+
PangeaAPIException: If an API Error happens.
|
839
1474
|
|
840
1475
|
Examples:
|
841
|
-
response = vault.
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
name="my-very-secret-secret",
|
846
|
-
folder="/personal",
|
847
|
-
metadata={
|
848
|
-
"created_by": "John Doe",
|
849
|
-
"used_in": "Google products"
|
850
|
-
},
|
851
|
-
tags=[
|
852
|
-
"irs_2023",
|
853
|
-
"personal"
|
854
|
-
],
|
855
|
-
rotation_frequency="10d",
|
856
|
-
rotation_state=ItemVersionState.DEACTIVATED,
|
857
|
-
expiration="2025-01-01T10:00:00Z",
|
1476
|
+
response = await vault.store_key(
|
1477
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
1478
|
+
purpose=SymmetricKeyPurpose.FPE,
|
1479
|
+
algorithm=SymmetricKeyFpeAlgorithm.AES_FF3_1_256_BETA,
|
858
1480
|
)
|
859
1481
|
"""
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
1482
|
+
|
1483
|
+
async def store_key(
|
1484
|
+
self,
|
1485
|
+
*,
|
1486
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY, ItemType.SYMMETRIC_KEY],
|
1487
|
+
purpose: SymmetricKeyPurpose | AsymmetricKeyPurpose,
|
1488
|
+
algorithm: (
|
1489
|
+
AsymmetricKeySigningAlgorithm
|
1490
|
+
| AsymmetricKeyEncryptionAlgorithm
|
1491
|
+
| AsymmetricKeyJwtAlgorithm
|
1492
|
+
| AsymmetricKeyPkiAlgorithm
|
1493
|
+
| SymmetricKeyEncryptionAlgorithm
|
1494
|
+
| SymmetricKeyJwtAlgorithm
|
1495
|
+
| SymmetricKeyFpeAlgorithm
|
1496
|
+
),
|
1497
|
+
public_key: str | None = None,
|
1498
|
+
private_key: str | None = None,
|
1499
|
+
key: str | None = None,
|
1500
|
+
name: str | None = None,
|
1501
|
+
folder: str | None = None,
|
1502
|
+
metadata: Metadata | None = None,
|
1503
|
+
tags: Tags | None = None,
|
1504
|
+
rotation_frequency: str | None = None,
|
1505
|
+
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
1506
|
+
disabled_at: datetime.datetime | None = None,
|
1507
|
+
exportable: bool = False,
|
1508
|
+
) -> PangeaResponse[Any]:
|
1509
|
+
"""
|
1510
|
+
Store key
|
1511
|
+
|
1512
|
+
Import a key.
|
1513
|
+
|
1514
|
+
Args:
|
1515
|
+
key_type: Key type.
|
1516
|
+
purpose: The purpose of this key.
|
1517
|
+
algorithm: The algorithm of the key.
|
1518
|
+
public_key: The public key (in PEM format).
|
1519
|
+
private_key: The private key (in PEM format).
|
1520
|
+
key: The key material.
|
1521
|
+
name: The name of this item.
|
1522
|
+
folder: The folder where this item is stored.
|
1523
|
+
metadata: User-provided metadata.
|
1524
|
+
tags: A list of user-defined tags.
|
1525
|
+
rotation_frequency: Period of time between item rotations.
|
1526
|
+
rotation_state: State to which the previous version should
|
1527
|
+
transition upon rotation.
|
1528
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1529
|
+
exportable: Whether the key is exportable or not.
|
1530
|
+
|
1531
|
+
Raises:
|
1532
|
+
PangeaAPIException: If an API Error happens.
|
1533
|
+
|
1534
|
+
Examples:
|
1535
|
+
response = await vault.store_key(
|
1536
|
+
key_type=ItemType.SYMMETRIC_KEY,
|
1537
|
+
purpose=SymmetricKeyPurpose.FPE,
|
1538
|
+
algorithm=SymmetricKeyFpeAlgorithm.AES_FF3_1_256_BETA,
|
1539
|
+
)
|
1540
|
+
"""
|
1541
|
+
|
1542
|
+
return await self.request.post(
|
1543
|
+
"v2/key/store",
|
1544
|
+
AsymmetricKey if key_type == ItemType.ASYMMETRIC_KEY else SymmetricKey,
|
1545
|
+
data=KeyStoreRequest(
|
1546
|
+
type=key_type,
|
1547
|
+
purpose=purpose,
|
1548
|
+
algorithm=algorithm,
|
1549
|
+
public_key=public_key,
|
1550
|
+
private_key=private_key,
|
1551
|
+
key=key,
|
1552
|
+
name=name,
|
1553
|
+
folder=folder,
|
1554
|
+
metadata=metadata,
|
1555
|
+
tags=tags,
|
1556
|
+
rotation_frequency=rotation_frequency,
|
1557
|
+
rotation_state=rotation_state,
|
1558
|
+
disabled_at=disabled_at,
|
1559
|
+
exportable=exportable,
|
1560
|
+
),
|
873
1561
|
)
|
874
|
-
return await self.request.post("v1/key/store", SymmetricStoreResult, data=input.model_dump(exclude_none=True))
|
875
1562
|
|
876
|
-
|
877
|
-
async def
|
1563
|
+
@overload
|
1564
|
+
async def rotate_key(
|
878
1565
|
self,
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
1566
|
+
key_id: str,
|
1567
|
+
*,
|
1568
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY],
|
1569
|
+
rotation_state: RequestManualRotationState = RequestManualRotationState.DEACTIVATED,
|
1570
|
+
public_key: str | None = None,
|
1571
|
+
private_key: str | None = None,
|
1572
|
+
) -> PangeaResponse[AsymmetricKey]:
|
885
1573
|
"""
|
886
|
-
|
1574
|
+
Rotate key
|
887
1575
|
|
888
|
-
Manually rotate
|
1576
|
+
Manually rotate an asymmetric key.
|
889
1577
|
|
890
|
-
|
1578
|
+
Args:
|
1579
|
+
key_id: The ID of the key.
|
1580
|
+
key_type: Key type.
|
1581
|
+
rotation_state: State to which the previous version should
|
1582
|
+
transition upon rotation.
|
1583
|
+
public_key: The public key (in PEM format).
|
1584
|
+
private_key: The private key (in PEM format).
|
1585
|
+
|
1586
|
+
Raises:
|
1587
|
+
PangeaAPIException: If an API Error happens.
|
1588
|
+
|
1589
|
+
Examples:
|
1590
|
+
response = await vault.rotate_key("pvi_...", key_type=ItemType.ASYMMETRIC_KEY)
|
1591
|
+
"""
|
1592
|
+
|
1593
|
+
@overload
|
1594
|
+
async def rotate_key(
|
1595
|
+
self,
|
1596
|
+
key_id: str,
|
1597
|
+
*,
|
1598
|
+
key_type: Literal[ItemType.SYMMETRIC_KEY],
|
1599
|
+
rotation_state: RequestManualRotationState = RequestManualRotationState.DEACTIVATED,
|
1600
|
+
key: str | None = None,
|
1601
|
+
) -> PangeaResponse[SymmetricKey]:
|
1602
|
+
"""
|
1603
|
+
Rotate key
|
1604
|
+
|
1605
|
+
Manually rotate a symmetric key.
|
891
1606
|
|
892
1607
|
Args:
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
- `destroyed`
|
899
|
-
|
900
|
-
Default is `deactivated`.
|
901
|
-
public_key (EncodedPublicKey, optional): The public key (in PEM format)
|
902
|
-
private_key (EncodedPrivateKey, optional): The private key (in PEM format)
|
903
|
-
key (EncodedSymmetricKey, optional): The key material (in base64)
|
1608
|
+
key_id: The ID of the key.
|
1609
|
+
key_type: Key type.
|
1610
|
+
rotation_state: State to which the previous version should
|
1611
|
+
transition upon rotation.
|
1612
|
+
key: The key material.
|
904
1613
|
|
905
1614
|
Raises:
|
906
|
-
PangeaAPIException: If an API Error happens
|
1615
|
+
PangeaAPIException: If an API Error happens.
|
907
1616
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
1617
|
+
Examples:
|
1618
|
+
response = await vault.rotate_key("pvi_...", key_type=ItemType.SYMMETRIC_KEY)
|
1619
|
+
"""
|
1620
|
+
|
1621
|
+
async def rotate_key(
|
1622
|
+
self,
|
1623
|
+
key_id: str,
|
1624
|
+
*,
|
1625
|
+
key_type: Literal[ItemType.ASYMMETRIC_KEY, ItemType.SYMMETRIC_KEY],
|
1626
|
+
rotation_state: RequestManualRotationState = RequestManualRotationState.DEACTIVATED,
|
1627
|
+
public_key: str | None = None,
|
1628
|
+
private_key: str | None = None,
|
1629
|
+
key: str | None = None,
|
1630
|
+
) -> PangeaResponse[Any]:
|
1631
|
+
"""
|
1632
|
+
Rotate key
|
1633
|
+
|
1634
|
+
Manually rotate an asymmetric or symmetric key.
|
1635
|
+
|
1636
|
+
Args:
|
1637
|
+
key_id: The ID of the key.
|
1638
|
+
key_type: Key type.
|
1639
|
+
rotation_state: State to which the previous version should
|
1640
|
+
transition upon rotation.
|
1641
|
+
public_key: The public key (in PEM format).
|
1642
|
+
private_key: The private key (in PEM format).
|
1643
|
+
key: The key material.
|
1644
|
+
|
1645
|
+
Raises:
|
1646
|
+
PangeaAPIException: If an API Error happens.
|
912
1647
|
|
913
1648
|
Examples:
|
914
|
-
response = vault.
|
915
|
-
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
916
|
-
rotation_state=ItemVersionState.DEACTIVATED,
|
917
|
-
key="lJkk0gCLux+Q+rPNqLPEYw==",
|
918
|
-
)
|
1649
|
+
response = await vault.rotate_key("pvi_...", key_type=ItemType.SYMMETRIC_KEY)
|
919
1650
|
"""
|
920
|
-
|
921
|
-
|
1651
|
+
|
1652
|
+
return await self.request.post(
|
1653
|
+
"v2/key/rotate",
|
1654
|
+
AsymmetricKey if key_type == ItemType.ASYMMETRIC_KEY else SymmetricKey,
|
1655
|
+
data=KeyRotateRequest(
|
1656
|
+
id=key_id,
|
1657
|
+
public_key=public_key,
|
1658
|
+
private_key=private_key,
|
1659
|
+
key=key,
|
1660
|
+
rotation_state=rotation_state,
|
1661
|
+
),
|
922
1662
|
)
|
923
|
-
return await self.request.post("v1/key/rotate", KeyRotateResult, data=input.model_dump(exclude_none=True))
|
924
1663
|
|
925
|
-
|
926
|
-
|
1664
|
+
async def encrypt(
|
1665
|
+
self, item_id: str, plain_text: str, *, version: int | None = None, additional_data: str | None = None
|
1666
|
+
) -> PangeaResponse[EncryptResult]:
|
927
1667
|
"""
|
928
1668
|
Encrypt
|
929
1669
|
|
930
|
-
Encrypt a message using a key
|
1670
|
+
Encrypt a message using a key.
|
931
1671
|
|
932
|
-
OperationId:
|
1672
|
+
OperationId: vault_post_v2_key_encrypt
|
933
1673
|
|
934
1674
|
Args:
|
935
|
-
|
936
|
-
plain_text
|
937
|
-
version
|
1675
|
+
item_id: The item ID.
|
1676
|
+
plain_text: A message to be encrypted (in base64).
|
1677
|
+
version: The item version.
|
1678
|
+
additional_data: User provided authentication data.
|
1679
|
+
|
1680
|
+
Returns:
|
1681
|
+
A PangeaResponse where the encrypted message in base64 is returned
|
1682
|
+
in the response.result field. Available response fields can be found
|
1683
|
+
in our [API documentation](https://pangea.cloud/docs/api/vault#encrypt).
|
938
1684
|
|
939
1685
|
Raises:
|
940
1686
|
PangeaAPIException: If an API Error happens
|
941
1687
|
|
942
|
-
Returns:
|
943
|
-
A PangeaResponse where the encrypted message in base64
|
944
|
-
is returned in the response.result field.
|
945
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#encrypt).
|
946
|
-
|
947
1688
|
Examples:
|
948
|
-
response = vault.encrypt(
|
1689
|
+
response = await vault.encrypt(
|
949
1690
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
950
1691
|
plain_text="lJkk0gCLux+Q+rPNqLPEYw==",
|
951
1692
|
version=1,
|
952
1693
|
)
|
953
1694
|
"""
|
954
|
-
|
955
|
-
|
1695
|
+
return await self.request.post(
|
1696
|
+
"v2/encrypt",
|
1697
|
+
EncryptResult,
|
1698
|
+
data=EncryptRequest(id=item_id, plain_text=plain_text, version=version, additional_data=additional_data),
|
1699
|
+
)
|
956
1700
|
|
957
|
-
|
958
|
-
|
1701
|
+
async def decrypt(
|
1702
|
+
self, item_id: str, cipher_text: str, *, version: int | None = None, additional_data: str | None = None
|
1703
|
+
) -> PangeaResponse[DecryptResult]:
|
959
1704
|
"""
|
960
1705
|
Decrypt
|
961
1706
|
|
962
|
-
Decrypt a message using a key
|
1707
|
+
Decrypt a message using a key.
|
963
1708
|
|
964
|
-
OperationId:
|
1709
|
+
OperationId: vault_post_v2_key_decrypt
|
965
1710
|
|
966
1711
|
Args:
|
967
|
-
|
968
|
-
cipher_text
|
969
|
-
version
|
1712
|
+
item_id: The item ID.
|
1713
|
+
cipher_text: A message encrypted by Vault (in base64).
|
1714
|
+
version: The item version.
|
1715
|
+
additional_data: User provided authentication data.
|
1716
|
+
|
1717
|
+
Returns:
|
1718
|
+
A PangeaResponse where the decrypted message in base64 is returned
|
1719
|
+
in the response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#decrypt).
|
970
1720
|
|
971
1721
|
Raises:
|
972
1722
|
PangeaAPIException: If an API Error happens
|
973
1723
|
|
974
|
-
Returns:
|
975
|
-
A PangeaResponse where the decrypted message in base64
|
976
|
-
is returned in the response.result field.
|
977
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#decrypt).
|
978
|
-
|
979
1724
|
Examples:
|
980
|
-
response = vault.decrypt(
|
1725
|
+
response = await vault.decrypt(
|
981
1726
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
982
1727
|
cipher_text="lJkk0gCLux+Q+rPNqLPEYw==",
|
983
1728
|
version=1,
|
984
1729
|
)
|
985
1730
|
"""
|
986
|
-
|
987
|
-
|
1731
|
+
return await self.request.post(
|
1732
|
+
"v2/decrypt",
|
1733
|
+
DecryptResult,
|
1734
|
+
data=DecryptRequest(id=item_id, cipher_text=cipher_text, version=version, additional_data=additional_data),
|
1735
|
+
)
|
988
1736
|
|
989
|
-
|
990
|
-
async def sign(self, id: str, message: str, version: Optional[int] = None) -> PangeaResponse[SignResult]:
|
1737
|
+
async def sign(self, item_id: str, message: str, *, version: int | None = None) -> PangeaResponse[SignResult]:
|
991
1738
|
"""
|
992
1739
|
Sign
|
993
1740
|
|
994
1741
|
Sign a message using a key
|
995
1742
|
|
996
|
-
OperationId:
|
1743
|
+
OperationId: vault_post_v2_sign
|
997
1744
|
|
998
1745
|
Args:
|
999
|
-
id
|
1000
|
-
message
|
1001
|
-
version
|
1746
|
+
id: The item ID.
|
1747
|
+
message: The message to be signed, in base64.
|
1748
|
+
version: The item version.
|
1749
|
+
|
1750
|
+
Returns:
|
1751
|
+
A PangeaResponse where the signature of the message in base64 is
|
1752
|
+
returned in the response.result field. Available response fields can
|
1753
|
+
be found in our [API documentation](https://pangea.cloud/docs/api/vault#sign).
|
1002
1754
|
|
1003
1755
|
Raises:
|
1004
1756
|
PangeaAPIException: If an API Error happens
|
1005
1757
|
|
1006
|
-
Returns:
|
1007
|
-
A PangeaResponse where the signature of the message in base64
|
1008
|
-
is returned in the response.result field.
|
1009
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#sign).
|
1010
|
-
|
1011
1758
|
Examples:
|
1012
|
-
response = vault.sign(
|
1759
|
+
response = await vault.sign(
|
1013
1760
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
1014
1761
|
message="lJkk0gCLux+Q+rPNqLPEYw==",
|
1015
1762
|
version=1,
|
1016
1763
|
)
|
1017
1764
|
"""
|
1018
|
-
|
1019
|
-
|
1765
|
+
return await self.request.post(
|
1766
|
+
"v2/sign", SignResult, data=SignRequest(id=item_id, message=message, version=version)
|
1767
|
+
)
|
1020
1768
|
|
1021
|
-
# Verify
|
1022
1769
|
async def verify(
|
1023
|
-
self,
|
1770
|
+
self, item_id: str, message: str, signature: str, *, version: int | None = None
|
1024
1771
|
) -> PangeaResponse[VerifyResult]:
|
1025
1772
|
"""
|
1026
1773
|
Verify
|
1027
1774
|
|
1028
|
-
Verify a signature using a key
|
1775
|
+
Verify a signature using a key.
|
1029
1776
|
|
1030
|
-
OperationId:
|
1777
|
+
OperationId: vault_post_v2_key_verify
|
1031
1778
|
|
1032
1779
|
Args:
|
1033
|
-
id
|
1034
|
-
message
|
1035
|
-
signature
|
1036
|
-
version
|
1780
|
+
id: The item ID.
|
1781
|
+
message: A message to be verified (in base64).
|
1782
|
+
signature: The message signature (in base64).
|
1783
|
+
version: The item version.
|
1037
1784
|
|
1038
1785
|
Raises:
|
1039
1786
|
PangeaAPIException: If an API Error happens
|
@@ -1044,31 +1791,34 @@ class VaultAsync(ServiceBaseAsync):
|
|
1044
1791
|
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#verify).
|
1045
1792
|
|
1046
1793
|
Examples:
|
1047
|
-
response = vault.verify(
|
1794
|
+
response = await vault.verify(
|
1048
1795
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
1049
1796
|
message="lJkk0gCLux+Q+rPNqLPEYw==",
|
1050
1797
|
signature="FfWuT2Mq/+cxa7wIugfhzi7ktZxVf926idJNgBDCysF/knY9B7M6wxqHMMPDEBs86D8OsEGuED21y3J7IGOpCQ==",
|
1051
1798
|
version=1,
|
1052
1799
|
)
|
1053
1800
|
"""
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1801
|
+
return await self.request.post(
|
1802
|
+
"v2/verify",
|
1803
|
+
VerifyResult,
|
1804
|
+
data=VerifyRequest(
|
1805
|
+
id=item_id,
|
1806
|
+
message=message,
|
1807
|
+
signature=signature,
|
1808
|
+
version=version,
|
1809
|
+
),
|
1059
1810
|
)
|
1060
|
-
return await self.request.post("v1/key/verify", VerifyResult, data=input.model_dump(exclude_none=True))
|
1061
1811
|
|
1062
1812
|
async def jwt_verify(self, jws: str) -> PangeaResponse[JWTVerifyResult]:
|
1063
1813
|
"""
|
1064
1814
|
JWT Verify
|
1065
1815
|
|
1066
|
-
Verify the signature of a JSON Web Token (JWT)
|
1816
|
+
Verify the signature of a JSON Web Token (JWT).
|
1067
1817
|
|
1068
|
-
OperationId:
|
1818
|
+
OperationId: vault_post_v2_key_verify_jwt
|
1069
1819
|
|
1070
1820
|
Args:
|
1071
|
-
jws
|
1821
|
+
jws: The signed JSON Web Token (JWS).
|
1072
1822
|
|
1073
1823
|
Raises:
|
1074
1824
|
PangeaAPIException: If an API Error happens
|
@@ -1079,180 +1829,196 @@ class VaultAsync(ServiceBaseAsync):
|
|
1079
1829
|
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#verify-jwt).
|
1080
1830
|
|
1081
1831
|
Examples:
|
1082
|
-
response = vault.jwt_verify(
|
1083
|
-
jws="ewogICJhbGciO...",
|
1084
|
-
)
|
1832
|
+
response = await vault.jwt_verify(jws="ewogICJhbGciO...")
|
1085
1833
|
"""
|
1086
|
-
|
1087
|
-
return await self.request.post("v1/key/verify/jwt", JWTVerifyResult, data=input.model_dump(exclude_none=True))
|
1834
|
+
return await self.request.post("v2/jwt/verify", JWTVerifyResult, data=JWTVerifyRequest(jws=jws))
|
1088
1835
|
|
1089
|
-
async def jwt_sign(self,
|
1836
|
+
async def jwt_sign(self, item_id: str, payload: str) -> PangeaResponse[JWTSignResult]:
|
1090
1837
|
"""
|
1091
1838
|
JWT Sign
|
1092
1839
|
|
1093
|
-
Sign a JSON Web Token (JWT) using a key
|
1840
|
+
Sign a JSON Web Token (JWT) using a key.
|
1094
1841
|
|
1095
|
-
OperationId:
|
1842
|
+
OperationId: vault_post_v2_jwt_sign
|
1096
1843
|
|
1097
1844
|
Args:
|
1098
|
-
id
|
1099
|
-
payload
|
1845
|
+
id: The item ID.
|
1846
|
+
payload: The JWT payload (in JSON).
|
1100
1847
|
|
1101
1848
|
Raises:
|
1102
1849
|
PangeaAPIException: If an API Error happens
|
1103
1850
|
|
1104
1851
|
Returns:
|
1105
|
-
A PangeaResponse where the signed JSON Web Token (JWS)
|
1106
|
-
|
1107
|
-
|
1852
|
+
A PangeaResponse where the signed JSON Web Token (JWS) is returned
|
1853
|
+
in the response.result field. Available response fields can be found
|
1854
|
+
in our [API documentation](https://pangea.cloud/docs/api/vault#sign-a-jwt).
|
1108
1855
|
|
1109
1856
|
Examples:
|
1110
|
-
response = vault.jwt_sign(
|
1857
|
+
response = await vault.jwt_sign(
|
1111
1858
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
1112
1859
|
payload="{\\"sub\\": \\"1234567890\\",\\"name\\": \\"John Doe\\",\\"admin\\": true}"
|
1113
1860
|
)
|
1114
1861
|
"""
|
1115
|
-
|
1116
|
-
return await self.request.post("v1/key/sign/jwt", JWTSignResult, data=input.model_dump(exclude_none=True))
|
1862
|
+
return await self.request.post("v2/jwt/sign", JWTSignResult, data=JWTSignRequest(id=item_id, payload=payload))
|
1117
1863
|
|
1118
|
-
|
1119
|
-
async def jwk_get(self, id: str, version: Optional[str] = None) -> PangeaResponse[JWKGetResult]:
|
1864
|
+
async def jwk_get(self, item_id: str, *, version: str | None = None) -> PangeaResponse[JWKGetResult]:
|
1120
1865
|
"""
|
1121
1866
|
JWT Retrieve
|
1122
1867
|
|
1123
|
-
Retrieve a key in JWK format
|
1868
|
+
Retrieve a key in JWK format.
|
1124
1869
|
|
1125
|
-
OperationId:
|
1870
|
+
OperationId: vault_post_v2_jwk_get
|
1126
1871
|
|
1127
1872
|
Args:
|
1128
|
-
id
|
1129
|
-
version
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1873
|
+
id: The item ID
|
1874
|
+
version: The key version(s).
|
1875
|
+
- `all` for all versions
|
1876
|
+
- `num` for a specific version
|
1877
|
+
- `-num` for the `num` latest versions
|
1133
1878
|
Raises:
|
1134
1879
|
PangeaAPIException: If an API Error happens
|
1135
1880
|
|
1136
1881
|
Returns:
|
1137
|
-
A PangeaResponse where the JSON Web Key Set (JWKS) object
|
1138
|
-
|
1139
|
-
|
1882
|
+
A PangeaResponse where the JSON Web Key Set (JWKS) object is
|
1883
|
+
returned in the response.result field. Available response fields can
|
1884
|
+
be found in our [API documentation](https://pangea.cloud/docs/api/vault#retrieve-jwk).
|
1140
1885
|
|
1141
1886
|
Examples:
|
1142
|
-
response = vault.jwk_get(
|
1143
|
-
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
1144
|
-
)
|
1887
|
+
response = await vault.jwk_get("pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5")
|
1145
1888
|
"""
|
1146
|
-
|
1147
|
-
return await self.request.post("v1/get/jwk", JWKGetResult, data=input.model_dump(exclude_none=True))
|
1889
|
+
return await self.request.post("v2/jwk/get", JWKGetResult, data=JWKGetRequest(id=item_id, version=version))
|
1148
1890
|
|
1149
|
-
# State change
|
1150
1891
|
async def state_change(
|
1151
|
-
self,
|
1152
|
-
|
1892
|
+
self,
|
1893
|
+
item_id: str,
|
1894
|
+
state: ItemVersionState,
|
1895
|
+
*,
|
1896
|
+
version: int | None = None,
|
1897
|
+
destroy_period: str | None = None,
|
1898
|
+
) -> PangeaResponse[VaultItem]:
|
1153
1899
|
"""
|
1154
1900
|
State change
|
1155
1901
|
|
1156
|
-
Change the state of a specific version of a secret or key
|
1902
|
+
Change the state of a specific version of a secret or key.
|
1157
1903
|
|
1158
|
-
OperationId:
|
1904
|
+
OperationId: vault_post_v2_state_change
|
1159
1905
|
|
1160
1906
|
Args:
|
1161
|
-
|
1162
|
-
state
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
- `compromised`
|
1167
|
-
- `destroyed`
|
1168
|
-
version (int, optional): the item version
|
1169
|
-
destroy_period (str, optional): Period of time for the destruction of a compromised key.
|
1170
|
-
Only valid if state=`compromised`
|
1171
|
-
Raises:
|
1172
|
-
PangeaAPIException: If an API Error happens
|
1907
|
+
item_id: The item ID.
|
1908
|
+
state: The new state of the item version.
|
1909
|
+
version: The item version.
|
1910
|
+
destroy_period: Period of time for the destruction of a compromised
|
1911
|
+
key. Only valid if state=`compromised`.
|
1173
1912
|
|
1174
1913
|
Returns:
|
1175
|
-
A PangeaResponse where the state change object
|
1176
|
-
|
1177
|
-
|
1914
|
+
A PangeaResponse where the state change object is returned in the
|
1915
|
+
response.result field. Available response fields can be found in our
|
1916
|
+
[API documentation](https://pangea.cloud/docs/api/vault#change-state).
|
1917
|
+
|
1918
|
+
Raises:
|
1919
|
+
PangeaAPIException: If an API Error happens
|
1178
1920
|
|
1179
1921
|
Examples:
|
1180
|
-
response = vault.state_change(
|
1922
|
+
response = await vault.state_change(
|
1181
1923
|
id="pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5",
|
1182
1924
|
state=ItemVersionState.DEACTIVATED,
|
1183
1925
|
)
|
1184
1926
|
"""
|
1185
|
-
|
1186
|
-
|
1927
|
+
response = await self.request.post(
|
1928
|
+
"v2/state/change",
|
1929
|
+
PangeaResponseResult,
|
1930
|
+
data=StateChangeRequest(id=item_id, state=state, version=version, destroy_period=destroy_period),
|
1931
|
+
)
|
1932
|
+
response.result = vault_item_adapter.validate_python(response.json["result"])
|
1933
|
+
return cast(PangeaResponse[VaultItem], response)
|
1187
1934
|
|
1188
|
-
# Folder create
|
1189
1935
|
async def folder_create(
|
1190
1936
|
self,
|
1191
1937
|
name: str,
|
1192
1938
|
folder: str,
|
1193
|
-
|
1194
|
-
|
1939
|
+
*,
|
1940
|
+
metadata: Metadata | None = None,
|
1941
|
+
tags: Tags | None = None,
|
1942
|
+
rotation_frequency: str | None = None,
|
1943
|
+
rotation_state: RequestRotationState = RequestRotationState.INHERITED,
|
1944
|
+
rotation_grace_period: str | None = None,
|
1945
|
+
disabled_at: datetime.datetime | None = None,
|
1195
1946
|
) -> PangeaResponse[FolderCreateResult]:
|
1196
1947
|
"""
|
1197
1948
|
Create
|
1198
1949
|
|
1199
|
-
Creates a folder
|
1950
|
+
Creates a folder.
|
1200
1951
|
|
1201
|
-
OperationId:
|
1952
|
+
OperationId: vault_post_v2_folder_create
|
1202
1953
|
|
1203
1954
|
Args:
|
1204
|
-
name
|
1205
|
-
folder
|
1206
|
-
metadata
|
1207
|
-
tags
|
1955
|
+
name: The name of this folder.
|
1956
|
+
folder: The parent folder where this folder is stored.
|
1957
|
+
metadata: User-provided metadata.
|
1958
|
+
tags: A list of user-defined tags.
|
1959
|
+
rotation_frequency: Period of time between item rotations.
|
1960
|
+
rotation_state: State to which the previous version should
|
1961
|
+
transition upon rotation.
|
1962
|
+
rotation_grace_period: Grace period for the previous version.
|
1963
|
+
disabled_at: Timestamp indicating when the item will be disabled.
|
1964
|
+
|
1965
|
+
Returns: The created folder object.
|
1966
|
+
|
1208
1967
|
Raises:
|
1209
1968
|
PangeaAPIException: If an API Error happens
|
1210
1969
|
|
1211
|
-
Returns:
|
1212
|
-
A PangeaResponse where the state change object
|
1213
|
-
is returned in the response.result field.
|
1214
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault#create).
|
1215
|
-
|
1216
1970
|
Examples:
|
1217
|
-
response = vault.folder_create(
|
1971
|
+
response = await vault.folder_create(
|
1218
1972
|
name="folder_name",
|
1219
1973
|
folder="parent/folder/name",
|
1220
1974
|
)
|
1221
1975
|
"""
|
1222
|
-
|
1223
|
-
|
1976
|
+
return await self.request.post(
|
1977
|
+
"v2/folder/create",
|
1978
|
+
FolderCreateResult,
|
1979
|
+
data=FolderCreateRequest(
|
1980
|
+
name=name,
|
1981
|
+
folder=folder,
|
1982
|
+
metadata=metadata,
|
1983
|
+
tags=tags,
|
1984
|
+
rotation_frequency=rotation_frequency,
|
1985
|
+
rotation_state=rotation_state,
|
1986
|
+
rotation_grace_period=rotation_grace_period,
|
1987
|
+
disabled_at=disabled_at,
|
1988
|
+
),
|
1989
|
+
)
|
1224
1990
|
|
1225
|
-
# Encrypt structured
|
1226
1991
|
async def encrypt_structured(
|
1227
1992
|
self,
|
1228
|
-
|
1993
|
+
key_id: str,
|
1229
1994
|
structured_data: TDict,
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1995
|
+
filter_expr: str,
|
1996
|
+
*,
|
1997
|
+
version: int | None = None,
|
1998
|
+
additional_data: str | None = None,
|
1233
1999
|
) -> PangeaResponse[EncryptStructuredResult[TDict]]:
|
1234
2000
|
"""
|
1235
2001
|
Encrypt structured
|
1236
2002
|
|
1237
2003
|
Encrypt parts of a JSON object.
|
1238
2004
|
|
1239
|
-
OperationId:
|
2005
|
+
OperationId: vault_post_v2_encrypt_structured
|
1240
2006
|
|
1241
2007
|
Args:
|
1242
|
-
|
1243
|
-
structured_data
|
1244
|
-
|
1245
|
-
version
|
1246
|
-
additional_data
|
1247
|
-
|
1248
|
-
Raises:
|
1249
|
-
PangeaAPIException: If an API error happens.
|
2008
|
+
key_id: The ID of the key to use.
|
2009
|
+
structured_data: Structured data for applying bulk operations.
|
2010
|
+
filter_expr: A filter expression.
|
2011
|
+
version: The item version. Defaults to the current version.
|
2012
|
+
additional_data: User provided authentication data.
|
1250
2013
|
|
1251
2014
|
Returns:
|
1252
2015
|
A `PangeaResponse` where the encrypted object is returned in the
|
1253
2016
|
`response.result` field. Available response fields can be found in
|
1254
2017
|
our [API documentation](https://pangea.cloud/docs/api/vault#encrypt-structured).
|
1255
2018
|
|
2019
|
+
Raises:
|
2020
|
+
PangeaAPIException: If an API error happens.
|
2021
|
+
|
1256
2022
|
Examples:
|
1257
2023
|
data = {"field1": [1, 2, "true", "false"], "field2": "data2"}
|
1258
2024
|
response = await vault.encrypt_structured(
|
@@ -1262,37 +2028,41 @@ class VaultAsync(ServiceBaseAsync):
|
|
1262
2028
|
)
|
1263
2029
|
"""
|
1264
2030
|
|
1265
|
-
|
1266
|
-
id=
|
2031
|
+
data: EncryptStructuredRequest[TDict] = EncryptStructuredRequest(
|
2032
|
+
id=key_id,
|
2033
|
+
structured_data=structured_data,
|
2034
|
+
filter=filter_expr,
|
2035
|
+
version=version,
|
2036
|
+
additional_data=additional_data,
|
1267
2037
|
)
|
1268
2038
|
return await self.request.post(
|
1269
|
-
"
|
2039
|
+
"v2/encrypt_structured",
|
1270
2040
|
EncryptStructuredResult,
|
1271
|
-
data=
|
2041
|
+
data=data.model_dump(exclude_none=True),
|
1272
2042
|
)
|
1273
2043
|
|
1274
|
-
# Decrypt structured
|
1275
2044
|
async def decrypt_structured(
|
1276
2045
|
self,
|
1277
|
-
|
2046
|
+
key_id: str,
|
1278
2047
|
structured_data: TDict,
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
2048
|
+
filter_expr: str,
|
2049
|
+
*,
|
2050
|
+
version: int | None = None,
|
2051
|
+
additional_data: str | None = None,
|
1282
2052
|
) -> PangeaResponse[EncryptStructuredResult[TDict]]:
|
1283
2053
|
"""
|
1284
2054
|
Decrypt structured
|
1285
2055
|
|
1286
2056
|
Decrypt parts of a JSON object.
|
1287
2057
|
|
1288
|
-
OperationId:
|
2058
|
+
OperationId: vault_post_v2_decrypt_structured
|
1289
2059
|
|
1290
2060
|
Args:
|
1291
|
-
id
|
1292
|
-
structured_data
|
1293
|
-
filter
|
1294
|
-
version
|
1295
|
-
additional_data
|
2061
|
+
id: The ID of the key to use.
|
2062
|
+
structured_data: Structured data for applying bulk operations.
|
2063
|
+
filter: A filter expression.
|
2064
|
+
version: The item version. Defaults to the current version.
|
2065
|
+
additional_data: User provided authentication data.
|
1296
2066
|
|
1297
2067
|
Raises:
|
1298
2068
|
PangeaAPIException: If an API error happens.
|
@@ -1311,20 +2081,25 @@ class VaultAsync(ServiceBaseAsync):
|
|
1311
2081
|
)
|
1312
2082
|
"""
|
1313
2083
|
|
1314
|
-
|
1315
|
-
id=
|
2084
|
+
data: EncryptStructuredRequest[TDict] = EncryptStructuredRequest(
|
2085
|
+
id=key_id,
|
2086
|
+
structured_data=structured_data,
|
2087
|
+
filter=filter_expr,
|
2088
|
+
version=version,
|
2089
|
+
additional_data=additional_data,
|
1316
2090
|
)
|
1317
2091
|
return await self.request.post(
|
1318
|
-
"
|
2092
|
+
"v2/decrypt_structured",
|
1319
2093
|
EncryptStructuredResult,
|
1320
|
-
data=
|
2094
|
+
data=data.model_dump(exclude_none=True),
|
1321
2095
|
)
|
1322
2096
|
|
1323
2097
|
async def encrypt_transform(
|
1324
2098
|
self,
|
1325
|
-
|
2099
|
+
item_id: str,
|
1326
2100
|
plain_text: str,
|
1327
2101
|
alphabet: TransformAlphabet,
|
2102
|
+
*,
|
1328
2103
|
tweak: str | None = None,
|
1329
2104
|
version: int | None = None,
|
1330
2105
|
) -> PangeaResponse[EncryptTransformResult]:
|
@@ -1333,13 +2108,14 @@ class VaultAsync(ServiceBaseAsync):
|
|
1333
2108
|
|
1334
2109
|
Encrypt using a format-preserving algorithm (FPE).
|
1335
2110
|
|
1336
|
-
OperationId:
|
2111
|
+
OperationId: vault_post_v2_encrypt_transform
|
1337
2112
|
|
1338
2113
|
Args:
|
1339
|
-
|
2114
|
+
item_id: The item ID.
|
1340
2115
|
plain_text: A message to be encrypted.
|
1341
2116
|
alphabet: Set of characters to use for format-preserving encryption (FPE).
|
1342
|
-
tweak: User provided tweak string. If not provided, a random string
|
2117
|
+
tweak: User provided tweak string. If not provided, a random string
|
2118
|
+
will be generated and returned.
|
1343
2119
|
version: The item version. Defaults to the current version.
|
1344
2120
|
|
1345
2121
|
Raises:
|
@@ -1357,28 +2133,27 @@ class VaultAsync(ServiceBaseAsync):
|
|
1357
2133
|
)
|
1358
2134
|
"""
|
1359
2135
|
|
1360
|
-
input = EncryptTransformRequest(
|
1361
|
-
id=id,
|
1362
|
-
plain_text=plain_text,
|
1363
|
-
alphabet=alphabet,
|
1364
|
-
tweak=tweak,
|
1365
|
-
version=version,
|
1366
|
-
)
|
1367
2136
|
return await self.request.post(
|
1368
|
-
"
|
2137
|
+
"v2/encrypt_transform",
|
1369
2138
|
EncryptTransformResult,
|
1370
|
-
data=
|
2139
|
+
data=EncryptTransformRequest(
|
2140
|
+
id=item_id,
|
2141
|
+
plain_text=plain_text,
|
2142
|
+
tweak=tweak,
|
2143
|
+
alphabet=alphabet,
|
2144
|
+
version=version,
|
2145
|
+
),
|
1371
2146
|
)
|
1372
2147
|
|
1373
2148
|
async def decrypt_transform(
|
1374
|
-
self,
|
2149
|
+
self, item_id: str, cipher_text: str, tweak: str, alphabet: TransformAlphabet, *, version: int | None = None
|
1375
2150
|
) -> PangeaResponse[DecryptTransformResult]:
|
1376
2151
|
"""
|
1377
2152
|
Decrypt transform
|
1378
2153
|
|
1379
2154
|
Decrypt using a format-preserving algorithm (FPE).
|
1380
2155
|
|
1381
|
-
OperationId:
|
2156
|
+
OperationId: vault_post_v2_decrypt_transform
|
1382
2157
|
|
1383
2158
|
Args:
|
1384
2159
|
id: The item ID.
|
@@ -1387,12 +2162,12 @@ class VaultAsync(ServiceBaseAsync):
|
|
1387
2162
|
alphabet: Set of characters to use for format-preserving encryption (FPE).
|
1388
2163
|
version: The item version. Defaults to the current version.
|
1389
2164
|
|
1390
|
-
Raises:
|
1391
|
-
PangeaAPIException: If an API error happens.
|
1392
|
-
|
1393
2165
|
Returns:
|
1394
2166
|
A `PangeaResponse` containing the decrypted message.
|
1395
2167
|
|
2168
|
+
Raises:
|
2169
|
+
PangeaAPIException: If an API error happens.
|
2170
|
+
|
1396
2171
|
Examples:
|
1397
2172
|
await vault.decrypt_transform(
|
1398
2173
|
id="pvi_[...]",
|
@@ -1402,55 +2177,64 @@ class VaultAsync(ServiceBaseAsync):
|
|
1402
2177
|
)
|
1403
2178
|
"""
|
1404
2179
|
|
1405
|
-
input = DecryptTransformRequest(id=id, cipher_text=cipher_text, tweak=tweak, alphabet=alphabet, version=version)
|
1406
2180
|
return await self.request.post(
|
1407
|
-
"
|
2181
|
+
"v2/decrypt_transform",
|
1408
2182
|
DecryptTransformResult,
|
1409
|
-
data=
|
2183
|
+
data=DecryptTransformRequest(
|
2184
|
+
id=item_id, cipher_text=cipher_text, tweak=tweak, alphabet=alphabet, version=version
|
2185
|
+
),
|
1410
2186
|
)
|
1411
2187
|
|
1412
2188
|
async def export(
|
1413
2189
|
self,
|
1414
|
-
|
2190
|
+
item_id: str,
|
2191
|
+
*,
|
1415
2192
|
version: int | None = None,
|
1416
|
-
|
1417
|
-
|
2193
|
+
kem_password: str | None = None,
|
2194
|
+
asymmetric_public_key: str | None = None,
|
2195
|
+
asymmetric_algorithm: ExportEncryptionAlgorithm | None = None,
|
1418
2196
|
) -> PangeaResponse[ExportResult]:
|
1419
2197
|
"""
|
1420
2198
|
Export
|
1421
2199
|
|
1422
2200
|
Export a symmetric or asymmetric key.
|
1423
2201
|
|
1424
|
-
OperationId:
|
2202
|
+
OperationId: vault_post_v2_export
|
1425
2203
|
|
1426
2204
|
Args:
|
1427
|
-
|
2205
|
+
item_id: The item ID.
|
1428
2206
|
version: The item version.
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
2207
|
+
kem_password: This is the password that will be used along with a
|
2208
|
+
salt to derive the symmetric key that is used to encrypt the
|
2209
|
+
exported key material.
|
2210
|
+
asymmetric_public_key: Public key in pem format used to encrypt
|
2211
|
+
exported key(s).
|
2212
|
+
asymmetric_algorithm: The algorithm of the public key.
|
1434
2213
|
|
1435
2214
|
Returns:
|
1436
2215
|
A `PangeaResponse` where the exported key is returned in the
|
1437
2216
|
`response.result` field. Available response fields can be found in
|
1438
2217
|
our [API documentation](https://pangea.cloud/docs/api/vault#export).
|
1439
2218
|
|
2219
|
+
Raises:
|
2220
|
+
PangeaAPIException: If an API error happens.
|
2221
|
+
|
1440
2222
|
Examples:
|
1441
|
-
exp_encrypted_resp = await
|
2223
|
+
exp_encrypted_resp = await vault.export(
|
1442
2224
|
id=id,
|
1443
|
-
|
1444
|
-
|
1445
|
-
encryption_algorithm=ExportEncryptionAlgorithm.RSA4096_OAEP_SHA512,
|
2225
|
+
asymmetric_public_key=rsa_pub_key_pem,
|
2226
|
+
asymmetric_algorithm=ExportEncryptionAlgorithm.RSA4096_OAEP_SHA512,
|
1446
2227
|
)
|
1447
2228
|
"""
|
1448
2229
|
|
1449
|
-
input: ExportRequest = ExportRequest(
|
1450
|
-
id=id, version=version, encryption_algorithm=encryption_algorithm, encryption_key=encryption_key
|
1451
|
-
)
|
1452
2230
|
return await self.request.post(
|
1453
|
-
"
|
2231
|
+
"v2/export",
|
1454
2232
|
ExportResult,
|
1455
|
-
data=
|
2233
|
+
data=ExportRequest(
|
2234
|
+
id=item_id,
|
2235
|
+
version=version,
|
2236
|
+
kem_password=kem_password,
|
2237
|
+
asymmetric_public_key=asymmetric_public_key,
|
2238
|
+
asymmetric_algorithm=asymmetric_algorithm,
|
2239
|
+
),
|
1456
2240
|
)
|