From b4f7da3735ade490404106c736e20a2fad3d1e62 Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Fri, 6 Jun 2025 11:37:48 +0100 Subject: [PATCH 01/13] Add generation dependency --- pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 050a09e6..4073aac7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,10 @@ test = [ "pytest-env==1.1.5", ] +client-generation = [ + "openapi-python-client==0.25.0", +] + [tool.setuptools] packages = ["fia_api"] @@ -94,4 +98,4 @@ max-args = 10 "test/scripts/transforms/test_tosca_transform.py" = ["E501"] # Long script lines in this file [tool.pytest.ini_options] -required_plugins = "pytest-env" \ No newline at end of file +required_plugins = "pytest-env" From 49c7fa01a8c21fa9254c736c5aefa23a2234c4ed Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Fri, 6 Jun 2025 11:37:57 +0100 Subject: [PATCH 02/13] Create workflow --- .github/workflows/generate-client.yml | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/generate-client.yml diff --git a/.github/workflows/generate-client.yml b/.github/workflows/generate-client.yml new file mode 100644 index 00000000..d1028199 --- /dev/null +++ b/.github/workflows/generate-client.yml @@ -0,0 +1,71 @@ +name: Generate API Client + +on: push + +permissions: + contents: write + +jobs: + generate-client: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: fia + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3.5.0 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v4.5.0 + with: + python-version: "3.12" + + - name: Set up cache for Python dependencies + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install API dependencies + run: | + python -m pip install --upgrade pip + python -m pip install . + + - name: Install client generation dependencies + run: | + python -m pip install ".[client-generation]" + + - name: Start FIA API in background + run: | + uvicorn fia_api.fia_api:app --host 0.0.0.0 --port 8000 & + # Wait for API to start + sleep 10 + + - name: Generate client code + run: | + # Generate the client code + openapi-python-client generate --url http://localhost:8000/openapi.json + # Move generated files to fia_api_client directory if needed + if [ -d "fia-api-client" ]; then + cp -r fia-api-client/* fia_api_client/ + rm -rf fia-api-client + fi + + - name: Commit changes + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add fia_api_client/ + git commit -m "Update API client based on latest OpenAPI schema" || echo "No changes to commit" + git push From 54663fe3e8d1d9a8495b5f21ae1eafc84f2b410b Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Fri, 6 Jun 2025 11:42:00 +0100 Subject: [PATCH 03/13] Update workflow --- .github/workflows/formatting_and_linting.yml | 1 + .github/workflows/generate-client.yml | 9 ++------- .github/workflows/tests.yml | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/formatting_and_linting.yml b/.github/workflows/formatting_and_linting.yml index 4925b417..8632ad6a 100644 --- a/.github/workflows/formatting_and_linting.yml +++ b/.github/workflows/formatting_and_linting.yml @@ -1,4 +1,5 @@ --- +name: Formatting and Linting on: push: branches-ignore: diff --git a/.github/workflows/generate-client.yml b/.github/workflows/generate-client.yml index d1028199..8188a6c2 100644 --- a/.github/workflows/generate-client.yml +++ b/.github/workflows/generate-client.yml @@ -54,18 +54,13 @@ jobs: - name: Generate client code run: | - # Generate the client code openapi-python-client generate --url http://localhost:8000/openapi.json - # Move generated files to fia_api_client directory if needed - if [ -d "fia-api-client" ]; then - cp -r fia-api-client/* fia_api_client/ - rm -rf fia-api-client - fi + - name: Commit changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" - git add fia_api_client/ + git add fia-api-client/ git commit -m "Update API client based on latest OpenAPI schema" || echo "No changes to commit" git push diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1a63e161..8b13035c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,5 @@ --- +name: Run Tests on: push permissions: From 64b27a9bd261402f7d6f019494e64c4f4f45506c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 6 Jun 2025 10:43:07 +0000 Subject: [PATCH 04/13] Update API client based on latest OpenAPI schema --- fia-api-client/.gitignore | 23 ++ fia-api-client/README.md | 124 ++++++ fia-api-client/fia_api_client/__init__.py | 8 + fia-api-client/fia_api_client/api/__init__.py | 1 + .../fia_api_client/api/files/__init__.py | 1 + ...experiment_number_experiment_number_get.py | 182 +++++++++ ...ile_generic_user_number_user_number_get.py | 182 +++++++++ ...experiment_number_experiment_number_get.py | 195 ++++++++++ ...get_extras_top_level_folders_extras_get.py | 129 +++++++ ..._subfolder_files_list_extras_subdir_get.py | 166 +++++++++ ..._folder_extras_instrument_filename_post.py | 203 ++++++++++ .../fia_api_client/api/health/__init__.py | 1 + .../api/health/get_healthz_get.py | 130 +++++++ .../api/health/ready_ready_get.py | 122 ++++++ .../api/instrument_specifications/__init__.py | 1 + ...ument_instrument_name_specification_get.py | 161 ++++++++ ...ument_instrument_name_specification_put.py | 221 +++++++++++ .../api/job_creation/__init__.py | 1 + .../get_mantid_runners_jobs_runners_get.py | 129 +++++++ .../make_rerun_job_job_rerun_post.py | 170 +++++++++ .../make_simple_job_job_simple_post.py | 170 +++++++++ .../fia_api_client/api/jobs/__init__.py | 1 + .../api/jobs/count_all_jobs_jobs_count_get.py | 176 +++++++++ ...nt_instrument_instrument_jobs_count_get.py | 189 ++++++++++ ...te_autoreduction_job_autoreduction_post.py | 180 +++++++++ ...d_file_job_job_id_filename_filename_get.py | 174 +++++++++ .../api/jobs/get_job_job_job_id_get.py | 163 ++++++++ ...strument_instrument_instrument_jobs_get.py | 352 ++++++++++++++++++ .../api/jobs/get_jobs_jobs_get.py | 307 +++++++++++++++ .../api/jobs/update_job_job_job_id_patch.py | 197 ++++++++++ fia-api-client/fia_api_client/client.py | 268 +++++++++++++ fia-api-client/fia_api_client/errors.py | 16 + .../fia_api_client/models/__init__.py | 61 +++ .../models/autoreduction_request.py | 146 ++++++++ ...autoreduction_request_additional_values.py | 44 +++ .../models/autoreduction_response.py | 68 ++++ ..._folder_extras_instrument_filename_post.py | 73 ++++ .../fia_api_client/models/count_response.py | 60 +++ ...instrument_instrument_jobs_get_order_by.py | 17 + ...ent_instrument_jobs_get_order_direction.py | 9 + .../models/get_jobs_jobs_get_order_by.py | 17 + .../get_jobs_jobs_get_order_direction.py | 9 + .../models/http_validation_error.py | 75 ++++ .../fia_api_client/models/job_response.py | 233 ++++++++++++ .../models/job_with_run_response.py | 261 +++++++++++++ .../models/partial_job_update_request.py | 183 +++++++++ .../fia_api_client/models/rerun_job.py | 75 ++++ .../fia_api_client/models/run_response.py | 132 +++++++ .../fia_api_client/models/script_response.py | 60 +++ .../fia_api_client/models/simple_job.py | 67 ++++ fia-api-client/fia_api_client/models/state.py | 11 + ...ument_instrument_name_specification_put.py | 47 +++ ...nt_name_specification_put_specification.py | 44 +++ ...ras_instrument_filename_post_instrument.py | 43 +++ .../fia_api_client/models/validation_error.py | 88 +++++ fia-api-client/fia_api_client/py.typed | 1 + fia-api-client/fia_api_client/types.py | 54 +++ fia-api-client/pyproject.toml | 27 ++ 58 files changed, 6248 insertions(+) create mode 100644 fia-api-client/.gitignore create mode 100644 fia-api-client/README.md create mode 100644 fia-api-client/fia_api_client/__init__.py create mode 100644 fia-api-client/fia_api_client/api/__init__.py create mode 100644 fia-api-client/fia_api_client/api/files/__init__.py create mode 100644 fia-api-client/fia_api_client/api/files/find_file_generic_experiment_number_find_file_generic_experiment_number_experiment_number_get.py create mode 100644 fia-api-client/fia_api_client/api/files/find_file_generic_user_number_find_file_generic_user_number_user_number_get.py create mode 100644 fia-api-client/fia_api_client/api/files/find_file_get_instrument_find_file_instrument_instrument_experiment_number_experiment_number_get.py create mode 100644 fia-api-client/fia_api_client/api/files/get_extras_top_level_folders_extras_get.py create mode 100644 fia-api-client/fia_api_client/api/files/get_subfolder_files_list_extras_subdir_get.py create mode 100644 fia-api-client/fia_api_client/api/files/upload_file_to_instrument_folder_extras_instrument_filename_post.py create mode 100644 fia-api-client/fia_api_client/api/health/__init__.py create mode 100644 fia-api-client/fia_api_client/api/health/get_healthz_get.py create mode 100644 fia-api-client/fia_api_client/api/health/ready_ready_get.py create mode 100644 fia-api-client/fia_api_client/api/instrument_specifications/__init__.py create mode 100644 fia-api-client/fia_api_client/api/instrument_specifications/get_instrument_specification_instrument_instrument_name_specification_get.py create mode 100644 fia-api-client/fia_api_client/api/instrument_specifications/update_instrument_specification_instrument_instrument_name_specification_put.py create mode 100644 fia-api-client/fia_api_client/api/job_creation/__init__.py create mode 100644 fia-api-client/fia_api_client/api/job_creation/get_mantid_runners_jobs_runners_get.py create mode 100644 fia-api-client/fia_api_client/api/job_creation/make_rerun_job_job_rerun_post.py create mode 100644 fia-api-client/fia_api_client/api/job_creation/make_simple_job_job_simple_post.py create mode 100644 fia-api-client/fia_api_client/api/jobs/__init__.py create mode 100644 fia-api-client/fia_api_client/api/jobs/count_all_jobs_jobs_count_get.py create mode 100644 fia-api-client/fia_api_client/api/jobs/count_jobs_for_instrument_instrument_instrument_jobs_count_get.py create mode 100644 fia-api-client/fia_api_client/api/jobs/create_autoreduction_job_autoreduction_post.py create mode 100644 fia-api-client/fia_api_client/api/jobs/download_file_job_job_id_filename_filename_get.py create mode 100644 fia-api-client/fia_api_client/api/jobs/get_job_job_job_id_get.py create mode 100644 fia-api-client/fia_api_client/api/jobs/get_jobs_by_instrument_instrument_instrument_jobs_get.py create mode 100644 fia-api-client/fia_api_client/api/jobs/get_jobs_jobs_get.py create mode 100644 fia-api-client/fia_api_client/api/jobs/update_job_job_job_id_patch.py create mode 100644 fia-api-client/fia_api_client/client.py create mode 100644 fia-api-client/fia_api_client/errors.py create mode 100644 fia-api-client/fia_api_client/models/__init__.py create mode 100644 fia-api-client/fia_api_client/models/autoreduction_request.py create mode 100644 fia-api-client/fia_api_client/models/autoreduction_request_additional_values.py create mode 100644 fia-api-client/fia_api_client/models/autoreduction_response.py create mode 100644 fia-api-client/fia_api_client/models/body_upload_file_to_instrument_folder_extras_instrument_filename_post.py create mode 100644 fia-api-client/fia_api_client/models/count_response.py create mode 100644 fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_by.py create mode 100644 fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_direction.py create mode 100644 fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_by.py create mode 100644 fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_direction.py create mode 100644 fia-api-client/fia_api_client/models/http_validation_error.py create mode 100644 fia-api-client/fia_api_client/models/job_response.py create mode 100644 fia-api-client/fia_api_client/models/job_with_run_response.py create mode 100644 fia-api-client/fia_api_client/models/partial_job_update_request.py create mode 100644 fia-api-client/fia_api_client/models/rerun_job.py create mode 100644 fia-api-client/fia_api_client/models/run_response.py create mode 100644 fia-api-client/fia_api_client/models/script_response.py create mode 100644 fia-api-client/fia_api_client/models/simple_job.py create mode 100644 fia-api-client/fia_api_client/models/state.py create mode 100644 fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put.py create mode 100644 fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_specification.py create mode 100644 fia-api-client/fia_api_client/models/upload_file_to_instrument_folder_extras_instrument_filename_post_instrument.py create mode 100644 fia-api-client/fia_api_client/models/validation_error.py create mode 100644 fia-api-client/fia_api_client/py.typed create mode 100644 fia-api-client/fia_api_client/types.py create mode 100644 fia-api-client/pyproject.toml diff --git a/fia-api-client/.gitignore b/fia-api-client/.gitignore new file mode 100644 index 00000000..79a2c3d7 --- /dev/null +++ b/fia-api-client/.gitignore @@ -0,0 +1,23 @@ +__pycache__/ +build/ +dist/ +*.egg-info/ +.pytest_cache/ + +# pyenv +.python-version + +# Environments +.env +.venv + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# JetBrains +.idea/ + +/coverage.xml +/.coverage diff --git a/fia-api-client/README.md b/fia-api-client/README.md new file mode 100644 index 00000000..c5c67eec --- /dev/null +++ b/fia-api-client/README.md @@ -0,0 +1,124 @@ +# fia-api-client +A client library for accessing FIA API + +## Usage +First, create a client: + +```python +from fia_api_client import Client + +client = Client(base_url="https://api.example.com") +``` + +If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead: + +```python +from fia_api_client import AuthenticatedClient + +client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") +``` + +Now call your endpoint and use your models: + +```python +from fia_api_client.models import MyDataModel +from fia_api_client.api.my_tag import get_my_data_model +from fia_api_client.types import Response + +with client as client: + my_data: MyDataModel = get_my_data_model.sync(client=client) + # or if you need more info (e.g. status_code) + response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) +``` + +Or do the same thing with an async version: + +```python +from fia_api_client.models import MyDataModel +from fia_api_client.api.my_tag import get_my_data_model +from fia_api_client.types import Response + +async with client as client: + my_data: MyDataModel = await get_my_data_model.asyncio(client=client) + response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) +``` + +By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl="/path/to/certificate_bundle.pem", +) +``` + +You can also disable certificate validation altogether, but beware that **this is a security risk**. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl=False +) +``` + +Things to know: +1. Every path/method combo becomes a Python module with four functions: + 1. `sync`: Blocking request that returns parsed data (if successful) or `None` + 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. + 1. `asyncio`: Like `sync` but async instead of blocking + 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking + +1. All path/query params, and bodies become method arguments. +1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) +1. Any endpoint which did not have a tag will be in `fia_api_client.api.default` + +## Advanced customizations + +There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case): + +```python +from fia_api_client import Client + +def log_request(request): + print(f"Request event hook: {request.method} {request.url} - Waiting for response") + +def log_response(response): + request = response.request + print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}") + +client = Client( + base_url="https://api.example.com", + httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}}, +) + +# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client() +``` + +You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url): + +```python +import httpx +from fia_api_client import Client + +client = Client( + base_url="https://api.example.com", +) +# Note that base_url needs to be re-set, as would any shared cookies, headers, etc. +client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030")) +``` + +## Building / publishing this package +This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics: +1. Update the metadata in pyproject.toml (e.g. authors, version) +1. If you're using a private repository, configure it with Poetry + 1. `poetry config repositories. ` + 1. `poetry config http-basic. ` +1. Publish the client with `poetry publish --build -r ` or, if for public PyPI, just `poetry publish --build` + +If you want to install this client into another project without publishing it (e.g. for development) then: +1. If that project **is using Poetry**, you can simply do `poetry add ` from that project +1. If that project is not using Poetry: + 1. Build a wheel with `poetry build -f wheel` + 1. Install that wheel from the other project `pip install ` diff --git a/fia-api-client/fia_api_client/__init__.py b/fia-api-client/fia_api_client/__init__.py new file mode 100644 index 00000000..6d41c6f0 --- /dev/null +++ b/fia-api-client/fia_api_client/__init__.py @@ -0,0 +1,8 @@ +"""A client library for accessing FIA API""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/fia-api-client/fia_api_client/api/__init__.py b/fia-api-client/fia_api_client/api/__init__.py new file mode 100644 index 00000000..81f9fa24 --- /dev/null +++ b/fia-api-client/fia_api_client/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/files/__init__.py b/fia-api-client/fia_api_client/api/files/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/fia-api-client/fia_api_client/api/files/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/files/find_file_generic_experiment_number_find_file_generic_experiment_number_experiment_number_get.py b/fia-api-client/fia_api_client/api/files/find_file_generic_experiment_number_find_file_generic_experiment_number_experiment_number_get.py new file mode 100644 index 00000000..b6f35a47 --- /dev/null +++ b/fia-api-client/fia_api_client/api/files/find_file_generic_experiment_number_find_file_generic_experiment_number_experiment_number_get.py @@ -0,0 +1,182 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response + + +def _get_kwargs( + experiment_number: int, + *, + filename: str, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["filename"] = filename + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/find_file/generic/experiment_number/{experiment_number}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Response[Union[HTTPValidationError, str]]: + """Find File Generic Experiment Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + experiment_number=experiment_number, + filename=filename, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Find File Generic Experiment Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + experiment_number=experiment_number, + client=client, + filename=filename, + ).parsed + + +async def asyncio_detailed( + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Response[Union[HTTPValidationError, str]]: + """Find File Generic Experiment Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + experiment_number=experiment_number, + filename=filename, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Find File Generic Experiment Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + experiment_number=experiment_number, + client=client, + filename=filename, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/files/find_file_generic_user_number_find_file_generic_user_number_user_number_get.py b/fia-api-client/fia_api_client/api/files/find_file_generic_user_number_find_file_generic_user_number_user_number_get.py new file mode 100644 index 00000000..56dd11a0 --- /dev/null +++ b/fia-api-client/fia_api_client/api/files/find_file_generic_user_number_find_file_generic_user_number_user_number_get.py @@ -0,0 +1,182 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response + + +def _get_kwargs( + user_number: int, + *, + filename: str, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["filename"] = filename + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/find_file/generic/user_number/{user_number}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + user_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Response[Union[HTTPValidationError, str]]: + """Find File Generic User Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + user_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + user_number=user_number, + filename=filename, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + user_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Find File Generic User Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + user_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + user_number=user_number, + client=client, + filename=filename, + ).parsed + + +async def asyncio_detailed( + user_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Response[Union[HTTPValidationError, str]]: + """Find File Generic User Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + user_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + user_number=user_number, + filename=filename, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + user_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Find File Generic User Number + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + user_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + user_number=user_number, + client=client, + filename=filename, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/files/find_file_get_instrument_find_file_instrument_instrument_experiment_number_experiment_number_get.py b/fia-api-client/fia_api_client/api/files/find_file_get_instrument_find_file_instrument_instrument_experiment_number_experiment_number_get.py new file mode 100644 index 00000000..917906b0 --- /dev/null +++ b/fia-api-client/fia_api_client/api/files/find_file_get_instrument_find_file_instrument_instrument_experiment_number_experiment_number_get.py @@ -0,0 +1,195 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response + + +def _get_kwargs( + instrument: str, + experiment_number: int, + *, + filename: str, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["filename"] = filename + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/find_file/instrument/{instrument}/experiment_number/{experiment_number}", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: str, + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Response[Union[HTTPValidationError, str]]: + """Find File Get Instrument + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + instrument (str): + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + experiment_number=experiment_number, + filename=filename, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: str, + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Find File Get Instrument + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + instrument (str): + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + instrument=instrument, + experiment_number=experiment_number, + client=client, + filename=filename, + ).parsed + + +async def asyncio_detailed( + instrument: str, + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Response[Union[HTTPValidationError, str]]: + """Find File Get Instrument + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + instrument (str): + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + experiment_number=experiment_number, + filename=filename, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: str, + experiment_number: int, + *, + client: AuthenticatedClient, + filename: str, +) -> Optional[Union[HTTPValidationError, str]]: + """Find File Get Instrument + + Return the relative path to the env var CEPH_DIR that leads to the requested file if one exists. + + Args: + instrument (str): + experiment_number (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + experiment_number=experiment_number, + client=client, + filename=filename, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/files/get_extras_top_level_folders_extras_get.py b/fia-api-client/fia_api_client/api/files/get_extras_top_level_folders_extras_get.py new file mode 100644 index 00000000..791ac057 --- /dev/null +++ b/fia-api-client/fia_api_client/api/files/get_extras_top_level_folders_extras_get.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/extras/", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[str]]: + if response.status_code == 200: + response_200 = cast(list[str], response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, +) -> Response[list[str]]: + """Get Extras Top Level Folders + + Returns top level folders in the extras directory + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, +) -> Optional[list[str]]: + """Get Extras Top Level Folders + + Returns top level folders in the extras directory + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, +) -> Response[list[str]]: + """Get Extras Top Level Folders + + Returns top level folders in the extras directory + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, +) -> Optional[list[str]]: + """Get Extras Top Level Folders + + Returns top level folders in the extras directory + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/files/get_subfolder_files_list_extras_subdir_get.py b/fia-api-client/fia_api_client/api/files/get_subfolder_files_list_extras_subdir_get.py new file mode 100644 index 00000000..4b6ebe96 --- /dev/null +++ b/fia-api-client/fia_api_client/api/files/get_subfolder_files_list_extras_subdir_get.py @@ -0,0 +1,166 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + subdir: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/extras/{subdir}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, list[str]]]: + if response.status_code == 200: + response_200 = cast(list[str], response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, list[str]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + subdir: str, + *, + client: AuthenticatedClient, +) -> Response[Union[HTTPValidationError, list[str]]]: + """Get Subfolder Files List + + Returns a list of files within a sub_folder. Directs users to use the /extras endpoint if folder not + found + + Args: + subdir (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, list[str]]] + """ + + kwargs = _get_kwargs( + subdir=subdir, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + subdir: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[HTTPValidationError, list[str]]]: + """Get Subfolder Files List + + Returns a list of files within a sub_folder. Directs users to use the /extras endpoint if folder not + found + + Args: + subdir (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, list[str]] + """ + + return sync_detailed( + subdir=subdir, + client=client, + ).parsed + + +async def asyncio_detailed( + subdir: str, + *, + client: AuthenticatedClient, +) -> Response[Union[HTTPValidationError, list[str]]]: + """Get Subfolder Files List + + Returns a list of files within a sub_folder. Directs users to use the /extras endpoint if folder not + found + + Args: + subdir (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, list[str]]] + """ + + kwargs = _get_kwargs( + subdir=subdir, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + subdir: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[HTTPValidationError, list[str]]]: + """Get Subfolder Files List + + Returns a list of files within a sub_folder. Directs users to use the /extras endpoint if folder not + found + + Args: + subdir (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, list[str]] + """ + + return ( + await asyncio_detailed( + subdir=subdir, + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/files/upload_file_to_instrument_folder_extras_instrument_filename_post.py b/fia-api-client/fia_api_client/api/files/upload_file_to_instrument_folder_extras_instrument_filename_post.py new file mode 100644 index 00000000..fbf602df --- /dev/null +++ b/fia-api-client/fia_api_client/api/files/upload_file_to_instrument_folder_extras_instrument_filename_post.py @@ -0,0 +1,203 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.body_upload_file_to_instrument_folder_extras_instrument_filename_post import ( + BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, +) +from ...models.http_validation_error import HTTPValidationError +from ...models.upload_file_to_instrument_folder_extras_instrument_filename_post_instrument import ( + UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument, +) +from ...types import Response + + +def _get_kwargs( + instrument: UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument, + filename: str, + *, + body: BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": f"/extras/{instrument}/{filename}", + } + + _kwargs["files"] = body.to_multipart() + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument, + filename: str, + *, + client: AuthenticatedClient, + body: BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, +) -> Response[Union[HTTPValidationError, str]]: + """Upload File To Instrument Folder + + Uploads a file to the instrument folder, prevents access to folder any other + directory other than extras and its sub folders. + + Args: + instrument (UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument): + filename (str): + body (BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + filename=filename, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument, + filename: str, + *, + client: AuthenticatedClient, + body: BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, +) -> Optional[Union[HTTPValidationError, str]]: + """Upload File To Instrument Folder + + Uploads a file to the instrument folder, prevents access to folder any other + directory other than extras and its sub folders. + + Args: + instrument (UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument): + filename (str): + body (BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + instrument=instrument, + filename=filename, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + instrument: UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument, + filename: str, + *, + client: AuthenticatedClient, + body: BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, +) -> Response[Union[HTTPValidationError, str]]: + """Upload File To Instrument Folder + + Uploads a file to the instrument folder, prevents access to folder any other + directory other than extras and its sub folders. + + Args: + instrument (UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument): + filename (str): + body (BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + filename=filename, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument, + filename: str, + *, + client: AuthenticatedClient, + body: BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, +) -> Optional[Union[HTTPValidationError, str]]: + """Upload File To Instrument Folder + + Uploads a file to the instrument folder, prevents access to folder any other + directory other than extras and its sub folders. + + Args: + instrument (UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument): + filename (str): + body (BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + filename=filename, + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/health/__init__.py b/fia-api-client/fia_api_client/api/health/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/fia-api-client/fia_api_client/api/health/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/health/get_healthz_get.py b/fia-api-client/fia_api_client/api/health/get_healthz_get.py new file mode 100644 index 00000000..a97b4223 --- /dev/null +++ b/fia-api-client/fia_api_client/api/health/get_healthz_get.py @@ -0,0 +1,130 @@ +from http import HTTPStatus +from typing import Any, Literal, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/healthz", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Literal["ok"]]: + if response.status_code == 200: + response_200 = cast(Literal["ok"], response.json()) + if response_200 != "ok": + raise ValueError(f"response_200 must match const 'ok', got '{response_200}'") + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Literal["ok"]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Literal["ok"]]: + """Get + + Health Check endpoint. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Literal['ok']] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Literal["ok"]]: + """Get + + Health Check endpoint. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Literal['ok'] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Literal["ok"]]: + """Get + + Health Check endpoint. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Literal['ok']] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Literal["ok"]]: + """Get + + Health Check endpoint. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Literal['ok'] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/health/ready_ready_get.py b/fia-api-client/fia_api_client/api/health/ready_ready_get.py new file mode 100644 index 00000000..4c0e0e66 --- /dev/null +++ b/fia-api-client/fia_api_client/api/health/ready_ready_get.py @@ -0,0 +1,122 @@ +from http import HTTPStatus +from typing import Any, Literal, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/ready", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Literal["ok"]]: + if response.status_code == 200: + response_200 = cast(Literal["ok"], response.json()) + if response_200 != "ok": + raise ValueError(f"response_200 must match const 'ok', got '{response_200}'") + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Literal["ok"]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Literal["ok"]]: + """Ready + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Literal['ok']] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Literal["ok"]]: + """Ready + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Literal['ok'] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Literal["ok"]]: + """Ready + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Literal['ok']] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Literal["ok"]]: + """Ready + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Literal['ok'] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/instrument_specifications/__init__.py b/fia-api-client/fia_api_client/api/instrument_specifications/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/fia-api-client/fia_api_client/api/instrument_specifications/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/instrument_specifications/get_instrument_specification_instrument_instrument_name_specification_get.py b/fia-api-client/fia_api_client/api/instrument_specifications/get_instrument_specification_instrument_instrument_name_specification_get.py new file mode 100644 index 00000000..46762d11 --- /dev/null +++ b/fia-api-client/fia_api_client/api/instrument_specifications/get_instrument_specification_instrument_instrument_name_specification_get.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + instrument_name: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/instrument/{instrument_name}/specification", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument_name: str, + *, + client: AuthenticatedClient, +) -> Response[Union[Any, HTTPValidationError]]: + """Get Instrument Specification + + Return the specification for the given instrument + + Args: + instrument_name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + instrument_name=instrument_name, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument_name: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[Any, HTTPValidationError]]: + """Get Instrument Specification + + Return the specification for the given instrument + + Args: + instrument_name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + instrument_name=instrument_name, + client=client, + ).parsed + + +async def asyncio_detailed( + instrument_name: str, + *, + client: AuthenticatedClient, +) -> Response[Union[Any, HTTPValidationError]]: + """Get Instrument Specification + + Return the specification for the given instrument + + Args: + instrument_name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + instrument_name=instrument_name, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument_name: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[Any, HTTPValidationError]]: + """Get Instrument Specification + + Return the specification for the given instrument + + Args: + instrument_name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + instrument_name=instrument_name, + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/instrument_specifications/update_instrument_specification_instrument_instrument_name_specification_put.py b/fia-api-client/fia_api_client/api/instrument_specifications/update_instrument_specification_instrument_instrument_name_specification_put.py new file mode 100644 index 00000000..3aab8770 --- /dev/null +++ b/fia-api-client/fia_api_client/api/instrument_specifications/update_instrument_specification_instrument_instrument_name_specification_put.py @@ -0,0 +1,221 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...models.update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put import ( + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, +) +from ...models.update_instrument_specification_instrument_instrument_name_specification_put_specification import ( + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification, +) +from ...types import Response + + +def _get_kwargs( + instrument_name: str, + *, + body: UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": f"/instrument/{instrument_name}/specification", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ + Union[ + HTTPValidationError, + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, + ] +]: + if response.status_code == 200: + response_200 = UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut.from_dict( + response.json() + ) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ + Union[ + HTTPValidationError, + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, + ] +]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument_name: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification, +) -> Response[ + Union[ + HTTPValidationError, + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, + ] +]: + """Update Instrument Specification + + Replace the current specification with the given specification for the given instrument + + Args: + instrument_name (str): + body (UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut]] + """ + + kwargs = _get_kwargs( + instrument_name=instrument_name, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument_name: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification, +) -> Optional[ + Union[ + HTTPValidationError, + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, + ] +]: + """Update Instrument Specification + + Replace the current specification with the given specification for the given instrument + + Args: + instrument_name (str): + body (UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut] + """ + + return sync_detailed( + instrument_name=instrument_name, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + instrument_name: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification, +) -> Response[ + Union[ + HTTPValidationError, + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, + ] +]: + """Update Instrument Specification + + Replace the current specification with the given specification for the given instrument + + Args: + instrument_name (str): + body (UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut]] + """ + + kwargs = _get_kwargs( + instrument_name=instrument_name, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument_name: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification, +) -> Optional[ + Union[ + HTTPValidationError, + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, + ] +]: + """Update Instrument Specification + + Replace the current specification with the given specification for the given instrument + + Args: + instrument_name (str): + body (UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut] + """ + + return ( + await asyncio_detailed( + instrument_name=instrument_name, + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/job_creation/__init__.py b/fia-api-client/fia_api_client/api/job_creation/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/fia-api-client/fia_api_client/api/job_creation/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/job_creation/get_mantid_runners_jobs_runners_get.py b/fia-api-client/fia_api_client/api/job_creation/get_mantid_runners_jobs_runners_get.py new file mode 100644 index 00000000..92004c00 --- /dev/null +++ b/fia-api-client/fia_api_client/api/job_creation/get_mantid_runners_jobs_runners_get.py @@ -0,0 +1,129 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/jobs/runners", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[str]]: + if response.status_code == 200: + response_200 = cast(list[str], response.json()) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, +) -> Response[list[str]]: + """Get Mantid Runners + + Return a list of Mantid versions if user is authenticated. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, +) -> Optional[list[str]]: + """Get Mantid Runners + + Return a list of Mantid versions if user is authenticated. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, +) -> Response[list[str]]: + """Get Mantid Runners + + Return a list of Mantid versions if user is authenticated. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, +) -> Optional[list[str]]: + """Get Mantid Runners + + Return a list of Mantid versions if user is authenticated. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/job_creation/make_rerun_job_job_rerun_post.py b/fia-api-client/fia_api_client/api/job_creation/make_rerun_job_job_rerun_post.py new file mode 100644 index 00000000..c3f8dde9 --- /dev/null +++ b/fia-api-client/fia_api_client/api/job_creation/make_rerun_job_job_rerun_post.py @@ -0,0 +1,170 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...models.rerun_job import RerunJob +from ...types import Response + + +def _get_kwargs( + *, + body: RerunJob, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/job/rerun", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, int]]: + if response.status_code == 200: + response_200 = cast(int, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, int]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, + body: RerunJob, +) -> Response[Union[HTTPValidationError, int]]: + """Make Rerun Job + + Create a rerun job, returning the ID of the created job. + + Args: + body (RerunJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, int]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + body: RerunJob, +) -> Optional[Union[HTTPValidationError, int]]: + """Make Rerun Job + + Create a rerun job, returning the ID of the created job. + + Args: + body (RerunJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, int] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + body: RerunJob, +) -> Response[Union[HTTPValidationError, int]]: + """Make Rerun Job + + Create a rerun job, returning the ID of the created job. + + Args: + body (RerunJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, int]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + body: RerunJob, +) -> Optional[Union[HTTPValidationError, int]]: + """Make Rerun Job + + Create a rerun job, returning the ID of the created job. + + Args: + body (RerunJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, int] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/job_creation/make_simple_job_job_simple_post.py b/fia-api-client/fia_api_client/api/job_creation/make_simple_job_job_simple_post.py new file mode 100644 index 00000000..ff9c20e9 --- /dev/null +++ b/fia-api-client/fia_api_client/api/job_creation/make_simple_job_job_simple_post.py @@ -0,0 +1,170 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...models.simple_job import SimpleJob +from ...types import Response + + +def _get_kwargs( + *, + body: SimpleJob, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/job/simple", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, int]]: + if response.status_code == 200: + response_200 = cast(int, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, int]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, + body: SimpleJob, +) -> Response[Union[HTTPValidationError, int]]: + """Make Simple Job + + Create a simple job, returning the ID of the created job. + + Args: + body (SimpleJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, int]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + body: SimpleJob, +) -> Optional[Union[HTTPValidationError, int]]: + """Make Simple Job + + Create a simple job, returning the ID of the created job. + + Args: + body (SimpleJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, int] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + body: SimpleJob, +) -> Response[Union[HTTPValidationError, int]]: + """Make Simple Job + + Create a simple job, returning the ID of the created job. + + Args: + body (SimpleJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, int]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + body: SimpleJob, +) -> Optional[Union[HTTPValidationError, int]]: + """Make Simple Job + + Create a simple job, returning the ID of the created job. + + Args: + body (SimpleJob): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, int] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/__init__.py b/fia-api-client/fia_api_client/api/jobs/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/jobs/count_all_jobs_jobs_count_get.py b/fia-api-client/fia_api_client/api/jobs/count_all_jobs_jobs_count_get.py new file mode 100644 index 00000000..9873654a --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/count_all_jobs_jobs_count_get.py @@ -0,0 +1,176 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.count_response import CountResponse +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + filters: Union[None, Unset, str] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + json_filters: Union[None, Unset, str] + if isinstance(filters, Unset): + json_filters = UNSET + else: + json_filters = filters + params["filters"] = json_filters + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/jobs/count", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[CountResponse, HTTPValidationError]]: + if response.status_code == 200: + response_200 = CountResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[CountResponse, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Response[Union[CountResponse, HTTPValidationError]]: + """Count All Jobs + + Count all jobs + + Args: + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[CountResponse, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + filters=filters, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Optional[Union[CountResponse, HTTPValidationError]]: + """Count All Jobs + + Count all jobs + + Args: + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[CountResponse, HTTPValidationError] + """ + + return sync_detailed( + client=client, + filters=filters, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Response[Union[CountResponse, HTTPValidationError]]: + """Count All Jobs + + Count all jobs + + Args: + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[CountResponse, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + filters=filters, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Optional[Union[CountResponse, HTTPValidationError]]: + """Count All Jobs + + Count all jobs + + Args: + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[CountResponse, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + filters=filters, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/count_jobs_for_instrument_instrument_instrument_jobs_count_get.py b/fia-api-client/fia_api_client/api/jobs/count_jobs_for_instrument_instrument_instrument_jobs_count_get.py new file mode 100644 index 00000000..cb917f08 --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/count_jobs_for_instrument_instrument_instrument_jobs_count_get.py @@ -0,0 +1,189 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.count_response import CountResponse +from ...models.http_validation_error import HTTPValidationError +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + instrument: str, + *, + filters: Union[None, Unset, str] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + json_filters: Union[None, Unset, str] + if isinstance(filters, Unset): + json_filters = UNSET + else: + json_filters = filters + params["filters"] = json_filters + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/instrument/{instrument}/jobs/count", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[CountResponse, HTTPValidationError]]: + if response.status_code == 200: + response_200 = CountResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[CountResponse, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: str, + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Response[Union[CountResponse, HTTPValidationError]]: + """Count Jobs For Instrument + + Count jobs for a given instrument. + + Args: + instrument (str): + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[CountResponse, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + filters=filters, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: str, + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Optional[Union[CountResponse, HTTPValidationError]]: + """Count Jobs For Instrument + + Count jobs for a given instrument. + + Args: + instrument (str): + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[CountResponse, HTTPValidationError] + """ + + return sync_detailed( + instrument=instrument, + client=client, + filters=filters, + ).parsed + + +async def asyncio_detailed( + instrument: str, + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Response[Union[CountResponse, HTTPValidationError]]: + """Count Jobs For Instrument + + Count jobs for a given instrument. + + Args: + instrument (str): + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[CountResponse, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + filters=filters, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: str, + *, + client: Union[AuthenticatedClient, Client], + filters: Union[None, Unset, str] = UNSET, +) -> Optional[Union[CountResponse, HTTPValidationError]]: + """Count Jobs For Instrument + + Count jobs for a given instrument. + + Args: + instrument (str): + filters (Union[None, Unset, str]): json string of filters + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[CountResponse, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + client=client, + filters=filters, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/create_autoreduction_job_autoreduction_post.py b/fia-api-client/fia_api_client/api/jobs/create_autoreduction_job_autoreduction_post.py new file mode 100644 index 00000000..fdf1a3b7 --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/create_autoreduction_job_autoreduction_post.py @@ -0,0 +1,180 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.autoreduction_request import AutoreductionRequest +from ...models.autoreduction_response import AutoreductionResponse +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + *, + body: AutoreductionRequest, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/job/autoreduction", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[AutoreductionResponse, HTTPValidationError]]: + if response.status_code == 200: + response_200 = AutoreductionResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[AutoreductionResponse, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, + body: AutoreductionRequest, +) -> Response[Union[AutoreductionResponse, HTTPValidationError]]: + """Create Autoreduction + + Given an AutoreductionRequest, return an AutoreductionResponse containing the job id and the + autoreduction script + + Args: + body (AutoreductionRequest): Autoreduction request encompasses all the fields necessary + for an autoreduction job to be created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[AutoreductionResponse, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + body: AutoreductionRequest, +) -> Optional[Union[AutoreductionResponse, HTTPValidationError]]: + """Create Autoreduction + + Given an AutoreductionRequest, return an AutoreductionResponse containing the job id and the + autoreduction script + + Args: + body (AutoreductionRequest): Autoreduction request encompasses all the fields necessary + for an autoreduction job to be created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[AutoreductionResponse, HTTPValidationError] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + body: AutoreductionRequest, +) -> Response[Union[AutoreductionResponse, HTTPValidationError]]: + """Create Autoreduction + + Given an AutoreductionRequest, return an AutoreductionResponse containing the job id and the + autoreduction script + + Args: + body (AutoreductionRequest): Autoreduction request encompasses all the fields necessary + for an autoreduction job to be created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[AutoreductionResponse, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + body: AutoreductionRequest, +) -> Optional[Union[AutoreductionResponse, HTTPValidationError]]: + """Create Autoreduction + + Given an AutoreductionRequest, return an AutoreductionResponse containing the job id and the + autoreduction script + + Args: + body (AutoreductionRequest): Autoreduction request encompasses all the fields necessary + for an autoreduction job to be created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[AutoreductionResponse, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/download_file_job_job_id_filename_filename_get.py b/fia-api-client/fia_api_client/api/jobs/download_file_job_job_id_filename_filename_get.py new file mode 100644 index 00000000..c5af749e --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/download_file_job_job_id_filename_filename_get.py @@ -0,0 +1,174 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + job_id: int, + filename: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/job/{job_id}/filename/{filename}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + job_id: int, + filename: str, + *, + client: AuthenticatedClient, +) -> Response[Union[Any, HTTPValidationError]]: + """Download File + + Find a file in the CEPH_DIR and return it as a FileResponse. + + Args: + job_id (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + job_id=job_id, + filename=filename, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + job_id: int, + filename: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[Any, HTTPValidationError]]: + """Download File + + Find a file in the CEPH_DIR and return it as a FileResponse. + + Args: + job_id (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + job_id=job_id, + filename=filename, + client=client, + ).parsed + + +async def asyncio_detailed( + job_id: int, + filename: str, + *, + client: AuthenticatedClient, +) -> Response[Union[Any, HTTPValidationError]]: + """Download File + + Find a file in the CEPH_DIR and return it as a FileResponse. + + Args: + job_id (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + job_id=job_id, + filename=filename, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + job_id: int, + filename: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[Any, HTTPValidationError]]: + """Download File + + Find a file in the CEPH_DIR and return it as a FileResponse. + + Args: + job_id (int): + filename (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + job_id=job_id, + filename=filename, + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/get_job_job_job_id_get.py b/fia-api-client/fia_api_client/api/jobs/get_job_job_job_id_get.py new file mode 100644 index 00000000..f5691e55 --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/get_job_job_job_id_get.py @@ -0,0 +1,163 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...models.job_with_run_response import JobWithRunResponse +from ...types import Response + + +def _get_kwargs( + job_id: int, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/job/{job_id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, JobWithRunResponse]]: + if response.status_code == 200: + response_200 = JobWithRunResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, JobWithRunResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + job_id: int, + *, + client: AuthenticatedClient, +) -> Response[Union[HTTPValidationError, JobWithRunResponse]]: + """Get Job + + Retrieve a job with nested run data, by iD. + + Args: + job_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, JobWithRunResponse]] + """ + + kwargs = _get_kwargs( + job_id=job_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + job_id: int, + *, + client: AuthenticatedClient, +) -> Optional[Union[HTTPValidationError, JobWithRunResponse]]: + """Get Job + + Retrieve a job with nested run data, by iD. + + Args: + job_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, JobWithRunResponse] + """ + + return sync_detailed( + job_id=job_id, + client=client, + ).parsed + + +async def asyncio_detailed( + job_id: int, + *, + client: AuthenticatedClient, +) -> Response[Union[HTTPValidationError, JobWithRunResponse]]: + """Get Job + + Retrieve a job with nested run data, by iD. + + Args: + job_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, JobWithRunResponse]] + """ + + kwargs = _get_kwargs( + job_id=job_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + job_id: int, + *, + client: AuthenticatedClient, +) -> Optional[Union[HTTPValidationError, JobWithRunResponse]]: + """Get Job + + Retrieve a job with nested run data, by iD. + + Args: + job_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, JobWithRunResponse] + """ + + return ( + await asyncio_detailed( + job_id=job_id, + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/get_jobs_by_instrument_instrument_instrument_jobs_get.py b/fia-api-client/fia_api_client/api/jobs/get_jobs_by_instrument_instrument_instrument_jobs_get.py new file mode 100644 index 00000000..a5f0c3cc --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/get_jobs_by_instrument_instrument_instrument_jobs_get.py @@ -0,0 +1,352 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_jobs_by_instrument_instrument_instrument_jobs_get_order_by import ( + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy, +) +from ...models.get_jobs_by_instrument_instrument_instrument_jobs_get_order_direction import ( + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection, +) +from ...models.http_validation_error import HTTPValidationError +from ...models.job_response import JobResponse +from ...models.job_with_run_response import JobWithRunResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + instrument: str, + *, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START, + order_direction: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["limit"] = limit + + params["offset"] = offset + + json_order_by: Union[Unset, str] = UNSET + if not isinstance(order_by, Unset): + json_order_by = order_by.value + + params["order_by"] = json_order_by + + json_order_direction: Union[Unset, str] = UNSET + if not isinstance(order_direction, Unset): + json_order_direction = order_direction.value + + params["order_direction"] = json_order_direction + + params["include_run"] = include_run + + json_filters: Union[None, Unset, str] + if isinstance(filters, Unset): + json_filters = UNSET + else: + json_filters = filters + params["filters"] = json_filters + + params["as_user"] = as_user + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/instrument/{instrument}/jobs", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + if response.status_code == 200: + + def _parse_response_200(data: object) -> Union[list["JobResponse"], list["JobWithRunResponse"]]: + try: + if not isinstance(data, list): + raise TypeError() + response_200_type_0 = [] + _response_200_type_0 = data + for response_200_type_0_item_data in _response_200_type_0: + response_200_type_0_item = JobResponse.from_dict(response_200_type_0_item_data) + + response_200_type_0.append(response_200_type_0_item) + + return response_200_type_0 + except: # noqa: E722 + pass + if not isinstance(data, list): + raise TypeError() + response_200_type_1 = [] + _response_200_type_1 = data + for response_200_type_1_item_data in _response_200_type_1: + response_200_type_1_item = JobWithRunResponse.from_dict(response_200_type_1_item_data) + + response_200_type_1.append(response_200_type_1_item) + + return response_200_type_1 + + response_200 = _parse_response_200(response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START, + order_direction: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Response[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs By Instrument + + Retrieve a list of jobs for a given instrument. + + Args: + instrument (str): + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START. + order_direction (Union[Unset, + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START, + order_direction: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Optional[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs By Instrument + + Retrieve a list of jobs for a given instrument. + + Args: + instrument (str): + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START. + order_direction (Union[Unset, + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]] + """ + + return sync_detailed( + instrument=instrument, + client=client, + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ).parsed + + +async def asyncio_detailed( + instrument: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START, + order_direction: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Response[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs By Instrument + + Retrieve a list of jobs for a given instrument. + + Args: + instrument (str): + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START. + order_direction (Union[Unset, + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START, + order_direction: Union[ + Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection + ] = GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Optional[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs By Instrument + + Retrieve a list of jobs for a given instrument. + + Args: + instrument (str): + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy.START. + order_direction (Union[Unset, + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection]): Default: + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + client=client, + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/get_jobs_jobs_get.py b/fia-api-client/fia_api_client/api/jobs/get_jobs_jobs_get.py new file mode 100644 index 00000000..ff0e77d8 --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/get_jobs_jobs_get.py @@ -0,0 +1,307 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_jobs_jobs_get_order_by import GetJobsJobsGetOrderBy +from ...models.get_jobs_jobs_get_order_direction import GetJobsJobsGetOrderDirection +from ...models.http_validation_error import HTTPValidationError +from ...models.job_response import JobResponse +from ...models.job_with_run_response import JobWithRunResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[Unset, GetJobsJobsGetOrderBy] = GetJobsJobsGetOrderBy.START, + order_direction: Union[Unset, GetJobsJobsGetOrderDirection] = GetJobsJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["limit"] = limit + + params["offset"] = offset + + json_order_by: Union[Unset, str] = UNSET + if not isinstance(order_by, Unset): + json_order_by = order_by.value + + params["order_by"] = json_order_by + + json_order_direction: Union[Unset, str] = UNSET + if not isinstance(order_direction, Unset): + json_order_direction = order_direction.value + + params["order_direction"] = json_order_direction + + params["include_run"] = include_run + + json_filters: Union[None, Unset, str] + if isinstance(filters, Unset): + json_filters = UNSET + else: + json_filters = filters + params["filters"] = json_filters + + params["as_user"] = as_user + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/jobs", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + if response.status_code == 200: + + def _parse_response_200(data: object) -> Union[list["JobResponse"], list["JobWithRunResponse"]]: + try: + if not isinstance(data, list): + raise TypeError() + response_200_type_0 = [] + _response_200_type_0 = data + for response_200_type_0_item_data in _response_200_type_0: + response_200_type_0_item = JobResponse.from_dict(response_200_type_0_item_data) + + response_200_type_0.append(response_200_type_0_item) + + return response_200_type_0 + except: # noqa: E722 + pass + if not isinstance(data, list): + raise TypeError() + response_200_type_1 = [] + _response_200_type_1 = data + for response_200_type_1_item_data in _response_200_type_1: + response_200_type_1_item = JobWithRunResponse.from_dict(response_200_type_1_item_data) + + response_200_type_1.append(response_200_type_1_item) + + return response_200_type_1 + + response_200 = _parse_response_200(response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[Unset, GetJobsJobsGetOrderBy] = GetJobsJobsGetOrderBy.START, + order_direction: Union[Unset, GetJobsJobsGetOrderDirection] = GetJobsJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Response[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs + + Retrieve all jobs. + + Args: + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsJobsGetOrderBy]): Default: GetJobsJobsGetOrderBy.START. + order_direction (Union[Unset, GetJobsJobsGetOrderDirection]): Default: + GetJobsJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]]] + """ + + kwargs = _get_kwargs( + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[Unset, GetJobsJobsGetOrderBy] = GetJobsJobsGetOrderBy.START, + order_direction: Union[Unset, GetJobsJobsGetOrderDirection] = GetJobsJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Optional[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs + + Retrieve all jobs. + + Args: + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsJobsGetOrderBy]): Default: GetJobsJobsGetOrderBy.START. + order_direction (Union[Unset, GetJobsJobsGetOrderDirection]): Default: + GetJobsJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]] + """ + + return sync_detailed( + client=client, + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[Unset, GetJobsJobsGetOrderBy] = GetJobsJobsGetOrderBy.START, + order_direction: Union[Unset, GetJobsJobsGetOrderDirection] = GetJobsJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Response[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs + + Retrieve all jobs. + + Args: + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsJobsGetOrderBy]): Default: GetJobsJobsGetOrderBy.START. + order_direction (Union[Unset, GetJobsJobsGetOrderDirection]): Default: + GetJobsJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]]] + """ + + kwargs = _get_kwargs( + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = 0, + offset: Union[Unset, int] = 0, + order_by: Union[Unset, GetJobsJobsGetOrderBy] = GetJobsJobsGetOrderBy.START, + order_direction: Union[Unset, GetJobsJobsGetOrderDirection] = GetJobsJobsGetOrderDirection.DESC, + include_run: Union[Unset, bool] = False, + filters: Union[None, Unset, str] = UNSET, + as_user: Union[Unset, bool] = False, +) -> Optional[Union[HTTPValidationError, Union[list["JobResponse"], list["JobWithRunResponse"]]]]: + """Get Jobs + + Retrieve all jobs. + + Args: + limit (Union[Unset, int]): Default: 0. + offset (Union[Unset, int]): Default: 0. + order_by (Union[Unset, GetJobsJobsGetOrderBy]): Default: GetJobsJobsGetOrderBy.START. + order_direction (Union[Unset, GetJobsJobsGetOrderDirection]): Default: + GetJobsJobsGetOrderDirection.DESC. + include_run (Union[Unset, bool]): Default: False. + filters (Union[None, Unset, str]): json string of filters + as_user (Union[Unset, bool]): Default: False. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, Union[list['JobResponse'], list['JobWithRunResponse']]] + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + offset=offset, + order_by=order_by, + order_direction=order_direction, + include_run=include_run, + filters=filters, + as_user=as_user, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/update_job_job_job_id_patch.py b/fia-api-client/fia_api_client/api/jobs/update_job_job_job_id_patch.py new file mode 100644 index 00000000..ec8d8333 --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/update_job_job_job_id_patch.py @@ -0,0 +1,197 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...models.job_response import JobResponse +from ...models.partial_job_update_request import PartialJobUpdateRequest +from ...types import Response + + +def _get_kwargs( + job_id: int, + *, + body: PartialJobUpdateRequest, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "patch", + "url": f"/job/{job_id}", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, JobResponse]]: + if response.status_code == 200: + response_200 = JobResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, JobResponse]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + job_id: int, + *, + client: AuthenticatedClient, + body: PartialJobUpdateRequest, +) -> Response[Union[HTTPValidationError, JobResponse]]: + """Update Job + + Safely update the job of the given id with the new details provided. The update is safe as it + prevents + retroactive changes of values that should never change + + Args: + job_id (int): + body (PartialJobUpdateRequest): Partial Job Update Request encompasses all the safely + updatable fields on a Job + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, JobResponse]] + """ + + kwargs = _get_kwargs( + job_id=job_id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + job_id: int, + *, + client: AuthenticatedClient, + body: PartialJobUpdateRequest, +) -> Optional[Union[HTTPValidationError, JobResponse]]: + """Update Job + + Safely update the job of the given id with the new details provided. The update is safe as it + prevents + retroactive changes of values that should never change + + Args: + job_id (int): + body (PartialJobUpdateRequest): Partial Job Update Request encompasses all the safely + updatable fields on a Job + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, JobResponse] + """ + + return sync_detailed( + job_id=job_id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + job_id: int, + *, + client: AuthenticatedClient, + body: PartialJobUpdateRequest, +) -> Response[Union[HTTPValidationError, JobResponse]]: + """Update Job + + Safely update the job of the given id with the new details provided. The update is safe as it + prevents + retroactive changes of values that should never change + + Args: + job_id (int): + body (PartialJobUpdateRequest): Partial Job Update Request encompasses all the safely + updatable fields on a Job + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, JobResponse]] + """ + + kwargs = _get_kwargs( + job_id=job_id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + job_id: int, + *, + client: AuthenticatedClient, + body: PartialJobUpdateRequest, +) -> Optional[Union[HTTPValidationError, JobResponse]]: + """Update Job + + Safely update the job of the given id with the new details provided. The update is safe as it + prevents + retroactive changes of values that should never change + + Args: + job_id (int): + body (PartialJobUpdateRequest): Partial Job Update Request encompasses all the safely + updatable fields on a Job + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, JobResponse] + """ + + return ( + await asyncio_detailed( + job_id=job_id, + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/client.py b/fia-api-client/fia_api_client/client.py new file mode 100644 index 00000000..e80446f1 --- /dev/null +++ b/fia-api-client/fia_api_client/client.py @@ -0,0 +1,268 @@ +import ssl +from typing import Any, Optional, Union + +import httpx +from attrs import define, evolve, field + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + def with_headers(self, headers: dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: Optional[httpx.Client] = field(default=None, init=False) + _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout (in seconds)""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/fia-api-client/fia_api_client/errors.py b/fia-api-client/fia_api_client/errors.py new file mode 100644 index 00000000..5f92e76a --- /dev/null +++ b/fia-api-client/fia_api_client/errors.py @@ -0,0 +1,16 @@ +"""Contains shared errors types that can be raised from API functions""" + + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + + +__all__ = ["UnexpectedStatus"] diff --git a/fia-api-client/fia_api_client/models/__init__.py b/fia-api-client/fia_api_client/models/__init__.py new file mode 100644 index 00000000..0323a776 --- /dev/null +++ b/fia-api-client/fia_api_client/models/__init__.py @@ -0,0 +1,61 @@ +"""Contains all the data models used in inputs/outputs""" + +from .autoreduction_request import AutoreductionRequest +from .autoreduction_request_additional_values import AutoreductionRequestAdditionalValues +from .autoreduction_response import AutoreductionResponse +from .body_upload_file_to_instrument_folder_extras_instrument_filename_post import ( + BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, +) +from .count_response import CountResponse +from .get_jobs_by_instrument_instrument_instrument_jobs_get_order_by import ( + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy, +) +from .get_jobs_by_instrument_instrument_instrument_jobs_get_order_direction import ( + GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection, +) +from .get_jobs_jobs_get_order_by import GetJobsJobsGetOrderBy +from .get_jobs_jobs_get_order_direction import GetJobsJobsGetOrderDirection +from .http_validation_error import HTTPValidationError +from .job_response import JobResponse +from .job_with_run_response import JobWithRunResponse +from .partial_job_update_request import PartialJobUpdateRequest +from .rerun_job import RerunJob +from .run_response import RunResponse +from .script_response import ScriptResponse +from .simple_job import SimpleJob +from .state import State +from .update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put import ( + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, +) +from .update_instrument_specification_instrument_instrument_name_specification_put_specification import ( + UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification, +) +from .upload_file_to_instrument_folder_extras_instrument_filename_post_instrument import ( + UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument, +) +from .validation_error import ValidationError + +__all__ = ( + "AutoreductionRequest", + "AutoreductionRequestAdditionalValues", + "AutoreductionResponse", + "BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost", + "CountResponse", + "GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy", + "GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection", + "GetJobsJobsGetOrderBy", + "GetJobsJobsGetOrderDirection", + "HTTPValidationError", + "JobResponse", + "JobWithRunResponse", + "PartialJobUpdateRequest", + "RerunJob", + "RunResponse", + "ScriptResponse", + "SimpleJob", + "State", + "UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut", + "UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification", + "UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument", + "ValidationError", +) diff --git a/fia-api-client/fia_api_client/models/autoreduction_request.py b/fia-api-client/fia_api_client/models/autoreduction_request.py new file mode 100644 index 00000000..7e866dae --- /dev/null +++ b/fia-api-client/fia_api_client/models/autoreduction_request.py @@ -0,0 +1,146 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.autoreduction_request_additional_values import AutoreductionRequestAdditionalValues + + +T = TypeVar("T", bound="AutoreductionRequest") + + +@_attrs_define +class AutoreductionRequest: + """Autoreduction request encompasses all the fields necessary for an autoreduction job to be created + + Attributes: + filename (str): + rb_number (str): + instrument_name (str): + title (str): + users (str): + run_start (str): + run_end (str): + good_frames (int): + raw_frames (int): + additional_values (AutoreductionRequestAdditionalValues): + runner_image (str): + """ + + filename: str + rb_number: str + instrument_name: str + title: str + users: str + run_start: str + run_end: str + good_frames: int + raw_frames: int + additional_values: "AutoreductionRequestAdditionalValues" + runner_image: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + filename = self.filename + + rb_number = self.rb_number + + instrument_name = self.instrument_name + + title = self.title + + users = self.users + + run_start = self.run_start + + run_end = self.run_end + + good_frames = self.good_frames + + raw_frames = self.raw_frames + + additional_values = self.additional_values.to_dict() + + runner_image = self.runner_image + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "filename": filename, + "rb_number": rb_number, + "instrument_name": instrument_name, + "title": title, + "users": users, + "run_start": run_start, + "run_end": run_end, + "good_frames": good_frames, + "raw_frames": raw_frames, + "additional_values": additional_values, + "runner_image": runner_image, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.autoreduction_request_additional_values import AutoreductionRequestAdditionalValues + + d = dict(src_dict) + filename = d.pop("filename") + + rb_number = d.pop("rb_number") + + instrument_name = d.pop("instrument_name") + + title = d.pop("title") + + users = d.pop("users") + + run_start = d.pop("run_start") + + run_end = d.pop("run_end") + + good_frames = d.pop("good_frames") + + raw_frames = d.pop("raw_frames") + + additional_values = AutoreductionRequestAdditionalValues.from_dict(d.pop("additional_values")) + + runner_image = d.pop("runner_image") + + autoreduction_request = cls( + filename=filename, + rb_number=rb_number, + instrument_name=instrument_name, + title=title, + users=users, + run_start=run_start, + run_end=run_end, + good_frames=good_frames, + raw_frames=raw_frames, + additional_values=additional_values, + runner_image=runner_image, + ) + + autoreduction_request.additional_properties = d + return autoreduction_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/autoreduction_request_additional_values.py b/fia-api-client/fia_api_client/models/autoreduction_request_additional_values.py new file mode 100644 index 00000000..9368d100 --- /dev/null +++ b/fia-api-client/fia_api_client/models/autoreduction_request_additional_values.py @@ -0,0 +1,44 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="AutoreductionRequestAdditionalValues") + + +@_attrs_define +class AutoreductionRequestAdditionalValues: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + autoreduction_request_additional_values = cls() + + autoreduction_request_additional_values.additional_properties = d + return autoreduction_request_additional_values + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/autoreduction_response.py b/fia-api-client/fia_api_client/models/autoreduction_response.py new file mode 100644 index 00000000..047dc81a --- /dev/null +++ b/fia-api-client/fia_api_client/models/autoreduction_response.py @@ -0,0 +1,68 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="AutoreductionResponse") + + +@_attrs_define +class AutoreductionResponse: + """Autoreduction response contains all the data required to trigger an autoreduction + + Attributes: + script (str): + job_id (int): + """ + + script: str + job_id: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + script = self.script + + job_id = self.job_id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "script": script, + "job_id": job_id, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + script = d.pop("script") + + job_id = d.pop("job_id") + + autoreduction_response = cls( + script=script, + job_id=job_id, + ) + + autoreduction_response.additional_properties = d + return autoreduction_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/body_upload_file_to_instrument_folder_extras_instrument_filename_post.py b/fia-api-client/fia_api_client/models/body_upload_file_to_instrument_folder_extras_instrument_filename_post.py new file mode 100644 index 00000000..9179d1f5 --- /dev/null +++ b/fia-api-client/fia_api_client/models/body_upload_file_to_instrument_folder_extras_instrument_filename_post.py @@ -0,0 +1,73 @@ +from collections.abc import Mapping +from io import BytesIO +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from .. import types +from ..types import File + +T = TypeVar("T", bound="BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost") + + +@_attrs_define +class BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost: + """ + Attributes: + file (File): + """ + + file: File + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + file = self.file.to_tuple() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "file": file, + } + ) + + return field_dict + + def to_multipart(self) -> types.RequestFiles: + files: types.RequestFiles = [] + + files.append(("file", self.file.to_tuple())) + + for prop_name, prop in self.additional_properties.items(): + files.append((prop_name, (None, str(prop).encode(), "text/plain"))) + + return files + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + file = File(payload=BytesIO(d.pop("file"))) + + body_upload_file_to_instrument_folder_extras_instrument_filename_post = cls( + file=file, + ) + + body_upload_file_to_instrument_folder_extras_instrument_filename_post.additional_properties = d + return body_upload_file_to_instrument_folder_extras_instrument_filename_post + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/count_response.py b/fia-api-client/fia_api_client/models/count_response.py new file mode 100644 index 00000000..1978b69b --- /dev/null +++ b/fia-api-client/fia_api_client/models/count_response.py @@ -0,0 +1,60 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="CountResponse") + + +@_attrs_define +class CountResponse: + """Count response shows the count of a model + + Attributes: + count (int): + """ + + count: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + count = self.count + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "count": count, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + count = d.pop("count") + + count_response = cls( + count=count, + ) + + count_response.additional_properties = d + return count_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_by.py b/fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_by.py new file mode 100644 index 00000000..8be6026d --- /dev/null +++ b/fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_by.py @@ -0,0 +1,17 @@ +from enum import Enum + + +class GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy(str, Enum): + END = "end" + EXPERIMENT_NUMBER = "experiment_number" + EXPERIMENT_TITLE = "experiment_title" + FILENAME = "filename" + ID = "id" + OUTPUTS = "outputs" + RUN_END = "run_end" + RUN_START = "run_start" + START = "start" + STATE = "state" + + def __str__(self) -> str: + return str(self.value) diff --git a/fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_direction.py b/fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_direction.py new file mode 100644 index 00000000..2bf2c4e5 --- /dev/null +++ b/fia-api-client/fia_api_client/models/get_jobs_by_instrument_instrument_instrument_jobs_get_order_direction.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection(str, Enum): + ASC = "asc" + DESC = "desc" + + def __str__(self) -> str: + return str(self.value) diff --git a/fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_by.py b/fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_by.py new file mode 100644 index 00000000..f2828663 --- /dev/null +++ b/fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_by.py @@ -0,0 +1,17 @@ +from enum import Enum + + +class GetJobsJobsGetOrderBy(str, Enum): + END = "end" + EXPERIMENT_NUMBER = "experiment_number" + EXPERIMENT_TITLE = "experiment_title" + FILENAME = "filename" + ID = "id" + OUTPUTS = "outputs" + RUN_END = "run_end" + RUN_START = "run_start" + START = "start" + STATE = "state" + + def __str__(self) -> str: + return str(self.value) diff --git a/fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_direction.py b/fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_direction.py new file mode 100644 index 00000000..95009ab4 --- /dev/null +++ b/fia-api-client/fia_api_client/models/get_jobs_jobs_get_order_direction.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class GetJobsJobsGetOrderDirection(str, Enum): + ASC = "asc" + DESC = "desc" + + def __str__(self) -> str: + return str(self.value) diff --git a/fia-api-client/fia_api_client/models/http_validation_error.py b/fia-api-client/fia_api_client/models/http_validation_error.py new file mode 100644 index 00000000..36bb758b --- /dev/null +++ b/fia-api-client/fia_api_client/models/http_validation_error.py @@ -0,0 +1,75 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.validation_error import ValidationError + + +T = TypeVar("T", bound="HTTPValidationError") + + +@_attrs_define +class HTTPValidationError: + """ + Attributes: + detail (Union[Unset, list['ValidationError']]): + """ + + detail: Union[Unset, list["ValidationError"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + detail: Union[Unset, list[dict[str, Any]]] = UNSET + if not isinstance(self.detail, Unset): + detail = [] + for detail_item_data in self.detail: + detail_item = detail_item_data.to_dict() + detail.append(detail_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if detail is not UNSET: + field_dict["detail"] = detail + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.validation_error import ValidationError + + d = dict(src_dict) + detail = [] + _detail = d.pop("detail", UNSET) + for detail_item_data in _detail or []: + detail_item = ValidationError.from_dict(detail_item_data) + + detail.append(detail_item) + + http_validation_error = cls( + detail=detail, + ) + + http_validation_error.additional_properties = d + return http_validation_error + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/job_response.py b/fia-api-client/fia_api_client/models/job_response.py new file mode 100644 index 00000000..d4c8f56d --- /dev/null +++ b/fia-api-client/fia_api_client/models/job_response.py @@ -0,0 +1,233 @@ +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.state import State + +if TYPE_CHECKING: + from ..models.script_response import ScriptResponse + + +T = TypeVar("T", bound="JobResponse") + + +@_attrs_define +class JobResponse: + """JobResponse object that does not contain the related runs + + Attributes: + id (int): + start (Union[None, datetime.datetime]): + end (Union[None, datetime.datetime]): + state (State): An enumeration representing the possible reduction states. + status_message (Union[None, str]): + inputs (Any): + outputs (Union[None, str]): + stacktrace (Union[None, str]): + script (Union['ScriptResponse', None]): + runner_image (Union[None, str]): + type_ (Union[None, str]): + """ + + id: int + start: Union[None, datetime.datetime] + end: Union[None, datetime.datetime] + state: State + status_message: Union[None, str] + inputs: Any + outputs: Union[None, str] + stacktrace: Union[None, str] + script: Union["ScriptResponse", None] + runner_image: Union[None, str] + type_: Union[None, str] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.script_response import ScriptResponse + + id = self.id + + start: Union[None, str] + if isinstance(self.start, datetime.datetime): + start = self.start.isoformat() + else: + start = self.start + + end: Union[None, str] + if isinstance(self.end, datetime.datetime): + end = self.end.isoformat() + else: + end = self.end + + state = self.state.value + + status_message: Union[None, str] + status_message = self.status_message + + inputs = self.inputs + + outputs: Union[None, str] + outputs = self.outputs + + stacktrace: Union[None, str] + stacktrace = self.stacktrace + + script: Union[None, dict[str, Any]] + if isinstance(self.script, ScriptResponse): + script = self.script.to_dict() + else: + script = self.script + + runner_image: Union[None, str] + runner_image = self.runner_image + + type_: Union[None, str] + type_ = self.type_ + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "start": start, + "end": end, + "state": state, + "status_message": status_message, + "inputs": inputs, + "outputs": outputs, + "stacktrace": stacktrace, + "script": script, + "runner_image": runner_image, + "type": type_, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.script_response import ScriptResponse + + d = dict(src_dict) + id = d.pop("id") + + def _parse_start(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + start_type_0 = isoparse(data) + + return start_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + start = _parse_start(d.pop("start")) + + def _parse_end(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + end_type_0 = isoparse(data) + + return end_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + end = _parse_end(d.pop("end")) + + state = State(d.pop("state")) + + def _parse_status_message(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + status_message = _parse_status_message(d.pop("status_message")) + + inputs = d.pop("inputs") + + def _parse_outputs(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + outputs = _parse_outputs(d.pop("outputs")) + + def _parse_stacktrace(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + stacktrace = _parse_stacktrace(d.pop("stacktrace")) + + def _parse_script(data: object) -> Union["ScriptResponse", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + script_type_0 = ScriptResponse.from_dict(data) + + return script_type_0 + except: # noqa: E722 + pass + return cast(Union["ScriptResponse", None], data) + + script = _parse_script(d.pop("script")) + + def _parse_runner_image(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + runner_image = _parse_runner_image(d.pop("runner_image")) + + def _parse_type_(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + type_ = _parse_type_(d.pop("type")) + + job_response = cls( + id=id, + start=start, + end=end, + state=state, + status_message=status_message, + inputs=inputs, + outputs=outputs, + stacktrace=stacktrace, + script=script, + runner_image=runner_image, + type_=type_, + ) + + job_response.additional_properties = d + return job_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/job_with_run_response.py b/fia-api-client/fia_api_client/models/job_with_run_response.py new file mode 100644 index 00000000..3d1ebf1b --- /dev/null +++ b/fia-api-client/fia_api_client/models/job_with_run_response.py @@ -0,0 +1,261 @@ +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.state import State + +if TYPE_CHECKING: + from ..models.run_response import RunResponse + from ..models.script_response import ScriptResponse + + +T = TypeVar("T", bound="JobWithRunResponse") + + +@_attrs_define +class JobWithRunResponse: + """JobWithRunsResponse is the same as a Job response, with the runs nested + + Attributes: + id (int): + start (Union[None, datetime.datetime]): + end (Union[None, datetime.datetime]): + state (State): An enumeration representing the possible reduction states. + status_message (Union[None, str]): + inputs (Any): + outputs (Union[None, str]): + stacktrace (Union[None, str]): + script (Union['ScriptResponse', None]): + runner_image (Union[None, str]): + type_ (Union[None, str]): + run (Union['RunResponse', None]): + """ + + id: int + start: Union[None, datetime.datetime] + end: Union[None, datetime.datetime] + state: State + status_message: Union[None, str] + inputs: Any + outputs: Union[None, str] + stacktrace: Union[None, str] + script: Union["ScriptResponse", None] + runner_image: Union[None, str] + type_: Union[None, str] + run: Union["RunResponse", None] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.run_response import RunResponse + from ..models.script_response import ScriptResponse + + id = self.id + + start: Union[None, str] + if isinstance(self.start, datetime.datetime): + start = self.start.isoformat() + else: + start = self.start + + end: Union[None, str] + if isinstance(self.end, datetime.datetime): + end = self.end.isoformat() + else: + end = self.end + + state = self.state.value + + status_message: Union[None, str] + status_message = self.status_message + + inputs = self.inputs + + outputs: Union[None, str] + outputs = self.outputs + + stacktrace: Union[None, str] + stacktrace = self.stacktrace + + script: Union[None, dict[str, Any]] + if isinstance(self.script, ScriptResponse): + script = self.script.to_dict() + else: + script = self.script + + runner_image: Union[None, str] + runner_image = self.runner_image + + type_: Union[None, str] + type_ = self.type_ + + run: Union[None, dict[str, Any]] + if isinstance(self.run, RunResponse): + run = self.run.to_dict() + else: + run = self.run + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "start": start, + "end": end, + "state": state, + "status_message": status_message, + "inputs": inputs, + "outputs": outputs, + "stacktrace": stacktrace, + "script": script, + "runner_image": runner_image, + "type": type_, + "run": run, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.run_response import RunResponse + from ..models.script_response import ScriptResponse + + d = dict(src_dict) + id = d.pop("id") + + def _parse_start(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + start_type_0 = isoparse(data) + + return start_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + start = _parse_start(d.pop("start")) + + def _parse_end(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + end_type_0 = isoparse(data) + + return end_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + end = _parse_end(d.pop("end")) + + state = State(d.pop("state")) + + def _parse_status_message(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + status_message = _parse_status_message(d.pop("status_message")) + + inputs = d.pop("inputs") + + def _parse_outputs(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + outputs = _parse_outputs(d.pop("outputs")) + + def _parse_stacktrace(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + stacktrace = _parse_stacktrace(d.pop("stacktrace")) + + def _parse_script(data: object) -> Union["ScriptResponse", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + script_type_0 = ScriptResponse.from_dict(data) + + return script_type_0 + except: # noqa: E722 + pass + return cast(Union["ScriptResponse", None], data) + + script = _parse_script(d.pop("script")) + + def _parse_runner_image(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + runner_image = _parse_runner_image(d.pop("runner_image")) + + def _parse_type_(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + type_ = _parse_type_(d.pop("type")) + + def _parse_run(data: object) -> Union["RunResponse", None]: + if data is None: + return data + try: + if not isinstance(data, dict): + raise TypeError() + run_type_0 = RunResponse.from_dict(data) + + return run_type_0 + except: # noqa: E722 + pass + return cast(Union["RunResponse", None], data) + + run = _parse_run(d.pop("run")) + + job_with_run_response = cls( + id=id, + start=start, + end=end, + state=state, + status_message=status_message, + inputs=inputs, + outputs=outputs, + stacktrace=stacktrace, + script=script, + runner_image=runner_image, + type_=type_, + run=run, + ) + + job_with_run_response.additional_properties = d + return job_with_run_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/partial_job_update_request.py b/fia-api-client/fia_api_client/models/partial_job_update_request.py new file mode 100644 index 00000000..a6878bc7 --- /dev/null +++ b/fia-api-client/fia_api_client/models/partial_job_update_request.py @@ -0,0 +1,183 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.state import State +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PartialJobUpdateRequest") + + +@_attrs_define +class PartialJobUpdateRequest: + """Partial Job Update Request encompasses all the safely updatable fields on a Job + + Attributes: + state (Union[None, State, Unset]): + status_message (Union[None, Unset, str]): + outputs (Union[None, Unset, str]): + start (Union[None, Unset, str]): + stacktrace (Union[None, Unset, str]): + end (Union[None, Unset, str]): + """ + + state: Union[None, State, Unset] = UNSET + status_message: Union[None, Unset, str] = UNSET + outputs: Union[None, Unset, str] = UNSET + start: Union[None, Unset, str] = UNSET + stacktrace: Union[None, Unset, str] = UNSET + end: Union[None, Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + state: Union[None, Unset, str] + if isinstance(self.state, Unset): + state = UNSET + elif isinstance(self.state, State): + state = self.state.value + else: + state = self.state + + status_message: Union[None, Unset, str] + if isinstance(self.status_message, Unset): + status_message = UNSET + else: + status_message = self.status_message + + outputs: Union[None, Unset, str] + if isinstance(self.outputs, Unset): + outputs = UNSET + else: + outputs = self.outputs + + start: Union[None, Unset, str] + if isinstance(self.start, Unset): + start = UNSET + else: + start = self.start + + stacktrace: Union[None, Unset, str] + if isinstance(self.stacktrace, Unset): + stacktrace = UNSET + else: + stacktrace = self.stacktrace + + end: Union[None, Unset, str] + if isinstance(self.end, Unset): + end = UNSET + else: + end = self.end + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if state is not UNSET: + field_dict["state"] = state + if status_message is not UNSET: + field_dict["status_message"] = status_message + if outputs is not UNSET: + field_dict["outputs"] = outputs + if start is not UNSET: + field_dict["start"] = start + if stacktrace is not UNSET: + field_dict["stacktrace"] = stacktrace + if end is not UNSET: + field_dict["end"] = end + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + + def _parse_state(data: object) -> Union[None, State, Unset]: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, str): + raise TypeError() + state_type_0 = State(data) + + return state_type_0 + except: # noqa: E722 + pass + return cast(Union[None, State, Unset], data) + + state = _parse_state(d.pop("state", UNSET)) + + def _parse_status_message(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + status_message = _parse_status_message(d.pop("status_message", UNSET)) + + def _parse_outputs(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + outputs = _parse_outputs(d.pop("outputs", UNSET)) + + def _parse_start(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + start = _parse_start(d.pop("start", UNSET)) + + def _parse_stacktrace(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + stacktrace = _parse_stacktrace(d.pop("stacktrace", UNSET)) + + def _parse_end(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + end = _parse_end(d.pop("end", UNSET)) + + partial_job_update_request = cls( + state=state, + status_message=status_message, + outputs=outputs, + start=start, + stacktrace=stacktrace, + end=end, + ) + + partial_job_update_request.additional_properties = d + return partial_job_update_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/rerun_job.py b/fia-api-client/fia_api_client/models/rerun_job.py new file mode 100644 index 00000000..81560517 --- /dev/null +++ b/fia-api-client/fia_api_client/models/rerun_job.py @@ -0,0 +1,75 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RerunJob") + + +@_attrs_define +class RerunJob: + """ + Attributes: + job_id (int): + runner_image (str): + script (str): + """ + + job_id: int + runner_image: str + script: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + job_id = self.job_id + + runner_image = self.runner_image + + script = self.script + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "job_id": job_id, + "runner_image": runner_image, + "script": script, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + job_id = d.pop("job_id") + + runner_image = d.pop("runner_image") + + script = d.pop("script") + + rerun_job = cls( + job_id=job_id, + runner_image=runner_image, + script=script, + ) + + rerun_job.additional_properties = d + return rerun_job + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/run_response.py b/fia-api-client/fia_api_client/models/run_response.py new file mode 100644 index 00000000..90ed3a78 --- /dev/null +++ b/fia-api-client/fia_api_client/models/run_response.py @@ -0,0 +1,132 @@ +import datetime +from collections.abc import Mapping +from typing import Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +T = TypeVar("T", bound="RunResponse") + + +@_attrs_define +class RunResponse: + """Run Response object + + Attributes: + filename (str): + experiment_number (Union[None, int]): + title (str): + users (str): + run_start (datetime.datetime): + run_end (datetime.datetime): + good_frames (int): + raw_frames (int): + instrument_name (str): + """ + + filename: str + experiment_number: Union[None, int] + title: str + users: str + run_start: datetime.datetime + run_end: datetime.datetime + good_frames: int + raw_frames: int + instrument_name: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + filename = self.filename + + experiment_number: Union[None, int] + experiment_number = self.experiment_number + + title = self.title + + users = self.users + + run_start = self.run_start.isoformat() + + run_end = self.run_end.isoformat() + + good_frames = self.good_frames + + raw_frames = self.raw_frames + + instrument_name = self.instrument_name + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "filename": filename, + "experiment_number": experiment_number, + "title": title, + "users": users, + "run_start": run_start, + "run_end": run_end, + "good_frames": good_frames, + "raw_frames": raw_frames, + "instrument_name": instrument_name, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + filename = d.pop("filename") + + def _parse_experiment_number(data: object) -> Union[None, int]: + if data is None: + return data + return cast(Union[None, int], data) + + experiment_number = _parse_experiment_number(d.pop("experiment_number")) + + title = d.pop("title") + + users = d.pop("users") + + run_start = isoparse(d.pop("run_start")) + + run_end = isoparse(d.pop("run_end")) + + good_frames = d.pop("good_frames") + + raw_frames = d.pop("raw_frames") + + instrument_name = d.pop("instrument_name") + + run_response = cls( + filename=filename, + experiment_number=experiment_number, + title=title, + users=users, + run_start=run_start, + run_end=run_end, + good_frames=good_frames, + raw_frames=raw_frames, + instrument_name=instrument_name, + ) + + run_response.additional_properties = d + return run_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/script_response.py b/fia-api-client/fia_api_client/models/script_response.py new file mode 100644 index 00000000..110a186c --- /dev/null +++ b/fia-api-client/fia_api_client/models/script_response.py @@ -0,0 +1,60 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ScriptResponse") + + +@_attrs_define +class ScriptResponse: + """ScriptResponse returns from the API a script value + + Attributes: + value (str): + """ + + value: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + value = self.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "value": value, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + value = d.pop("value") + + script_response = cls( + value=value, + ) + + script_response.additional_properties = d + return script_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/simple_job.py b/fia-api-client/fia_api_client/models/simple_job.py new file mode 100644 index 00000000..9d53e9d4 --- /dev/null +++ b/fia-api-client/fia_api_client/models/simple_job.py @@ -0,0 +1,67 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="SimpleJob") + + +@_attrs_define +class SimpleJob: + """ + Attributes: + runner_image (str): + script (str): + """ + + runner_image: str + script: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + runner_image = self.runner_image + + script = self.script + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "runner_image": runner_image, + "script": script, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + runner_image = d.pop("runner_image") + + script = d.pop("script") + + simple_job = cls( + runner_image=runner_image, + script=script, + ) + + simple_job.additional_properties = d + return simple_job + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/state.py b/fia-api-client/fia_api_client/models/state.py new file mode 100644 index 00000000..782daade --- /dev/null +++ b/fia-api-client/fia_api_client/models/state.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class State(str, Enum): + ERROR = "ERROR" + NOT_STARTED = "NOT_STARTED" + SUCCESSFUL = "SUCCESSFUL" + UNSUCCESSFUL = "UNSUCCESSFUL" + + def __str__(self) -> str: + return str(self.value) diff --git a/fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put.py b/fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put.py new file mode 100644 index 00000000..e4b4924d --- /dev/null +++ b/fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put.py @@ -0,0 +1,47 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar( + "T", + bound="UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut", +) + + +@_attrs_define +class UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put = cls() + + update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put.additional_properties = d + return update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_specification.py b/fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_specification.py new file mode 100644 index 00000000..828834c4 --- /dev/null +++ b/fia-api-client/fia_api_client/models/update_instrument_specification_instrument_instrument_name_specification_put_specification.py @@ -0,0 +1,44 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification") + + +@_attrs_define +class UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + update_instrument_specification_instrument_instrument_name_specification_put_specification = cls() + + update_instrument_specification_instrument_instrument_name_specification_put_specification.additional_properties = d + return update_instrument_specification_instrument_instrument_name_specification_put_specification + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/upload_file_to_instrument_folder_extras_instrument_filename_post_instrument.py b/fia-api-client/fia_api_client/models/upload_file_to_instrument_folder_extras_instrument_filename_post_instrument.py new file mode 100644 index 00000000..a25fe1e1 --- /dev/null +++ b/fia-api-client/fia_api_client/models/upload_file_to_instrument_folder_extras_instrument_filename_post_instrument.py @@ -0,0 +1,43 @@ +from enum import Enum + + +class UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument(str, Enum): + ALF = "alf" + ARGUS = "argus" + CHIPIR = "chipir" + CHRONUS = "chronus" + CRISP = "crisp" + EMU = "emu" + ENGINX = "enginx" + GEM = "gem" + HIFI = "hifi" + HRPD = "hrpd" + IMAT = "imat" + INES = "ines" + INTER = "inter" + IRIS = "iris" + LARMOR = "larmor" + LET = "let" + LOQ = "loq" + MAPS = "maps" + MARI = "mari" + MERLIN = "merlin" + MUSR = "musr" + NIMROD = "nimrod" + OFFSPEC = "offspec" + OSIRIS = "osiris" + PEARL = "pearl" + POLARIS = "polaris" + POLREF = "polref" + SANDALS = "sandals" + SANS2D = "sans2d" + SURF = "surf" + SXD = "sxd" + TEST = "test" + TOSCA = "tosca" + VESUVIO = "vesuvio" + WISH = "wish" + ZOOM = "zoom" + + def __str__(self) -> str: + return str(self.value) diff --git a/fia-api-client/fia_api_client/models/validation_error.py b/fia-api-client/fia_api_client/models/validation_error.py new file mode 100644 index 00000000..e2988333 --- /dev/null +++ b/fia-api-client/fia_api_client/models/validation_error.py @@ -0,0 +1,88 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ValidationError") + + +@_attrs_define +class ValidationError: + """ + Attributes: + loc (list[Union[int, str]]): + msg (str): + type_ (str): + """ + + loc: list[Union[int, str]] + msg: str + type_: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + loc = [] + for loc_item_data in self.loc: + loc_item: Union[int, str] + loc_item = loc_item_data + loc.append(loc_item) + + msg = self.msg + + type_ = self.type_ + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "loc": loc, + "msg": msg, + "type": type_, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + loc = [] + _loc = d.pop("loc") + for loc_item_data in _loc: + + def _parse_loc_item(data: object) -> Union[int, str]: + return cast(Union[int, str], data) + + loc_item = _parse_loc_item(loc_item_data) + + loc.append(loc_item) + + msg = d.pop("msg") + + type_ = d.pop("type") + + validation_error = cls( + loc=loc, + msg=msg, + type_=type_, + ) + + validation_error.additional_properties = d + return validation_error + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/py.typed b/fia-api-client/fia_api_client/py.typed new file mode 100644 index 00000000..1aad3271 --- /dev/null +++ b/fia-api-client/fia_api_client/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/fia-api-client/fia_api_client/types.py b/fia-api-client/fia_api_client/types.py new file mode 100644 index 00000000..1b96ca40 --- /dev/null +++ b/fia-api-client/fia_api_client/types.py @@ -0,0 +1,54 @@ +"""Contains some shared types for properties""" + +from collections.abc import Mapping, MutableMapping +from http import HTTPStatus +from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +# The types that `httpx.Client(files=)` can accept, copied from that library. +FileContent = Union[IO[bytes], bytes, str] +FileTypes = Union[ + # (filename, file (or bytes), content_type) + tuple[Optional[str], FileContent, Optional[str]], + # (filename, file (or bytes), content_type, headers) + tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], +] +RequestFiles = list[tuple[str, FileTypes]] + + +@define +class File: + """Contains information for file uploads""" + + payload: BinaryIO + file_name: Optional[str] = None + mime_type: Optional[str] = None + + def to_tuple(self) -> FileTypes: + """Return a tuple representation that httpx will accept for multipart/form-data""" + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """A response from an endpoint""" + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: Optional[T] + + +__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"] diff --git a/fia-api-client/pyproject.toml b/fia-api-client/pyproject.toml new file mode 100644 index 00000000..6f7c8ca9 --- /dev/null +++ b/fia-api-client/pyproject.toml @@ -0,0 +1,27 @@ +[tool.poetry] +name = "fia-api-client" +version = "0.1.0" +description = "A client library for accessing FIA API" +authors = [] +readme = "README.md" +packages = [ + {include = "fia_api_client"}, +] +include = ["CHANGELOG.md", "fia_api_client/py.typed"] + + +[tool.poetry.dependencies] +python = "^3.9" +httpx = ">=0.23.0,<0.29.0" +attrs = ">=22.2.0" +python-dateutil = "^2.8.0" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.ruff] +line-length = 120 + +[tool.ruff.lint] +select = ["F", "I", "UP"] From 16b4b580245d1b890e1e9ddb263d00c0fa54aa4e Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Fri, 6 Jun 2025 11:43:16 +0100 Subject: [PATCH 05/13] Rename jobs --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8b13035c..52889f51 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ permissions: packages: read jobs: - pytest: + Unit Tests: runs-on: ubuntu-latest steps: - name: Checkout project @@ -38,7 +38,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} - integration: + Integration Tests: runs-on: ubuntu-latest services: From 98c848d729b5d53afd5c288bcc21db371343b708 Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Fri, 6 Jun 2025 11:47:59 +0100 Subject: [PATCH 06/13] overwrite existing client --- .github/workflows/generate-client.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-client.yml b/.github/workflows/generate-client.yml index 8188a6c2..0e966952 100644 --- a/.github/workflows/generate-client.yml +++ b/.github/workflows/generate-client.yml @@ -54,7 +54,7 @@ jobs: - name: Generate client code run: | - openapi-python-client generate --url http://localhost:8000/openapi.json + openapi-python-client generate --url http://localhost:8000/openapi.json --overwrite - name: Commit changes From 685582c27359c4209e4a71ee4b5f224e2f83491e Mon Sep 17 00:00:00 2001 From: esmith1729 Date: Tue, 2 Sep 2025 14:33:54 +0100 Subject: [PATCH 07/13] simple test for autogenerated client and github action --- .github/workflows/test-generated-client.yml | 54 +++++++++++++++++++++ test/core/test_autogenerated_client.py | 34 +++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/workflows/test-generated-client.yml create mode 100644 test/core/test_autogenerated_client.py diff --git a/.github/workflows/test-generated-client.yml b/.github/workflows/test-generated-client.yml new file mode 100644 index 00000000..a2df5964 --- /dev/null +++ b/.github/workflows/test-generated-client.yml @@ -0,0 +1,54 @@ +--- +name: Run Tests on Autogenerated Client +on: push + +permissions: + contents: read + packages: read + +jobs: + unit-tests: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:14.7 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: fia + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Checkout project + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3.5.0 + + - name: Set up python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v4.5.0 + with: + python-version: "3.12" + + - name: Set up cache for Python dependencies + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies. + run: | + python -m pip install --upgrade pip + python -m pip install .[test] + + - name: Run pytest + env: + DATABASE_URL: postgresql://postgres:password@localhost:5432/test_db + GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: pytest test/core/test_autogenerated_client.py + + - name: Upload coverage + uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/test/core/test_autogenerated_client.py b/test/core/test_autogenerated_client.py new file mode 100644 index 00000000..6bc25df5 --- /dev/null +++ b/test/core/test_autogenerated_client.py @@ -0,0 +1,34 @@ +"""testing autogenerated client""" + +from http import HTTPStatus + +import pytest +from starlette.testclient import TestClient + +from fia_api.fia_api import app +from test.utils import setup_database + +client = TestClient(app) +setup = False + +@pytest.fixture(autouse=True) +def _setup(faker): + """ + Setup database pre-testing + :return: + """ + # We require this horrible global setup as faker is a function scoped fixture and not a session scoped + global setup # noqa: PLW0603 + if not setup: + setup_database(faker) + setup = True + + +def test_jobs_count(): + """ + Test count endpoint for all jobs + :return: + """ + response = client.get("/jobs/count") + assert response.status_code == HTTPStatus.OK + assert response.json()["count"] == 5001 # noqa: PLR2004 From 9a68a349e18dc255e77501ff163494d35628b5c2 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 2 Sep 2025 14:09:28 +0000 Subject: [PATCH 08/13] Formatting and linting commit --- test/core/test_autogenerated_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/core/test_autogenerated_client.py b/test/core/test_autogenerated_client.py index 6bc25df5..5f615384 100644 --- a/test/core/test_autogenerated_client.py +++ b/test/core/test_autogenerated_client.py @@ -11,6 +11,7 @@ client = TestClient(app) setup = False + @pytest.fixture(autouse=True) def _setup(faker): """ From 2757a6c45a0b0dc849a0d23f39bac3af6480bb32 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 2 Sep 2025 14:25:23 +0000 Subject: [PATCH 09/13] Update API client based on latest OpenAPI schema --- .../fia_api_client/api/instrument/__init__.py | 1 + ...un_instrument_instrument_latest_run_get.py | 197 ++++++++++++++++ ...un_instrument_instrument_latest_run_put.py | 221 ++++++++++++++++++ .../download_zip_job_download_zip_post.py | 170 ++++++++++++++ .../fia_api_client/api/live_data/__init__.py | 1 + ..._script_live_data_instrument_script_get.py | 164 +++++++++++++ ..._script_live_data_instrument_script_put.py | 188 +++++++++++++++ .../fia_api_client/models/__init__.py | 24 ++ ...oad_zip_job_download_zip_post_job_files.py | 51 ++++ ...un_instrument_instrument_latest_run_get.py | 60 +++++ ...e_data_instrument_script_get_instrument.py | 43 ++++ .../models/live_data_script_update_request.py | 60 +++++ ...nt_instrument_latest_run_put_latest_run.py | 44 ++++ ...un_instrument_instrument_latest_run_put.py | 47 ++++ ...e_data_instrument_script_put_instrument.py | 43 ++++ 15 files changed, 1314 insertions(+) create mode 100644 fia-api-client/fia_api_client/api/instrument/__init__.py create mode 100644 fia-api-client/fia_api_client/api/instrument/get_instrument_latest_run_instrument_instrument_latest_run_get.py create mode 100644 fia-api-client/fia_api_client/api/instrument/update_instrument_latest_run_instrument_instrument_latest_run_put.py create mode 100644 fia-api-client/fia_api_client/api/jobs/download_zip_job_download_zip_post.py create mode 100644 fia-api-client/fia_api_client/api/live_data/__init__.py create mode 100644 fia-api-client/fia_api_client/api/live_data/get_instrument_script_live_data_instrument_script_get.py create mode 100644 fia-api-client/fia_api_client/api/live_data/update_instrument_script_live_data_instrument_script_put.py create mode 100644 fia-api-client/fia_api_client/models/download_zip_job_download_zip_post_job_files.py create mode 100644 fia-api-client/fia_api_client/models/get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get.py create mode 100644 fia-api-client/fia_api_client/models/get_instrument_script_live_data_instrument_script_get_instrument.py create mode 100644 fia-api-client/fia_api_client/models/live_data_script_update_request.py create mode 100644 fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run.py create mode 100644 fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put.py create mode 100644 fia-api-client/fia_api_client/models/update_instrument_script_live_data_instrument_script_put_instrument.py diff --git a/fia-api-client/fia_api_client/api/instrument/__init__.py b/fia-api-client/fia_api_client/api/instrument/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/fia-api-client/fia_api_client/api/instrument/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/instrument/get_instrument_latest_run_instrument_instrument_latest_run_get.py b/fia-api-client/fia_api_client/api/instrument/get_instrument_latest_run_instrument_instrument_latest_run_get.py new file mode 100644 index 00000000..7561e909 --- /dev/null +++ b/fia-api-client/fia_api_client/api/instrument/get_instrument_latest_run_instrument_instrument_latest_run_get.py @@ -0,0 +1,197 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get import ( + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, +) +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + instrument: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/instrument/{instrument}/latest-run", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ + Union[ + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, + HTTPValidationError, + ] +]: + if response.status_code == 200: + response_200 = GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet.from_dict( + response.json() + ) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ + Union[ + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, + HTTPValidationError, + ] +]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: str, + *, + client: AuthenticatedClient, +) -> Response[ + Union[ + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, + HTTPValidationError, + ] +]: + """Get Instrument Latest Run + + Return the latest run for the given instrument + + Args: + instrument (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: str, + *, + client: AuthenticatedClient, +) -> Optional[ + Union[ + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, + HTTPValidationError, + ] +]: + """Get Instrument Latest Run + + Return the latest run for the given instrument + + Args: + instrument (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, HTTPValidationError] + """ + + return sync_detailed( + instrument=instrument, + client=client, + ).parsed + + +async def asyncio_detailed( + instrument: str, + *, + client: AuthenticatedClient, +) -> Response[ + Union[ + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, + HTTPValidationError, + ] +]: + """Get Instrument Latest Run + + Return the latest run for the given instrument + + Args: + instrument (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: str, + *, + client: AuthenticatedClient, +) -> Optional[ + Union[ + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, + HTTPValidationError, + ] +]: + """Get Instrument Latest Run + + Return the latest run for the given instrument + + Args: + instrument (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/instrument/update_instrument_latest_run_instrument_instrument_latest_run_put.py b/fia-api-client/fia_api_client/api/instrument/update_instrument_latest_run_instrument_instrument_latest_run_put.py new file mode 100644 index 00000000..5b6be99d --- /dev/null +++ b/fia-api-client/fia_api_client/api/instrument/update_instrument_latest_run_instrument_instrument_latest_run_put.py @@ -0,0 +1,221 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...models.update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run import ( + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun, +) +from ...models.update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put import ( + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, +) +from ...types import Response + + +def _get_kwargs( + instrument: str, + *, + body: UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": f"/instrument/{instrument}/latest-run", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ + Union[ + HTTPValidationError, + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, + ] +]: + if response.status_code == 200: + response_200 = UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut.from_dict( + response.json() + ) + + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ + Union[ + HTTPValidationError, + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, + ] +]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun, +) -> Response[ + Union[ + HTTPValidationError, + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, + ] +]: + """Update Instrument Latest Run + + Update the latest run for the given instrument + + Args: + instrument (str): + body (UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun, +) -> Optional[ + Union[ + HTTPValidationError, + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, + ] +]: + """Update Instrument Latest Run + + Update the latest run for the given instrument + + Args: + instrument (str): + body (UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut] + """ + + return sync_detailed( + instrument=instrument, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + instrument: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun, +) -> Response[ + Union[ + HTTPValidationError, + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, + ] +]: + """Update Instrument Latest Run + + Update the latest run for the given instrument + + Args: + instrument (str): + body (UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: str, + *, + client: AuthenticatedClient, + body: UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun, +) -> Optional[ + Union[ + HTTPValidationError, + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, + ] +]: + """Update Instrument Latest Run + + Update the latest run for the given instrument + + Args: + instrument (str): + body (UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/jobs/download_zip_job_download_zip_post.py b/fia-api-client/fia_api_client/api/jobs/download_zip_job_download_zip_post.py new file mode 100644 index 00000000..b1969684 --- /dev/null +++ b/fia-api-client/fia_api_client/api/jobs/download_zip_job_download_zip_post.py @@ -0,0 +1,170 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.download_zip_job_download_zip_post_job_files import DownloadZipJobDownloadZipPostJobFiles +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + *, + body: DownloadZipJobDownloadZipPostJobFiles, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/job/download-zip", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, HTTPValidationError]]: + if response.status_code == 200: + response_200 = response.json() + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, HTTPValidationError]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient, + body: DownloadZipJobDownloadZipPostJobFiles, +) -> Response[Union[Any, HTTPValidationError]]: + """Download Zip + + Zips and returns a set of files given job IDs and filenames. + + Args: + body (DownloadZipJobDownloadZipPostJobFiles): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + body: DownloadZipJobDownloadZipPostJobFiles, +) -> Optional[Union[Any, HTTPValidationError]]: + """Download Zip + + Zips and returns a set of files given job IDs and filenames. + + Args: + body (DownloadZipJobDownloadZipPostJobFiles): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + body: DownloadZipJobDownloadZipPostJobFiles, +) -> Response[Union[Any, HTTPValidationError]]: + """Download Zip + + Zips and returns a set of files given job IDs and filenames. + + Args: + body (DownloadZipJobDownloadZipPostJobFiles): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, HTTPValidationError]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + body: DownloadZipJobDownloadZipPostJobFiles, +) -> Optional[Union[Any, HTTPValidationError]]: + """Download Zip + + Zips and returns a set of files given job IDs and filenames. + + Args: + body (DownloadZipJobDownloadZipPostJobFiles): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, HTTPValidationError] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/live_data/__init__.py b/fia-api-client/fia_api_client/api/live_data/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/fia-api-client/fia_api_client/api/live_data/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/fia-api-client/fia_api_client/api/live_data/get_instrument_script_live_data_instrument_script_get.py b/fia-api-client/fia_api_client/api/live_data/get_instrument_script_live_data_instrument_script_get.py new file mode 100644 index 00000000..8daf727c --- /dev/null +++ b/fia-api-client/fia_api_client/api/live_data/get_instrument_script_live_data_instrument_script_get.py @@ -0,0 +1,164 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_instrument_script_live_data_instrument_script_get_instrument import ( + GetInstrumentScriptLiveDataInstrumentScriptGetInstrument, +) +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + instrument: GetInstrumentScriptLiveDataInstrumentScriptGetInstrument, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/live-data/{instrument}/script", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, str]]: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: GetInstrumentScriptLiveDataInstrumentScriptGetInstrument, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[HTTPValidationError, str]]: + """Get Instrument Script + + Given an instrument string, return the live data script for that instrument + + Args: + instrument (GetInstrumentScriptLiveDataInstrumentScriptGetInstrument): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: GetInstrumentScriptLiveDataInstrumentScriptGetInstrument, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[HTTPValidationError, str]]: + """Get Instrument Script + + Given an instrument string, return the live data script for that instrument + + Args: + instrument (GetInstrumentScriptLiveDataInstrumentScriptGetInstrument): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return sync_detailed( + instrument=instrument, + client=client, + ).parsed + + +async def asyncio_detailed( + instrument: GetInstrumentScriptLiveDataInstrumentScriptGetInstrument, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[HTTPValidationError, str]]: + """Get Instrument Script + + Given an instrument string, return the live data script for that instrument + + Args: + instrument (GetInstrumentScriptLiveDataInstrumentScriptGetInstrument): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, str]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: GetInstrumentScriptLiveDataInstrumentScriptGetInstrument, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[HTTPValidationError, str]]: + """Get Instrument Script + + Given an instrument string, return the live data script for that instrument + + Args: + instrument (GetInstrumentScriptLiveDataInstrumentScriptGetInstrument): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, str] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + client=client, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/api/live_data/update_instrument_script_live_data_instrument_script_put.py b/fia-api-client/fia_api_client/api/live_data/update_instrument_script_live_data_instrument_script_put.py new file mode 100644 index 00000000..8dfb4279 --- /dev/null +++ b/fia-api-client/fia_api_client/api/live_data/update_instrument_script_live_data_instrument_script_put.py @@ -0,0 +1,188 @@ +from http import HTTPStatus +from typing import Any, Literal, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.http_validation_error import HTTPValidationError +from ...models.live_data_script_update_request import LiveDataScriptUpdateRequest +from ...models.update_instrument_script_live_data_instrument_script_put_instrument import ( + UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument, +) +from ...types import Response + + +def _get_kwargs( + instrument: UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument, + *, + body: LiveDataScriptUpdateRequest, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": f"/live-data/{instrument}/script", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[HTTPValidationError, Literal["ok"]]]: + if response.status_code == 200: + response_200 = cast(Literal["ok"], response.json()) + if response_200 != "ok": + raise ValueError(f"response_200 must match const 'ok', got '{response_200}'") + return response_200 + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[HTTPValidationError, Literal["ok"]]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + instrument: UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument, + *, + client: AuthenticatedClient, + body: LiveDataScriptUpdateRequest, +) -> Response[Union[HTTPValidationError, Literal["ok"]]]: + """Update Instrument Script + + Given an instrument string and a script request, update the live data script for that instrument + + Args: + instrument (UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument): + body (LiveDataScriptUpdateRequest): Script Update Request for live data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, Literal['ok']]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + instrument: UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument, + *, + client: AuthenticatedClient, + body: LiveDataScriptUpdateRequest, +) -> Optional[Union[HTTPValidationError, Literal["ok"]]]: + """Update Instrument Script + + Given an instrument string and a script request, update the live data script for that instrument + + Args: + instrument (UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument): + body (LiveDataScriptUpdateRequest): Script Update Request for live data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, Literal['ok']] + """ + + return sync_detailed( + instrument=instrument, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + instrument: UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument, + *, + client: AuthenticatedClient, + body: LiveDataScriptUpdateRequest, +) -> Response[Union[HTTPValidationError, Literal["ok"]]]: + """Update Instrument Script + + Given an instrument string and a script request, update the live data script for that instrument + + Args: + instrument (UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument): + body (LiveDataScriptUpdateRequest): Script Update Request for live data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[HTTPValidationError, Literal['ok']]] + """ + + kwargs = _get_kwargs( + instrument=instrument, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + instrument: UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument, + *, + client: AuthenticatedClient, + body: LiveDataScriptUpdateRequest, +) -> Optional[Union[HTTPValidationError, Literal["ok"]]]: + """Update Instrument Script + + Given an instrument string and a script request, update the live data script for that instrument + + Args: + instrument (UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument): + body (LiveDataScriptUpdateRequest): Script Update Request for live data + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[HTTPValidationError, Literal['ok']] + """ + + return ( + await asyncio_detailed( + instrument=instrument, + client=client, + body=body, + ) + ).parsed diff --git a/fia-api-client/fia_api_client/models/__init__.py b/fia-api-client/fia_api_client/models/__init__.py index 0323a776..b5bc132f 100644 --- a/fia-api-client/fia_api_client/models/__init__.py +++ b/fia-api-client/fia_api_client/models/__init__.py @@ -7,6 +7,13 @@ BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost, ) from .count_response import CountResponse +from .download_zip_job_download_zip_post_job_files import DownloadZipJobDownloadZipPostJobFiles +from .get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get import ( + GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet, +) +from .get_instrument_script_live_data_instrument_script_get_instrument import ( + GetInstrumentScriptLiveDataInstrumentScriptGetInstrument, +) from .get_jobs_by_instrument_instrument_instrument_jobs_get_order_by import ( GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy, ) @@ -18,12 +25,22 @@ from .http_validation_error import HTTPValidationError from .job_response import JobResponse from .job_with_run_response import JobWithRunResponse +from .live_data_script_update_request import LiveDataScriptUpdateRequest from .partial_job_update_request import PartialJobUpdateRequest from .rerun_job import RerunJob from .run_response import RunResponse from .script_response import ScriptResponse from .simple_job import SimpleJob from .state import State +from .update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run import ( + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun, +) +from .update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put import ( + UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut, +) +from .update_instrument_script_live_data_instrument_script_put_instrument import ( + UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument, +) from .update_instrument_specification_instrument_instrument_name_specification_put_response_update_instrument_specification_instrument_instrument_name_specification_put import ( UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut, ) @@ -41,6 +58,9 @@ "AutoreductionResponse", "BodyUploadFileToInstrumentFolderExtrasInstrumentFilenamePost", "CountResponse", + "DownloadZipJobDownloadZipPostJobFiles", + "GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet", + "GetInstrumentScriptLiveDataInstrumentScriptGetInstrument", "GetJobsByInstrumentInstrumentInstrumentJobsGetOrderBy", "GetJobsByInstrumentInstrumentInstrumentJobsGetOrderDirection", "GetJobsJobsGetOrderBy", @@ -48,12 +68,16 @@ "HTTPValidationError", "JobResponse", "JobWithRunResponse", + "LiveDataScriptUpdateRequest", "PartialJobUpdateRequest", "RerunJob", "RunResponse", "ScriptResponse", "SimpleJob", "State", + "UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun", + "UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut", + "UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument", "UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutResponseUpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPut", "UpdateInstrumentSpecificationInstrumentInstrumentNameSpecificationPutSpecification", "UploadFileToInstrumentFolderExtrasInstrumentFilenamePostInstrument", diff --git a/fia-api-client/fia_api_client/models/download_zip_job_download_zip_post_job_files.py b/fia-api-client/fia_api_client/models/download_zip_job_download_zip_post_job_files.py new file mode 100644 index 00000000..13938dd3 --- /dev/null +++ b/fia-api-client/fia_api_client/models/download_zip_job_download_zip_post_job_files.py @@ -0,0 +1,51 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="DownloadZipJobDownloadZipPostJobFiles") + + +@_attrs_define +class DownloadZipJobDownloadZipPostJobFiles: + """ """ + + additional_properties: dict[str, list[str]] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + download_zip_job_download_zip_post_job_files = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = cast(list[str], prop_dict) + + additional_properties[prop_name] = additional_property + + download_zip_job_download_zip_post_job_files.additional_properties = additional_properties + return download_zip_job_download_zip_post_job_files + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> list[str]: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: list[str]) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get.py b/fia-api-client/fia_api_client/models/get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get.py new file mode 100644 index 00000000..1930ffb8 --- /dev/null +++ b/fia-api-client/fia_api_client/models/get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get.py @@ -0,0 +1,60 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, Union, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar( + "T", + bound="GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet", +) + + +@_attrs_define +class GetInstrumentLatestRunInstrumentInstrumentLatestRunGetResponseGetInstrumentLatestRunInstrumentInstrumentLatestRunGet: + """ """ + + additional_properties: dict[str, Union[None, str]] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = prop + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + + def _parse_additional_property(data: object) -> Union[None, str]: + if data is None: + return data + return cast(Union[None, str], data) + + additional_property = _parse_additional_property(prop_dict) + + additional_properties[prop_name] = additional_property + + get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get.additional_properties = additional_properties + return get_instrument_latest_run_instrument_instrument_latest_run_get_response_get_instrument_latest_run_instrument_instrument_latest_run_get + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Union[None, str]: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Union[None, str]) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/get_instrument_script_live_data_instrument_script_get_instrument.py b/fia-api-client/fia_api_client/models/get_instrument_script_live_data_instrument_script_get_instrument.py new file mode 100644 index 00000000..8caa8c05 --- /dev/null +++ b/fia-api-client/fia_api_client/models/get_instrument_script_live_data_instrument_script_get_instrument.py @@ -0,0 +1,43 @@ +from enum import Enum + + +class GetInstrumentScriptLiveDataInstrumentScriptGetInstrument(str, Enum): + ALF = "alf" + ARGUS = "argus" + CHIPIR = "chipir" + CHRONUS = "chronus" + CRISP = "crisp" + EMU = "emu" + ENGINX = "enginx" + GEM = "gem" + HIFI = "hifi" + HRPD = "hrpd" + IMAT = "imat" + INES = "ines" + INTER = "inter" + IRIS = "iris" + LARMOR = "larmor" + LET = "let" + LOQ = "loq" + MAPS = "maps" + MARI = "mari" + MERLIN = "merlin" + MUSR = "musr" + NIMROD = "nimrod" + OFFSPEC = "offspec" + OSIRIS = "osiris" + PEARL = "pearl" + POLARIS = "polaris" + POLREF = "polref" + SANDALS = "sandals" + SANS2D = "sans2d" + SURF = "surf" + SXD = "sxd" + TEST = "test" + TOSCA = "tosca" + VESUVIO = "vesuvio" + WISH = "wish" + ZOOM = "zoom" + + def __str__(self) -> str: + return str(self.value) diff --git a/fia-api-client/fia_api_client/models/live_data_script_update_request.py b/fia-api-client/fia_api_client/models/live_data_script_update_request.py new file mode 100644 index 00000000..04b1bb44 --- /dev/null +++ b/fia-api-client/fia_api_client/models/live_data_script_update_request.py @@ -0,0 +1,60 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="LiveDataScriptUpdateRequest") + + +@_attrs_define +class LiveDataScriptUpdateRequest: + """Script Update Request for live data + + Attributes: + value (str): + """ + + value: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + value = self.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "value": value, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + value = d.pop("value") + + live_data_script_update_request = cls( + value=value, + ) + + live_data_script_update_request.additional_properties = d + return live_data_script_update_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run.py b/fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run.py new file mode 100644 index 00000000..2b42de7f --- /dev/null +++ b/fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run.py @@ -0,0 +1,44 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun") + + +@_attrs_define +class UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutLatestRun: + """ """ + + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run = cls() + + update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run.additional_properties = d + return update_instrument_latest_run_instrument_instrument_latest_run_put_latest_run + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> str: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: str) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put.py b/fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put.py new file mode 100644 index 00000000..fb0c8594 --- /dev/null +++ b/fia-api-client/fia_api_client/models/update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put.py @@ -0,0 +1,47 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar( + "T", + bound="UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut", +) + + +@_attrs_define +class UpdateInstrumentLatestRunInstrumentInstrumentLatestRunPutResponseUpdateInstrumentLatestRunInstrumentInstrumentLatestRunPut: + """ """ + + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put = cls() + + update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put.additional_properties = d + return update_instrument_latest_run_instrument_instrument_latest_run_put_response_update_instrument_latest_run_instrument_instrument_latest_run_put + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> str: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: str) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fia-api-client/fia_api_client/models/update_instrument_script_live_data_instrument_script_put_instrument.py b/fia-api-client/fia_api_client/models/update_instrument_script_live_data_instrument_script_put_instrument.py new file mode 100644 index 00000000..975f4faf --- /dev/null +++ b/fia-api-client/fia_api_client/models/update_instrument_script_live_data_instrument_script_put_instrument.py @@ -0,0 +1,43 @@ +from enum import Enum + + +class UpdateInstrumentScriptLiveDataInstrumentScriptPutInstrument(str, Enum): + ALF = "alf" + ARGUS = "argus" + CHIPIR = "chipir" + CHRONUS = "chronus" + CRISP = "crisp" + EMU = "emu" + ENGINX = "enginx" + GEM = "gem" + HIFI = "hifi" + HRPD = "hrpd" + IMAT = "imat" + INES = "ines" + INTER = "inter" + IRIS = "iris" + LARMOR = "larmor" + LET = "let" + LOQ = "loq" + MAPS = "maps" + MARI = "mari" + MERLIN = "merlin" + MUSR = "musr" + NIMROD = "nimrod" + OFFSPEC = "offspec" + OSIRIS = "osiris" + PEARL = "pearl" + POLARIS = "polaris" + POLREF = "polref" + SANDALS = "sandals" + SANS2D = "sans2d" + SURF = "surf" + SXD = "sxd" + TEST = "test" + TOSCA = "tosca" + VESUVIO = "vesuvio" + WISH = "wish" + ZOOM = "zoom" + + def __str__(self) -> str: + return str(self.value) From a80ea0028f60c51b2a5bdd1080ee93b9fb85c5b3 Mon Sep 17 00:00:00 2001 From: esmith1729 Date: Tue, 2 Sep 2025 15:26:42 +0100 Subject: [PATCH 10/13] Fix unit and integration test jobs name --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0232e0ae..f8a82e52 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ permissions: packages: read jobs: - Unit Tests: + Unit-Tests: runs-on: ubuntu-latest steps: - name: Checkout project @@ -38,7 +38,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} - Integration Tests: + Integration-Tests: runs-on: ubuntu-latest services: From f4b2649984e95ebf726fede0050952ed298551d0 Mon Sep 17 00:00:00 2001 From: esmith1729 Date: Tue, 2 Sep 2025 15:29:28 +0100 Subject: [PATCH 11/13] Add ignore to unit tests for autogenerated client test --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f8a82e52..95f99521 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: python -m pip install --upgrade pip python -m pip install .[test] - name: Run pytest - run: pytest . --random-order --random-order-bucket=global --ignore=test/e2e --ignore=test/core/test_repositories_integration.py --cov --cov-report=xml + run: pytest . --random-order --random-order-bucket=global --ignore=test/e2e --ignore=test/core/test_repositories_integration.py --ignore=test/core/test_autogenerated_client.py --cov --cov-report=xml - name: Upload coverage uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0 From b5e3a03a5abd52e742c8da032a671da7a0b467a1 Mon Sep 17 00:00:00 2001 From: esmith1729 Date: Thu, 4 Sep 2025 13:40:17 +0100 Subject: [PATCH 12/13] Add fia_api_client as submodule --- .gitmodules | 3 +++ fia_api_client | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 fia_api_client diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..797c6a0f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "fia_api_client"] + path = fia_api_client + url = https://github.com/fiaisis/fia_api_client.git diff --git a/fia_api_client b/fia_api_client new file mode 160000 index 00000000..fc60d8f0 --- /dev/null +++ b/fia_api_client @@ -0,0 +1 @@ +Subproject commit fc60d8f074333845fe076c7765b07284da54521c From be6ad1d1f39e27d65a8f7f7edd32c300af0db37e Mon Sep 17 00:00:00 2001 From: esmith1729 Date: Thu, 4 Sep 2025 14:20:00 +0100 Subject: [PATCH 13/13] change name of generated client repo; write GH Action to test generated client, write initial tests for generated client --- .github/workflows/generate-client.yml | 2 +- .github/workflows/test-generated-client.yml | 21 ++++++++++++++----- test/core/test_autogenerated_client.py | 23 +++++++++++++++++++-- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/generate-client.yml b/.github/workflows/generate-client.yml index 0e966952..2e322ddf 100644 --- a/.github/workflows/generate-client.yml +++ b/.github/workflows/generate-client.yml @@ -61,6 +61,6 @@ jobs: run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" - git add fia-api-client/ + git add fia_api_client/ git commit -m "Update API client based on latest OpenAPI schema" || echo "No changes to commit" git push diff --git a/.github/workflows/test-generated-client.yml b/.github/workflows/test-generated-client.yml index a2df5964..720cb966 100644 --- a/.github/workflows/test-generated-client.yml +++ b/.github/workflows/test-generated-client.yml @@ -41,14 +41,25 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install .[test] + + - name: Install client generation dependencies + run: | + python -m pip install ".[client-generation]" + + - name: Start FIA API in background + run: | + uvicorn fia_api.fia_api:app --host 0.0.0.0 --port 8000 & + # Wait for API to start + sleep 10 + + - name: Generate client code + run: | + openapi-python-client generate --url http://localhost:8000/openapi.json --overwrite - name: Run pytest env: DATABASE_URL: postgresql://postgres:password@localhost:5432/test_db GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: pytest test/core/test_autogenerated_client.py - - - name: Upload coverage - uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2 - with: - token: ${{ secrets.CODECOV_TOKEN }} + + diff --git a/test/core/test_autogenerated_client.py b/test/core/test_autogenerated_client.py index 5f615384..59725b42 100644 --- a/test/core/test_autogenerated_client.py +++ b/test/core/test_autogenerated_client.py @@ -6,12 +6,20 @@ from starlette.testclient import TestClient from fia_api.fia_api import app +from fia-api-client.fia_api_client import Client +from fia_api_client.api.healthz import get_healthz_get +from fia_api_client.models import MyDataModel +from fia_api_client.api.my_tag import get_my_data_model +from fia_api_client.types import Response from test.utils import setup_database -client = TestClient(app) -setup = False +start_fia_client = TestClient(app) +# create a client from the autogenerated code for the entire test session: +client = Client(base_url = "localhost:8000") +setup = False +# set up a database with phony data for each test, if it doesn't exist already @pytest.fixture(autouse=True) def _setup(faker): """ @@ -33,3 +41,14 @@ def test_jobs_count(): response = client.get("/jobs/count") assert response.status_code == HTTPStatus.OK assert response.json()["count"] == 5001 # noqa: PLR2004 + + +#We need some tests to ensure that autogenerated client code is getting data from FIA API properly + +async def test_client_get_healthz(): + # this is more or less straight from fia_api_client README + #data: MyDataModel = await get_my_data_model.asyncio(client=client) + #response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) + + response = await client.get("/healthz") + assert response.status_code == HTTPStatus.OK