automated-actions-client 0.1.0__tar.gz
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.
- automated_actions_client-0.1.0/PKG-INFO +122 -0
- automated_actions_client-0.1.0/README.md +106 -0
- automated_actions_client-0.1.0/automated_actions_client/__init__.py +8 -0
- automated_actions_client-0.1.0/automated_actions_client/api/__init__.py +1 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/__init__.py +24 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/action_cancel.py +194 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/action_detail.py +194 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/action_list.py +282 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/create_token.py +214 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/external_resource_rds_reboot.py +255 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/me.py +162 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/no_op.py +174 -0
- automated_actions_client-0.1.0/automated_actions_client/api/v1/openshift_workload_restart.py +271 -0
- automated_actions_client-0.1.0/automated_actions_client/client.py +285 -0
- automated_actions_client-0.1.0/automated_actions_client/errors.py +16 -0
- automated_actions_client-0.1.0/automated_actions_client/models/__init__.py +21 -0
- automated_actions_client-0.1.0/automated_actions_client/models/action_schema_out.py +150 -0
- automated_actions_client-0.1.0/automated_actions_client/models/action_schema_out_task_args.py +44 -0
- automated_actions_client-0.1.0/automated_actions_client/models/action_status.py +12 -0
- automated_actions_client-0.1.0/automated_actions_client/models/create_token_param.py +83 -0
- automated_actions_client-0.1.0/automated_actions_client/models/http_validation_error.py +75 -0
- automated_actions_client-0.1.0/automated_actions_client/models/openshift_workload_restart_kind.py +11 -0
- automated_actions_client-0.1.0/automated_actions_client/models/user_schema_out.py +97 -0
- automated_actions_client-0.1.0/automated_actions_client/models/validation_error.py +86 -0
- automated_actions_client-0.1.0/automated_actions_client/py.typed +0 -0
- automated_actions_client-0.1.0/automated_actions_client/types.py +46 -0
- automated_actions_client-0.1.0/pyproject.toml +73 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: automated-actions-client
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automated Actions Client
|
|
5
|
+
Project-URL: homepage, https://github.com/app-sre/automated-actions
|
|
6
|
+
Project-URL: repository, https://github.com/app-sre/automated-actions
|
|
7
|
+
Project-URL: documentation, https://github.com/app-sre/automated-actions
|
|
8
|
+
Author-email: AppSRE <sd-app-sre@redhat.com>
|
|
9
|
+
License: Apache 2.0
|
|
10
|
+
Requires-Python: ~=3.12.0
|
|
11
|
+
Requires-Dist: attrs
|
|
12
|
+
Requires-Dist: httpx
|
|
13
|
+
Requires-Dist: python-dateutil
|
|
14
|
+
Requires-Dist: typer
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# `automated_actions_client` Package 🤖🐍
|
|
18
|
+
|
|
19
|
+
Welcome, developer, to the `automated_actions_client` package! This package provides a Python client library for interacting with the `automated_actions` API server.
|
|
20
|
+
|
|
21
|
+
## 🎯 Overview
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
This package includes:
|
|
26
|
+
|
|
27
|
+
* A Python module that maps API operations to Python methods.
|
|
28
|
+
* Pydantic models for API request and response bodies, ensuring data validation and providing editor auto-completion.
|
|
29
|
+
* Auto-generated [CLI](../automated_actions_cli/) commands using Typer, built from the same OpenAPI specification.
|
|
30
|
+
|
|
31
|
+
## 🛠️ Generation Process
|
|
32
|
+
|
|
33
|
+
### Based on OpenAPI Schema
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
### `openapi-python-client`
|
|
38
|
+
|
|
39
|
+
We use the [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) tool to perform the generation. This tool takes the OpenAPI schema as input and outputs the Python client code.
|
|
40
|
+
|
|
41
|
+
### `make generate-client`
|
|
42
|
+
|
|
43
|
+
To regenerate the client (e.g., after the `automated_actions` API has changed), you can use the following command from the **project root**:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
make generate-client
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This command typically performs the following steps:
|
|
50
|
+
|
|
51
|
+
1. Ensures the `automated_actions` server is running and its OpenAPI schema is accessible (or fetches a static schema file).
|
|
52
|
+
2. Invokes `openapi-python-client` with the appropriate configuration (input schema URL/file, output directory, custom templates).
|
|
53
|
+
3. Overwrites the existing client code in this package with the newly generated version.
|
|
54
|
+
|
|
55
|
+
**Important:** After regenerating the client, always review the changes and run tests to ensure compatibility.
|
|
56
|
+
|
|
57
|
+
## ✨ Key Features & Structure
|
|
58
|
+
|
|
59
|
+
### Client Class
|
|
60
|
+
|
|
61
|
+
The core of the generated client is usually a class (e.g., `AuthenticatedClient` or `Client`) that provides methods for each API endpoint.
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
# Example Usage (conceptual)
|
|
65
|
+
from automated_actions_client import AuthenticatedClient
|
|
66
|
+
from automated_actions_client.models import ActionRequest, ActionStatus
|
|
67
|
+
from automated_actions_client.api.actions import submit_action, get_action_status
|
|
68
|
+
from automated_actions_client.types import Response
|
|
69
|
+
|
|
70
|
+
# Assuming client is initialized and authenticated
|
|
71
|
+
client = AuthenticatedClient(base_url="http://localhost:8080", token="your-auth-token")
|
|
72
|
+
|
|
73
|
+
# Submit an action
|
|
74
|
+
action_data = ActionRequest(action_name="restart_pod", parameters={"pod_name": "my-app-123"})
|
|
75
|
+
response: Response[ActionStatus] = submit_action.sync(client=client, json_body=action_data)
|
|
76
|
+
|
|
77
|
+
if response.status_code == 202 and response.parsed:
|
|
78
|
+
task_id = response.parsed.task_id
|
|
79
|
+
print(f"Action submitted, task ID: {task_id}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
See our [integration tests](../integration_tests/tests/test_views_user.py) for more examples.
|
|
83
|
+
|
|
84
|
+
### Pydantic Models
|
|
85
|
+
|
|
86
|
+
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:
|
|
87
|
+
|
|
88
|
+
* Data validation.
|
|
89
|
+
* Type hints for better static analysis and auto-completion.
|
|
90
|
+
* Easy serialization and deserialization.
|
|
91
|
+
|
|
92
|
+
### API Modules
|
|
93
|
+
|
|
94
|
+
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.
|
|
95
|
+
|
|
96
|
+
### CLI Commands (via Custom Templates) 💻
|
|
97
|
+
|
|
98
|
+
This client package might also generate Command Line Interface (CLI) commands using [Typer](https://typer.tiangolo.com/). This is achieved by using **custom templates** with `openapi-python-client`.
|
|
99
|
+
|
|
100
|
+
* **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 instruct `openapi-python-client` on how to generate Typer app structures and commands based on the OpenAPI paths and operations.
|
|
101
|
+
* **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.
|
|
102
|
+
* **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.
|
|
103
|
+
|
|
104
|
+
The `make generate-client` command should also handle the generation of these CLI components if custom templates are configured.
|
|
105
|
+
|
|
106
|
+
## 🚀 Development & Contribution
|
|
107
|
+
|
|
108
|
+
### When to Regenerate
|
|
109
|
+
|
|
110
|
+
You should regenerate the client whenever:
|
|
111
|
+
|
|
112
|
+
* The `automated_actions` API's OpenAPI schema changes (e.g., new endpoints, modified models, changed parameters).
|
|
113
|
+
* The version of `openapi-python-client` is updated, and you want to leverage new features or bug fixes from the generator.
|
|
114
|
+
* The custom templates for CLI generation are modified.
|
|
115
|
+
|
|
116
|
+
### Testing
|
|
117
|
+
|
|
118
|
+
See [tests](./tests/) for unit tests and [integration tests](../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.
|
|
119
|
+
|
|
120
|
+
### Release Process
|
|
121
|
+
|
|
122
|
+
Please refer to the main project [README.md](/README.md) for the release process, as it typically includes steps for versioning, changelogs, and deployment.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# `automated_actions_client` Package 🤖🐍
|
|
2
|
+
|
|
3
|
+
Welcome, developer, to the `automated_actions_client` package! This package provides a Python client library for interacting with the `automated_actions` API server.
|
|
4
|
+
|
|
5
|
+
## 🎯 Overview
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
This package includes:
|
|
10
|
+
|
|
11
|
+
* A Python module that maps API operations to Python methods.
|
|
12
|
+
* Pydantic models for API request and response bodies, ensuring data validation and providing editor auto-completion.
|
|
13
|
+
* Auto-generated [CLI](../automated_actions_cli/) commands using Typer, built from the same OpenAPI specification.
|
|
14
|
+
|
|
15
|
+
## 🛠️ Generation Process
|
|
16
|
+
|
|
17
|
+
### Based on OpenAPI Schema
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
### `openapi-python-client`
|
|
22
|
+
|
|
23
|
+
We use the [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) tool to perform the generation. This tool takes the OpenAPI schema as input and outputs the Python client code.
|
|
24
|
+
|
|
25
|
+
### `make generate-client`
|
|
26
|
+
|
|
27
|
+
To regenerate the client (e.g., after the `automated_actions` API has changed), you can use the following command from the **project root**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
make generate-client
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This command typically performs the following steps:
|
|
34
|
+
|
|
35
|
+
1. Ensures the `automated_actions` server is running and its OpenAPI schema is accessible (or fetches a static schema file).
|
|
36
|
+
2. Invokes `openapi-python-client` with the appropriate configuration (input schema URL/file, output directory, custom templates).
|
|
37
|
+
3. Overwrites the existing client code in this package with the newly generated version.
|
|
38
|
+
|
|
39
|
+
**Important:** After regenerating the client, always review the changes and run tests to ensure compatibility.
|
|
40
|
+
|
|
41
|
+
## ✨ Key Features & Structure
|
|
42
|
+
|
|
43
|
+
### Client Class
|
|
44
|
+
|
|
45
|
+
The core of the generated client is usually a class (e.g., `AuthenticatedClient` or `Client`) that provides methods for each API endpoint.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
# Example Usage (conceptual)
|
|
49
|
+
from automated_actions_client import AuthenticatedClient
|
|
50
|
+
from automated_actions_client.models import ActionRequest, ActionStatus
|
|
51
|
+
from automated_actions_client.api.actions import submit_action, get_action_status
|
|
52
|
+
from automated_actions_client.types import Response
|
|
53
|
+
|
|
54
|
+
# Assuming client is initialized and authenticated
|
|
55
|
+
client = AuthenticatedClient(base_url="http://localhost:8080", token="your-auth-token")
|
|
56
|
+
|
|
57
|
+
# Submit an action
|
|
58
|
+
action_data = ActionRequest(action_name="restart_pod", parameters={"pod_name": "my-app-123"})
|
|
59
|
+
response: Response[ActionStatus] = submit_action.sync(client=client, json_body=action_data)
|
|
60
|
+
|
|
61
|
+
if response.status_code == 202 and response.parsed:
|
|
62
|
+
task_id = response.parsed.task_id
|
|
63
|
+
print(f"Action submitted, task ID: {task_id}")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
See our [integration tests](../integration_tests/tests/test_views_user.py) for more examples.
|
|
67
|
+
|
|
68
|
+
### Pydantic Models
|
|
69
|
+
|
|
70
|
+
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:
|
|
71
|
+
|
|
72
|
+
* Data validation.
|
|
73
|
+
* Type hints for better static analysis and auto-completion.
|
|
74
|
+
* Easy serialization and deserialization.
|
|
75
|
+
|
|
76
|
+
### API Modules
|
|
77
|
+
|
|
78
|
+
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.
|
|
79
|
+
|
|
80
|
+
### CLI Commands (via Custom Templates) 💻
|
|
81
|
+
|
|
82
|
+
This client package might also generate Command Line Interface (CLI) commands using [Typer](https://typer.tiangolo.com/). This is achieved by using **custom templates** with `openapi-python-client`.
|
|
83
|
+
|
|
84
|
+
* **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 instruct `openapi-python-client` on how to generate Typer app structures and commands based on the OpenAPI paths and operations.
|
|
85
|
+
* **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.
|
|
86
|
+
* **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.
|
|
87
|
+
|
|
88
|
+
The `make generate-client` command should also handle the generation of these CLI components if custom templates are configured.
|
|
89
|
+
|
|
90
|
+
## 🚀 Development & Contribution
|
|
91
|
+
|
|
92
|
+
### When to Regenerate
|
|
93
|
+
|
|
94
|
+
You should regenerate the client whenever:
|
|
95
|
+
|
|
96
|
+
* The `automated_actions` API's OpenAPI schema changes (e.g., new endpoints, modified models, changed parameters).
|
|
97
|
+
* The version of `openapi-python-client` is updated, and you want to leverage new features or bug fixes from the generator.
|
|
98
|
+
* The custom templates for CLI generation are modified.
|
|
99
|
+
|
|
100
|
+
### Testing
|
|
101
|
+
|
|
102
|
+
See [tests](./tests/) for unit tests and [integration tests](../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.
|
|
103
|
+
|
|
104
|
+
### Release Process
|
|
105
|
+
|
|
106
|
+
Please refer to the main project [README.md](/README.md) for the release process, as it typically includes steps for versioning, changelogs, and deployment.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains methods for accessing the API"""
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file is auto-generated by OpenAPI Python Client.
|
|
2
|
+
# Do not edit manually.
|
|
3
|
+
|
|
4
|
+
from . import (
|
|
5
|
+
action_cancel,
|
|
6
|
+
action_detail,
|
|
7
|
+
action_list,
|
|
8
|
+
create_token,
|
|
9
|
+
external_resource_rds_reboot,
|
|
10
|
+
me,
|
|
11
|
+
no_op,
|
|
12
|
+
openshift_workload_restart,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"action_cancel",
|
|
17
|
+
"action_detail",
|
|
18
|
+
"action_list",
|
|
19
|
+
"create_token",
|
|
20
|
+
"external_resource_rds_reboot",
|
|
21
|
+
"me",
|
|
22
|
+
"no_op",
|
|
23
|
+
"openshift_workload_restart",
|
|
24
|
+
]
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# This file is auto-generated by OpenAPI Python Client.
|
|
2
|
+
# Do not edit manually.
|
|
3
|
+
|
|
4
|
+
from http import HTTPStatus
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ... import errors
|
|
10
|
+
from ...client import AuthenticatedClient, Client
|
|
11
|
+
from ...models.action_schema_out import ActionSchemaOut
|
|
12
|
+
from ...models.http_validation_error import HTTPValidationError
|
|
13
|
+
from ...types import Response
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _get_kwargs(
|
|
17
|
+
action_id: str,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
_kwargs: dict[str, Any] = {
|
|
20
|
+
"method": "post",
|
|
21
|
+
"url": f"/api/v1/actions/{action_id}",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return _kwargs
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _parse_response(
|
|
28
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
29
|
+
) -> ActionSchemaOut | HTTPValidationError | None:
|
|
30
|
+
if response.status_code == 202:
|
|
31
|
+
response_202 = ActionSchemaOut.from_dict(response.json())
|
|
32
|
+
|
|
33
|
+
return response_202
|
|
34
|
+
if response.status_code == 422:
|
|
35
|
+
response_422 = HTTPValidationError.from_dict(response.json())
|
|
36
|
+
|
|
37
|
+
return response_422
|
|
38
|
+
if client.raise_on_unexpected_status:
|
|
39
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
40
|
+
else:
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _build_response(
|
|
45
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
46
|
+
) -> Response[ActionSchemaOut | HTTPValidationError]:
|
|
47
|
+
return Response(
|
|
48
|
+
status_code=HTTPStatus(response.status_code),
|
|
49
|
+
content=response.content,
|
|
50
|
+
headers=response.headers,
|
|
51
|
+
parsed=_parse_response(client=client, response=response),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def sync_detailed(
|
|
56
|
+
action_id: str,
|
|
57
|
+
*,
|
|
58
|
+
client: AuthenticatedClient | Client,
|
|
59
|
+
) -> Response[ActionSchemaOut | HTTPValidationError]:
|
|
60
|
+
"""Action Cancel
|
|
61
|
+
|
|
62
|
+
Cancels a pending or running action by its ID.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
action_id (str):
|
|
66
|
+
|
|
67
|
+
Raises:
|
|
68
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
69
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Response[Union[ActionSchemaOut, HTTPValidationError]]
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
kwargs = _get_kwargs(
|
|
76
|
+
action_id=action_id,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
with client as _client:
|
|
80
|
+
response = _client.request(
|
|
81
|
+
**kwargs,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return _build_response(client=client, response=response)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def sync(
|
|
88
|
+
action_id: str,
|
|
89
|
+
*,
|
|
90
|
+
client: AuthenticatedClient | Client,
|
|
91
|
+
) -> ActionSchemaOut | HTTPValidationError | None:
|
|
92
|
+
"""Action Cancel
|
|
93
|
+
|
|
94
|
+
Cancels a pending or running action by its ID.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
action_id (str):
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
101
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
Union[ActionSchemaOut, HTTPValidationError]
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
return sync_detailed(
|
|
108
|
+
action_id=action_id,
|
|
109
|
+
client=client,
|
|
110
|
+
).parsed
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
async def asyncio_detailed(
|
|
114
|
+
action_id: str,
|
|
115
|
+
*,
|
|
116
|
+
client: AuthenticatedClient | Client,
|
|
117
|
+
) -> Response[ActionSchemaOut | HTTPValidationError]:
|
|
118
|
+
"""Action Cancel
|
|
119
|
+
|
|
120
|
+
Cancels a pending or running action by its ID.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
action_id (str):
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
127
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Response[Union[ActionSchemaOut, HTTPValidationError]]
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
kwargs = _get_kwargs(
|
|
134
|
+
action_id=action_id,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
async with client as _client:
|
|
138
|
+
response = await _client.request(
|
|
139
|
+
**kwargs,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
return _build_response(client=client, response=response)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
async def asyncio(
|
|
146
|
+
action_id: str,
|
|
147
|
+
*,
|
|
148
|
+
client: AuthenticatedClient | Client,
|
|
149
|
+
) -> ActionSchemaOut | HTTPValidationError | None:
|
|
150
|
+
"""Action Cancel
|
|
151
|
+
|
|
152
|
+
Cancels a pending or running action by its ID.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
action_id (str):
|
|
156
|
+
|
|
157
|
+
Raises:
|
|
158
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
159
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
Union[ActionSchemaOut, HTTPValidationError]
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
await asyncio_detailed(
|
|
167
|
+
action_id=action_id,
|
|
168
|
+
client=client,
|
|
169
|
+
)
|
|
170
|
+
).parsed
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
from typing import Annotated
|
|
174
|
+
|
|
175
|
+
import typer
|
|
176
|
+
|
|
177
|
+
app = typer.Typer()
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@app.command(help="""Cancels a pending or running action by its ID.""")
|
|
181
|
+
def action_cancel(
|
|
182
|
+
ctx: typer.Context,
|
|
183
|
+
action_id: Annotated[str, typer.Option(help="", show_default=False)],
|
|
184
|
+
) -> None:
|
|
185
|
+
result = sync(action_id=action_id, client=ctx.obj["client"])
|
|
186
|
+
if "formatter" in ctx.obj and result:
|
|
187
|
+
output: Any = result
|
|
188
|
+
if isinstance(result, list):
|
|
189
|
+
output = [
|
|
190
|
+
item.to_dict() if hasattr(item, "to_dict") else item for item in result
|
|
191
|
+
]
|
|
192
|
+
elif hasattr(result, "to_dict"):
|
|
193
|
+
output = result.to_dict()
|
|
194
|
+
ctx.obj["formatter"](output)
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# This file is auto-generated by OpenAPI Python Client.
|
|
2
|
+
# Do not edit manually.
|
|
3
|
+
|
|
4
|
+
from http import HTTPStatus
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ... import errors
|
|
10
|
+
from ...client import AuthenticatedClient, Client
|
|
11
|
+
from ...models.action_schema_out import ActionSchemaOut
|
|
12
|
+
from ...models.http_validation_error import HTTPValidationError
|
|
13
|
+
from ...types import Response
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _get_kwargs(
|
|
17
|
+
action_id: str,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
_kwargs: dict[str, Any] = {
|
|
20
|
+
"method": "get",
|
|
21
|
+
"url": f"/api/v1/actions/{action_id}",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return _kwargs
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _parse_response(
|
|
28
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
29
|
+
) -> ActionSchemaOut | HTTPValidationError | None:
|
|
30
|
+
if response.status_code == 200:
|
|
31
|
+
response_200 = ActionSchemaOut.from_dict(response.json())
|
|
32
|
+
|
|
33
|
+
return response_200
|
|
34
|
+
if response.status_code == 422:
|
|
35
|
+
response_422 = HTTPValidationError.from_dict(response.json())
|
|
36
|
+
|
|
37
|
+
return response_422
|
|
38
|
+
if client.raise_on_unexpected_status:
|
|
39
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
40
|
+
else:
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _build_response(
|
|
45
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
46
|
+
) -> Response[ActionSchemaOut | HTTPValidationError]:
|
|
47
|
+
return Response(
|
|
48
|
+
status_code=HTTPStatus(response.status_code),
|
|
49
|
+
content=response.content,
|
|
50
|
+
headers=response.headers,
|
|
51
|
+
parsed=_parse_response(client=client, response=response),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def sync_detailed(
|
|
56
|
+
action_id: str,
|
|
57
|
+
*,
|
|
58
|
+
client: AuthenticatedClient | Client,
|
|
59
|
+
) -> Response[ActionSchemaOut | HTTPValidationError]:
|
|
60
|
+
"""Action Detail
|
|
61
|
+
|
|
62
|
+
Retrieves the details of a specific action by its ID.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
action_id (str):
|
|
66
|
+
|
|
67
|
+
Raises:
|
|
68
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
69
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Response[Union[ActionSchemaOut, HTTPValidationError]]
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
kwargs = _get_kwargs(
|
|
76
|
+
action_id=action_id,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
with client as _client:
|
|
80
|
+
response = _client.request(
|
|
81
|
+
**kwargs,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return _build_response(client=client, response=response)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def sync(
|
|
88
|
+
action_id: str,
|
|
89
|
+
*,
|
|
90
|
+
client: AuthenticatedClient | Client,
|
|
91
|
+
) -> ActionSchemaOut | HTTPValidationError | None:
|
|
92
|
+
"""Action Detail
|
|
93
|
+
|
|
94
|
+
Retrieves the details of a specific action by its ID.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
action_id (str):
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
101
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
Union[ActionSchemaOut, HTTPValidationError]
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
return sync_detailed(
|
|
108
|
+
action_id=action_id,
|
|
109
|
+
client=client,
|
|
110
|
+
).parsed
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
async def asyncio_detailed(
|
|
114
|
+
action_id: str,
|
|
115
|
+
*,
|
|
116
|
+
client: AuthenticatedClient | Client,
|
|
117
|
+
) -> Response[ActionSchemaOut | HTTPValidationError]:
|
|
118
|
+
"""Action Detail
|
|
119
|
+
|
|
120
|
+
Retrieves the details of a specific action by its ID.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
action_id (str):
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
127
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Response[Union[ActionSchemaOut, HTTPValidationError]]
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
kwargs = _get_kwargs(
|
|
134
|
+
action_id=action_id,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
async with client as _client:
|
|
138
|
+
response = await _client.request(
|
|
139
|
+
**kwargs,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
return _build_response(client=client, response=response)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
async def asyncio(
|
|
146
|
+
action_id: str,
|
|
147
|
+
*,
|
|
148
|
+
client: AuthenticatedClient | Client,
|
|
149
|
+
) -> ActionSchemaOut | HTTPValidationError | None:
|
|
150
|
+
"""Action Detail
|
|
151
|
+
|
|
152
|
+
Retrieves the details of a specific action by its ID.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
action_id (str):
|
|
156
|
+
|
|
157
|
+
Raises:
|
|
158
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
159
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
Union[ActionSchemaOut, HTTPValidationError]
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
await asyncio_detailed(
|
|
167
|
+
action_id=action_id,
|
|
168
|
+
client=client,
|
|
169
|
+
)
|
|
170
|
+
).parsed
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
from typing import Annotated
|
|
174
|
+
|
|
175
|
+
import typer
|
|
176
|
+
|
|
177
|
+
app = typer.Typer()
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@app.command(help="""Retrieves the details of a specific action by its ID.""")
|
|
181
|
+
def action_detail(
|
|
182
|
+
ctx: typer.Context,
|
|
183
|
+
action_id: Annotated[str, typer.Option(help="", show_default=False)],
|
|
184
|
+
) -> None:
|
|
185
|
+
result = sync(action_id=action_id, client=ctx.obj["client"])
|
|
186
|
+
if "formatter" in ctx.obj and result:
|
|
187
|
+
output: Any = result
|
|
188
|
+
if isinstance(result, list):
|
|
189
|
+
output = [
|
|
190
|
+
item.to_dict() if hasattr(item, "to_dict") else item for item in result
|
|
191
|
+
]
|
|
192
|
+
elif hasattr(result, "to_dict"):
|
|
193
|
+
output = result.to_dict()
|
|
194
|
+
ctx.obj["formatter"](output)
|