Python DSL reference
ServiceArchitectClient | AuthenticationError | CodeGenerationErrorClient reuse and errors
Reuse authentication across requests and handle network, API, payload, base64, and archive failures explicitly.
When to use
Use the client directly in automation that generates several projects or needs structured error handling.
Behavior
ServiceArchitectClient.from_env()creates a reusable client and caches the temporary ID token in memory after successful authentication.AuthenticationErrorrepresents rejected credentials, unsupported challenges, invalid SRP values, and Cognito connectivity failures.CodeGenerationErrorrepresents HTTP failures, API error payloads, malformed JSON/base64, and non-ZIP responses.- A successful response may be an API Gateway JSON envelope or a direct
application/zipbody.
Error attributes properties
Structured information preserved by client exceptions.
PropertyTypeDescription
AuthenticationError.detailsanyCognito response details without deliberately adding credentials.
CodeGenerationError.status_codeint | NoneOuter HTTP status or API payload status.
CodeGenerationError.detailsanyDecoded JSON error payload or response text.
Python example
from sa_dsl import AuthenticationError, CodeGenerationError, ServiceArchitectClient
client = ServiceArchitectClient.from_env()
try:
archive = client.generate_code(project)
except AuthenticationError as error:
print(f"Authentication failed: {error}")
except CodeGenerationError as error:
print(f"Generation failed ({error.status_code}): {error}")