infisicalsdk 1.0.3__py3-none-any.whl → 1.0.5__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.

Potentially problematic release.


This version of infisicalsdk might be problematic. Click here for more details.

@@ -74,6 +74,7 @@ class BaseSecret(BaseModel):
74
74
  createdAt: str
75
75
  updatedAt: str
76
76
  secretMetadata: Optional[Dict[str, Any]] = None
77
+ secretValueHidden: Optional[bool] = False
77
78
  secretReminderNote: Optional[str] = None
78
79
  secretReminderRepeatDays: Optional[int] = None
79
80
  skipMultilineEncoding: Optional[bool] = False
@@ -112,7 +113,7 @@ class SingleSecretResponse(BaseModel):
112
113
  secret: BaseSecret
113
114
 
114
115
  @classmethod
115
- def from_dict(cls, data: Dict) -> 'ListSecretsResponse':
116
+ def from_dict(cls, data: Dict) -> 'SingleSecretResponse':
116
117
  return cls(
117
118
  secret=BaseSecret.from_dict(data['secret']),
118
119
  )
@@ -125,3 +126,71 @@ class MachineIdentityLoginResponse(BaseModel):
125
126
  expiresIn: int
126
127
  accessTokenMaxTTL: int
127
128
  tokenType: str
129
+
130
+
131
+ class SymmetricEncryption(str, Enum):
132
+ AES_GCM_256 = "aes-256-gcm"
133
+ AES_GCM_128 = "aes-128-gcm"
134
+
135
+
136
+ class OrderDirection(str, Enum):
137
+ ASC = "asc"
138
+ DESC = "desc"
139
+
140
+
141
+ class KmsKeysOrderBy(str, Enum):
142
+ NAME = "name"
143
+
144
+
145
+ @dataclass
146
+ class KmsKey(BaseModel):
147
+ """Infisical KMS Key"""
148
+ id: str
149
+ description: str
150
+ isDisabled: bool
151
+ orgId: str
152
+ name: str
153
+ createdAt: str
154
+ updatedAt: str
155
+ projectId: str
156
+ version: int
157
+ encryptionAlgorithm: SymmetricEncryption
158
+
159
+
160
+ @dataclass
161
+ class ListKmsKeysResponse(BaseModel):
162
+ """Complete response model for Kms Keys API"""
163
+ keys: List[KmsKey]
164
+ totalCount: int
165
+
166
+ @classmethod
167
+ def from_dict(cls, data: Dict) -> 'ListKmsKeysResponse':
168
+ """Create model from dictionary with camelCase keys, handling nested objects"""
169
+ return cls(
170
+ keys=[KmsKey.from_dict(key) for key in data['keys']],
171
+ totalCount=data['totalCount']
172
+ )
173
+
174
+
175
+ @dataclass
176
+ class SingleKmsKeyResponse(BaseModel):
177
+ """Response model for get/create/update/delete API"""
178
+ key: KmsKey
179
+
180
+ @classmethod
181
+ def from_dict(cls, data: Dict) -> 'SingleKmsKeyResponse':
182
+ return cls(
183
+ key=KmsKey.from_dict(data['key']),
184
+ )
185
+
186
+
187
+ @dataclass
188
+ class KmsKeyEncryptDataResponse(BaseModel):
189
+ """Response model for encrypt data API"""
190
+ ciphertext: str
191
+
192
+
193
+ @dataclass
194
+ class KmsKeyDecryptDataResponse(BaseModel):
195
+ """Response model for decrypt data API"""
196
+ plaintext: str
infisical_sdk/client.py CHANGED
@@ -12,8 +12,11 @@ from botocore.awsrequest import AWSRequest
12
12
  from botocore.exceptions import NoCredentialsError
13
13
 
14
14
  from .infisical_requests import InfisicalRequests
15
- from .api_types import ListSecretsResponse, MachineIdentityLoginResponse
16
- from .api_types import SingleSecretResponse, BaseSecret
15
+
16
+ from .api_types import ListSecretsResponse, SingleSecretResponse, BaseSecret
17
+ from .api_types import SymmetricEncryption, KmsKeysOrderBy, OrderDirection
18
+ from .api_types import ListKmsKeysResponse, SingleKmsKeyResponse, MachineIdentityLoginResponse
19
+ from .api_types import KmsKey, KmsKeyEncryptDataResponse, KmsKeyDecryptDataResponse
17
20
 
18
21
 
19
22
  class InfisicalSDKClient:
@@ -25,6 +28,7 @@ class InfisicalSDKClient:
25
28
 
26
29
  self.auth = Auth(self)
27
30
  self.secrets = V3RawSecrets(self)
31
+ self.kms = KMS(self)
28
32
 
29
33
  def set_token(self, token: str):
30
34
  """
@@ -205,6 +209,7 @@ class V3RawSecrets:
205
209
  environment_slug: str,
206
210
  secret_path: str,
207
211
  expand_secret_references: bool = True,
212
+ view_secret_value: bool = True,
208
213
  recursive: bool = False,
209
214
  include_imports: bool = True,
210
215
  tag_filters: List[str] = []) -> ListSecretsResponse:
@@ -213,13 +218,14 @@ class V3RawSecrets:
213
218
  "workspaceId": project_id,
214
219
  "environment": environment_slug,
215
220
  "secretPath": secret_path,
221
+ "viewSecretValue": str(view_secret_value).lower(),
216
222
  "expandSecretReferences": str(expand_secret_references).lower(),
217
223
  "recursive": str(recursive).lower(),
218
224
  "include_imports": str(include_imports).lower(),
219
225
  }
220
226
 
221
227
  if tag_filters:
222
- params["tag_slugs"] = ",".join(tag_filters)
228
+ params["tagSlugs"] = ",".join(tag_filters)
223
229
 
224
230
  result = self.client.api.get(
225
231
  path="/api/v3/secrets/raw",
@@ -237,10 +243,12 @@ class V3RawSecrets:
237
243
  secret_path: str,
238
244
  expand_secret_references: bool = True,
239
245
  include_imports: bool = True,
246
+ view_secret_value: bool = True,
240
247
  version: str = None) -> BaseSecret:
241
248
 
242
249
  params = {
243
250
  "workspaceId": project_id,
251
+ "viewSecretValue": str(view_secret_value).lower(),
244
252
  "environment": environment_slug,
245
253
  "secretPath": secret_path,
246
254
  "expandSecretReferences": str(expand_secret_references).lower(),
@@ -307,7 +315,7 @@ class V3RawSecrets:
307
315
  "secretPath": secret_path,
308
316
  "secretValue": secret_value,
309
317
  "secretComment": secret_comment,
310
- "new_secret_name": new_secret_name,
318
+ "newSecretName": new_secret_name,
311
319
  "tagIds": None,
312
320
  "skipMultilineEncoding": skip_multiline_encoding,
313
321
  "type": "shared",
@@ -343,3 +351,175 @@ class V3RawSecrets:
343
351
  )
344
352
 
345
353
  return result.data.secret
354
+
355
+
356
+ class KMS:
357
+ def __init__(self, client: InfisicalSDKClient) -> None:
358
+ self.client = client
359
+
360
+ def list_keys(
361
+ self,
362
+ project_id: str,
363
+ offset: int = 0,
364
+ limit: int = 100,
365
+ order_by: KmsKeysOrderBy = KmsKeysOrderBy.NAME,
366
+ order_direction: OrderDirection = OrderDirection.ASC,
367
+ search: str = None) -> ListKmsKeysResponse:
368
+
369
+ params = {
370
+ "projectId": project_id,
371
+ "search": search,
372
+ "offset": offset,
373
+ "limit": limit,
374
+ "orderBy": order_by,
375
+ "orderDirection": order_direction,
376
+ }
377
+
378
+ result = self.client.api.get(
379
+ path="/api/v1/kms/keys",
380
+ params=params,
381
+ model=ListKmsKeysResponse
382
+ )
383
+
384
+ return result.data
385
+
386
+ def get_key_by_id(
387
+ self,
388
+ key_id: str) -> KmsKey:
389
+
390
+ result = self.client.api.get(
391
+ path=f"/api/v1/kms/keys/{key_id}",
392
+ model=SingleKmsKeyResponse
393
+ )
394
+
395
+ return result.data.key
396
+
397
+ def get_key_by_name(
398
+ self,
399
+ key_name: str,
400
+ project_id: str) -> KmsKey:
401
+
402
+ params = {
403
+ "projectId": project_id,
404
+ }
405
+
406
+ result = self.client.api.get(
407
+ path=f"/api/v1/kms/keys/key-name/{key_name}",
408
+ params=params,
409
+ model=SingleKmsKeyResponse
410
+ )
411
+
412
+ return result.data.key
413
+
414
+ def create_key(
415
+ self,
416
+ name: str,
417
+ project_id: str,
418
+ encryption_algorithm: SymmetricEncryption,
419
+ description: str = None) -> KmsKey:
420
+
421
+ request_body = {
422
+ "name": name,
423
+ "projectId": project_id,
424
+ "encryptionAlgorithm": encryption_algorithm,
425
+ "description": description,
426
+ }
427
+
428
+ result = self.client.api.post(
429
+ path="/api/v1/kms/keys",
430
+ json=request_body,
431
+ model=SingleKmsKeyResponse
432
+ )
433
+
434
+ return result.data.key
435
+
436
+ def update_key(
437
+ self,
438
+ key_id: str,
439
+ name: str = None,
440
+ is_disabled: bool = None,
441
+ description: str = None) -> KmsKey:
442
+
443
+ request_body = {
444
+ "name": name,
445
+ "isDisabled": is_disabled,
446
+ "description": description,
447
+ }
448
+
449
+ result = self.client.api.patch(
450
+ path=f"/api/v1/kms/keys/{key_id}",
451
+ json=request_body,
452
+ model=SingleKmsKeyResponse
453
+ )
454
+
455
+ return result.data.key
456
+
457
+ def delete_key(
458
+ self,
459
+ key_id: str) -> KmsKey:
460
+
461
+ result = self.client.api.delete(
462
+ path=f"/api/v1/kms/keys/{key_id}",
463
+ json={},
464
+ model=SingleKmsKeyResponse
465
+ )
466
+
467
+ return result.data.key
468
+
469
+ def encrypt_data(
470
+ self,
471
+ key_id: str,
472
+ base64EncodedPlaintext: str) -> str:
473
+ """
474
+ Encrypt data with the specified KMS key.
475
+
476
+ :param key_id: The ID of the key to decrypt the ciphertext with
477
+ :type key_id: str
478
+ :param base64EncodedPlaintext: The base64 encoded plaintext to encrypt
479
+ :type plaintext: str
480
+
481
+
482
+ :return: The encrypted base64 encoded plaintext (ciphertext)
483
+ :rtype: str
484
+ """
485
+
486
+ request_body = {
487
+ "plaintext": base64EncodedPlaintext
488
+ }
489
+
490
+ result = self.client.api.post(
491
+ path=f"/api/v1/kms/keys/{key_id}/encrypt",
492
+ json=request_body,
493
+ model=KmsKeyEncryptDataResponse
494
+ )
495
+
496
+ return result.data.ciphertext
497
+
498
+ def decrypt_data(
499
+ self,
500
+ key_id: str,
501
+ ciphertext: str) -> str:
502
+ """
503
+ Decrypt data with the specified KMS key.
504
+
505
+ :param key_id: The ID of the key to decrypt the ciphertext with
506
+ :type key_id: str
507
+ :param ciphertext: The encrypted base64 plaintext to decrypt
508
+ :type ciphertext: str
509
+
510
+
511
+ :return: The base64 encoded plaintext
512
+ :rtype: str
513
+ """
514
+
515
+ request_body = {
516
+ "ciphertext": ciphertext
517
+ }
518
+
519
+ result = self.client.api.post(
520
+ path=f"/api/v1/kms/keys/{key_id}/decrypt",
521
+ json=request_body,
522
+ model=KmsKeyDecryptDataResponse
523
+ )
524
+
525
+ return result.data.plaintext
@@ -1,4 +1,4 @@
1
- from typing import Any, Dict, Generic, Optional, TypeVar
1
+ from typing import Any, Dict, Generic, Optional, TypeVar, Type
2
2
  from urllib.parse import urljoin
3
3
  import requests
4
4
  from dataclasses import dataclass
@@ -90,7 +90,7 @@ class InfisicalRequests:
90
90
  def get(
91
91
  self,
92
92
  path: str,
93
- model: type[T],
93
+ model: Type[T],
94
94
  params: Optional[Dict[str, Any]] = None
95
95
  ) -> APIResponse[T]:
96
96
 
@@ -116,7 +116,7 @@ class InfisicalRequests:
116
116
  def post(
117
117
  self,
118
118
  path: str,
119
- model: type[T],
119
+ model: Type[T],
120
120
  json: Optional[Dict[str, Any]] = None
121
121
  ) -> APIResponse[T]:
122
122
 
@@ -140,7 +140,7 @@ class InfisicalRequests:
140
140
  def patch(
141
141
  self,
142
142
  path: str,
143
- model: type[T],
143
+ model: Type[T],
144
144
  json: Optional[Dict[str, Any]] = None
145
145
  ) -> APIResponse[T]:
146
146
 
@@ -164,7 +164,7 @@ class InfisicalRequests:
164
164
  def delete(
165
165
  self,
166
166
  path: str,
167
- model: type[T],
167
+ model: Type[T],
168
168
  json: Optional[Dict[str, Any]] = None
169
169
  ) -> APIResponse[T]:
170
170
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: infisicalsdk
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: Infisical API Client
5
5
  Home-page: https://github.com/Infisical/python-sdk-official
6
6
  Author: Infisical
@@ -0,0 +1,8 @@
1
+ infisical_sdk/__init__.py,sha256=UzssDXpMhK79mFBW4fpSea1bOVjoD_UILjvizFkLNz4,183
2
+ infisical_sdk/api_types.py,sha256=-SFKKhDx0GZGlzZ0kysvEMmBRtbQQXl5vwaH1a4m1Ac,5170
3
+ infisical_sdk/client.py,sha256=wZB-9ukEFIoOtNhgRJUZYQyfZ3-Rgq4CKslelMe3oWA,15773
4
+ infisical_sdk/infisical_requests.py,sha256=7y-0FS2BnlDRjfgZ4eRMXwPhA9-A7hLO3lCSOC63qt4,5661
5
+ infisicalsdk-1.0.5.dist-info/METADATA,sha256=RwpCgZu7AP6dXAXIF4UVyimTnYwoQdkLm2CmwRhyjwg,763
6
+ infisicalsdk-1.0.5.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
7
+ infisicalsdk-1.0.5.dist-info/top_level.txt,sha256=FvJjMGD1FvxwipO_qFajdH20yNV8n3lJ7G3DkQoPJNU,14
8
+ infisicalsdk-1.0.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- infisical_sdk/__init__.py,sha256=UzssDXpMhK79mFBW4fpSea1bOVjoD_UILjvizFkLNz4,183
2
- infisical_sdk/api_types.py,sha256=FjyDQ71pOYiyYA9oGAPsW5jW7LGe5L7yDuOvCr4UxwQ,3651
3
- infisical_sdk/client.py,sha256=i1poZEz2tiGJLYZuRePfWONs7hQyP_A5QJJt1UeW8WQ,10936
4
- infisical_sdk/infisical_requests.py,sha256=mROtB1fuF3E39fU9J6MiH0gQ-LhsK10W-zzEH0knePU,5655
5
- infisicalsdk-1.0.3.dist-info/METADATA,sha256=LuJqI82C7DTQdeYLCpixwYmYF49y_RfdDlVrSFDBpW4,763
6
- infisicalsdk-1.0.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
- infisicalsdk-1.0.3.dist-info/top_level.txt,sha256=FvJjMGD1FvxwipO_qFajdH20yNV8n3lJ7G3DkQoPJNU,14
8
- infisicalsdk-1.0.3.dist-info/RECORD,,