Automated Actions Client
Project description
automated_actions_client Package 🤖🐍
Welcome, developer, to the automated_actions_client package! This package provides a Python client library for interacting with the automated_actions API server.
🎯 Overview
The primary purpose of this client is to offer a convenient, type-safe, and Pythonic way to make API calls to the automated_actions service. It is auto-generated based on the OpenAPI (formerly Swagger) specification provided by the automated_actions server.
This package includes:
- A Python module that maps API operations to Python methods.
- Pydantic models for API request and response bodies, ensuring data validation and providing editor auto-completion.
- Auto-generated CLI commands using Typer, built from the same OpenAPI specification.
🛠️ Generation Process
Based on OpenAPI Schema
The client code is not manually written but generated automatically from the OpenAPI 3.x schema. This schema is typically exposed by the automated_actions FastAPI server (e.g., at /openapi.json). This ensures that the client stays in sync with the API's capabilities.
openapi-python-client
We use the openapi-python-client tool to perform the generation. This tool takes the OpenAPI schema as input and outputs the Python client code.
make generate-client
To regenerate the client (e.g., after the automated_actions API has changed), you can use the following command from the project root:
make generate-client
This command typically performs the following steps:
- Ensures the
automated_actionsserver is running and its OpenAPI schema is accessible (or fetches a static schema file). - Invokes
openapi-python-clientwith the appropriate configuration (input schema URL/file, output directory, custom templates). - Overwrites the existing client code in this package with the newly generated version.
Important: After regenerating the client, always review the changes and run tests to ensure compatibility.
✨ Key Features & Structure
Client Class
The core of the generated client is usually a class (e.g., AuthenticatedClient or Client) that provides methods for each API endpoint.
# Example Usage (conceptual)
from automated_actions_client import AuthenticatedClient
from automated_actions_client.models import ActionRequest, ActionStatus
from automated_actions_client.api.actions import submit_action, get_action_status
from automated_actions_client.types import Response
# Assuming client is initialized and authenticated
client = AuthenticatedClient(base_url="http://localhost:8080", token="your-auth-token")
# Submit an action
action_data = ActionRequest(action_name="restart_pod", parameters={"pod_name": "my-app-123"})
response: Response[ActionStatus] = submit_action.sync(client=client, json_body=action_data)
if response.status_code == 202 and response.parsed:
task_id = response.parsed.task_id
print(f"Action submitted, task ID: {task_id}")
See our integration tests for more examples.
Pydantic Models
All request and response bodies, as well as complex parameters, are represented by Pydantic models. These are typically found in automated_actions_client/models/. This provides:
- Data validation.
- Type hints for better static analysis and auto-completion.
- Easy serialization and deserialization.
API Modules
API operations are often grouped into modules corresponding to their tags in the OpenAPI specification (e.g., automated_actions_client/api/actions.py, automated_actions_client/api/users.py). Each module contains functions for synchronous and asynchronous calls to the endpoints.
CLI Commands (via Custom Templates) 💻
This client package might also generate Command Line Interface (CLI) commands using Typer. This is achieved by using custom templates with openapi-python-client.
- Custom Templates: These templates are located in a directory like
openapi_python_client_templates/(often at the project root or within this package's parent). They instructopenapi-python-clienton how to generate Typer app structures and commands based on the OpenAPI paths and operations. - Functionality: This allows users to interact with the API directly from the command line using a familiar CLI structure, with arguments and options derived from the API parameters.
- Entry Point: The generated CLI might have an entry point defined in
pyproject.toml(e.g.,automated-actions-client ...) or be part of a larger CLI tool.
The make generate-client command should also handle the generation of these CLI components if custom templates are configured.
🚀 Development & Contribution
When to Regenerate
You should regenerate the client whenever:
- The
automated_actionsAPI's OpenAPI schema changes (e.g., new endpoints, modified models, changed parameters). - The version of
openapi-python-clientis updated, and you want to leverage new features or bug fixes from the generator. - The custom templates for CLI generation are modified.
Testing
See tests for unit tests and integration tests that validate the generated client against the actual API. These tests ensure that the client behaves as expected and that any changes in the API are reflected correctly in the client.
Release Process
Please refer to the main project README.md for the release process, as it typically includes steps for versioning, changelogs, and deployment.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file automated_actions_client-0.1.4.tar.gz.
File metadata
- Download URL: automated_actions_client-0.1.4.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef17547831dcc8a186c4007ebc234d487604624d48ed37607003c8ac6aee569e
|
|
| MD5 |
ef9048d19c350d267877e7c9eea0e484
|
|
| BLAKE2b-256 |
aea45eb3601bb42a4fc5b36436bcd8e94f9ef77ed5e8d4b0a1fe6419cc64b0e1
|
File details
Details for the file automated_actions_client-0.1.4-py3-none-any.whl.
File metadata
- Download URL: automated_actions_client-0.1.4-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1c90a5144b06e8148686c6da60bc8d387ceddc0469d58327faba1c3aa717bbe
|
|
| MD5 |
9f059969e0d3bb3e7473c2c7f4774584
|
|
| BLAKE2b-256 |
aee8959fcd3094d22f7796d9df6a97bbcb8d55e1fae503d18d1c517c6ea5e7ff
|