Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infisical_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .client import InfisicalSDKClient # noqa
from .infisical_requests import InfisicalError # noqa
from .api_types import SingleSecretResponse, ListSecretsResponse, BaseSecret, SymmetricEncryption # noqa
from .api_types import SingleSecretResponse, ListSecretsResponse, BaseSecret, SymmetricEncryption, DynamicSecretProviders # noqa
102 changes: 102 additions & 0 deletions infisical_sdk/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,105 @@ def from_dict(cls, data: Dict) -> 'SingleFolderResponse':
return cls(
folder=SingleFolderResponseItem.from_dict(data['folder']),
)

class DynamicSecretProviders(str, Enum):
"""Enum for dynamic secret provider types"""
AWS_ELASTICACHE = "aws-elasticache"
AWS_IAM = "aws-iam"
AZURE_ENTRA_ID = "azure-entra-id"
AZURE_SQL_DATABASE = "azure-sql-database"
CASSANDRA = "cassandra"
COUCHBASE = "couchbase"
ELASTICSEARCH = "elastic-search"
GCP_IAM = "gcp-iam"
GITHUB = "github"
KUBERNETES = "kubernetes"
LDAP = "ldap"
MONGO_ATLAS = "mongo-db-atlas"
MONGODB = "mongo-db"
RABBITMQ = "rabbit-mq"
REDIS = "redis"
SAP_ASE = "sap-ase"
SAP_HANA = "sap-hana"
SNOWFLAKE = "snowflake"
SQL_DATABASE = "sql-database"
TOTP = "totp"
VERTICA = "vertica"

@dataclass
class DynamicSecret(BaseModel):
"""Infisical Dynamic Secret"""
id: str
name: str
version: int
type: str
folderId: str
createdAt: str
updatedAt: str
defaultTTL: Optional[str] = None
maxTTL: Optional[str] = None
status: Optional[str] = None
statusDetails: Optional[str] = None
usernameTemplate: Optional[str] = None
metadata: Optional[List[Dict[str, str]]] = field(default_factory=list)
inputs: Optional[Any] = None

@dataclass
class SingleDynamicSecretResponse(BaseModel):
"""Response model for get/create/update/delete dynamic secret API"""
dynamicSecret: DynamicSecret

@classmethod
def from_dict(cls, data: Dict) -> 'SingleDynamicSecretResponse':
return cls(
dynamicSecret=DynamicSecret.from_dict(data['dynamicSecret']),
)

@dataclass
class DynamicSecretLease(BaseModel):
"""Infisical Dynamic Secret Lease"""
id: str
expireAt: str
createdAt: str
updatedAt: str
version: int
dynamicSecretId: str
externalEntityId: str
status: Optional[str] = None
statusDetails: Optional[str] = None
dynamicSecret: Optional[DynamicSecret] = None

@classmethod
def from_dict(cls, data: Dict) -> 'DynamicSecretLease':
"""Create model from dictionary with nested DynamicSecret"""
lease_data = data.copy()
if 'dynamicSecret' in data and data['dynamicSecret'] is not None:
lease_data['dynamicSecret'] = DynamicSecret.from_dict(data['dynamicSecret'])

return super().from_dict(lease_data)

@dataclass
class CreateLeaseResponse(BaseModel):
"""Response model for create lease API - returns lease, dynamicSecret, and data"""
lease: DynamicSecretLease
dynamicSecret: DynamicSecret
data: Any

@classmethod
def from_dict(cls, data: Dict) -> 'CreateLeaseResponse':
return cls(
lease=DynamicSecretLease.from_dict(data['lease']),
dynamicSecret=DynamicSecret.from_dict(data['dynamicSecret']),
data=data.get('data', {}),
)

@dataclass
class SingleLeaseResponse(BaseModel):
"""Response model for get/delete/renew lease API - returns only lease"""
lease: DynamicSecretLease

@classmethod
def from_dict(cls, data: Dict) -> 'SingleLeaseResponse':
return cls(
lease=DynamicSecretLease.from_dict(data['lease']),
)
2 changes: 2 additions & 0 deletions infisical_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from infisical_sdk.resources import V3RawSecrets
from infisical_sdk.resources import KMS
from infisical_sdk.resources import V2Folders
from infisical_sdk.resources import DynamicSecrets

from infisical_sdk.util import SecretsCache

Expand All @@ -26,6 +27,7 @@ def __init__(self, host: str, token: str = None, cache_ttl: int = 60):
self.secrets = V3RawSecrets(self.api, self.cache)
self.kms = KMS(self.api)
self.folders = V2Folders(self.api)
self.dynamic_secrets = DynamicSecrets(self.api)

def set_token(self, token: str):
"""
Expand Down
3 changes: 2 additions & 1 deletion infisical_sdk/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .secrets import V3RawSecrets
from .kms import KMS
from .auth import Auth
from .folders import V2Folders
from .folders import V2Folders
from .dynamic_secrets import DynamicSecrets
Loading