From de53d1fc80df8d4d5a7dc1dd387b54099e14ea9e Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Mon, 7 Apr 2025 12:32:07 -0700 Subject: [PATCH 1/8] temp: api client --- src/codegen/api/clients/.gitignore | 66 ++ src/codegen/api/clients/.gitlab-ci.yml | 31 + .../api/clients/.openapi-generator-ignore | 23 + .../api/clients/.openapi-generator/FILES | 23 + .../api/clients/.openapi-generator/VERSION | 1 + src/codegen/api/clients/.travis.yml | 17 + src/codegen/api/clients/README.md | 81 ++ src/codegen/api/clients/git_push.sh | 57 ++ src/codegen/api/clients/main.py | 6 + .../api/clients/openapi_client/__init__.py | 32 + .../clients/openapi_client/api/__init__.py | 4 + .../api/clients/openapi_client/api_client.py | 797 ++++++++++++++++++ .../clients/openapi_client/api_response.py | 21 + .../clients/openapi_client/configuration.py | 572 +++++++++++++ .../api/clients/openapi_client/exceptions.py | 216 +++++ .../clients/openapi_client/models/__init__.py | 16 + .../api/clients/openapi_client/py.typed | 0 .../api/clients/openapi_client/rest.py | 258 ++++++ src/codegen/api/clients/pyproject.toml | 82 ++ src/codegen/api/clients/requirements.txt | 4 + src/codegen/api/clients/script.py | 8 + src/codegen/api/clients/setup.cfg | 2 + src/codegen/api/clients/setup.py | 49 ++ src/codegen/api/clients/test-requirements.txt | 6 + src/codegen/api/clients/test.ipynb | 30 + src/codegen/api/clients/test/__init__.py | 0 src/codegen/api/clients/tox.ini | 9 + 27 files changed, 2411 insertions(+) create mode 100644 src/codegen/api/clients/.gitignore create mode 100644 src/codegen/api/clients/.gitlab-ci.yml create mode 100644 src/codegen/api/clients/.openapi-generator-ignore create mode 100644 src/codegen/api/clients/.openapi-generator/FILES create mode 100644 src/codegen/api/clients/.openapi-generator/VERSION create mode 100644 src/codegen/api/clients/.travis.yml create mode 100644 src/codegen/api/clients/README.md create mode 100644 src/codegen/api/clients/git_push.sh create mode 100644 src/codegen/api/clients/main.py create mode 100644 src/codegen/api/clients/openapi_client/__init__.py create mode 100644 src/codegen/api/clients/openapi_client/api/__init__.py create mode 100644 src/codegen/api/clients/openapi_client/api_client.py create mode 100644 src/codegen/api/clients/openapi_client/api_response.py create mode 100644 src/codegen/api/clients/openapi_client/configuration.py create mode 100644 src/codegen/api/clients/openapi_client/exceptions.py create mode 100644 src/codegen/api/clients/openapi_client/models/__init__.py create mode 100644 src/codegen/api/clients/openapi_client/py.typed create mode 100644 src/codegen/api/clients/openapi_client/rest.py create mode 100644 src/codegen/api/clients/pyproject.toml create mode 100644 src/codegen/api/clients/requirements.txt create mode 100644 src/codegen/api/clients/script.py create mode 100644 src/codegen/api/clients/setup.cfg create mode 100644 src/codegen/api/clients/setup.py create mode 100644 src/codegen/api/clients/test-requirements.txt create mode 100644 src/codegen/api/clients/test.ipynb create mode 100644 src/codegen/api/clients/test/__init__.py create mode 100644 src/codegen/api/clients/tox.ini diff --git a/src/codegen/api/clients/.gitignore b/src/codegen/api/clients/.gitignore new file mode 100644 index 000000000..43995bd42 --- /dev/null +++ b/src/codegen/api/clients/.gitignore @@ -0,0 +1,66 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.venv/ +.python-version +.pytest_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/src/codegen/api/clients/.gitlab-ci.yml b/src/codegen/api/clients/.gitlab-ci.yml new file mode 100644 index 000000000..156d5a581 --- /dev/null +++ b/src/codegen/api/clients/.gitlab-ci.yml @@ -0,0 +1,31 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.gitlab.com/ee/ci/README.html +# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml + +stages: + - test + +.pytest: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + - pytest --cov=openapi_client + +pytest-3.8: + extends: .pytest + image: python:3.8-alpine +pytest-3.9: + extends: .pytest + image: python:3.9-alpine +pytest-3.10: + extends: .pytest + image: python:3.10-alpine +pytest-3.11: + extends: .pytest + image: python:3.11-alpine +pytest-3.12: + extends: .pytest + image: python:3.12-alpine diff --git a/src/codegen/api/clients/.openapi-generator-ignore b/src/codegen/api/clients/.openapi-generator-ignore new file mode 100644 index 000000000..7484ee590 --- /dev/null +++ b/src/codegen/api/clients/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/src/codegen/api/clients/.openapi-generator/FILES b/src/codegen/api/clients/.openapi-generator/FILES new file mode 100644 index 000000000..be20b1fd2 --- /dev/null +++ b/src/codegen/api/clients/.openapi-generator/FILES @@ -0,0 +1,23 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.openapi-generator-ignore +.travis.yml +README.md +git_push.sh +openapi_client/__init__.py +openapi_client/api/__init__.py +openapi_client/api_client.py +openapi_client/api_response.py +openapi_client/configuration.py +openapi_client/exceptions.py +openapi_client/models/__init__.py +openapi_client/py.typed +openapi_client/rest.py +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +tox.ini diff --git a/src/codegen/api/clients/.openapi-generator/VERSION b/src/codegen/api/clients/.openapi-generator/VERSION new file mode 100644 index 000000000..5f84a81db --- /dev/null +++ b/src/codegen/api/clients/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.12.0 diff --git a/src/codegen/api/clients/.travis.yml b/src/codegen/api/clients/.travis.yml new file mode 100644 index 000000000..ae1aaf0be --- /dev/null +++ b/src/codegen/api/clients/.travis.yml @@ -0,0 +1,17 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" + # uncomment the following if needed + #- "3.12-dev" # 3.12 development branch + #- "nightly" # nightly build +# command to install dependencies +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +# command to run tests +script: pytest --cov=openapi_client diff --git a/src/codegen/api/clients/README.md b/src/codegen/api/clients/README.md new file mode 100644 index 000000000..d42f334ef --- /dev/null +++ b/src/codegen/api/clients/README.md @@ -0,0 +1,81 @@ +# openapi-client +API for application developers + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.12.0 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen + +## Requirements. + +Python 3.8+ + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) + +Then import the package: +```python +import openapi_client +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import openapi_client +``` + +### Tests + +Execute `pytest` to run the tests. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python + +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- + + +## Documentation For Models + + + + +## Documentation For Authorization + +Endpoints do not require authorization. + + +## Author + + + diff --git a/src/codegen/api/clients/git_push.sh b/src/codegen/api/clients/git_push.sh new file mode 100644 index 000000000..f53a75d4f --- /dev/null +++ b/src/codegen/api/clients/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/src/codegen/api/clients/main.py b/src/codegen/api/clients/main.py new file mode 100644 index 000000000..5cd91de72 --- /dev/null +++ b/src/codegen/api/clients/main.py @@ -0,0 +1,6 @@ +def main(): + print("Hello from client!") + + +if __name__ == "__main__": + main() diff --git a/src/codegen/api/clients/openapi_client/__init__.py b/src/codegen/api/clients/openapi_client/__init__.py new file mode 100644 index 000000000..541cf3e01 --- /dev/null +++ b/src/codegen/api/clients/openapi_client/__init__.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +# flake8: noqa + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +__version__ = "1.0.0" + +# import apis into sdk package + +# import ApiClient +from openapi_client.api_response import ApiResponse +from openapi_client.api_client import ApiClient +from openapi_client.configuration import Configuration +from openapi_client.exceptions import OpenApiException +from openapi_client.exceptions import ApiTypeError +from openapi_client.exceptions import ApiValueError +from openapi_client.exceptions import ApiKeyError +from openapi_client.exceptions import ApiAttributeError +from openapi_client.exceptions import ApiException + +# import models into sdk package diff --git a/src/codegen/api/clients/openapi_client/api/__init__.py b/src/codegen/api/clients/openapi_client/api/__init__.py new file mode 100644 index 000000000..c3bb408f1 --- /dev/null +++ b/src/codegen/api/clients/openapi_client/api/__init__.py @@ -0,0 +1,4 @@ +# flake8: noqa + +# import apis into api package + diff --git a/src/codegen/api/clients/openapi_client/api_client.py b/src/codegen/api/clients/openapi_client/api_client.py new file mode 100644 index 000000000..9c8253061 --- /dev/null +++ b/src/codegen/api/clients/openapi_client/api_client.py @@ -0,0 +1,797 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import datetime +from dateutil.parser import parse +from enum import Enum +import decimal +import json +import mimetypes +import os +import re +import tempfile + +from urllib.parse import quote +from typing import Tuple, Optional, List, Dict, Union +from pydantic import SecretStr + +from openapi_client.configuration import Configuration +from openapi_client.api_response import ApiResponse, T as ApiResponseT +import openapi_client.models +from openapi_client import rest +from openapi_client.exceptions import ( + ApiValueError, + ApiException, + BadRequestException, + UnauthorizedException, + ForbiddenException, + NotFoundException, + ServiceException +) + +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int, # TODO remove as only py3 is supported? + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'decimal': decimal.Decimal, + 'object': object, + } + _pool = None + + def __init__( + self, + configuration=None, + header_name=None, + header_value=None, + cookie=None + ) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + self.client_side_validation = configuration.client_side_validation + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + pass + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def param_serialize( + self, + method, + resource_path, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, auth_settings=None, + collection_formats=None, + _host=None, + _request_auth=None + ) -> RequestSerialized: + + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict( + self.parameters_to_tuples(header_params,collection_formats) + ) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples( + path_params, + collection_formats + ) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples( + post_params, + collection_formats + ) + if files: + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth( + header_params, + query_params, + auth_settings, + resource_path, + method, + body, + request_auth=_request_auth + ) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None or self.configuration.ignore_operation_servers: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query( + query_params, + collection_formats + ) + url += "?" + url_query + + return method, url, header_params, body, post_params + + + def call_api( + self, + method, + url, + header_params=None, + body=None, + post_params=None, + _request_timeout=None + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + + try: + # perform request and return response + response_data = self.rest_client.request( + method, url, + headers=header_params, + body=body, post_params=post_params, + _request_timeout=_request_timeout + ) + + except ApiException as e: + raise e + + return response_data + + def response_deserialize( + self, + response_data: rest.RESTResponse, + response_types_map: Optional[Dict[str, ApiResponseT]]=None + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ + + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg + + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + # deserialize response data + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type, content_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) + + return ApiResponse( + status_code = response_data.status, + data = return_data, + headers = response_data.getheaders(), + raw_data = response_data.data + ) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is decimal.Decimal return string representation. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [ + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ] + elif isinstance(obj, tuple): + return tuple( + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + elif isinstance(obj, decimal.Decimal): + return str(obj) + + elif isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ + + return { + key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items() + } + + def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + :param content_type: content type of response. + + :return: deserialized object. + """ + + # fetch data from response object + if content_type is None: + try: + data = json.loads(response_text) + except ValueError: + data = response_text + elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE): + if response_text == "": + data = "" + else: + data = json.loads(response_text) + elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE): + data = response_text + else: + raise ApiException( + status=0, + reason="Unsupported content type: {0}".format(content_type) + ) + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith('List['): + m = re.match(r'List\[(.*)]', klass) + assert m is not None, "Malformed List type definition" + sub_kls = m.group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + m = re.match(r'Dict\[([^,]*), (.*)]', klass) + assert m is not None, "Malformed Dict type definition" + sub_kls = m.group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(openapi_client.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + elif klass == decimal.Decimal: + return decimal.Decimal(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) + else: + return self.__deserialize_model(data, klass) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, quote(str(value))) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(quote(str(value)) for value in v)) + ) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(map(str, item)) for item in new_params]) + + def files_parameters( + self, + files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]], + ): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + for k, v in files.items(): + if isinstance(v, str): + with open(v, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + elif isinstance(v, tuple): + filename, filedata = v + elif isinstance(v, list): + for file_param in v: + params.extend(self.files_parameters({k: file_param})) + continue + else: + raise ValueError("Unsupported file value") + mimetype = ( + mimetypes.guess_type(filename)[0] + or 'application/octet-stream' + ) + params.append( + tuple([k, tuple([filename, filedata, mimetype])]) + ) + return params + + def select_header_accept(self, accepts: List[str]) -> Optional[str]: + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return None + + for accept in accepts: + if re.search('json', accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search('json', content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth( + self, + headers, + queries, + auth_settings, + resource_path, + method, + body, + request_auth=None + ) -> None: + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. + """ + if not auth_settings: + return + + if request_auth: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + request_auth + ) + else: + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + auth_setting + ) + + def _apply_auth_params( + self, + headers, + queries, + resource_path, + method, + body, + auth_setting + ) -> None: + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + queries.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + handle file downloading + save response body into a tmp file and return the instance + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + m = re.search( + r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition + ) + assert m is not None, "Unexpected 'content-disposition' header value" + filename = m.group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as `{1}`" + .format(data, klass) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/src/codegen/api/clients/openapi_client/api_response.py b/src/codegen/api/clients/openapi_client/api_response.py new file mode 100644 index 000000000..9bc7c11f6 --- /dev/null +++ b/src/codegen/api/clients/openapi_client/api_response.py @@ -0,0 +1,21 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel + +T = TypeVar("T") + +class ApiResponse(BaseModel, Generic[T]): + """ + API response object + """ + + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = { + "arbitrary_types_allowed": True + } diff --git a/src/codegen/api/clients/openapi_client/configuration.py b/src/codegen/api/clients/openapi_client/configuration.py new file mode 100644 index 000000000..1ea14d6bc --- /dev/null +++ b/src/codegen/api/clients/openapi_client/configuration.py @@ -0,0 +1,572 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import copy +import http.client as httplib +import logging +from logging import FileHandler +import multiprocessing +import sys +from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union +from typing_extensions import NotRequired, Self + +import urllib3 + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +ServerVariablesT = Dict[str, str] + +GenericAuthSetting = TypedDict( + "GenericAuthSetting", + { + "type": str, + "in": str, + "key": str, + "value": str, + }, +) + + +OAuth2AuthSetting = TypedDict( + "OAuth2AuthSetting", + { + "type": Literal["oauth2"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +APIKeyAuthSetting = TypedDict( + "APIKeyAuthSetting", + { + "type": Literal["api_key"], + "in": str, + "key": str, + "value": Optional[str], + }, +) + + +BasicAuthSetting = TypedDict( + "BasicAuthSetting", + { + "type": Literal["basic"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": Optional[str], + }, +) + + +BearerFormatAuthSetting = TypedDict( + "BearerFormatAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "format": Literal["JWT"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +BearerAuthSetting = TypedDict( + "BearerAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +HTTPSignatureAuthSetting = TypedDict( + "HTTPSignatureAuthSetting", + { + "type": Literal["http-signature"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": None, + }, +) + + +AuthSettings = TypedDict( + "AuthSettings", + { + }, + total=False, +) + + +class HostSettingVariable(TypedDict): + description: str + default_value: str + enum_values: List[str] + + +class HostSetting(TypedDict): + url: str + description: str + variables: NotRequired[Dict[str, HostSettingVariable]] + + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :param ignore_operation_servers + Boolean to ignore operation servers for the API client. + Config will use `host` as the base url regardless of the operation servers. + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer). + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + :param retries: Number of retries for API requests. + :param ca_cert_data: verify the peer using concatenated CA certificate data + in PEM (str) or DER (bytes) format. + + """ + + _default: ClassVar[Optional[Self]] = None + + def __init__( + self, + host: Optional[str]=None, + api_key: Optional[Dict[str, str]]=None, + api_key_prefix: Optional[Dict[str, str]]=None, + username: Optional[str]=None, + password: Optional[str]=None, + access_token: Optional[str]=None, + server_index: Optional[int]=None, + server_variables: Optional[ServerVariablesT]=None, + server_operation_index: Optional[Dict[int, int]]=None, + server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None, + ignore_operation_servers: bool=False, + ssl_ca_cert: Optional[str]=None, + retries: Optional[int] = None, + ca_cert_data: Optional[Union[str, bytes]] = None, + *, + debug: Optional[bool] = None, + ) -> None: + """Constructor + """ + self._base_path = "http://localhost" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.ignore_operation_servers = ignore_operation_servers + """Ignore operation servers + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.access_token = access_token + """Access token + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("openapi_client") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler: Optional[FileHandler] = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + if debug is not None: + self.debug = debug + else: + self.__debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.ca_cert_data = ca_cert_data + """Set this to verify the peer using PEM (str) or DER (bytes) + certificate data. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy: Optional[str] = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = retries + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + + def __deepcopy__(self, memo: Dict[int, Any]) -> Self: + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name: str, value: Any) -> None: + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default: Optional[Self]) -> None: + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = default + + @classmethod + def get_default_copy(cls) -> Self: + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls) -> Self: + """Return the default configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration. + + :return: The configuration object. + """ + if cls._default is None: + cls._default = cls() + return cls._default + + @property + def logger_file(self) -> Optional[str]: + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value: Optional[str]) -> None: + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self) -> bool: + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value: bool) -> None: + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self) -> str: + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value: str) -> None: + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]: + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + return None + + def get_basic_auth_token(self) -> Optional[str]: + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self)-> AuthSettings: + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth: AuthSettings = {} + return auth + + def to_debug_report(self) -> str: + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 1.0.0\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self) -> List[HostSetting]: + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "", + 'description': "No description provided", + } + ] + + def get_host_from_settings( + self, + index: Optional[int], + variables: Optional[ServerVariablesT]=None, + servers: Optional[List[HostSetting]]=None, + ) -> str: + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self) -> str: + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value: str) -> None: + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/src/codegen/api/clients/openapi_client/exceptions.py b/src/codegen/api/clients/openapi_client/exceptions.py new file mode 100644 index 000000000..edec82866 --- /dev/null +++ b/src/codegen/api/clients/openapi_client/exceptions.py @@ -0,0 +1,216 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from typing import Any, Optional +from typing_extensions import Self + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None) -> None: + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + + if http_resp: + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass + self.headers = http_resp.getheaders() + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + # Added new conditions for 409 and 422 + if http_resp.status == 409: + raise ConflictException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 422: + raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) + + return error_message + + +class BadRequestException(ApiException): + pass + + +class NotFoundException(ApiException): + pass + + +class UnauthorizedException(ApiException): + pass + + +class ForbiddenException(ApiException): + pass + + +class ServiceException(ApiException): + pass + + +class ConflictException(ApiException): + """Exception for HTTP 409 Conflict.""" + pass + + +class UnprocessableEntityException(ApiException): + """Exception for HTTP 422 Unprocessable Entity.""" + pass + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/src/codegen/api/clients/openapi_client/models/__init__.py b/src/codegen/api/clients/openapi_client/models/__init__.py new file mode 100644 index 000000000..6b49c0b94 --- /dev/null +++ b/src/codegen/api/clients/openapi_client/models/__init__.py @@ -0,0 +1,16 @@ +# coding: utf-8 + +# flake8: noqa +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +# import models into model package diff --git a/src/codegen/api/clients/openapi_client/py.typed b/src/codegen/api/clients/openapi_client/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/src/codegen/api/clients/openapi_client/rest.py b/src/codegen/api/clients/openapi_client/rest.py new file mode 100644 index 000000000..e41059f82 --- /dev/null +++ b/src/codegen/api/clients/openapi_client/rest.py @@ -0,0 +1,258 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import io +import json +import re +import ssl + +import urllib3 + +from openapi_client.exceptions import ApiException, ApiValueError + +SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} +RESTResponseType = urllib3.HTTPResponse + + +def is_socks_proxy_url(url): + if url is None: + return False + split_section = url.split("://") + if len(split_section) < 2: + return False + else: + return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.response = resp + self.status = resp.status + self.reason = resp.reason + self.data = None + + def read(self): + if self.data is None: + self.data = self.response.data + return self.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration) -> None: + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + "ca_cert_data": configuration.ca_cert_data, + } + if configuration.assert_hostname is not None: + pool_args['assert_hostname'] = ( + configuration.assert_hostname + ) + + if configuration.retries is not None: + pool_args['retries'] = configuration.retries + + if configuration.tls_server_name: + pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + pool_args['socket_options'] = configuration.socket_options + + if configuration.connection_pool_maxsize is not None: + pool_args['maxsize'] = configuration.connection_pool_maxsize + + # https pool manager + self.pool_manager: urllib3.PoolManager + + if configuration.proxy: + if is_socks_proxy_url(configuration.proxy): + from urllib3.contrib.socks import SOCKSProxyManager + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) + else: + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) + else: + self.pool_manager = urllib3.PoolManager(**pool_args) + + def request( + self, + method, + url, + headers=None, + body=None, + post_params=None, + _request_timeout=None + ): + """Perform requests. + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in [ + 'GET', + 'HEAD', + 'DELETE', + 'POST', + 'PUT', + 'PATCH', + 'OPTIONS' + ] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int, float)): + timeout = urllib3.Timeout(total=_request_timeout) + elif ( + isinstance(_request_timeout, tuple) + and len(_request_timeout) == 2 + ): + timeout = urllib3.Timeout( + connect=_request_timeout[0], + read=_request_timeout[1] + ) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + + # no content type provided or payload is json + content_type = headers.get('Content-Type') + if ( + not content_type + or re.search('json', content_type, re.IGNORECASE) + ): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, + url, + body=request_body, + timeout=timeout, + headers=headers, + preload_content=False + ) + elif content_type == 'application/x-www-form-urlencoded': + r = self.pool_manager.request( + method, + url, + fields=post_params, + encode_multipart=False, + timeout=timeout, + headers=headers, + preload_content=False + ) + elif content_type == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + # Ensures that dict objects are serialized + post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params] + r = self.pool_manager.request( + method, + url, + fields=post_params, + encode_multipart=True, + timeout=timeout, + headers=headers, + preload_content=False + ) + # Pass a `string` parameter directly in the body to support + # other content types than JSON when `body` argument is + # provided in serialized form. + elif isinstance(body, str) or isinstance(body, bytes): + r = self.pool_manager.request( + method, + url, + body=body, + timeout=timeout, + headers=headers, + preload_content=False + ) + elif headers['Content-Type'].startswith('text/') and isinstance(body, bool): + request_body = "true" if body else "false" + r = self.pool_manager.request( + method, + url, + body=request_body, + preload_content=False, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request( + method, + url, + fields={}, + timeout=timeout, + headers=headers, + preload_content=False + ) + except urllib3.exceptions.SSLError as e: + msg = "\n".join([type(e).__name__, str(e)]) + raise ApiException(status=0, reason=msg) + + return RESTResponse(r) diff --git a/src/codegen/api/clients/pyproject.toml b/src/codegen/api/clients/pyproject.toml new file mode 100644 index 000000000..c969d16b0 --- /dev/null +++ b/src/codegen/api/clients/pyproject.toml @@ -0,0 +1,82 @@ +[project] +name = "client" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.12, <3.14" +dependencies = [] + +[tool.uv] +python = "^3.8" +urllib3 = ">= 1.25.3, < 3.0.0" +python-dateutil = ">= 2.8.2" +pydantic = ">= 2" +typing-extensions = ">= 4.7.1" + +pytest = ">= 7.2.1" +pytest-cov = ">= 2.8.1" +tox = ">= 3.9.0" +flake8 = ">= 4.0.0" +types-python-dateutil = ">= 2.8.19.14" +mypy = ">= 1.5" + + +[build-system] +requires = ["setuptools>=65.5.0", "setuptools-scm>=8.0.0"] +build-backend = "setuptools.build_meta" + +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "openapi_client", + #"test", # auto-generated tests + "tests", # hand-written tests +] +# TODO: enable "strict" once all these individual checks are passing +# strict = true + +# List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options +warn_unused_configs = true +warn_redundant_casts = true +warn_unused_ignores = true + +## Getting these passing should be easy +strict_equality = true +extra_checks = true + +## Strongly recommend enabling this one as soon as you can +check_untyped_defs = true + +## These shouldn't be too much additional work, but may be tricky to +## get passing if you use a lot of untyped libraries +disallow_subclassing_any = true +disallow_untyped_decorators = true +disallow_any_generics = true + +### These next few are various gradations of forcing use of type annotations +#disallow_untyped_calls = true +#disallow_incomplete_defs = true +#disallow_untyped_defs = true +# +### This one isn't too hard to get passing, but return on investment is lower +#no_implicit_reexport = true +# +### This one can be tricky to get passing if you use a lot of untyped libraries +#warn_return_any = true + +[[tool.mypy.overrides]] +module = ["openapi_client.configuration"] +warn_unused_ignores = true +strict_equality = true +extra_checks = true +check_untyped_defs = true +disallow_subclassing_any = true +disallow_untyped_decorators = true +disallow_any_generics = true +disallow_untyped_calls = true +disallow_incomplete_defs = true +disallow_untyped_defs = true +no_implicit_reexport = true +warn_return_any = true diff --git a/src/codegen/api/clients/requirements.txt b/src/codegen/api/clients/requirements.txt new file mode 100644 index 000000000..3c6f164cf --- /dev/null +++ b/src/codegen/api/clients/requirements.txt @@ -0,0 +1,4 @@ +urllib3 >= 1.25.3, < 3.0.0 +python_dateutil >= 2.8.2 +pydantic +typing-extensions >= 4.7.1 diff --git a/src/codegen/api/clients/script.py b/src/codegen/api/clients/script.py new file mode 100644 index 000000000..27df0c4b1 --- /dev/null +++ b/src/codegen/api/clients/script.py @@ -0,0 +1,8 @@ +from openapi_client.api_client import ApiClient +from openapi_client.configuration import Configuration + + +ApiClient(configuration=Configuration(access_token="sk-c0d6602a-e0e2-4ec7-ad3f-d079b3cad46b", host="https://codegen-sh--rest-api.modal.run")) + + + diff --git a/src/codegen/api/clients/setup.cfg b/src/codegen/api/clients/setup.cfg new file mode 100644 index 000000000..11433ee87 --- /dev/null +++ b/src/codegen/api/clients/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/src/codegen/api/clients/setup.py b/src/codegen/api/clients/setup.py new file mode 100644 index 000000000..9efcd2270 --- /dev/null +++ b/src/codegen/api/clients/setup.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from setuptools import setup, find_packages # noqa: H301 + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools +NAME = "openapi-client" +VERSION = "1.0.0" +PYTHON_REQUIRES = ">= 3.8" +REQUIRES = [ + "urllib3 >= 1.25.3, < 3.0.0", + "python-dateutil >= 2.8.2", + "pydantic >= 2", + "typing-extensions >= 4.7.1", +] + +setup( + name=NAME, + version=VERSION, + description="Developer API", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "Developer API"], + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + long_description_content_type='text/markdown', + long_description="""\ + API for application developers + """, # noqa: E501 + package_data={"openapi_client": ["py.typed"]}, +) \ No newline at end of file diff --git a/src/codegen/api/clients/test-requirements.txt b/src/codegen/api/clients/test-requirements.txt new file mode 100644 index 000000000..e98555c11 --- /dev/null +++ b/src/codegen/api/clients/test-requirements.txt @@ -0,0 +1,6 @@ +pytest >= 7.2.1 +pytest-cov >= 2.8.1 +tox >= 3.9.0 +flake8 >= 4.0.0 +types-python-dateutil >= 2.8.19.14 +mypy >= 1.5 diff --git a/src/codegen/api/clients/test.ipynb b/src/codegen/api/clients/test.ipynb new file mode 100644 index 000000000..4f1eb9505 --- /dev/null +++ b/src/codegen/api/clients/test.ipynb @@ -0,0 +1,30 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from app.generated.sdk.openapi_client.api_client import ApiClient\n", + "from app.generated.sdk.openapi_client.configuration import Configuration\n", + "\n", + "\n", + "ApiClient(configuration=Configuration(access_token=\"\", host=\"https://codegen-sh--rest-api.modal.run/\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.13.1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/src/codegen/api/clients/test/__init__.py b/src/codegen/api/clients/test/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/codegen/api/clients/tox.ini b/src/codegen/api/clients/tox.ini new file mode 100644 index 000000000..1a9028b78 --- /dev/null +++ b/src/codegen/api/clients/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=openapi_client From bd8950092b51cba5d98862445b1f301a0949dd52 Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Mon, 7 Apr 2025 17:24:46 -0700 Subject: [PATCH 2/8] fix: cleanup --- src/codegen/__init__.py | 3 +- src/codegen/agents/__init__.py | 6 + src/codegen/agents/agent.py | 106 + .../agents/client/.openapi-generator/FILES | 62 + .../client}/.openapi-generator/VERSION | 0 src/codegen/agents/client/README.md | 24 + .../agents/client/openapi_client/__init__.py | 45 + .../client/openapi_client/api/__init__.py | 7 + .../client/openapi_client/api/agents_api.py | 1836 ++++++++++++++++ .../openapi_client/api/organizations_api.py | 930 +++++++++ .../client/openapi_client/api/users_api.py | 1855 +++++++++++++++++ .../client}/openapi_client/api_client.py | 10 +- .../client}/openapi_client/api_response.py | 0 .../client}/openapi_client/configuration.py | 0 .../client}/openapi_client/exceptions.py | 0 .../client/openapi_client/models/__init__.py | 26 + .../models/agent_run_response.py | 110 + .../models/create_agent_run_input.py | 87 + .../models/http_validation_error.py | 95 + .../models/organization_response.py | 95 + .../models/organization_settings.py | 89 + .../models/page_organization_response.py | 103 + .../models/page_user_response.py | 103 + .../openapi_client/models/user_response.py | 112 + .../openapi_client/models/validation_error.py | 99 + .../models/validation_error_loc_inner.py | 138 ++ .../client}/openapi_client/rest.py | 2 +- src/codegen/agents/constants.py | 1 + src/codegen/agents/scratch.ipynb | 56 + src/codegen/api/clients/.gitignore | 66 - src/codegen/api/clients/.gitlab-ci.yml | 31 - .../api/clients/.openapi-generator-ignore | 23 - .../api/clients/.openapi-generator/FILES | 23 - src/codegen/api/clients/.travis.yml | 17 - src/codegen/api/clients/README.md | 81 - src/codegen/api/clients/git_push.sh | 57 - src/codegen/api/clients/main.py | 6 - .../api/clients/openapi_client/__init__.py | 32 - .../clients/openapi_client/api/__init__.py | 4 - .../clients/openapi_client/models/__init__.py | 16 - .../api/clients/openapi_client/py.typed | 0 src/codegen/api/clients/pyproject.toml | 82 - src/codegen/api/clients/requirements.txt | 4 - src/codegen/api/clients/script.py | 8 - src/codegen/api/clients/setup.cfg | 2 - src/codegen/api/clients/setup.py | 49 - src/codegen/api/clients/test-requirements.txt | 6 - src/codegen/api/clients/test.ipynb | 30 - src/codegen/api/clients/test/__init__.py | 0 src/codegen/api/clients/tox.ini | 9 - 50 files changed, 5993 insertions(+), 553 deletions(-) create mode 100644 src/codegen/agents/__init__.py create mode 100644 src/codegen/agents/agent.py create mode 100644 src/codegen/agents/client/.openapi-generator/FILES rename src/codegen/{api/clients => agents/client}/.openapi-generator/VERSION (100%) create mode 100644 src/codegen/agents/client/README.md create mode 100644 src/codegen/agents/client/openapi_client/__init__.py create mode 100644 src/codegen/agents/client/openapi_client/api/__init__.py create mode 100644 src/codegen/agents/client/openapi_client/api/agents_api.py create mode 100644 src/codegen/agents/client/openapi_client/api/organizations_api.py create mode 100644 src/codegen/agents/client/openapi_client/api/users_api.py rename src/codegen/{api/clients => agents/client}/openapi_client/api_client.py (98%) rename src/codegen/{api/clients => agents/client}/openapi_client/api_response.py (100%) rename src/codegen/{api/clients => agents/client}/openapi_client/configuration.py (100%) rename src/codegen/{api/clients => agents/client}/openapi_client/exceptions.py (100%) create mode 100644 src/codegen/agents/client/openapi_client/models/__init__.py create mode 100644 src/codegen/agents/client/openapi_client/models/agent_run_response.py create mode 100644 src/codegen/agents/client/openapi_client/models/create_agent_run_input.py create mode 100644 src/codegen/agents/client/openapi_client/models/http_validation_error.py create mode 100644 src/codegen/agents/client/openapi_client/models/organization_response.py create mode 100644 src/codegen/agents/client/openapi_client/models/organization_settings.py create mode 100644 src/codegen/agents/client/openapi_client/models/page_organization_response.py create mode 100644 src/codegen/agents/client/openapi_client/models/page_user_response.py create mode 100644 src/codegen/agents/client/openapi_client/models/user_response.py create mode 100644 src/codegen/agents/client/openapi_client/models/validation_error.py create mode 100644 src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py rename src/codegen/{api/clients => agents/client}/openapi_client/rest.py (99%) create mode 100644 src/codegen/agents/constants.py create mode 100644 src/codegen/agents/scratch.ipynb delete mode 100644 src/codegen/api/clients/.gitignore delete mode 100644 src/codegen/api/clients/.gitlab-ci.yml delete mode 100644 src/codegen/api/clients/.openapi-generator-ignore delete mode 100644 src/codegen/api/clients/.openapi-generator/FILES delete mode 100644 src/codegen/api/clients/.travis.yml delete mode 100644 src/codegen/api/clients/README.md delete mode 100644 src/codegen/api/clients/git_push.sh delete mode 100644 src/codegen/api/clients/main.py delete mode 100644 src/codegen/api/clients/openapi_client/__init__.py delete mode 100644 src/codegen/api/clients/openapi_client/api/__init__.py delete mode 100644 src/codegen/api/clients/openapi_client/models/__init__.py delete mode 100644 src/codegen/api/clients/openapi_client/py.typed delete mode 100644 src/codegen/api/clients/pyproject.toml delete mode 100644 src/codegen/api/clients/requirements.txt delete mode 100644 src/codegen/api/clients/script.py delete mode 100644 src/codegen/api/clients/setup.cfg delete mode 100644 src/codegen/api/clients/setup.py delete mode 100644 src/codegen/api/clients/test-requirements.txt delete mode 100644 src/codegen/api/clients/test.ipynb delete mode 100644 src/codegen/api/clients/test/__init__.py delete mode 100644 src/codegen/api/clients/tox.ini diff --git a/src/codegen/__init__.py b/src/codegen/__init__.py index ce25a4938..f464305c7 100644 --- a/src/codegen/__init__.py +++ b/src/codegen/__init__.py @@ -3,5 +3,6 @@ from codegen.extensions.events.codegen_app import CodegenApp from codegen.sdk.core.codebase import Codebase from codegen.shared.enums.programming_language import ProgrammingLanguage +from codegen.agents.agent import Agent -__all__ = ["Codebase", "CodegenApp", "Function", "ProgrammingLanguage", "function"] +__all__ = ["Agent", "Codebase", "CodegenApp", "Function", "ProgrammingLanguage", "function"] diff --git a/src/codegen/agents/__init__.py b/src/codegen/agents/__init__.py new file mode 100644 index 000000000..ee1c6da1a --- /dev/null +++ b/src/codegen/agents/__init__.py @@ -0,0 +1,6 @@ +""" +Codegen Agent API module. +""" +from codegen.agents.agent import Agent + +__all__ = ["Agent"] \ No newline at end of file diff --git a/src/codegen/agents/agent.py b/src/codegen/agents/agent.py new file mode 100644 index 000000000..dfae14df2 --- /dev/null +++ b/src/codegen/agents/agent.py @@ -0,0 +1,106 @@ +from typing import Optional, Dict, Any +import os + +from codegen.agents.client.openapi_client.api.agents_api import AgentsApi +from codegen.agents.client.openapi_client.api_client import ApiClient +from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse +from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput +from codegen.agents.client.openapi_client.configuration import Configuration +from codegen.agents.constants import CODEGEN_BASE_API_URL + + +class AgentTask: + """Represents an agent run job.""" + + def __init__(self, task_data: AgentRunResponse, api_client: ApiClient, org_id: int): + self.id = task_data.id + self.org_id = org_id + self.status = task_data.status + self.result = task_data.result + self._api_client = api_client + self._agents_api = AgentsApi(api_client) + + def refresh(self) -> None: + """Refresh the job status from the API.""" + if self.id is None: + return + + job_data = self._agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get( + agent_run_id=int(self.id), + org_id=int(self.org_id), + authorization=f"Bearer {self._api_client.configuration.access_token}" + ) + + # Convert API response to dict for attribute access + job_dict = {} + if hasattr(job_data, '__dict__'): + job_dict = job_data.__dict__ + elif isinstance(job_data, dict): + job_dict = job_data + + self.status = job_dict.get("status") + self.result = job_dict.get("result") + + +class Agent: + """API client for interacting with Codegen AI agents.""" + + def __init__(self, token: str, org_id: Optional[int] = None, base_url: Optional[str] = CODEGEN_BASE_API_URL): + """ + Initialize a new Agent client. + + Args: + token: API authentication token + org_id: Optional organization ID. If not provided, default org will be used. + """ + self.token = token + self.org_id = org_id or int(os.environ.get("CODEGEN_ORG_ID", "1")) # Default to org ID 1 if not specified + + # Configure API client + config = Configuration(host=base_url, access_token=token) + self.api_client = ApiClient(configuration=config) + self.agents_api = AgentsApi(self.api_client) + + # Current job + self.current_job = None + + def run(self, prompt: str) -> AgentTask: + """ + Run an agent with the given prompt. + + Args: + prompt: The instruction for the agent to execute + + Returns: + Job: A job object representing the agent run + """ + run_input = CreateAgentRunInput(prompt=prompt) + agent_run_response = self.agents_api.create_agent_run_v1_organizations_org_id_agent_run_post( + org_id=int(self.org_id), + create_agent_run_input=run_input, + authorization=f"Bearer {self.token}", + _headers={"Content-Type": "application/json"} + ) + + # Convert API response to dict for Job initialization + + job = AgentTask(agent_run_response, self.api_client, self.org_id) + self.current_job = job + return job + + def get_status(self) -> Optional[Dict[str, Any]]: + """ + Get the status of the current job. + + Returns: + dict: A dictionary containing job status information, + or None if no job has been run. + """ + if self.current_job: + self.current_job.refresh() + return { + "id": self.current_job.id, + "status": self.current_job.status, + "result": self.current_job.result + } + return None diff --git a/src/codegen/agents/client/.openapi-generator/FILES b/src/codegen/agents/client/.openapi-generator/FILES new file mode 100644 index 000000000..5aa764c59 --- /dev/null +++ b/src/codegen/agents/client/.openapi-generator/FILES @@ -0,0 +1,62 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.openapi-generator-ignore +.travis.yml +README.md +docs/AgentRunResponse.md +docs/AgentsApi.md +docs/CreateAgentRunInput.md +docs/HTTPValidationError.md +docs/OrganizationResponse.md +docs/OrganizationSettings.md +docs/OrganizationsApi.md +docs/PageOrganizationResponse.md +docs/PageUserResponse.md +docs/UserResponse.md +docs/UsersApi.md +docs/ValidationError.md +docs/ValidationErrorLocInner.md +git_push.sh +openapi_client/__init__.py +openapi_client/api/__init__.py +openapi_client/api/agents_api.py +openapi_client/api/organizations_api.py +openapi_client/api/users_api.py +openapi_client/api_client.py +openapi_client/api_response.py +openapi_client/configuration.py +openapi_client/exceptions.py +openapi_client/models/__init__.py +openapi_client/models/agent_run_response.py +openapi_client/models/create_agent_run_input.py +openapi_client/models/http_validation_error.py +openapi_client/models/organization_response.py +openapi_client/models/organization_settings.py +openapi_client/models/page_organization_response.py +openapi_client/models/page_user_response.py +openapi_client/models/user_response.py +openapi_client/models/validation_error.py +openapi_client/models/validation_error_loc_inner.py +openapi_client/py.typed +openapi_client/rest.py +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +test/test_agent_run_response.py +test/test_agents_api.py +test/test_create_agent_run_input.py +test/test_http_validation_error.py +test/test_organization_response.py +test/test_organization_settings.py +test/test_organizations_api.py +test/test_page_organization_response.py +test/test_page_user_response.py +test/test_user_response.py +test/test_users_api.py +test/test_validation_error.py +test/test_validation_error_loc_inner.py +tox.ini diff --git a/src/codegen/api/clients/.openapi-generator/VERSION b/src/codegen/agents/client/.openapi-generator/VERSION similarity index 100% rename from src/codegen/api/clients/.openapi-generator/VERSION rename to src/codegen/agents/client/.openapi-generator/VERSION diff --git a/src/codegen/agents/client/README.md b/src/codegen/agents/client/README.md new file mode 100644 index 000000000..fc9f39f30 --- /dev/null +++ b/src/codegen/agents/client/README.md @@ -0,0 +1,24 @@ +# openapi-client +API for application developers + +This Python directory was automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. However it the generated code was altered to make compatible with the rest of the project. + +- API version: 1.0.0 + + + +### Steps to update client directory + +1. Fetch the api schema from the API endpoint [https://codegen-sh--rest-api.modal.run/api/openapi.json](schema file) +2. generate the client code with the following command: + +```bash +openapi-generator generate -i openapi.yaml -g python -o ./client +``` +3. This command will generate a lot of unused files we just need to include the files in the `openapi_client` directory to the project. + +4. May need to fix the imports for `openapi_client` to be fully qualified import paths. + + +5. TODO: make updates more streamlined. Ideally setup this api client as it's own package so all it takes is to generate the new code, no addtional manual steps are needed. + diff --git a/src/codegen/agents/client/openapi_client/__init__.py b/src/codegen/agents/client/openapi_client/__init__.py new file mode 100644 index 000000000..276e64e2c --- /dev/null +++ b/src/codegen/agents/client/openapi_client/__init__.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +# flake8: noqa + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +__version__ = "1.0.0" + +# import apis into sdk package +from codegen.agents.client.openapi_client.api.agents_api import AgentsApi +from codegen.agents.client.openapi_client.api.organizations_api import OrganizationsApi +from codegen.agents.client.openapi_client.api.users_api import UsersApi + +# import ApiClient +from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.api_client import ApiClient +from codegen.agents.client.openapi_client.configuration import Configuration +from codegen.agents.client.openapi_client.exceptions import OpenApiException +from codegen.agents.client.openapi_client.exceptions import ApiTypeError +from codegen.agents.client.openapi_client.exceptions import ApiValueError +from codegen.agents.client.openapi_client.exceptions import ApiKeyError +from codegen.agents.client.openapi_client.exceptions import ApiAttributeError +from codegen.agents.client.openapi_client.exceptions import ApiException + +# import models into sdk package +from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse +from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput +from codegen.agents.client.openapi_client.models.http_validation_error import HTTPValidationError +from codegen.agents.client.openapi_client.models.organization_response import OrganizationResponse +from codegen.agents.client.openapi_client.models.organization_settings import OrganizationSettings +from codegen.agents.client.openapi_client.models.page_organization_response import PageOrganizationResponse +from codegen.agents.client.openapi_client.models.page_user_response import PageUserResponse +from codegen.agents.client.openapi_client.models.user_response import UserResponse +from codegen.agents.client.openapi_client.models.validation_error import ValidationError +from codegen.agents.client.openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/src/codegen/agents/client/openapi_client/api/__init__.py b/src/codegen/agents/client/openapi_client/api/__init__.py new file mode 100644 index 000000000..27d2bb176 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/api/__init__.py @@ -0,0 +1,7 @@ +# flake8: noqa + +# import apis into api package +from codegen.agents.client.openapi_client.api.agents_api import AgentsApi +from codegen.agents.client.openapi_client.api.organizations_api import OrganizationsApi +from codegen.agents.client.openapi_client.api.users_api import UsersApi + diff --git a/src/codegen/agents/client/openapi_client/api/agents_api.py b/src/codegen/agents/client/openapi_client/api/agents_api.py new file mode 100644 index 000000000..08c410f4a --- /dev/null +++ b/src/codegen/agents/client/openapi_client/api/agents_api.py @@ -0,0 +1,1836 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import StrictInt +from typing import Any, Optional +from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse +from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput + +from codegen.agents.client.openapi_client.api_client import ApiClient, RequestSerialized +from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.rest import RESTResponseType + + +class AgentsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AgentRunResponse: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_with_http_info( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AgentRunResponse]: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_without_preload_content( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _create_agent_run_v1_organizations_org_id_agent_run_post_serialize( + self, + org_id, + create_agent_run_input, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + if create_agent_run_input is not None: + _body_params = create_agent_run_input + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/organizations/{org_id}/agent/run', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_0( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AgentRunResponse: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_0_with_http_info( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AgentRunResponse]: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_0_without_preload_content( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( + self, + org_id, + create_agent_run_input, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + if create_agent_run_input is not None: + _body_params = create_agent_run_input + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/organizations/{org_id}/agent/run', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_1( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AgentRunResponse: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_1_with_http_info( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AgentRunResponse]: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def create_agent_run_v1_organizations_org_id_agent_run_post_1_without_preload_content( + self, + org_id: StrictInt, + create_agent_run_input: CreateAgentRunInput, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create Agent Run + + Create a new agent run. Creates and initiates a long-running agent process based on the provided prompt. The process will complete asynchronously, and the response contains the agent run ID which can be used to check the status later. The requesting user must be a member of the specified organization. + + :param org_id: (required) + :type org_id: int + :param create_agent_run_input: (required) + :type create_agent_run_input: CreateAgentRunInput + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( + org_id=org_id, + create_agent_run_input=create_agent_run_input, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( + self, + org_id, + create_agent_run_input, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + if create_agent_run_input is not None: + _body_params = create_agent_run_input + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/organizations/{org_id}/agent/run', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AgentRunResponse: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_with_http_info( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AgentRunResponse]: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_without_preload_content( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( + self, + agent_run_id, + org_id, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if agent_run_id is not None: + _path_params['agent_run_id'] = agent_run_id + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/agent/run/{agent_run_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AgentRunResponse: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_with_http_info( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AgentRunResponse]: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_without_preload_content( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( + self, + agent_run_id, + org_id, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if agent_run_id is not None: + _path_params['agent_run_id'] = agent_run_id + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/agent/run/{agent_run_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AgentRunResponse: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_with_http_info( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AgentRunResponse]: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_without_preload_content( + self, + agent_run_id: StrictInt, + org_id: StrictInt, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Agent Run + + Retrieve the status and result of an agent run. Returns the current status, progress, and any available results for the specified agent run. The agent run must belong to the specified organization. If the agent run is still in progress, this endpoint can be polled to check for completion. + + :param agent_run_id: (required) + :type agent_run_id: int + :param org_id: (required) + :type org_id: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( + agent_run_id=agent_run_id, + org_id=org_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AgentRunResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( + self, + agent_run_id, + org_id, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if agent_run_id is not None: + _path_params['agent_run_id'] = agent_run_id + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/agent/run/{agent_run_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/src/codegen/agents/client/openapi_client/api/organizations_api.py b/src/codegen/agents/client/openapi_client/api/organizations_api.py new file mode 100644 index 000000000..823141ad5 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/api/organizations_api.py @@ -0,0 +1,930 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field +from typing import Any, Optional +from typing_extensions import Annotated +from codegen.agents.client.openapi_client.models.page_organization_response import PageOrganizationResponse + +from codegen.agents.client.openapi_client.api_client import ApiClient, RequestSerialized +from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.rest import RESTResponseType + + +class OrganizationsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def get_organizations_v1_organizations_get( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PageOrganizationResponse: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_organizations_v1_organizations_get_with_http_info( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PageOrganizationResponse]: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_organizations_v1_organizations_get_without_preload_content( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_organizations_v1_organizations_get_serialize( + self, + skip, + limit, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_organizations_v1_organizations_get_0( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PageOrganizationResponse: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_0_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_organizations_v1_organizations_get_0_with_http_info( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PageOrganizationResponse]: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_0_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_organizations_v1_organizations_get_0_without_preload_content( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_0_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_organizations_v1_organizations_get_0_serialize( + self, + skip, + limit, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_organizations_v1_organizations_get_1( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PageOrganizationResponse: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_1_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_organizations_v1_organizations_get_1_with_http_info( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PageOrganizationResponse]: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_1_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_organizations_v1_organizations_get_1_without_preload_content( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Organizations + + Get organizations for the authenticated user. Returns a paginated list of all organizations that the authenticated user is a member of. Results include basic organization details such as name, ID, and membership information. Use pagination parameters to control the number of results returned. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_organizations_v1_organizations_get_1_serialize( + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageOrganizationResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_organizations_v1_organizations_get_1_serialize( + self, + skip, + limit, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/src/codegen/agents/client/openapi_client/api/users_api.py b/src/codegen/agents/client/openapi_client/api/users_api.py new file mode 100644 index 000000000..d3f138510 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/api/users_api.py @@ -0,0 +1,1855 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictStr +from typing import Any, Optional +from typing_extensions import Annotated +from codegen.agents.client.openapi_client.models.page_user_response import PageUserResponse +from codegen.agents.client.openapi_client.models.user_response import UserResponse + +from codegen.agents.client.openapi_client.api_client import ApiClient, RequestSerialized +from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.rest import RESTResponseType + + +class UsersApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> UserResponse: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_with_http_info( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[UserResponse]: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_without_preload_content( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_user_v1_organizations_org_id_users_user_id_get_serialize( + self, + org_id, + user_id, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + if user_id is not None: + _path_params['user_id'] = user_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/users/{user_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_0( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> UserResponse: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_0_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_0_with_http_info( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[UserResponse]: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_0_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_0_without_preload_content( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_0_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_user_v1_organizations_org_id_users_user_id_get_0_serialize( + self, + org_id, + user_id, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + if user_id is not None: + _path_params['user_id'] = user_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/users/{user_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_1( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> UserResponse: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_1_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_1_with_http_info( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[UserResponse]: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_1_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_user_v1_organizations_org_id_users_user_id_get_1_without_preload_content( + self, + org_id: StrictStr, + user_id: StrictStr, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get User + + Get details for a specific user in an organization. Returns detailed information about a user within the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param user_id: (required) + :type user_id: str + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_v1_organizations_org_id_users_user_id_get_1_serialize( + org_id=org_id, + user_id=user_id, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_user_v1_organizations_org_id_users_user_id_get_1_serialize( + self, + org_id, + user_id, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + if user_id is not None: + _path_params['user_id'] = user_id + # process the query parameters + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/users/{user_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_users_v1_organizations_org_id_users_get( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PageUserResponse: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_users_v1_organizations_org_id_users_get_with_http_info( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PageUserResponse]: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_users_v1_organizations_org_id_users_get_without_preload_content( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_users_v1_organizations_org_id_users_get_serialize( + self, + org_id, + skip, + limit, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/users', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_users_v1_organizations_org_id_users_get_0( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PageUserResponse: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_0_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_users_v1_organizations_org_id_users_get_0_with_http_info( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PageUserResponse]: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_0_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_users_v1_organizations_org_id_users_get_0_without_preload_content( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_0_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_users_v1_organizations_org_id_users_get_0_serialize( + self, + org_id, + skip, + limit, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/users', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_users_v1_organizations_org_id_users_get_1( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PageUserResponse: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_1_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_users_v1_organizations_org_id_users_get_1_with_http_info( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PageUserResponse]: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_1_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_users_v1_organizations_org_id_users_get_1_without_preload_content( + self, + org_id: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, + authorization: Optional[Any] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get Users + + Get paginated list of users for a specific organization. Returns a paginated list of all users associated with the specified organization. The requesting user must be a member of the organization to access this endpoint. + + :param org_id: (required) + :type org_id: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param authorization: + :type authorization: object + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_users_v1_organizations_org_id_users_get_1_serialize( + org_id=org_id, + skip=skip, + limit=limit, + authorization=authorization, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PageUserResponse", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_users_v1_organizations_org_id_users_get_1_serialize( + self, + org_id, + skip, + limit, + authorization, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if org_id is not None: + _path_params['org_id'] = org_id + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/organizations/{org_id}/users', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/src/codegen/api/clients/openapi_client/api_client.py b/src/codegen/agents/client/openapi_client/api_client.py similarity index 98% rename from src/codegen/api/clients/openapi_client/api_client.py rename to src/codegen/agents/client/openapi_client/api_client.py index 9c8253061..c3fa8cc5f 100644 --- a/src/codegen/api/clients/openapi_client/api_client.py +++ b/src/codegen/agents/client/openapi_client/api_client.py @@ -26,11 +26,11 @@ from typing import Tuple, Optional, List, Dict, Union from pydantic import SecretStr -from openapi_client.configuration import Configuration -from openapi_client.api_response import ApiResponse, T as ApiResponseT -import openapi_client.models -from openapi_client import rest -from openapi_client.exceptions import ( +from codegen.agents.client.openapi_client.configuration import Configuration +from codegen.agents.client.openapi_client.api_response import ApiResponse, T as ApiResponseT +import codegen.agents.client.openapi_client as openapi_client +from codegen.agents.client.openapi_client import rest +from codegen.agents.client.openapi_client.exceptions import ( ApiValueError, ApiException, BadRequestException, diff --git a/src/codegen/api/clients/openapi_client/api_response.py b/src/codegen/agents/client/openapi_client/api_response.py similarity index 100% rename from src/codegen/api/clients/openapi_client/api_response.py rename to src/codegen/agents/client/openapi_client/api_response.py diff --git a/src/codegen/api/clients/openapi_client/configuration.py b/src/codegen/agents/client/openapi_client/configuration.py similarity index 100% rename from src/codegen/api/clients/openapi_client/configuration.py rename to src/codegen/agents/client/openapi_client/configuration.py diff --git a/src/codegen/api/clients/openapi_client/exceptions.py b/src/codegen/agents/client/openapi_client/exceptions.py similarity index 100% rename from src/codegen/api/clients/openapi_client/exceptions.py rename to src/codegen/agents/client/openapi_client/exceptions.py diff --git a/src/codegen/agents/client/openapi_client/models/__init__.py b/src/codegen/agents/client/openapi_client/models/__init__.py new file mode 100644 index 000000000..5dd0f3718 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/__init__.py @@ -0,0 +1,26 @@ +# coding: utf-8 + +# flake8: noqa +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +# import models into model package +from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse +from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput +from codegen.agents.client.openapi_client.models.http_validation_error import HTTPValidationError +from codegen.agents.client.openapi_client.models.organization_response import OrganizationResponse +from codegen.agents.client.openapi_client.models.organization_settings import OrganizationSettings +from codegen.agents.client.openapi_client.models.page_organization_response import PageOrganizationResponse +from codegen.agents.client.openapi_client.models.page_user_response import PageUserResponse +from codegen.agents.client.openapi_client.models.user_response import UserResponse +from codegen.agents.client.openapi_client.models.validation_error import ValidationError +from codegen.agents.client.openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner diff --git a/src/codegen/agents/client/openapi_client/models/agent_run_response.py b/src/codegen/agents/client/openapi_client/models/agent_run_response.py new file mode 100644 index 000000000..9e0aa6651 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/agent_run_response.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AgentRunResponse(BaseModel): + """ + Represents an agent run in API responses + """ # noqa: E501 + id: StrictInt + organization_id: StrictInt + status: Optional[StrictStr] = None + created_at: Optional[StrictStr] = None + result: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["id", "organization_id", "status", "created_at", "result"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AgentRunResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if status (nullable) is None + # and model_fields_set contains the field + if self.status is None and "status" in self.model_fields_set: + _dict['status'] = None + + # set to None if created_at (nullable) is None + # and model_fields_set contains the field + if self.created_at is None and "created_at" in self.model_fields_set: + _dict['created_at'] = None + + # set to None if result (nullable) is None + # and model_fields_set contains the field + if self.result is None and "result" in self.model_fields_set: + _dict['result'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AgentRunResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "organization_id": obj.get("organization_id"), + "status": obj.get("status"), + "created_at": obj.get("created_at"), + "result": obj.get("result") + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/create_agent_run_input.py b/src/codegen/agents/client/openapi_client/models/create_agent_run_input.py new file mode 100644 index 000000000..0f04f2245 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/create_agent_run_input.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class CreateAgentRunInput(BaseModel): + """ + CreateAgentRunInput + """ # noqa: E501 + prompt: StrictStr + __properties: ClassVar[List[str]] = ["prompt"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateAgentRunInput from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateAgentRunInput from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "prompt": obj.get("prompt") + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/http_validation_error.py b/src/codegen/agents/client/openapi_client/models/http_validation_error.py new file mode 100644 index 000000000..055a24efc --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/http_validation_error.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from codegen.agents.client.openapi_client.models.validation_error import ValidationError +from typing import Optional, Set +from typing_extensions import Self + +class HTTPValidationError(BaseModel): + """ + HTTPValidationError + """ # noqa: E501 + detail: Optional[List[ValidationError]] = None + __properties: ClassVar[List[str]] = ["detail"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HTTPValidationError from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in detail (list) + _items = [] + if self.detail: + for _item_detail in self.detail: + if _item_detail: + _items.append(_item_detail.to_dict()) + _dict['detail'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HTTPValidationError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "detail": [ValidationError.from_dict(_item) for _item in obj["detail"]] if obj.get("detail") is not None else None + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/organization_response.py b/src/codegen/agents/client/openapi_client/models/organization_response.py new file mode 100644 index 000000000..35c304970 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/organization_response.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from codegen.agents.client.openapi_client.models.organization_settings import OrganizationSettings +from typing import Optional, Set +from typing_extensions import Self + +class OrganizationResponse(BaseModel): + """ + Represents an organization in API responses + """ # noqa: E501 + id: StrictInt + name: StrictStr + settings: OrganizationSettings + __properties: ClassVar[List[str]] = ["id", "name", "settings"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrganizationResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of settings + if self.settings: + _dict['settings'] = self.settings.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrganizationResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "name": obj.get("name"), + "settings": OrganizationSettings.from_dict(obj["settings"]) if obj.get("settings") is not None else None + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/organization_settings.py b/src/codegen/agents/client/openapi_client/models/organization_settings.py new file mode 100644 index 000000000..3e4836f8a --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/organization_settings.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class OrganizationSettings(BaseModel): + """ + OrganizationSettings + """ # noqa: E501 + enable_pr_creation: Optional[StrictBool] = True + enable_rules_detection: Optional[StrictBool] = True + __properties: ClassVar[List[str]] = ["enable_pr_creation", "enable_rules_detection"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OrganizationSettings from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OrganizationSettings from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "enable_pr_creation": obj.get("enable_pr_creation") if obj.get("enable_pr_creation") is not None else True, + "enable_rules_detection": obj.get("enable_rules_detection") if obj.get("enable_rules_detection") is not None else True + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/page_organization_response.py b/src/codegen/agents/client/openapi_client/models/page_organization_response.py new file mode 100644 index 000000000..82c92dedc --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/page_organization_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List +from codegen.agents.client.openapi_client.models.organization_response import OrganizationResponse +from typing import Optional, Set +from typing_extensions import Self + +class PageOrganizationResponse(BaseModel): + """ + PageOrganizationResponse + """ # noqa: E501 + items: List[OrganizationResponse] + total: StrictInt + page: StrictInt + size: StrictInt + pages: StrictInt + __properties: ClassVar[List[str]] = ["items", "total", "page", "size", "pages"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PageOrganizationResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in items (list) + _items = [] + if self.items: + for _item_items in self.items: + if _item_items: + _items.append(_item_items.to_dict()) + _dict['items'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PageOrganizationResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "items": [OrganizationResponse.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, + "total": obj.get("total"), + "page": obj.get("page"), + "size": obj.get("size"), + "pages": obj.get("pages") + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/page_user_response.py b/src/codegen/agents/client/openapi_client/models/page_user_response.py new file mode 100644 index 000000000..dec46b9de --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/page_user_response.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List +from codegen.agents.client.openapi_client.models.user_response import UserResponse +from typing import Optional, Set +from typing_extensions import Self + +class PageUserResponse(BaseModel): + """ + PageUserResponse + """ # noqa: E501 + items: List[UserResponse] + total: StrictInt + page: StrictInt + size: StrictInt + pages: StrictInt + __properties: ClassVar[List[str]] = ["items", "total", "page", "size", "pages"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PageUserResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in items (list) + _items = [] + if self.items: + for _item_items in self.items: + if _item_items: + _items.append(_item_items.to_dict()) + _dict['items'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PageUserResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "items": [UserResponse.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, + "total": obj.get("total"), + "page": obj.get("page"), + "size": obj.get("size"), + "pages": obj.get("pages") + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/user_response.py b/src/codegen/agents/client/openapi_client/models/user_response.py new file mode 100644 index 000000000..ea9d4a8be --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/user_response.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class UserResponse(BaseModel): + """ + Represents a user in API responses + """ # noqa: E501 + id: StrictInt + email: Optional[StrictStr] + github_user_id: StrictStr + github_username: StrictStr + avatar_url: Optional[StrictStr] + full_name: Optional[StrictStr] + __properties: ClassVar[List[str]] = ["id", "email", "github_user_id", "github_username", "avatar_url", "full_name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UserResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if email (nullable) is None + # and model_fields_set contains the field + if self.email is None and "email" in self.model_fields_set: + _dict['email'] = None + + # set to None if avatar_url (nullable) is None + # and model_fields_set contains the field + if self.avatar_url is None and "avatar_url" in self.model_fields_set: + _dict['avatar_url'] = None + + # set to None if full_name (nullable) is None + # and model_fields_set contains the field + if self.full_name is None and "full_name" in self.model_fields_set: + _dict['full_name'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UserResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "email": obj.get("email"), + "github_user_id": obj.get("github_user_id"), + "github_username": obj.get("github_username"), + "avatar_url": obj.get("avatar_url"), + "full_name": obj.get("full_name") + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/validation_error.py b/src/codegen/agents/client/openapi_client/models/validation_error.py new file mode 100644 index 000000000..d85c10eff --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/validation_error.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List +from codegen.agents.client.openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner +from typing import Optional, Set +from typing_extensions import Self + +class ValidationError(BaseModel): + """ + ValidationError + """ # noqa: E501 + loc: List[ValidationErrorLocInner] + msg: StrictStr + type: StrictStr + __properties: ClassVar[List[str]] = ["loc", "msg", "type"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ValidationError from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in loc (list) + _items = [] + if self.loc: + for _item_loc in self.loc: + if _item_loc: + _items.append(_item_loc.to_dict()) + _dict['loc'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ValidationError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "loc": [ValidationErrorLocInner.from_dict(_item) for _item in obj["loc"]] if obj.get("loc") is not None else None, + "msg": obj.get("msg"), + "type": obj.get("type") + }) + return _obj + + diff --git a/src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py b/src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py new file mode 100644 index 000000000..b44c2ccf3 --- /dev/null +++ b/src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py @@ -0,0 +1,138 @@ +# coding: utf-8 + +""" + Developer API + + API for application developers + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, ValidationError, field_validator +from typing import Optional +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict +from typing_extensions import Literal, Self +from pydantic import Field + +VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS = ["int", "str"] + +class ValidationErrorLocInner(BaseModel): + """ + ValidationErrorLocInner + """ + + # data type: str + anyof_schema_1_validator: Optional[StrictStr] = None + # data type: int + anyof_schema_2_validator: Optional[StrictInt] = None + if TYPE_CHECKING: + actual_instance: Optional[Union[int, str]] = None + else: + actual_instance: Any = None + any_of_schemas: Set[str] = { "int", "str" } + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator('actual_instance') + def actual_instance_must_validate_anyof(cls, v): + instance = ValidationErrorLocInner.model_construct() + error_messages = [] + # validate data type: str + try: + instance.anyof_schema_1_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: int + try: + instance.anyof_schema_2_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if error_messages: + # no match + raise ValueError("No match found when setting the actual_instance in ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + # deserialize data into str + try: + # validation + instance.anyof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_1_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into int + try: + # validation + instance.anyof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_2_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError("No match found when deserializing the JSON string into ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) + + diff --git a/src/codegen/api/clients/openapi_client/rest.py b/src/codegen/agents/client/openapi_client/rest.py similarity index 99% rename from src/codegen/api/clients/openapi_client/rest.py rename to src/codegen/agents/client/openapi_client/rest.py index e41059f82..1b9aa1e76 100644 --- a/src/codegen/api/clients/openapi_client/rest.py +++ b/src/codegen/agents/client/openapi_client/rest.py @@ -19,7 +19,7 @@ import urllib3 -from openapi_client.exceptions import ApiException, ApiValueError +from codegen.agents.client.openapi_client.exceptions import ApiException, ApiValueError SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} RESTResponseType = urllib3.HTTPResponse diff --git a/src/codegen/agents/constants.py b/src/codegen/agents/constants.py new file mode 100644 index 000000000..38555c96a --- /dev/null +++ b/src/codegen/agents/constants.py @@ -0,0 +1 @@ +CODEGEN_BASE_API_URL = "https://codegen-sh--rest-api.modal.run" \ No newline at end of file diff --git a/src/codegen/agents/scratch.ipynb b/src/codegen/agents/scratch.ipynb new file mode 100644 index 000000000..7e14276b2 --- /dev/null +++ b/src/codegen/agents/scratch.ipynb @@ -0,0 +1,56 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'openapi_client'", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m AgentsApi\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/dev/codegen-sdk/src/codegen/agents/client/openapi_client/api/__init__.py:4\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# flake8: noqa\u001b[39;00m\n\u001b[32m 2\u001b[39m \n\u001b[32m 3\u001b[39m \u001b[38;5;66;03m# import apis into api package\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m AgentsApi\n\u001b[32m 5\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01morganizations_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m OrganizationsApi\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01musers_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m UsersApi\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/dev/codegen-sdk/src/codegen/agents/client/openapi_client/api/agents_api.py:23\u001b[39m\n\u001b[32m 20\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mtyping\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Any, Optional\n\u001b[32m 21\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mmodels\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mcreate_agent_run_input\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m CreateAgentRunInput\n\u001b[32m---> \u001b[39m\u001b[32m23\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi_client\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ApiClient, RequestSerialized\n\u001b[32m 24\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi_response\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ApiResponse\n\u001b[32m 25\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mrest\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m RESTResponseType\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/dev/codegen-sdk/src/codegen/agents/client/openapi_client/api_client.py:31\u001b[39m\n\u001b[32m 29\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mconfiguration\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Configuration\n\u001b[32m 30\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi_response\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ApiResponse, T \u001b[38;5;28;01mas\u001b[39;00m ApiResponseT\n\u001b[32m---> \u001b[39m\u001b[32m31\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mmodels\u001b[39;00m\n\u001b[32m 32\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m rest\n\u001b[32m 33\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mexceptions\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m (\n\u001b[32m 34\u001b[39m ApiValueError,\n\u001b[32m 35\u001b[39m ApiException,\n\u001b[32m (...)\u001b[39m\u001b[32m 40\u001b[39m ServiceException\n\u001b[32m 41\u001b[39m )\n", + "\u001b[31mModuleNotFoundError\u001b[39m: No module named 'openapi_client'" + ] + } + ], + "source": [ + "from codegen.agents.client.openapi_client.api.agents_api import AgentsApi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/src/codegen/api/clients/.gitignore b/src/codegen/api/clients/.gitignore deleted file mode 100644 index 43995bd42..000000000 --- a/src/codegen/api/clients/.gitignore +++ /dev/null @@ -1,66 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ -venv/ -.venv/ -.python-version -.pytest_cache - -# Translations -*.mo -*.pot - -# Django stuff: -*.log - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -#Ipython Notebook -.ipynb_checkpoints diff --git a/src/codegen/api/clients/.gitlab-ci.yml b/src/codegen/api/clients/.gitlab-ci.yml deleted file mode 100644 index 156d5a581..000000000 --- a/src/codegen/api/clients/.gitlab-ci.yml +++ /dev/null @@ -1,31 +0,0 @@ -# NOTE: This file is auto generated by OpenAPI Generator. -# URL: https://openapi-generator.tech -# -# ref: https://docs.gitlab.com/ee/ci/README.html -# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml - -stages: - - test - -.pytest: - stage: test - script: - - pip install -r requirements.txt - - pip install -r test-requirements.txt - - pytest --cov=openapi_client - -pytest-3.8: - extends: .pytest - image: python:3.8-alpine -pytest-3.9: - extends: .pytest - image: python:3.9-alpine -pytest-3.10: - extends: .pytest - image: python:3.10-alpine -pytest-3.11: - extends: .pytest - image: python:3.11-alpine -pytest-3.12: - extends: .pytest - image: python:3.12-alpine diff --git a/src/codegen/api/clients/.openapi-generator-ignore b/src/codegen/api/clients/.openapi-generator-ignore deleted file mode 100644 index 7484ee590..000000000 --- a/src/codegen/api/clients/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/src/codegen/api/clients/.openapi-generator/FILES b/src/codegen/api/clients/.openapi-generator/FILES deleted file mode 100644 index be20b1fd2..000000000 --- a/src/codegen/api/clients/.openapi-generator/FILES +++ /dev/null @@ -1,23 +0,0 @@ -.github/workflows/python.yml -.gitignore -.gitlab-ci.yml -.openapi-generator-ignore -.travis.yml -README.md -git_push.sh -openapi_client/__init__.py -openapi_client/api/__init__.py -openapi_client/api_client.py -openapi_client/api_response.py -openapi_client/configuration.py -openapi_client/exceptions.py -openapi_client/models/__init__.py -openapi_client/py.typed -openapi_client/rest.py -pyproject.toml -requirements.txt -setup.cfg -setup.py -test-requirements.txt -test/__init__.py -tox.ini diff --git a/src/codegen/api/clients/.travis.yml b/src/codegen/api/clients/.travis.yml deleted file mode 100644 index ae1aaf0be..000000000 --- a/src/codegen/api/clients/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -# ref: https://docs.travis-ci.com/user/languages/python -language: python -python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - # uncomment the following if needed - #- "3.12-dev" # 3.12 development branch - #- "nightly" # nightly build -# command to install dependencies -install: - - "pip install -r requirements.txt" - - "pip install -r test-requirements.txt" -# command to run tests -script: pytest --cov=openapi_client diff --git a/src/codegen/api/clients/README.md b/src/codegen/api/clients/README.md deleted file mode 100644 index d42f334ef..000000000 --- a/src/codegen/api/clients/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# openapi-client -API for application developers - -This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - -- API version: 1.0.0 -- Package version: 1.0.0 -- Generator version: 7.12.0 -- Build package: org.openapitools.codegen.languages.PythonClientCodegen - -## Requirements. - -Python 3.8+ - -## Installation & Usage -### pip install - -If the python package is hosted on a repository, you can install directly using: - -```sh -pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git -``` -(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) - -Then import the package: -```python -import openapi_client -``` - -### Setuptools - -Install via [Setuptools](http://pypi.python.org/pypi/setuptools). - -```sh -python setup.py install --user -``` -(or `sudo python setup.py install` to install the package for all users) - -Then import the package: -```python -import openapi_client -``` - -### Tests - -Execute `pytest` to run the tests. - -## Getting Started - -Please follow the [installation procedure](#installation--usage) and then run the following: - -```python - -import openapi_client -from openapi_client.rest import ApiException -from pprint import pprint - -``` - -## Documentation for API Endpoints - -All URIs are relative to *http://localhost* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- - - -## Documentation For Models - - - - -## Documentation For Authorization - -Endpoints do not require authorization. - - -## Author - - - diff --git a/src/codegen/api/clients/git_push.sh b/src/codegen/api/clients/git_push.sh deleted file mode 100644 index f53a75d4f..000000000 --- a/src/codegen/api/clients/git_push.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 -git_host=$4 - -if [ "$git_host" = "" ]; then - git_host="github.com" - echo "[INFO] No command line input provided. Set \$git_host to $git_host" -fi - -if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=$(git remote) -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' diff --git a/src/codegen/api/clients/main.py b/src/codegen/api/clients/main.py deleted file mode 100644 index 5cd91de72..000000000 --- a/src/codegen/api/clients/main.py +++ /dev/null @@ -1,6 +0,0 @@ -def main(): - print("Hello from client!") - - -if __name__ == "__main__": - main() diff --git a/src/codegen/api/clients/openapi_client/__init__.py b/src/codegen/api/clients/openapi_client/__init__.py deleted file mode 100644 index 541cf3e01..000000000 --- a/src/codegen/api/clients/openapi_client/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding: utf-8 - -# flake8: noqa - -""" - Developer API - - API for application developers - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -__version__ = "1.0.0" - -# import apis into sdk package - -# import ApiClient -from openapi_client.api_response import ApiResponse -from openapi_client.api_client import ApiClient -from openapi_client.configuration import Configuration -from openapi_client.exceptions import OpenApiException -from openapi_client.exceptions import ApiTypeError -from openapi_client.exceptions import ApiValueError -from openapi_client.exceptions import ApiKeyError -from openapi_client.exceptions import ApiAttributeError -from openapi_client.exceptions import ApiException - -# import models into sdk package diff --git a/src/codegen/api/clients/openapi_client/api/__init__.py b/src/codegen/api/clients/openapi_client/api/__init__.py deleted file mode 100644 index c3bb408f1..000000000 --- a/src/codegen/api/clients/openapi_client/api/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# flake8: noqa - -# import apis into api package - diff --git a/src/codegen/api/clients/openapi_client/models/__init__.py b/src/codegen/api/clients/openapi_client/models/__init__.py deleted file mode 100644 index 6b49c0b94..000000000 --- a/src/codegen/api/clients/openapi_client/models/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# coding: utf-8 - -# flake8: noqa -""" - Developer API - - API for application developers - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -# import models into model package diff --git a/src/codegen/api/clients/openapi_client/py.typed b/src/codegen/api/clients/openapi_client/py.typed deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/codegen/api/clients/pyproject.toml b/src/codegen/api/clients/pyproject.toml deleted file mode 100644 index c969d16b0..000000000 --- a/src/codegen/api/clients/pyproject.toml +++ /dev/null @@ -1,82 +0,0 @@ -[project] -name = "client" -version = "0.1.0" -description = "Add your description here" -readme = "README.md" -requires-python = ">=3.12, <3.14" -dependencies = [] - -[tool.uv] -python = "^3.8" -urllib3 = ">= 1.25.3, < 3.0.0" -python-dateutil = ">= 2.8.2" -pydantic = ">= 2" -typing-extensions = ">= 4.7.1" - -pytest = ">= 7.2.1" -pytest-cov = ">= 2.8.1" -tox = ">= 3.9.0" -flake8 = ">= 4.0.0" -types-python-dateutil = ">= 2.8.19.14" -mypy = ">= 1.5" - - -[build-system] -requires = ["setuptools>=65.5.0", "setuptools-scm>=8.0.0"] -build-backend = "setuptools.build_meta" - -[tool.pylint.'MESSAGES CONTROL'] -extension-pkg-whitelist = "pydantic" - -[tool.mypy] -files = [ - "openapi_client", - #"test", # auto-generated tests - "tests", # hand-written tests -] -# TODO: enable "strict" once all these individual checks are passing -# strict = true - -# List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options -warn_unused_configs = true -warn_redundant_casts = true -warn_unused_ignores = true - -## Getting these passing should be easy -strict_equality = true -extra_checks = true - -## Strongly recommend enabling this one as soon as you can -check_untyped_defs = true - -## These shouldn't be too much additional work, but may be tricky to -## get passing if you use a lot of untyped libraries -disallow_subclassing_any = true -disallow_untyped_decorators = true -disallow_any_generics = true - -### These next few are various gradations of forcing use of type annotations -#disallow_untyped_calls = true -#disallow_incomplete_defs = true -#disallow_untyped_defs = true -# -### This one isn't too hard to get passing, but return on investment is lower -#no_implicit_reexport = true -# -### This one can be tricky to get passing if you use a lot of untyped libraries -#warn_return_any = true - -[[tool.mypy.overrides]] -module = ["openapi_client.configuration"] -warn_unused_ignores = true -strict_equality = true -extra_checks = true -check_untyped_defs = true -disallow_subclassing_any = true -disallow_untyped_decorators = true -disallow_any_generics = true -disallow_untyped_calls = true -disallow_incomplete_defs = true -disallow_untyped_defs = true -no_implicit_reexport = true -warn_return_any = true diff --git a/src/codegen/api/clients/requirements.txt b/src/codegen/api/clients/requirements.txt deleted file mode 100644 index 3c6f164cf..000000000 --- a/src/codegen/api/clients/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -urllib3 >= 1.25.3, < 3.0.0 -python_dateutil >= 2.8.2 -pydantic -typing-extensions >= 4.7.1 diff --git a/src/codegen/api/clients/script.py b/src/codegen/api/clients/script.py deleted file mode 100644 index 27df0c4b1..000000000 --- a/src/codegen/api/clients/script.py +++ /dev/null @@ -1,8 +0,0 @@ -from openapi_client.api_client import ApiClient -from openapi_client.configuration import Configuration - - -ApiClient(configuration=Configuration(access_token="sk-c0d6602a-e0e2-4ec7-ad3f-d079b3cad46b", host="https://codegen-sh--rest-api.modal.run")) - - - diff --git a/src/codegen/api/clients/setup.cfg b/src/codegen/api/clients/setup.cfg deleted file mode 100644 index 11433ee87..000000000 --- a/src/codegen/api/clients/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length=99 diff --git a/src/codegen/api/clients/setup.py b/src/codegen/api/clients/setup.py deleted file mode 100644 index 9efcd2270..000000000 --- a/src/codegen/api/clients/setup.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding: utf-8 - -""" - Developer API - - API for application developers - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from setuptools import setup, find_packages # noqa: H301 - -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools -NAME = "openapi-client" -VERSION = "1.0.0" -PYTHON_REQUIRES = ">= 3.8" -REQUIRES = [ - "urllib3 >= 1.25.3, < 3.0.0", - "python-dateutil >= 2.8.2", - "pydantic >= 2", - "typing-extensions >= 4.7.1", -] - -setup( - name=NAME, - version=VERSION, - description="Developer API", - author="OpenAPI Generator community", - author_email="team@openapitools.org", - url="", - keywords=["OpenAPI", "OpenAPI-Generator", "Developer API"], - install_requires=REQUIRES, - packages=find_packages(exclude=["test", "tests"]), - include_package_data=True, - long_description_content_type='text/markdown', - long_description="""\ - API for application developers - """, # noqa: E501 - package_data={"openapi_client": ["py.typed"]}, -) \ No newline at end of file diff --git a/src/codegen/api/clients/test-requirements.txt b/src/codegen/api/clients/test-requirements.txt deleted file mode 100644 index e98555c11..000000000 --- a/src/codegen/api/clients/test-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -pytest >= 7.2.1 -pytest-cov >= 2.8.1 -tox >= 3.9.0 -flake8 >= 4.0.0 -types-python-dateutil >= 2.8.19.14 -mypy >= 1.5 diff --git a/src/codegen/api/clients/test.ipynb b/src/codegen/api/clients/test.ipynb deleted file mode 100644 index 4f1eb9505..000000000 --- a/src/codegen/api/clients/test.ipynb +++ /dev/null @@ -1,30 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from app.generated.sdk.openapi_client.api_client import ApiClient\n", - "from app.generated.sdk.openapi_client.configuration import Configuration\n", - "\n", - "\n", - "ApiClient(configuration=Configuration(access_token=\"\", host=\"https://codegen-sh--rest-api.modal.run/\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.13.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/src/codegen/api/clients/test/__init__.py b/src/codegen/api/clients/test/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/codegen/api/clients/tox.ini b/src/codegen/api/clients/tox.ini deleted file mode 100644 index 1a9028b78..000000000 --- a/src/codegen/api/clients/tox.ini +++ /dev/null @@ -1,9 +0,0 @@ -[tox] -envlist = py3 - -[testenv] -deps=-r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -commands= - pytest --cov=openapi_client From 9922bf9d96bf8122a4ef99e23bf9bf9a42d73cde Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Mon, 7 Apr 2025 18:27:42 -0700 Subject: [PATCH 3/8] fix: update schema --- src/codegen/agents/README.md | 120 ++++++++++++++++++ src/codegen/agents/agent.py | 7 +- .../models/agent_run_response.py | 6 +- 3 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 src/codegen/agents/README.md diff --git a/src/codegen/agents/README.md b/src/codegen/agents/README.md new file mode 100644 index 000000000..303ecc6d8 --- /dev/null +++ b/src/codegen/agents/README.md @@ -0,0 +1,120 @@ +# Codegen Agents - Python SDK + +This module provides a Python client for interacting with the Codegen AI agents API. + +## Installation + +The Codegen Agent SDK is included as part of the Codegen package. Ensure you have the latest version installed: + +```bash +pip install codegen +``` + +## Usage + +### Basic Example + +```python +from codegen.agents.agent import Agent + +# Initialize the Agent with your organization ID and API token +agent = Agent( + org_id="11", # Your organization ID + token="your_api_token_here", # Your API authentication token + base_url="https://codegen-sh-rest-api.modal.run" # Optional - defaults to this URL +) + +# Run an agent with a prompt +task = agent.run(prompt="Which github repos can you currently access?") + +# Check the initial status +print(task.status) # Returns the current status of the task (e.g., "queued", "in_progress", etc.) + +# Refresh the task to get updated status +task.refresh() + +# Check the updated status +print(task.status) + +# Once task is complete, you can access the result +if task.status == "completed": + print(task.result) +``` + +### Agent Class + +The `Agent` class is the main entry point for interacting with Codegen AI agents: + +```python +Agent(token: str, org_id: Optional[int] = None, base_url: Optional[str] = CODEGEN_BASE_API_URL) +``` + +Parameters: +- `token` (required): Your API authentication token +- `org_id` (optional): Your organization ID. If not provided, defaults to environment variable `CODEGEN_ORG_ID` or "1" +- `base_url` (optional): API base URL. Defaults to "https://codegen-sh-rest-api.modal.run" + +### Methods + +#### run() + +```python +run(prompt: str) -> AgentTask +``` + +Runs an agent with the given prompt. + +Parameters: +- `prompt` (required): The instruction for the agent to execute + +Returns: +- An `AgentTask` object representing the running task + +#### get_status() + +```python +get_status() -> Optional[Dict[str, Any]] +``` + +Gets the status of the current task. + +Returns: +- A dictionary containing task status information (`id`, `status`, `result`), or `None` if no task has been run + +### AgentTask Class + +The `AgentTask` class represents a running or completed agent task: + +#### Attributes + +- `id`: The unique identifier for the task +- `org_id`: The organization ID +- `status`: Current status of the task (e.g., "queued", "in_progress", "completed", "failed") +- `result`: The task result (available when status is "completed") + +#### Methods + +##### refresh() + +```python +refresh() -> None +``` + +Refreshes the task status from the API. + +## Environment Variables + +- `CODEGEN_ORG_ID`: Default organization ID (used if `org_id` is not provided) + +## Error Handling + +Handle potential API errors using standard try/except blocks: + +```python +try: + task = agent.run(prompt="Your prompt here") + task.refresh() + print(task.status) +except Exception as e: + print(f"Error: {e}") +``` diff --git a/src/codegen/agents/agent.py b/src/codegen/agents/agent.py index dfae14df2..f681d7e5d 100644 --- a/src/codegen/agents/agent.py +++ b/src/codegen/agents/agent.py @@ -17,9 +17,10 @@ def __init__(self, task_data: AgentRunResponse, api_client: ApiClient, org_id: i self.org_id = org_id self.status = task_data.status self.result = task_data.result + self.web_url = task_data.web_url self._api_client = api_client self._agents_api = AgentsApi(api_client) - + def refresh(self) -> None: """Refresh the job status from the API.""" if self.id is None: @@ -81,7 +82,6 @@ def run(self, prompt: str) -> AgentTask: authorization=f"Bearer {self.token}", _headers={"Content-Type": "application/json"} ) - # Convert API response to dict for Job initialization job = AgentTask(agent_run_response, self.api_client, self.org_id) @@ -101,6 +101,7 @@ def get_status(self) -> Optional[Dict[str, Any]]: return { "id": self.current_job.id, "status": self.current_job.status, - "result": self.current_job.result + "result": self.current_job.result, + "web_url": self.current_job.web_url } return None diff --git a/src/codegen/agents/client/openapi_client/models/agent_run_response.py b/src/codegen/agents/client/openapi_client/models/agent_run_response.py index 9e0aa6651..3ae6f333a 100644 --- a/src/codegen/agents/client/openapi_client/models/agent_run_response.py +++ b/src/codegen/agents/client/openapi_client/models/agent_run_response.py @@ -31,7 +31,8 @@ class AgentRunResponse(BaseModel): status: Optional[StrictStr] = None created_at: Optional[StrictStr] = None result: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "organization_id", "status", "created_at", "result"] + web_url: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["id", "organization_id", "status", "created_at", "result", "web_url"] model_config = ConfigDict( populate_by_name=True, @@ -103,7 +104,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "organization_id": obj.get("organization_id"), "status": obj.get("status"), "created_at": obj.get("created_at"), - "result": obj.get("result") + "result": obj.get("result"), + "web_url": obj.get("web_url") }) return _obj From 2a62dfb5d452bdfb99d26eb10eab535d8b58a5bc Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Tue, 8 Apr 2025 10:40:55 -0700 Subject: [PATCH 4/8] tests --- tests/unit/codegen/agents/__init__.py | 1 + tests/unit/codegen/agents/test_agent.py | 308 +++++++++++++ tests/unit/codegen/agents/test_api_client.py | 408 ++++++++++++++++++ .../unit/codegen/agents/test_simple_agent.py | 113 +++++ 4 files changed, 830 insertions(+) create mode 100644 tests/unit/codegen/agents/__init__.py create mode 100644 tests/unit/codegen/agents/test_agent.py create mode 100644 tests/unit/codegen/agents/test_api_client.py create mode 100644 tests/unit/codegen/agents/test_simple_agent.py diff --git a/tests/unit/codegen/agents/__init__.py b/tests/unit/codegen/agents/__init__.py new file mode 100644 index 000000000..e2689cfcf --- /dev/null +++ b/tests/unit/codegen/agents/__init__.py @@ -0,0 +1 @@ +# Unit tests for codegen.agents package \ No newline at end of file diff --git a/tests/unit/codegen/agents/test_agent.py b/tests/unit/codegen/agents/test_agent.py new file mode 100644 index 000000000..c626bb2af --- /dev/null +++ b/tests/unit/codegen/agents/test_agent.py @@ -0,0 +1,308 @@ +import pytest +from unittest.mock import MagicMock, patch +from typing import Dict, Any +import os # Add missing import for os module + +from codegen.agents.agent import Agent, AgentTask +from codegen.agents.client.openapi_client.api_client import ApiClient +from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse +from codegen.agents.client.openapi_client.api.agents_api import AgentsApi +from codegen.agents.client.openapi_client.configuration import Configuration +from codegen.agents.constants import CODEGEN_BASE_API_URL + + +class TestAgentTask: + + @pytest.fixture + def agent_run_response(self): + """Create a mock AgentRunResponse""" + mock_response = MagicMock(spec=AgentRunResponse) + mock_response.id = "123" # Keep as string as this is likely the format from API + mock_response.status = "running" + mock_response.result = None + mock_response.web_url = "https://example.com/run/123" + return mock_response + + @pytest.fixture + def api_client(self): + """Create a mock ApiClient""" + mock_client = MagicMock() # Remove spec to allow dynamic attributes + mock_client.configuration = MagicMock() # Create configuration attribute + mock_client.configuration.access_token = "test-token" + return mock_client + + @pytest.fixture + def mock_agents_api(self): + """Create a proper mock for the AgentsApi""" + # Create a proper mock with a get method + mock_api = MagicMock(spec=AgentsApi) + return mock_api + + @pytest.fixture + def agent_task(self, agent_run_response, api_client, mock_agents_api): + """Create an AgentTask instance with mock dependencies""" + # Patch the AgentsApi constructor to return our mock + with patch('codegen.agents.agent.AgentsApi', return_value=mock_agents_api): + task = AgentTask(agent_run_response, api_client, org_id=42) + return task + + def test_init(self, agent_task, agent_run_response, api_client, mock_agents_api): + """Test initialization of AgentTask""" + assert agent_task.id == "123" + assert agent_task.org_id == 42 + assert agent_task.status == "running" + assert agent_task.result is None + assert agent_task.web_url == "https://example.com/run/123" + assert agent_task._api_client == api_client + assert agent_task._agents_api == mock_agents_api + + def test_refresh_without_id(self, agent_task, mock_agents_api): + """Test refresh method when job ID is None""" + agent_task.id = None + # Should return early without making API call + agent_task.refresh() + mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_not_called() + + def test_refresh_with_id(self, agent_task, mock_agents_api): + """Test refresh method updates job status""" + # Setup mock API response + mock_updated_response = { + "status": "completed", + "result": {"output": "Success!"} + } + mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_updated_response + + # Call refresh + agent_task.refresh() + + # Verify API was called with correct params + mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_called_once_with( + agent_run_id="123", # Use string ID as stored in agent_task.id + org_id=42, + authorization="Bearer test-token" + ) + + # Verify status was updated + assert agent_task.status == "completed" + assert agent_task.result == {"output": "Success!"} + + def test_refresh_with_dict_response(self, agent_task, mock_agents_api): + """Test refresh method when API returns dict instead of object""" + # Setup mock API response as dict + mock_updated_response = { + "status": "failed", + "result": {"error": "Something went wrong"} + } + mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_updated_response + + # Call refresh + agent_task.refresh() + + # Verify status was updated + assert agent_task.status == "failed" + assert agent_task.result == {"error": "Something went wrong"} + + +class TestAgent: + + @pytest.fixture + def mock_api_client(self): + """Create a mock ApiClient""" + with patch("codegen.agents.agent.ApiClient") as mock_client_class: + mock_client = MagicMock() # Remove spec to allow dynamic attributes + mock_client.configuration = MagicMock() # Create configuration attribute + mock_client.configuration.access_token = "test-token" + mock_client_class.return_value = mock_client + yield mock_client + + @pytest.fixture + def mock_agents_api(self): + """Create a mock AgentsApi""" + with patch("codegen.agents.agent.AgentsApi") as mock_api_class: + mock_api = MagicMock(spec=AgentsApi) + mock_api_class.return_value = mock_api + yield mock_api + + @pytest.fixture + def agent(self, mock_api_client, mock_agents_api): + """Create an Agent instance with mock dependencies""" + with patch.object(Configuration, "__init__", return_value=None) as mock_config: + agent = Agent(token="test-token", org_id=42) + # Verify config initialization + mock_config.assert_called_once_with(host=CODEGEN_BASE_API_URL, access_token="test-token") + return agent + + def test_init_with_explicit_org_id(self, mock_api_client, mock_agents_api): + """Test initialization with explicitly provided org_id""" + with patch.object(Configuration, "__init__", return_value=None): + agent = Agent(token="test-token", org_id=42) + assert agent.token == "test-token" + assert agent.org_id == 42 + assert agent.api_client == mock_api_client + assert agent.agents_api == mock_agents_api + assert agent.current_job is None + + def test_init_with_default_org_id(self, mock_api_client, mock_agents_api): + """Test initialization with default org_id""" + with patch.object(Configuration, "__init__", return_value=None): + with patch.dict("os.environ", {"CODEGEN_ORG_ID": "99"}): + agent = Agent(token="test-token") + assert agent.org_id == 99 + + def test_init_with_custom_base_url(self, mock_api_client): + """Test initialization with custom base URL""" + with patch.object(Configuration, "__init__", return_value=None) as mock_config: + custom_url = "https://custom-api.example.com" + agent = Agent(token="test-token", org_id=42, base_url=custom_url) + mock_config.assert_called_once_with(host=custom_url, access_token="test-token") + + def test_run(self, agent, mock_agents_api): + """Test run method creates and returns job""" + # Setup mock API response + mock_run_response = MagicMock(spec=AgentRunResponse) + mock_run_response.id = "123" + mock_run_response.status = "running" + mock_run_response.result = None + mock_run_response.web_url = "https://example.com/run/123" + mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.return_value = mock_run_response + + # Call run + job = agent.run("Test prompt") + + # Verify API call + mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.assert_called_once() + call_args = mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.call_args + assert call_args[1]["org_id"] == 42 + assert call_args[1]["authorization"] == "Bearer test-token" + assert call_args[1]["_headers"] == {"Content-Type": "application/json"} + assert call_args[1]["create_agent_run_input"].prompt == "Test prompt" + + # Verify job + assert isinstance(job, AgentTask) + assert job.id == "123" + assert job.status == "running" + assert agent.current_job == job + + def test_get_status_with_no_job(self, agent): + """Test get_status when no job has been run""" + assert agent.get_status() is None + + def test_get_status_with_job(self, agent): + """Test get_status returns current job status""" + # Setup mock job + mock_job = MagicMock(spec=AgentTask) + mock_job.id = "123" + mock_job.status = "completed" + mock_job.result = {"output": "Success!"} + mock_job.web_url = "https://example.com/run/123" + + agent.current_job = mock_job + + # Call get_status + status = agent.get_status() + + # Verify job was refreshed + mock_job.refresh.assert_called_once() + + # Verify status + assert status == { + "id": "123", + "status": "completed", + "result": {"output": "Success!"}, + "web_url": "https://example.com/run/123" + } + + +# Integration-like tests +class TestAgentIntegration: + + @pytest.fixture + def mock_response(self): + """Create a mock response for API calls""" + mock_response = MagicMock() # Remove spec=AgentRunResponse + mock_response.id = "987" + mock_response.status = "running" + mock_response.result = None + mock_response.web_url = "https://example.com/run/987" + return mock_response + + @pytest.fixture + def mock_updated_response(self): + """Create a mock updated response for API calls""" + mock_updated = { + "id": "987", + "status": "completed", + "result": {"output": "Task completed successfully"}, + "web_url": "https://example.com/run/987" + } + + return mock_updated + + def test_full_workflow(self, mock_response, mock_updated_response): + """Test a complete agent workflow from initialization to status check""" + with patch("codegen.agents.agent.ApiClient") as mock_api_client_class, \ + patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, \ + patch.object(Configuration, "__init__", return_value=None): + + # Setup mocks + mock_api_client = MagicMock() # Remove spec to allow dynamic attributes + mock_api_client.configuration = MagicMock() # Create configuration attribute + mock_api_client.configuration.access_token = "test-token" + mock_api_client_class.return_value = mock_api_client + + # Setup agents API mock + mock_agents_api = MagicMock(spec=AgentsApi) + mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.return_value = mock_response + mock_agents_api_class.return_value = mock_agents_api + + # We're patching the same class for both the Agent and AgentTask + mock_inner_agents_api = mock_agents_api + mock_inner_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_updated_response + + # Initialize agent + agent = Agent(token="test-token", org_id=123) + + # Run agent + job = agent.run("Execute this instruction") + + # Verify job properties + assert job.id == "987" + assert job.status == "running" + assert job.result is None + + # Check status + status = agent.get_status() + + # Verify API calls + mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_called_once_with( + agent_run_id="987", # Use string ID + org_id=123, + authorization="Bearer test-token" + ) + + # Verify status + assert isinstance(status, dict) + assert status["id"] == "987" + assert status["status"] == "completed" + assert status["result"] == {"output": "Task completed successfully"} + assert status["web_url"] == "https://example.com/run/987" + + def test_exception_handling(self): + """Test handling of API exceptions during agent run""" + with patch("codegen.agents.agent.ApiClient"), \ + patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, \ + patch.object(Configuration, "__init__", return_value=None): + + # Setup API to raise exception + mock_agents_api = MagicMock(spec=AgentsApi) + mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.side_effect = Exception("API Error") + mock_agents_api_class.return_value = mock_agents_api + + # Initialize agent + agent = Agent(token="test-token", org_id=123) + + # Run agent and expect exception + with pytest.raises(Exception) as excinfo: + agent.run("Execute this instruction") + + assert "API Error" in str(excinfo.value) \ No newline at end of file diff --git a/tests/unit/codegen/agents/test_api_client.py b/tests/unit/codegen/agents/test_api_client.py new file mode 100644 index 000000000..e563f98bf --- /dev/null +++ b/tests/unit/codegen/agents/test_api_client.py @@ -0,0 +1,408 @@ +import pytest +import json +import datetime +import decimal +from unittest.mock import MagicMock, patch +from enum import Enum +from typing import Dict, List, Optional, Tuple, Any, Union +from pydantic import SecretStr + +from codegen.agents.client.openapi_client.api_client import ApiClient +from codegen.agents.client.openapi_client.configuration import Configuration +from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.exceptions import ApiException, ApiValueError + + +class TestEnum(Enum): + VALUE1 = "value1" + VALUE2 = "value2" + + +class TestModel: + def __init__(self, name: str, value: int): + self.name = name + self.value = value + + def to_dict(self): + return {"name": self.name, "value": self.value} + + +class TestApiClient: + + @pytest.fixture + def api_client(self): + config = Configuration() + # Mock the RESTClientObject to avoid making actual HTTP requests + with patch("codegen.agents.client.openapi_client.rest.RESTClientObject") as mock_rest: + client = ApiClient(configuration=config) + # Return the client with mocked rest_client + yield client + + def test_init_default_configuration(self): + """Test initialization with default configuration""" + with patch("codegen.agents.client.openapi_client.configuration.Configuration.get_default") as mock_get_default: + mock_config = MagicMock() + mock_get_default.return_value = mock_config + with patch("codegen.agents.client.openapi_client.rest.RESTClientObject"): + client = ApiClient() + assert client.configuration == mock_config + assert client.user_agent == 'OpenAPI-Generator/1.0.0/python' + + def test_user_agent(self, api_client): + """Test user agent getter and setter""" + api_client.user_agent = "TestAgent/1.0" + assert api_client.user_agent == "TestAgent/1.0" + assert api_client.default_headers["User-Agent"] == "TestAgent/1.0" + + def test_set_default_header(self, api_client): + """Test setting default header""" + api_client.set_default_header("Custom-Header", "Custom-Value") + assert api_client.default_headers["Custom-Header"] == "Custom-Value" + + def test_sanitize_for_serialization_none(self, api_client): + """Test sanitization of None value""" + assert api_client.sanitize_for_serialization(None) is None + + def test_sanitize_for_serialization_enum(self, api_client): + """Test sanitization of Enum value""" + assert api_client.sanitize_for_serialization(TestEnum.VALUE1) == "value1" + + def test_sanitize_for_serialization_secret_str(self, api_client): + """Test sanitization of SecretStr value""" + secret = SecretStr("secret_value") + assert api_client.sanitize_for_serialization(secret) == "secret_value" + + def test_sanitize_for_serialization_primitive(self, api_client): + """Test sanitization of primitive values""" + assert api_client.sanitize_for_serialization("string") == "string" + assert api_client.sanitize_for_serialization(123) == 123 + assert api_client.sanitize_for_serialization(True) == True + assert api_client.sanitize_for_serialization(b"bytes") == b"bytes" + + def test_sanitize_for_serialization_list(self, api_client): + """Test sanitization of list values""" + data = [1, "string", None] + assert api_client.sanitize_for_serialization(data) == [1, "string", None] + + def test_sanitize_for_serialization_tuple(self, api_client): + """Test sanitization of tuple values""" + data = (1, "string", None) + assert api_client.sanitize_for_serialization(data) == (1, "string", None) + + def test_sanitize_for_serialization_datetime(self, api_client): + """Test sanitization of datetime values""" + dt = datetime.datetime(2022, 1, 1, 12, 0, 0) + assert api_client.sanitize_for_serialization(dt) == "2022-01-01T12:00:00" + + date = datetime.date(2022, 1, 1) + assert api_client.sanitize_for_serialization(date) == "2022-01-01" + + def test_sanitize_for_serialization_decimal(self, api_client): + """Test sanitization of Decimal values""" + dec = decimal.Decimal("123.45") + assert api_client.sanitize_for_serialization(dec) == "123.45" + + def test_sanitize_for_serialization_dict(self, api_client): + """Test sanitization of dict values""" + data = {"key1": "value1", "key2": 123, "key3": None} + assert api_client.sanitize_for_serialization(data) == data + + def test_sanitize_for_serialization_model(self, api_client): + """Test sanitization of OpenAPI model""" + model = TestModel("test", 123) + assert api_client.sanitize_for_serialization(model) == {"name": "test", "value": 123} + + def test_deserialize_primitive(self, api_client): + """Test deserialization of primitive values""" + # Testing through __deserialize method + assert api_client._ApiClient__deserialize_primitive("123", int) == 123 + assert api_client._ApiClient__deserialize_primitive("true", bool) == True + assert api_client._ApiClient__deserialize_primitive("12.34", float) == 12.34 + + def test_deserialize_date(self, api_client): + """Test deserialization of date values""" + date_str = "2022-01-01" + result = api_client._ApiClient__deserialize_date(date_str) + assert isinstance(result, datetime.date) + assert result.year == 2022 + assert result.month == 1 + assert result.day == 1 + + def test_deserialize_datetime(self, api_client): + """Test deserialization of datetime values""" + dt_str = "2022-01-01T12:00:00Z" + result = api_client._ApiClient__deserialize_datetime(dt_str) + assert isinstance(result, datetime.datetime) + assert result.year == 2022 + assert result.month == 1 + assert result.day == 1 + assert result.hour == 12 + assert result.minute == 0 + assert result.second == 0 + + def test_deserialize_enum(self, api_client): + """Test deserialization of enum values""" + assert api_client._ApiClient__deserialize_enum("value1", TestEnum) == TestEnum.VALUE1 + + # Test exception case + with pytest.raises(ApiException): + api_client._ApiClient__deserialize_enum("invalid", TestEnum) + + def test_parameters_to_tuples(self, api_client): + """Test parameters_to_tuples method""" + # Test with dictionary + params = {"param1": "value1", "param2": "value2"} + result = api_client.parameters_to_tuples(params, None) + assert result == [("param1", "value1"), ("param2", "value2")] + + # Test with list of tuples + params = [("param1", "value1"), ("param2", "value2")] + result = api_client.parameters_to_tuples(params, None) + assert result == params + + # Test with collection format + params = {"param1": ["value1", "value2", "value3"]} + collection_formats = {"param1": "csv"} + result = api_client.parameters_to_tuples(params, collection_formats) + assert result == [("param1", "value1,value2,value3")] + + # Test with 'multi' collection format + params = {"param1": ["value1", "value2", "value3"]} + collection_formats = {"param1": "multi"} + result = api_client.parameters_to_tuples(params, collection_formats) + assert result == [("param1", "value1"), ("param1", "value2"), ("param1", "value3")] + + def test_parameters_to_url_query(self, api_client): + """Test parameters_to_url_query method""" + # Test basic parameters + params = {"param1": "value1", "param2": "value2"} + result = api_client.parameters_to_url_query(params, None) + assert result == "param1=value1¶m2=value2" + + # Test with boolean values + params = {"param1": True, "param2": False} + result = api_client.parameters_to_url_query(params, None) + assert result == "param1=true¶m2=false" + + # Test with numeric values + params = {"param1": 123, "param2": 45.67} + result = api_client.parameters_to_url_query(params, None) + assert result == "param1=123¶m2=45.67" + + # Test with dict values (should be JSON serialized) + params = {"param1": {"key": "value"}} + result = api_client.parameters_to_url_query(params, None) + assert result == 'param1=%7B%22key%22%3A%20%22value%22%7D' + + # Test with 'multi' collection format + params = {"param1": ["value1", "value2", "value3"]} + collection_formats = {"param1": "multi"} + result = api_client.parameters_to_url_query(params, collection_formats) + assert result == "param1=value1¶m1=value2¶m1=value3" + + def test_select_header_accept(self, api_client): + """Test select_header_accept method""" + # Test empty accepts + assert api_client.select_header_accept([]) is None + + # Test with JSON in accepts + accepts = ["application/xml", "application/json", "text/plain"] + assert api_client.select_header_accept(accepts) == "application/json" + + # Test without JSON in accepts + accepts = ["application/xml", "text/plain"] + assert api_client.select_header_accept(accepts) == "application/xml" + + def test_select_header_content_type(self, api_client): + """Test select_header_content_type method""" + # Test empty content types + assert api_client.select_header_content_type([]) is None + + # Test with JSON in content types + content_types = ["application/xml", "application/json", "text/plain"] + assert api_client.select_header_content_type(content_types) == "application/json" + + # Test without JSON in content types + content_types = ["application/xml", "text/plain"] + assert api_client.select_header_content_type(content_types) == "application/xml" + + def test_update_params_for_auth(self, api_client): + """Test update_params_for_auth method""" + # Setup mock configuration + api_client.configuration = MagicMock() + api_client.configuration.auth_settings.return_value = { + "api_key": { + "in": "header", + "key": "X-API-KEY", + "value": "test-api-key", + "type": "apiKey" + }, + "query_param": { + "in": "query", + "key": "api_key", + "value": "test-query-key", + "type": "apiKey" + }, + "cookie_auth": { + "in": "cookie", + "key": "session", + "value": "test-cookie", + "type": "apiKey" + } + } + + # Test authentication in header + headers = {} + queries = [] + api_client.update_params_for_auth(headers, queries, ["api_key"], "", "", None) + assert headers == {"X-API-KEY": "test-api-key"} + + # Test authentication in query + headers = {} + queries = [] + api_client.update_params_for_auth(headers, queries, ["query_param"], "", "", None) + assert queries == [("api_key", "test-query-key")] + + # Test authentication in cookie + headers = {} + queries = [] + api_client.update_params_for_auth(headers, queries, ["cookie_auth"], "", "", None) + assert headers == {"Cookie": "test-cookie"} + + # Test with request_auth override + headers = {} + queries = [] + request_auth = { + "in": "header", + "key": "X-CUSTOM-KEY", + "value": "custom-value", + "type": "apiKey" + } + api_client.update_params_for_auth(headers, queries, ["api_key"], "", "", None, request_auth) + assert headers == {"X-CUSTOM-KEY": "custom-value"} + + # Test with invalid auth location + invalid_auth = { + "in": "invalid", + "key": "x-key", + "value": "value", + "type": "apiKey" + } + with pytest.raises(ApiValueError): + api_client._apply_auth_params({}, [], "", "", None, invalid_auth) + + def test_param_serialize(self, api_client): + """Test param_serialize method""" + with patch.object(api_client, 'sanitize_for_serialization') as mock_sanitize, \ + patch.object(api_client, 'default_headers', {}): # Empty the default headers + # Set return values for sanitize_for_serialization + mock_sanitize.side_effect = lambda x: x + + # Test with basic parameters + method = "GET" + resource_path = "/test/{id}" + path_params = {"id": "123"} + query_params = {"query": "value"} + header_params = {"header": "value"} + body = {"body": "content"} + + result = api_client.param_serialize( + method, resource_path, path_params, query_params, + header_params, body, None, None, None, None, None + ) + + # Verify result + assert isinstance(result, tuple) + assert result[0] == "GET" # method + assert "/test/123" in result[1] # url + assert "query=value" in result[1] # query params in url + assert "header" in result[2] # header_params contains 'header' key + assert result[2]["header"] == "value" # header_params has correct value + assert result[3] == {"body": "content"} # body + + def test_call_api(self, api_client): + """Test call_api method""" + # Mock the rest_client.request method + api_client.rest_client.request = MagicMock() + mock_response = MagicMock() + api_client.rest_client.request.return_value = mock_response + + # Call the method + response = api_client.call_api( + "GET", + "https://api.example.com/test", + {"header": "value"}, + {"body": "content"}, + [("param", "value")], + 30 + ) + + # Verify the call to rest_client.request + api_client.rest_client.request.assert_called_once_with( + "GET", + "https://api.example.com/test", + headers={"header": "value"}, + body={"body": "content"}, + post_params=[("param", "value")], + _request_timeout=30 + ) + + # Verify the result + assert response == mock_response + + # Test exception case + api_client.rest_client.request.side_effect = ApiException(400) + with pytest.raises(ApiException): + api_client.call_api("GET", "https://api.example.com/test") + + def test_response_deserialize(self, api_client): + """Test response_deserialize method""" + # Mock RESTResponse + response_data = MagicMock() + response_data.status = 200 + response_data.data = b'{"name": "test", "value": 123}' + response_data.getheader.return_value = "application/json" + response_data.getheaders.return_value = {"Content-Type": "application/json"} + + # Create a mock response to return + mock_api_response = MagicMock(spec=ApiResponse) + + # Mock deserialize method and ApiResponse constructor + with patch.object(api_client, 'deserialize') as mock_deserialize, \ + patch("codegen.agents.client.openapi_client.api_client.ApiResponse", return_value=mock_api_response) as mock_api_response_class: + mock_deserialize.return_value = {"name": "test", "value": 123} + + # Test successful response deserialization + response_types_map = {"200": "TestModel"} + result = api_client.response_deserialize(response_data, response_types_map) + + # Verify ApiResponse was called with correct params + mock_api_response_class.assert_called_once_with( + status_code=200, + data={"name": "test", "value": 123}, + headers={"Content-Type": "application/json"}, + raw_data=response_data.data + ) + + # Verify the result + assert result == mock_api_response + + def test_response_deserialize_error(self, api_client): + """Test response_deserialize method with error response""" + # Mock RESTResponse for error + response_data = MagicMock() + response_data.status = 400 + response_data.data = b'{"error": "Bad Request"}' + response_data.getheader.return_value = "application/json" + response_data.getheaders.return_value = {"Content-Type": "application/json"} + + # Mock methods + with patch.object(api_client, 'deserialize') as mock_deserialize, \ + patch("codegen.agents.client.openapi_client.exceptions.ApiException.from_response") as mock_exception: + mock_deserialize.return_value = {"error": "Bad Request"} + mock_exception.side_effect = ApiException(400) + + # Test error response + response_types_map = {"400": "ErrorModel"} + with pytest.raises(ApiException): + api_client.response_deserialize(response_data, response_types_map) \ No newline at end of file diff --git a/tests/unit/codegen/agents/test_simple_agent.py b/tests/unit/codegen/agents/test_simple_agent.py new file mode 100644 index 000000000..dd3d63eb8 --- /dev/null +++ b/tests/unit/codegen/agents/test_simple_agent.py @@ -0,0 +1,113 @@ +""" +Simplified test for the Agent class focusing on public interfaces. +This approach avoids the complexity of mocking internal implementations. +""" +import pytest +from unittest.mock import MagicMock, patch, ANY +from codegen.agents.agent import Agent +from codegen.agents.constants import CODEGEN_BASE_API_URL + + +class TestAgent: + """Test the public interface of the Agent class.""" + + @pytest.fixture + def mock_agents_api(self): + """Create a mock for the AgentsApi.""" + mock_api = MagicMock() + # Set up response for create_agent_run + mock_create_response = MagicMock() + mock_create_response.id = 123 + mock_create_response.status = "running" + mock_create_response.result = None + mock_create_response.web_url = "https://example.com/agent/123" + + # Set up response for get_agent_run + mock_get_response = MagicMock() + mock_get_response.status = "completed" + mock_get_response.result = {"output": "Task completed successfully"} + + # Configure the mock methods + mock_api.create_agent_run_v1_organizations_org_id_agent_run_post.return_value = mock_create_response + mock_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_get_response + + return mock_api + + @pytest.fixture + def agent(self, mock_agents_api): + """Create an Agent with mocked dependencies.""" + with patch("codegen.agents.agent.ApiClient"), \ + patch("codegen.agents.agent.AgentsApi", return_value=mock_agents_api), \ + patch("codegen.agents.agent.Configuration"): + agent = Agent(token="test-token", org_id=42) + return agent + + def test_initialization(self): + """Test Agent initialization with different parameters.""" + # Test with explicit org_id + with patch("codegen.agents.agent.ApiClient"), \ + patch("codegen.agents.agent.AgentsApi"), \ + patch("codegen.agents.agent.Configuration") as mock_config: + + agent = Agent(token="test-token", org_id=42) + assert agent.token == "test-token" + assert agent.org_id == 42 + assert agent.current_job is None + + # Verify Configuration was initialized correctly + mock_config.assert_called_once_with(host=CODEGEN_BASE_API_URL, access_token="test-token") + + # Test with env var for org_id + with patch.dict("os.environ", {"CODEGEN_ORG_ID": "99"}): + agent = Agent(token="test-token") + assert agent.org_id == 99 + + # Test with custom base URL + custom_url = "https://custom-api.example.com" + agent = Agent(token="test-token", org_id=42, base_url=custom_url) + mock_config.assert_called_with(host=custom_url, access_token="test-token") + + def test_run_agent(self, agent, mock_agents_api): + """Test running an agent with a prompt.""" + # Run the agent + job = agent.run("Test prompt") + + # Verify the API was called correctly + mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.assert_called_once() + call_args = mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.call_args[1] + assert call_args["org_id"] == 42 + assert call_args["authorization"] == "Bearer test-token" + assert call_args["_headers"] == {"Content-Type": "application/json"} + assert call_args["create_agent_run_input"].prompt == "Test prompt" + + # Verify the job properties + assert job.id == 123 + assert job.status == "running" + assert job.result is None + assert job.web_url == "https://example.com/agent/123" + assert agent.current_job == job + + def test_get_status_no_job(self, agent): + """Test get_status when no job has been run.""" + assert agent.get_status() is None + + + def test_exception_handling(self): + """Test handling of API exceptions during agent run.""" + with patch("codegen.agents.agent.ApiClient"), \ + patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, \ + patch("codegen.agents.agent.Configuration"): + + # Setup API to raise exception + mock_agents_api = MagicMock() + mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.side_effect = Exception("API Error") + mock_agents_api_class.return_value = mock_agents_api + + # Initialize agent + agent = Agent(token="test-token", org_id=123) + + # Run agent and expect exception + with pytest.raises(Exception) as excinfo: + agent.run("Execute this instruction") + + assert "API Error" in str(excinfo.value) \ No newline at end of file From 5a1cf561fea4c1287b3223ae3be8b9024e15406b Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Tue, 8 Apr 2025 10:53:21 -0700 Subject: [PATCH 5/8] test fix --- tests/unit/codegen/agents/test_agent.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/codegen/agents/test_agent.py b/tests/unit/codegen/agents/test_agent.py index c626bb2af..dfa8787b5 100644 --- a/tests/unit/codegen/agents/test_agent.py +++ b/tests/unit/codegen/agents/test_agent.py @@ -77,7 +77,7 @@ def test_refresh_with_id(self, agent_task, mock_agents_api): # Verify API was called with correct params mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_called_once_with( - agent_run_id="123", # Use string ID as stored in agent_task.id + agent_run_id=123, # Use string ID as stored in agent_task.id org_id=42, authorization="Bearer test-token" ) @@ -220,7 +220,7 @@ class TestAgentIntegration: def mock_response(self): """Create a mock response for API calls""" mock_response = MagicMock() # Remove spec=AgentRunResponse - mock_response.id = "987" + mock_response.id = 987 mock_response.status = "running" mock_response.result = None mock_response.web_url = "https://example.com/run/987" @@ -230,7 +230,7 @@ def mock_response(self): def mock_updated_response(self): """Create a mock updated response for API calls""" mock_updated = { - "id": "987", + "id": 987, "status": "completed", "result": {"output": "Task completed successfully"}, "web_url": "https://example.com/run/987" @@ -266,7 +266,7 @@ def test_full_workflow(self, mock_response, mock_updated_response): job = agent.run("Execute this instruction") # Verify job properties - assert job.id == "987" + assert job.id == 987 assert job.status == "running" assert job.result is None @@ -275,14 +275,14 @@ def test_full_workflow(self, mock_response, mock_updated_response): # Verify API calls mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_called_once_with( - agent_run_id="987", # Use string ID + agent_run_id=987, org_id=123, authorization="Bearer test-token" ) # Verify status assert isinstance(status, dict) - assert status["id"] == "987" + assert status["id"] == 987 assert status["status"] == "completed" assert status["result"] == {"output": "Task completed successfully"} assert status["web_url"] == "https://example.com/run/987" From 3da493f9826b94fda1e35e778a3bd52fbea3001d Mon Sep 17 00:00:00 2001 From: rushilpatel0 <171610820+rushilpatel0@users.noreply.github.com> Date: Tue, 8 Apr 2025 17:54:23 +0000 Subject: [PATCH 6/8] Automated pre-commit update --- src/codegen/__init__.py | 2 +- src/codegen/agents/README.md | 6 +- src/codegen/agents/__init__.py | 7 +- src/codegen/agents/agent.py | 63 +- src/codegen/agents/client/README.md | 14 +- .../agents/client/openapi_client/__init__.py | 11 +- .../client/openapi_client/api/__init__.py | 1 - .../client/openapi_client/api/agents_api.py | 912 +++++----------- .../openapi_client/api/organizations_api.py | 500 +++------ .../client/openapi_client/api/users_api.py | 973 +++++------------- .../client/openapi_client/api_client.py | 346 ++----- .../client/openapi_client/api_response.py | 20 +- .../client/openapi_client/configuration.py | 129 +-- .../client/openapi_client/exceptions.py | 79 +- .../client/openapi_client/models/__init__.py | 11 +- .../models/agent_run_response.py | 74 +- .../models/create_agent_run_input.py | 46 +- .../models/http_validation_error.py | 53 +- .../models/organization_response.py | 53 +- .../models/organization_settings.py | 56 +- .../models/page_organization_response.py | 65 +- .../models/page_user_response.py | 65 +- .../openapi_client/models/user_response.py | 72 +- .../openapi_client/models/validation_error.py | 55 +- .../models/validation_error_loc_inner.py | 54 +- .../agents/client/openapi_client/rest.py | 148 +-- src/codegen/agents/constants.py | 2 +- src/codegen/agents/scratch.ipynb | 19 +- tests/unit/codegen/agents/__init__.py | 2 +- tests/unit/codegen/agents/test_agent.py | 147 ++- tests/unit/codegen/agents/test_api_client.py | 209 ++-- .../unit/codegen/agents/test_simple_agent.py | 59 +- 32 files changed, 1398 insertions(+), 2855 deletions(-) diff --git a/src/codegen/__init__.py b/src/codegen/__init__.py index f464305c7..d3244eb5d 100644 --- a/src/codegen/__init__.py +++ b/src/codegen/__init__.py @@ -1,8 +1,8 @@ +from codegen.agents.agent import Agent from codegen.cli.sdk.decorator import function from codegen.cli.sdk.functions import Function from codegen.extensions.events.codegen_app import CodegenApp from codegen.sdk.core.codebase import Codebase from codegen.shared.enums.programming_language import ProgrammingLanguage -from codegen.agents.agent import Agent __all__ = ["Agent", "Codebase", "CodegenApp", "Function", "ProgrammingLanguage", "function"] diff --git a/src/codegen/agents/README.md b/src/codegen/agents/README.md index 303ecc6d8..254ed4bc9 100644 --- a/src/codegen/agents/README.md +++ b/src/codegen/agents/README.md @@ -21,7 +21,7 @@ from codegen.agents.agent import Agent agent = Agent( org_id="11", # Your organization ID token="your_api_token_here", # Your API authentication token - base_url="https://codegen-sh-rest-api.modal.run" # Optional - defaults to this URL + base_url="https://codegen-sh-rest-api.modal.run", # Optional - defaults to this URL ) # Run an agent with a prompt @@ -50,6 +50,7 @@ Agent(token: str, org_id: Optional[int] = None, base_url: Optional[str] = CODEGE ``` Parameters: + - `token` (required): Your API authentication token - `org_id` (optional): Your organization ID. If not provided, defaults to environment variable `CODEGEN_ORG_ID` or "1" - `base_url` (optional): API base URL. Defaults to "https://codegen-sh-rest-api.modal.run" @@ -65,9 +66,11 @@ run(prompt: str) -> AgentTask Runs an agent with the given prompt. Parameters: + - `prompt` (required): The instruction for the agent to execute Returns: + - An `AgentTask` object representing the running task #### get_status() @@ -79,6 +82,7 @@ get_status() -> Optional[Dict[str, Any]] Gets the status of the current task. Returns: + - A dictionary containing task status information (`id`, `status`, `result`), or `None` if no task has been run ### AgentTask Class diff --git a/src/codegen/agents/__init__.py b/src/codegen/agents/__init__.py index ee1c6da1a..d428226e3 100644 --- a/src/codegen/agents/__init__.py +++ b/src/codegen/agents/__init__.py @@ -1,6 +1,5 @@ -""" -Codegen Agent API module. -""" +"""Codegen Agent API module.""" + from codegen.agents.agent import Agent -__all__ = ["Agent"] \ No newline at end of file +__all__ = ["Agent"] diff --git a/src/codegen/agents/agent.py b/src/codegen/agents/agent.py index f681d7e5d..3f50bb87f 100644 --- a/src/codegen/agents/agent.py +++ b/src/codegen/agents/agent.py @@ -1,17 +1,17 @@ -from typing import Optional, Dict, Any import os +from typing import Any, Optional from codegen.agents.client.openapi_client.api.agents_api import AgentsApi from codegen.agents.client.openapi_client.api_client import ApiClient +from codegen.agents.client.openapi_client.configuration import Configuration from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput -from codegen.agents.client.openapi_client.configuration import Configuration from codegen.agents.constants import CODEGEN_BASE_API_URL class AgentTask: """Represents an agent run job.""" - + def __init__(self, task_data: AgentRunResponse, api_client: ApiClient, org_id: int): self.id = task_data.id self.org_id = org_id @@ -20,88 +20,75 @@ def __init__(self, task_data: AgentRunResponse, api_client: ApiClient, org_id: i self.web_url = task_data.web_url self._api_client = api_client self._agents_api = AgentsApi(api_client) - + def refresh(self) -> None: """Refresh the job status from the API.""" if self.id is None: return - + job_data = self._agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get( - agent_run_id=int(self.id), - org_id=int(self.org_id), - authorization=f"Bearer {self._api_client.configuration.access_token}" + agent_run_id=int(self.id), org_id=int(self.org_id), authorization=f"Bearer {self._api_client.configuration.access_token}" ) - + # Convert API response to dict for attribute access job_dict = {} - if hasattr(job_data, '__dict__'): + if hasattr(job_data, "__dict__"): job_dict = job_data.__dict__ elif isinstance(job_data, dict): job_dict = job_data - + self.status = job_dict.get("status") self.result = job_dict.get("result") class Agent: """API client for interacting with Codegen AI agents.""" - + def __init__(self, token: str, org_id: Optional[int] = None, base_url: Optional[str] = CODEGEN_BASE_API_URL): - """ - Initialize a new Agent client. - + """Initialize a new Agent client. + Args: token: API authentication token org_id: Optional organization ID. If not provided, default org will be used. """ self.token = token self.org_id = org_id or int(os.environ.get("CODEGEN_ORG_ID", "1")) # Default to org ID 1 if not specified - + # Configure API client config = Configuration(host=base_url, access_token=token) self.api_client = ApiClient(configuration=config) self.agents_api = AgentsApi(self.api_client) - + # Current job self.current_job = None - + def run(self, prompt: str) -> AgentTask: - """ - Run an agent with the given prompt. - + """Run an agent with the given prompt. + Args: prompt: The instruction for the agent to execute - + Returns: Job: A job object representing the agent run """ run_input = CreateAgentRunInput(prompt=prompt) agent_run_response = self.agents_api.create_agent_run_v1_organizations_org_id_agent_run_post( - org_id=int(self.org_id), - create_agent_run_input=run_input, - authorization=f"Bearer {self.token}", - _headers={"Content-Type": "application/json"} + org_id=int(self.org_id), create_agent_run_input=run_input, authorization=f"Bearer {self.token}", _headers={"Content-Type": "application/json"} ) # Convert API response to dict for Job initialization - + job = AgentTask(agent_run_response, self.api_client, self.org_id) self.current_job = job return job - - def get_status(self) -> Optional[Dict[str, Any]]: - """ - Get the status of the current job. - + + def get_status(self) -> Optional[dict[str, Any]]: + """Get the status of the current job. + Returns: dict: A dictionary containing job status information, or None if no job has been run. """ if self.current_job: self.current_job.refresh() - return { - "id": self.current_job.id, - "status": self.current_job.status, - "result": self.current_job.result, - "web_url": self.current_job.web_url - } + return {"id": self.current_job.id, "status": self.current_job.status, "result": self.current_job.result, "web_url": self.current_job.web_url} return None diff --git a/src/codegen/agents/client/README.md b/src/codegen/agents/client/README.md index fc9f39f30..3dbaa3a7d 100644 --- a/src/codegen/agents/client/README.md +++ b/src/codegen/agents/client/README.md @@ -1,24 +1,22 @@ # openapi-client + API for application developers This Python directory was automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. However it the generated code was altered to make compatible with the rest of the project. - API version: 1.0.0 - - ### Steps to update client directory -1. Fetch the api schema from the API endpoint [https://codegen-sh--rest-api.modal.run/api/openapi.json](schema file) -2. generate the client code with the following command: +1. Fetch the api schema from the API endpoint \[https://codegen-sh--rest-api.modal.run/api/openapi.json\](schema file) +1. generate the client code with the following command: ```bash openapi-generator generate -i openapi.yaml -g python -o ./client ``` -3. This command will generate a lot of unused files we just need to include the files in the `openapi_client` directory to the project. - -4. May need to fix the imports for `openapi_client` to be fully qualified import paths. +3. This command will generate a lot of unused files we just need to include the files in the `openapi_client` directory to the project. -5. TODO: make updates more streamlined. Ideally setup this api client as it's own package so all it takes is to generate the new code, no addtional manual steps are needed. +1. May need to fix the imports for `openapi_client` to be fully qualified import paths. +1. TODO: make updates more streamlined. Ideally setup this api client as it's own package so all it takes is to generate the new code, no addtional manual steps are needed. diff --git a/src/codegen/agents/client/openapi_client/__init__.py b/src/codegen/agents/client/openapi_client/__init__.py index 276e64e2c..83f920a03 100644 --- a/src/codegen/agents/client/openapi_client/__init__.py +++ b/src/codegen/agents/client/openapi_client/__init__.py @@ -3,17 +3,16 @@ # flake8: noqa """ - Developer API +Developer API - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. +Do not edit the class manually. """ # noqa: E501 - __version__ = "1.0.0" # import apis into sdk package diff --git a/src/codegen/agents/client/openapi_client/api/__init__.py b/src/codegen/agents/client/openapi_client/api/__init__.py index 27d2bb176..952fb6199 100644 --- a/src/codegen/agents/client/openapi_client/api/__init__.py +++ b/src/codegen/agents/client/openapi_client/api/__init__.py @@ -4,4 +4,3 @@ from codegen.agents.client.openapi_client.api.agents_api import AgentsApi from codegen.agents.client.openapi_client.api.organizations_api import OrganizationsApi from codegen.agents.client.openapi_client.api.users_api import UsersApi - diff --git a/src/codegen/agents/client/openapi_client/api/agents_api.py b/src/codegen/agents/client/openapi_client/api/agents_api.py index 08c410f4a..73c570738 100644 --- a/src/codegen/agents/client/openapi_client/api/agents_api.py +++ b/src/codegen/agents/client/openapi_client/api/agents_api.py @@ -1,28 +1,21 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. -""" # noqa: E501 +Do not edit the class manually. +""" -import warnings -from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt -from typing import Any, Dict, List, Optional, Tuple, Union -from typing_extensions import Annotated +from typing import Annotated, Any, Optional, Union -from pydantic import StrictInt -from typing import Any, Optional -from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse -from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from codegen.agents.client.openapi_client.api_client import ApiClient, RequestSerialized from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse +from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput from codegen.agents.client.openapi_client.rest import RESTResponseType @@ -38,24 +31,16 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> AgentRunResponse: """Create Agent Run @@ -88,8 +73,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -97,41 +81,30 @@ def create_agent_run_v1_organizations_org_id_agent_run_post( _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_with_http_info( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[AgentRunResponse]: """Create Agent Run @@ -164,8 +137,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -173,41 +145,30 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_with_http_info( _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_without_preload_content( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Create Agent Run @@ -240,8 +201,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_without_preload_cont in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -249,20 +209,16 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_without_preload_cont _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _create_agent_run_v1_organizations_org_id_agent_run_post_serialize( self, org_id, @@ -273,63 +229,47 @@ def _create_agent_run_v1_organizations_org_id_agent_run_post_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter if create_agent_run_input is not None: _body_params = create_agent_run_input - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + _header_params["Content-Type"] = _content_type else: - _default_content_type = ( - self.api_client.select_header_content_type( - [ - 'application/json' - ] - ) - ) + _default_content_type = self.api_client.select_header_content_type(["application/json"]) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + _header_params["Content-Type"] = _default_content_type # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='POST', - resource_path='/v1/organizations/{org_id}/agent/run', + method="POST", + resource_path="/v1/organizations/{org_id}/agent/run", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -339,29 +279,19 @@ def _create_agent_run_v1_organizations_org_id_agent_run_post_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_0( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> AgentRunResponse: """Create Agent Run @@ -394,8 +324,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_0( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -403,41 +332,30 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_0( _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_0_with_http_info( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[AgentRunResponse]: """Create Agent Run @@ -470,8 +388,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_0_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -479,41 +396,30 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_0_with_http_info( _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_0_without_preload_content( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Create Agent Run @@ -546,8 +452,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_0_without_preload_co in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -555,20 +460,16 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_0_without_preload_co _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( self, org_id, @@ -579,63 +480,47 @@ def _create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter if create_agent_run_input is not None: _body_params = create_agent_run_input - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + _header_params["Content-Type"] = _content_type else: - _default_content_type = ( - self.api_client.select_header_content_type( - [ - 'application/json' - ] - ) - ) + _default_content_type = self.api_client.select_header_content_type(["application/json"]) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + _header_params["Content-Type"] = _default_content_type # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='POST', - resource_path='/v1/organizations/{org_id}/agent/run', + method="POST", + resource_path="/v1/organizations/{org_id}/agent/run", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -645,29 +530,19 @@ def _create_agent_run_v1_organizations_org_id_agent_run_post_0_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_1( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> AgentRunResponse: """Create Agent Run @@ -700,8 +575,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_1( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -709,41 +583,30 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_1( _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_1_with_http_info( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[AgentRunResponse]: """Create Agent Run @@ -776,8 +639,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_1_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -785,41 +647,30 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_1_with_http_info( _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def create_agent_run_v1_organizations_org_id_agent_run_post_1_without_preload_content( self, org_id: StrictInt, create_agent_run_input: CreateAgentRunInput, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Create Agent Run @@ -852,8 +703,7 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_1_without_preload_co in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( org_id=org_id, create_agent_run_input=create_agent_run_input, @@ -861,20 +711,16 @@ def create_agent_run_v1_organizations_org_id_agent_run_post_1_without_preload_co _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, - _host_index=_host_index + _host_index=_host_index, ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( self, org_id, @@ -885,63 +731,47 @@ def _create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter if create_agent_run_input is not None: _body_params = create_agent_run_input - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # set the HTTP header `Content-Type` if _content_type: - _header_params['Content-Type'] = _content_type + _header_params["Content-Type"] = _content_type else: - _default_content_type = ( - self.api_client.select_header_content_type( - [ - 'application/json' - ] - ) - ) + _default_content_type = self.api_client.select_header_content_type(["application/json"]) if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + _header_params["Content-Type"] = _default_content_type # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='POST', - resource_path='/v1/organizations/{org_id}/agent/run', + method="POST", + resource_path="/v1/organizations/{org_id}/agent/run", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -951,29 +781,19 @@ def _create_agent_run_v1_organizations_org_id_agent_run_post_1_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> AgentRunResponse: """Get Agent Run @@ -1006,50 +826,32 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_with_http_info( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[AgentRunResponse]: """Get Agent Run @@ -1082,50 +884,32 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_with_http_i in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_without_preload_content( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Agent Run @@ -1158,29 +942,18 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_without_pre in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( self, agent_run_id, @@ -1191,50 +964,39 @@ def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if agent_run_id is not None: - _path_params['agent_run_id'] = agent_run_id + _path_params["agent_run_id"] = agent_run_id if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/agent/run/{agent_run_id}', + method="GET", + resource_path="/v1/organizations/{org_id}/agent/run/{agent_run_id}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1244,29 +1006,19 @@ def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> AgentRunResponse: """Get Agent Run @@ -1299,50 +1051,32 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_with_http_info( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[AgentRunResponse]: """Get Agent Run @@ -1375,50 +1109,32 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_with_http in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_without_preload_content( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Agent Run @@ -1451,29 +1167,18 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_without_p in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serialize( self, agent_run_id, @@ -1484,50 +1189,39 @@ def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serializ _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if agent_run_id is not None: - _path_params['agent_run_id'] = agent_run_id + _path_params["agent_run_id"] = agent_run_id if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/agent/run/{agent_run_id}', + method="GET", + resource_path="/v1/organizations/{org_id}/agent/run/{agent_run_id}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1537,29 +1231,19 @@ def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_0_serializ auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> AgentRunResponse: """Get Agent Run @@ -1592,50 +1276,32 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_with_http_info( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[AgentRunResponse]: """Get Agent Run @@ -1668,50 +1334,32 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_with_http in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_without_preload_content( self, agent_run_id: StrictInt, org_id: StrictInt, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Agent Run @@ -1744,29 +1392,18 @@ def get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_without_p in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( - agent_run_id=agent_run_id, - org_id=org_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + agent_run_id=agent_run_id, org_id=org_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "AgentRunResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "AgentRunResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serialize( self, agent_run_id, @@ -1777,50 +1414,39 @@ def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serializ _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if agent_run_id is not None: - _path_params['agent_run_id'] = agent_run_id + _path_params["agent_run_id"] = agent_run_id if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/agent/run/{agent_run_id}', + method="GET", + resource_path="/v1/organizations/{org_id}/agent/run/{agent_run_id}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1830,7 +1456,5 @@ def _get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get_1_serializ auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - diff --git a/src/codegen/agents/client/openapi_client/api/organizations_api.py b/src/codegen/agents/client/openapi_client/api/organizations_api.py index 823141ad5..091c830a1 100644 --- a/src/codegen/agents/client/openapi_client/api/organizations_api.py +++ b/src/codegen/agents/client/openapi_client/api/organizations_api.py @@ -1,28 +1,20 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. -""" # noqa: E501 +Do not edit the class manually. +""" -import warnings -from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt -from typing import Any, Dict, List, Optional, Tuple, Union -from typing_extensions import Annotated +from typing import Annotated, Any, Optional, Union -from pydantic import Field -from typing import Any, Optional -from typing_extensions import Annotated -from codegen.agents.client.openapi_client.models.page_organization_response import PageOrganizationResponse +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from codegen.agents.client.openapi_client.api_client import ApiClient, RequestSerialized from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.models.page_organization_response import PageOrganizationResponse from codegen.agents.client.openapi_client.rest import RESTResponseType @@ -38,24 +30,16 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_call def get_organizations_v1_organizations_get( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> PageOrganizationResponse: """Get Organizations @@ -88,50 +72,32 @@ def get_organizations_v1_organizations_get( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_organizations_v1_organizations_get_with_http_info( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[PageOrganizationResponse]: """Get Organizations @@ -164,50 +130,32 @@ def get_organizations_v1_organizations_get_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_organizations_v1_organizations_get_without_preload_content( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Organizations @@ -240,29 +188,18 @@ def get_organizations_v1_organizations_get_without_preload_content( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_organizations_v1_organizations_get_serialize( self, skip, @@ -273,54 +210,41 @@ def _get_organizations_v1_organizations_get_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters # process the query parameters if skip is not None: - - _query_params.append(('skip', skip)) - + _query_params.append(("skip", skip)) + if limit is not None: - - _query_params.append(('limit', limit)) - + _query_params.append(("limit", limit)) + # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations', + method="GET", + resource_path="/v1/organizations", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -330,29 +254,19 @@ def _get_organizations_v1_organizations_get_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_organizations_v1_organizations_get_0( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> PageOrganizationResponse: """Get Organizations @@ -385,50 +299,32 @@ def get_organizations_v1_organizations_get_0( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_0_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_organizations_v1_organizations_get_0_with_http_info( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[PageOrganizationResponse]: """Get Organizations @@ -461,50 +357,32 @@ def get_organizations_v1_organizations_get_0_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_0_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_organizations_v1_organizations_get_0_without_preload_content( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Organizations @@ -537,29 +415,18 @@ def get_organizations_v1_organizations_get_0_without_preload_content( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_0_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_organizations_v1_organizations_get_0_serialize( self, skip, @@ -570,54 +437,41 @@ def _get_organizations_v1_organizations_get_0_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters # process the query parameters if skip is not None: - - _query_params.append(('skip', skip)) - + _query_params.append(("skip", skip)) + if limit is not None: - - _query_params.append(('limit', limit)) - + _query_params.append(("limit", limit)) + # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations', + method="GET", + resource_path="/v1/organizations", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -627,29 +481,19 @@ def _get_organizations_v1_organizations_get_0_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_organizations_v1_organizations_get_1( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> PageOrganizationResponse: """Get Organizations @@ -682,50 +526,32 @@ def get_organizations_v1_organizations_get_1( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_1_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_organizations_v1_organizations_get_1_with_http_info( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[PageOrganizationResponse]: """Get Organizations @@ -758,50 +584,32 @@ def get_organizations_v1_organizations_get_1_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_1_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_organizations_v1_organizations_get_1_without_preload_content( self, skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Organizations @@ -834,29 +642,18 @@ def get_organizations_v1_organizations_get_1_without_preload_content( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_organizations_v1_organizations_get_1_serialize( - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageOrganizationResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageOrganizationResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_organizations_v1_organizations_get_1_serialize( self, skip, @@ -867,54 +664,41 @@ def _get_organizations_v1_organizations_get_1_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters # process the query parameters if skip is not None: - - _query_params.append(('skip', skip)) - + _query_params.append(("skip", skip)) + if limit is not None: - - _query_params.append(('limit', limit)) - + _query_params.append(("limit", limit)) + # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations', + method="GET", + resource_path="/v1/organizations", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -924,7 +708,5 @@ def _get_organizations_v1_organizations_get_1_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - diff --git a/src/codegen/agents/client/openapi_client/api/users_api.py b/src/codegen/agents/client/openapi_client/api/users_api.py index d3f138510..2787cd5a4 100644 --- a/src/codegen/agents/client/openapi_client/api/users_api.py +++ b/src/codegen/agents/client/openapi_client/api/users_api.py @@ -1,29 +1,21 @@ -# coding: utf-8 +"""Developer API -""" - Developer API +API for application developers - API for application developers +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" - Do not edit the class manually. -""" # noqa: E501 +from typing import Annotated, Any, Optional, Union -import warnings -from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt -from typing import Any, Dict, List, Optional, Tuple, Union -from typing_extensions import Annotated - -from pydantic import Field, StrictStr -from typing import Any, Optional -from typing_extensions import Annotated -from codegen.agents.client.openapi_client.models.page_user_response import PageUserResponse -from codegen.agents.client.openapi_client.models.user_response import UserResponse +from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call from codegen.agents.client.openapi_client.api_client import ApiClient, RequestSerialized from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.models.page_user_response import PageUserResponse +from codegen.agents.client.openapi_client.models.user_response import UserResponse from codegen.agents.client.openapi_client.rest import RESTResponseType @@ -39,24 +31,16 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_call def get_user_v1_organizations_org_id_users_user_id_get( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> UserResponse: """Get User @@ -89,50 +73,32 @@ def get_user_v1_organizations_org_id_users_user_id_get( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_with_http_info( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[UserResponse]: """Get User @@ -165,50 +131,32 @@ def get_user_v1_organizations_org_id_users_user_id_get_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_without_preload_content( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get User @@ -241,29 +189,18 @@ def get_user_v1_organizations_org_id_users_user_id_get_without_preload_content( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_user_v1_organizations_org_id_users_user_id_get_serialize( self, org_id, @@ -274,50 +211,39 @@ def _get_user_v1_organizations_org_id_users_user_id_get_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id if user_id is not None: - _path_params['user_id'] = user_id + _path_params["user_id"] = user_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/users/{user_id}', + method="GET", + resource_path="/v1/organizations/{org_id}/users/{user_id}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -327,29 +253,19 @@ def _get_user_v1_organizations_org_id_users_user_id_get_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_0( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> UserResponse: """Get User @@ -382,50 +298,32 @@ def get_user_v1_organizations_org_id_users_user_id_get_0( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_0_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_0_with_http_info( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[UserResponse]: """Get User @@ -458,50 +356,32 @@ def get_user_v1_organizations_org_id_users_user_id_get_0_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_0_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_0_without_preload_content( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get User @@ -534,29 +414,18 @@ def get_user_v1_organizations_org_id_users_user_id_get_0_without_preload_content in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_0_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_user_v1_organizations_org_id_users_user_id_get_0_serialize( self, org_id, @@ -567,50 +436,39 @@ def _get_user_v1_organizations_org_id_users_user_id_get_0_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id if user_id is not None: - _path_params['user_id'] = user_id + _path_params["user_id"] = user_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/users/{user_id}', + method="GET", + resource_path="/v1/organizations/{org_id}/users/{user_id}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -620,29 +478,19 @@ def _get_user_v1_organizations_org_id_users_user_id_get_0_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_1( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> UserResponse: """Get User @@ -675,50 +523,32 @@ def get_user_v1_organizations_org_id_users_user_id_get_1( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_1_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_1_with_http_info( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[UserResponse]: """Get User @@ -751,50 +581,32 @@ def get_user_v1_organizations_org_id_users_user_id_get_1_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_1_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_user_v1_organizations_org_id_users_user_id_get_1_without_preload_content( self, org_id: StrictStr, user_id: StrictStr, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get User @@ -827,29 +639,18 @@ def get_user_v1_organizations_org_id_users_user_id_get_1_without_preload_content in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_user_v1_organizations_org_id_users_user_id_get_1_serialize( - org_id=org_id, - user_id=user_id, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, user_id=user_id, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "UserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "UserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_user_v1_organizations_org_id_users_user_id_get_1_serialize( self, org_id, @@ -860,50 +661,39 @@ def _get_user_v1_organizations_org_id_users_user_id_get_1_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id if user_id is not None: - _path_params['user_id'] = user_id + _path_params["user_id"] = user_id # process the query parameters # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/users/{user_id}', + method="GET", + resource_path="/v1/organizations/{org_id}/users/{user_id}", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -913,12 +703,9 @@ def _get_user_v1_organizations_org_id_users_user_id_get_1_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_users_v1_organizations_org_id_users_get( self, @@ -926,17 +713,10 @@ def get_users_v1_organizations_org_id_users_get( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> PageUserResponse: """Get Users @@ -971,34 +751,22 @@ def get_users_v1_organizations_org_id_users_get( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_users_v1_organizations_org_id_users_get_with_http_info( self, @@ -1006,17 +774,10 @@ def get_users_v1_organizations_org_id_users_get_with_http_info( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[PageUserResponse]: """Get Users @@ -1051,34 +812,22 @@ def get_users_v1_organizations_org_id_users_get_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_users_v1_organizations_org_id_users_get_without_preload_content( self, @@ -1086,17 +835,10 @@ def get_users_v1_organizations_org_id_users_get_without_preload_content( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Users @@ -1131,30 +873,18 @@ def get_users_v1_organizations_org_id_users_get_without_preload_content( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_users_v1_organizations_org_id_users_get_serialize( self, org_id, @@ -1166,56 +896,43 @@ def _get_users_v1_organizations_org_id_users_get_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters if skip is not None: - - _query_params.append(('skip', skip)) - + _query_params.append(("skip", skip)) + if limit is not None: - - _query_params.append(('limit', limit)) - + _query_params.append(("limit", limit)) + # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/users', + method="GET", + resource_path="/v1/organizations/{org_id}/users", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1225,12 +942,9 @@ def _get_users_v1_organizations_org_id_users_get_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_users_v1_organizations_org_id_users_get_0( self, @@ -1238,17 +952,10 @@ def get_users_v1_organizations_org_id_users_get_0( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> PageUserResponse: """Get Users @@ -1283,34 +990,22 @@ def get_users_v1_organizations_org_id_users_get_0( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_0_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_users_v1_organizations_org_id_users_get_0_with_http_info( self, @@ -1318,17 +1013,10 @@ def get_users_v1_organizations_org_id_users_get_0_with_http_info( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[PageUserResponse]: """Get Users @@ -1363,34 +1051,22 @@ def get_users_v1_organizations_org_id_users_get_0_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_0_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_users_v1_organizations_org_id_users_get_0_without_preload_content( self, @@ -1398,17 +1074,10 @@ def get_users_v1_organizations_org_id_users_get_0_without_preload_content( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Users @@ -1443,30 +1112,18 @@ def get_users_v1_organizations_org_id_users_get_0_without_preload_content( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_0_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_users_v1_organizations_org_id_users_get_0_serialize( self, org_id, @@ -1478,56 +1135,43 @@ def _get_users_v1_organizations_org_id_users_get_0_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters if skip is not None: - - _query_params.append(('skip', skip)) - + _query_params.append(("skip", skip)) + if limit is not None: - - _query_params.append(('limit', limit)) - + _query_params.append(("limit", limit)) + # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/users', + method="GET", + resource_path="/v1/organizations/{org_id}/users", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1537,12 +1181,9 @@ def _get_users_v1_organizations_org_id_users_get_0_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - - @validate_call def get_users_v1_organizations_org_id_users_get_1( self, @@ -1550,17 +1191,10 @@ def get_users_v1_organizations_org_id_users_get_1( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> PageUserResponse: """Get Users @@ -1595,34 +1229,22 @@ def get_users_v1_organizations_org_id_users_get_1( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_1_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ).data - @validate_call def get_users_v1_organizations_org_id_users_get_1_with_http_info( self, @@ -1630,17 +1252,10 @@ def get_users_v1_organizations_org_id_users_get_1_with_http_info( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[PageUserResponse]: """Get Users @@ -1675,34 +1290,22 @@ def get_users_v1_organizations_org_id_users_get_1_with_http_info( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_1_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, ) - @validate_call def get_users_v1_organizations_org_id_users_get_1_without_preload_content( self, @@ -1710,17 +1313,10 @@ def get_users_v1_organizations_org_id_users_get_1_without_preload_content( skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None, authorization: Optional[Any] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, + _request_timeout: Union[None, Annotated[StrictFloat, Field(gt=0)], tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]]] = None, + _request_auth: Optional[dict[StrictStr, Any]] = None, _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, + _headers: Optional[dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: """Get Users @@ -1755,30 +1351,18 @@ def get_users_v1_organizations_org_id_users_get_1_without_preload_content( in the spec for a single request. :type _host_index: int, optional :return: Returns the result object. - """ # noqa: E501 - + """ # noqa: E501 _param = self._get_users_v1_organizations_org_id_users_get_1_serialize( - org_id=org_id, - skip=skip, - limit=limit, - authorization=authorization, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index + org_id=org_id, skip=skip, limit=limit, authorization=authorization, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, _host_index=_host_index ) - _response_types_map: Dict[str, Optional[str]] = { - '200': "PageUserResponse", - '422': "HTTPValidationError", + _response_types_map: dict[str, Optional[str]] = { + "200": "PageUserResponse", + "422": "HTTPValidationError", } - response_data = self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response - def _get_users_v1_organizations_org_id_users_get_1_serialize( self, org_id, @@ -1790,56 +1374,43 @@ def _get_users_v1_organizations_org_id_users_get_1_serialize( _headers, _host_index, ) -> RequestSerialized: - _host = None - _collection_formats: Dict[str, str] = { - } + _collection_formats: dict[str, str] = {} - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[ - str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] - ] = {} + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, Optional[str]] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[str, Union[str, bytes, list[str], list[bytes], list[tuple[str, bytes]]]] = {} _body_params: Optional[bytes] = None # process the path parameters if org_id is not None: - _path_params['org_id'] = org_id + _path_params["org_id"] = org_id # process the query parameters if skip is not None: - - _query_params.append(('skip', skip)) - + _query_params.append(("skip", skip)) + if limit is not None: - - _query_params.append(('limit', limit)) - + _query_params.append(("limit", limit)) + # process the header parameters if authorization is not None: - _header_params['authorization'] = authorization + _header_params["authorization"] = authorization # process the form parameters # process the body parameter - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) # authentication setting - _auth_settings: List[str] = [ - ] + _auth_settings: list[str] = [] return self.api_client.param_serialize( - method='GET', - resource_path='/v1/organizations/{org_id}/users', + method="GET", + resource_path="/v1/organizations/{org_id}/users", path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1849,7 +1420,5 @@ def _get_users_v1_organizations_org_id_users_get_1_serialize( auth_settings=_auth_settings, collection_formats=_collection_formats, _host=_host, - _request_auth=_request_auth + _request_auth=_request_auth, ) - - diff --git a/src/codegen/agents/client/openapi_client/api_client.py b/src/codegen/agents/client/openapi_client/api_client.py index c3fa8cc5f..02e3fdb6c 100644 --- a/src/codegen/agents/client/openapi_client/api_client.py +++ b/src/codegen/agents/client/openapi_client/api_client.py @@ -1,46 +1,36 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +API for application developers - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" import datetime -from dateutil.parser import parse -from enum import Enum import decimal import json import mimetypes import os import re import tempfile - +from enum import Enum +from typing import Optional, Union from urllib.parse import quote -from typing import Tuple, Optional, List, Dict, Union + +from dateutil.parser import parse from pydantic import SecretStr -from codegen.agents.client.openapi_client.configuration import Configuration -from codegen.agents.client.openapi_client.api_response import ApiResponse, T as ApiResponseT import codegen.agents.client.openapi_client as openapi_client from codegen.agents.client.openapi_client import rest -from codegen.agents.client.openapi_client.exceptions import ( - ApiValueError, - ApiException, - BadRequestException, - UnauthorizedException, - ForbiddenException, - NotFoundException, - ServiceException -) - -RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] +from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.api_response import T as ApiResponseT +from codegen.agents.client.openapi_client.configuration import Configuration +from codegen.agents.client.openapi_client.exceptions import ApiException, ApiValueError + +RequestSerialized = tuple[str, str, dict[str, str], Optional[str], list[str]] + class ApiClient: """Generic API client for OpenAPI client library builds. @@ -60,25 +50,19 @@ class ApiClient: PRIMITIVE_TYPES = (float, bool, bytes, str, int) NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int, # TODO remove as only py3 is supported? - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'decimal': decimal.Decimal, - 'object': object, + "int": int, + "long": int, # TODO remove as only py3 is supported? + "float": float, + "str": str, + "bool": bool, + "date": datetime.date, + "datetime": datetime.datetime, + "decimal": decimal.Decimal, + "object": object, } _pool = None - def __init__( - self, - configuration=None, - header_name=None, - header_value=None, - cookie=None - ) -> None: + def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None) -> None: # use default configuration if none is provided if configuration is None: configuration = Configuration.get_default() @@ -90,7 +74,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.0.0/python' + self.user_agent = "OpenAPI-Generator/1.0.0/python" self.client_side_validation = configuration.client_side_validation def __enter__(self): @@ -102,16 +86,15 @@ def __exit__(self, exc_type, exc_value, traceback): @property def user_agent(self): """User agent for this API client""" - return self.default_headers['User-Agent'] + return self.default_headers["User-Agent"] @user_agent.setter def user_agent(self, value): - self.default_headers['User-Agent'] = value + self.default_headers["User-Agent"] = value def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value - _default = None @classmethod @@ -147,12 +130,12 @@ def param_serialize( header_params=None, body=None, post_params=None, - files=None, auth_settings=None, + files=None, + auth_settings=None, collection_formats=None, _host=None, - _request_auth=None + _request_auth=None, ) -> RequestSerialized: - """Builds the HTTP request params needed by the request. :param method: Method to call. :param resource_path: Path to method endpoint. @@ -174,55 +157,35 @@ def param_serialize( :return: tuple of form (path, http_method, query_params, header_params, body, post_params, files) """ - config = self.configuration # header parameters header_params = header_params or {} header_params.update(self.default_headers) if self.cookie: - header_params['Cookie'] = self.cookie + header_params["Cookie"] = self.cookie if header_params: header_params = self.sanitize_for_serialization(header_params) - header_params = dict( - self.parameters_to_tuples(header_params,collection_formats) - ) + header_params = dict(self.parameters_to_tuples(header_params, collection_formats)) # path parameters if path_params: path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples( - path_params, - collection_formats - ) + path_params = self.parameters_to_tuples(path_params, collection_formats) for k, v in path_params: # specified safe chars, encode everything - resource_path = resource_path.replace( - '{%s}' % k, - quote(str(v), safe=config.safe_chars_for_path_param) - ) + resource_path = resource_path.replace(f"{{{k}}}", quote(str(v), safe=config.safe_chars_for_path_param)) # post parameters if post_params or files: post_params = post_params if post_params else [] post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples( - post_params, - collection_formats - ) + post_params = self.parameters_to_tuples(post_params, collection_formats) if files: post_params.extend(self.files_parameters(files)) # auth setting - self.update_params_for_auth( - header_params, - query_params, - auth_settings, - resource_path, - method, - body, - request_auth=_request_auth - ) + self.update_params_for_auth(header_params, query_params, auth_settings, resource_path, method, body, request_auth=_request_auth) # body if body: @@ -238,24 +201,12 @@ def param_serialize( # query parameters if query_params: query_params = self.sanitize_for_serialization(query_params) - url_query = self.parameters_to_url_query( - query_params, - collection_formats - ) + url_query = self.parameters_to_url_query(query_params, collection_formats) url += "?" + url_query return method, url, header_params, body, post_params - - def call_api( - self, - method, - url, - header_params=None, - body=None, - post_params=None, - _request_timeout=None - ) -> rest.RESTResponse: + def call_api(self, method, url, header_params=None, body=None, post_params=None, _request_timeout=None) -> rest.RESTResponse: """Makes the HTTP request (synchronous) :param method: Method to call. :param url: Path to method endpoint. @@ -267,32 +218,21 @@ def call_api( :param _request_timeout: timeout setting for this request. :return: RESTResponse """ - try: # perform request and return response - response_data = self.rest_client.request( - method, url, - headers=header_params, - body=body, post_params=post_params, - _request_timeout=_request_timeout - ) + response_data = self.rest_client.request(method, url, headers=header_params, body=body, post_params=post_params, _request_timeout=_request_timeout) except ApiException as e: raise e return response_data - def response_deserialize( - self, - response_data: rest.RESTResponse, - response_types_map: Optional[Dict[str, ApiResponseT]]=None - ) -> ApiResponse[ApiResponseT]: + def response_deserialize(self, response_data: rest.RESTResponse, response_types_map: Optional[dict[str, ApiResponseT]] = None) -> ApiResponse[ApiResponseT]: """Deserializes response into an object. :param response_data: RESTResponse object to be deserialized. :param response_types_map: dict of response types. :return: ApiResponse """ - msg = "RESTResponse.read() must be called before passing it to response_deserialize()" assert response_data.data is not None, msg @@ -311,7 +251,7 @@ def response_deserialize( return_data = self.__deserialize_file(response_data) elif response_type is not None: match = None - content_type = response_data.getheader('content-type') + content_type = response_data.getheader("content-type") if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) encoding = match.group(1) if match else "utf-8" @@ -325,12 +265,7 @@ def response_deserialize( data=return_data, ) - return ApiResponse( - status_code = response_data.status, - data = return_data, - headers = response_data.getheaders(), - raw_data = response_data.data - ) + return ApiResponse(status_code=response_data.status, data=return_data, headers=response_data.getheaders(), raw_data=response_data.data) def sanitize_for_serialization(self, obj): """Builds a JSON POST object. @@ -357,13 +292,9 @@ def sanitize_for_serialization(self, obj): elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): - return [ - self.sanitize_for_serialization(sub_obj) for sub_obj in obj - ] + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): - return tuple( - self.sanitize_for_serialization(sub_obj) for sub_obj in obj - ) + return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() elif isinstance(obj, decimal.Decimal): @@ -377,15 +308,12 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): + if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): obj_dict = obj.to_dict() else: obj_dict = obj.__dict__ - return { - key: self.sanitize_for_serialization(val) - for key, val in obj_dict.items() - } + return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()} def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """Deserializes response into an object. @@ -397,25 +325,21 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti :return: deserialized object. """ - # fetch data from response object if content_type is None: try: data = json.loads(response_text) except ValueError: data = response_text - elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE): + elif re.match(r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE): if response_text == "": data = "" else: data = json.loads(response_text) - elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE): + elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE): data = response_text else: - raise ApiException( - status=0, - reason="Unsupported content type: {0}".format(content_type) - ) + raise ApiException(status=0, reason=f"Unsupported content type: {content_type}") return self.__deserialize(data, response_type) @@ -431,19 +355,17 @@ def __deserialize(self, data, klass): return None if isinstance(klass, str): - if klass.startswith('List['): - m = re.match(r'List\[(.*)]', klass) + if klass.startswith("List["): + m = re.match(r"List\[(.*)]", klass) assert m is not None, "Malformed List type definition" sub_kls = m.group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] + return [self.__deserialize(sub_data, sub_kls) for sub_data in data] - if klass.startswith('Dict['): - m = re.match(r'Dict\[([^,]*), (.*)]', klass) + if klass.startswith("Dict["): + m = re.match(r"Dict\[([^,]*), (.*)]", klass) assert m is not None, "Malformed Dict type definition" sub_kls = m.group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in data.items()} + return {k: self.__deserialize(v, sub_kls) for k, v in data.items()} # convert str to class if klass in self.NATIVE_TYPES_MAPPING: @@ -473,25 +395,24 @@ def parameters_to_tuples(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collections formatted """ - new_params: List[Tuple[str, str]] = [] + new_params: list[tuple[str, str]] = [] if collection_formats is None: collection_formats = {} for k, v in params.items() if isinstance(params, dict) else params: if k in collection_formats: collection_format = collection_formats[k] - if collection_format == 'multi': + if collection_format == "multi": new_params.extend((k, value) for value in v) else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) + delimiter = "," + new_params.append((k, delimiter.join(str(value) for value in v))) else: new_params.append((k, v)) return new_params @@ -503,7 +424,7 @@ def parameters_to_url_query(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: URL query string (e.g. a=Hello%20World&b=123) """ - new_params: List[Tuple[str, str]] = [] + new_params: list[tuple[str, str]] = [] if collection_formats is None: collection_formats = {} for k, v in params.items() if isinstance(params, dict) else params: @@ -516,20 +437,18 @@ def parameters_to_url_query(self, params, collection_formats): if k in collection_formats: collection_format = collection_formats[k] - if collection_format == 'multi': + if collection_format == "multi": new_params.extend((k, quote(str(value))) for value in v) else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(quote(str(value)) for value in v)) - ) + delimiter = "," + new_params.append((k, delimiter.join(quote(str(value)) for value in v))) else: new_params.append((k, quote(str(v)))) @@ -537,7 +456,7 @@ def parameters_to_url_query(self, params, collection_formats): def files_parameters( self, - files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]], + files: dict[str, Union[str, bytes, list[str], list[bytes], tuple[str, bytes]]], ): """Builds form parameters. @@ -547,7 +466,7 @@ def files_parameters( params = [] for k, v in files.items(): if isinstance(v, str): - with open(v, 'rb') as f: + with open(v, "rb") as f: filename = os.path.basename(f.name) filedata = f.read() elif isinstance(v, bytes): @@ -560,17 +479,13 @@ def files_parameters( params.extend(self.files_parameters({k: file_param})) continue else: - raise ValueError("Unsupported file value") - mimetype = ( - mimetypes.guess_type(filename)[0] - or 'application/octet-stream' - ) - params.append( - tuple([k, tuple([filename, filedata, mimetype])]) - ) + msg = "Unsupported file value" + raise ValueError(msg) + mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream" + params.append(tuple([k, tuple([filename, filedata, mimetype])])) return params - def select_header_accept(self, accepts: List[str]) -> Optional[str]: + def select_header_accept(self, accepts: list[str]) -> Optional[str]: """Returns `Accept` based on an array of accepts provided. :param accepts: List of headers. @@ -580,7 +495,7 @@ def select_header_accept(self, accepts: List[str]) -> Optional[str]: return None for accept in accepts: - if re.search('json', accept, re.IGNORECASE): + if re.search("json", accept, re.IGNORECASE): return accept return accepts[0] @@ -595,21 +510,12 @@ def select_header_content_type(self, content_types): return None for content_type in content_types: - if re.search('json', content_type, re.IGNORECASE): + if re.search("json", content_type, re.IGNORECASE): return content_type return content_types[0] - def update_params_for_auth( - self, - headers, - queries, - auth_settings, - resource_path, - method, - body, - request_auth=None - ) -> None: + def update_params_for_auth(self, headers, queries, auth_settings, resource_path, method, body, request_auth=None) -> None: """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. @@ -626,36 +532,14 @@ def update_params_for_auth( return if request_auth: - self._apply_auth_params( - headers, - queries, - resource_path, - method, - body, - request_auth - ) + self._apply_auth_params(headers, queries, resource_path, method, body, request_auth) else: for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - self._apply_auth_params( - headers, - queries, - resource_path, - method, - body, - auth_setting - ) - - def _apply_auth_params( - self, - headers, - queries, - resource_path, - method, - body, - auth_setting - ) -> None: + self._apply_auth_params(headers, queries, resource_path, method, body, auth_setting) + + def _apply_auth_params(self, headers, queries, resource_path, method, body, auth_setting) -> None: """Updates the request parameters based on a single auth_setting :param headers: Header parameters dict to be updated. @@ -666,17 +550,16 @@ def _apply_auth_params( The object type is the return value of sanitize_for_serialization(). :param auth_setting: auth settings for the endpoint """ - if auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - if auth_setting['type'] != 'http-signature': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - queries.append((auth_setting['key'], auth_setting['value'])) + if auth_setting["in"] == "cookie": + headers["Cookie"] = auth_setting["value"] + elif auth_setting["in"] == "header": + if auth_setting["type"] != "http-signature": + headers[auth_setting["key"]] = auth_setting["value"] + elif auth_setting["in"] == "query": + queries.append((auth_setting["key"], auth_setting["value"])) else: - raise ApiValueError( - 'Authentication token must be in `query` or `header`' - ) + msg = "Authentication token must be in `query` or `header`" + raise ApiValueError(msg) def __deserialize_file(self, response): """Deserializes body to file @@ -696,10 +579,7 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - m = re.search( - r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition - ) + m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition) assert m is not None, "Unexpected 'content-disposition' header value" filename = m.group(1) path = os.path.join(os.path.dirname(path), filename) @@ -742,10 +622,7 @@ def __deserialize_date(self, string): except ImportError: return string except ValueError: - raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) - ) + raise rest.ApiException(status=0, reason=f"Failed to parse `{string}` as date object") def __deserialize_datetime(self, string): """Deserializes string to datetime. @@ -760,13 +637,7 @@ def __deserialize_datetime(self, string): except ImportError: return string except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) - ) + raise rest.ApiException(status=0, reason=(f"Failed to parse `{string}` as datetime object")) def __deserialize_enum(self, data, klass): """Deserializes primitive type to enum. @@ -778,13 +649,7 @@ def __deserialize_enum(self, data, klass): try: return klass(data) except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as `{1}`" - .format(data, klass) - ) - ) + raise rest.ApiException(status=0, reason=(f"Failed to parse `{data}` as `{klass}`")) def __deserialize_model(self, data, klass): """Deserializes list or dict to model. @@ -793,5 +658,4 @@ def __deserialize_model(self, data, klass): :param klass: class literal. :return: model object. """ - return klass.from_dict(data) diff --git a/src/codegen/agents/client/openapi_client/api_response.py b/src/codegen/agents/client/openapi_client/api_response.py index 9bc7c11f6..e8af61447 100644 --- a/src/codegen/agents/client/openapi_client/api_response.py +++ b/src/codegen/agents/client/openapi_client/api_response.py @@ -1,21 +1,23 @@ """API response object.""" from __future__ import annotations -from typing import Optional, Generic, Mapping, TypeVar -from pydantic import Field, StrictInt, StrictBytes, BaseModel + +from typing import TYPE_CHECKING, Generic, TypeVar + +from pydantic import BaseModel, Field, StrictBytes, StrictInt + +if TYPE_CHECKING: + from collections.abc import Mapping T = TypeVar("T") + class ApiResponse(BaseModel, Generic[T]): - """ - API response object - """ + """API response object""" status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + headers: Mapping[str, str] | None = Field(None, description="HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") - model_config = { - "arbitrary_types_allowed": True - } + model_config = {"arbitrary_types_allowed": True} diff --git a/src/codegen/agents/client/openapi_client/configuration.py b/src/codegen/agents/client/openapi_client/configuration.py index 1ea14d6bc..8c1b3f2e6 100644 --- a/src/codegen/agents/client/openapi_client/configuration.py +++ b/src/codegen/agents/client/openapi_client/configuration.py @@ -1,36 +1,27 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" import copy import http.client as httplib import logging -from logging import FileHandler import multiprocessing import sys -from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union -from typing_extensions import NotRequired, Self +from logging import FileHandler +from typing import Any, ClassVar, Literal, Optional, TypedDict, Union import urllib3 +from typing_extensions import NotRequired, Self +JSON_SCHEMA_VALIDATION_KEYWORDS = {"multipleOf", "maximum", "exclusiveMaximum", "minimum", "exclusiveMinimum", "maxLength", "minLength", "pattern", "maxItems", "minItems"} -JSON_SCHEMA_VALIDATION_KEYWORDS = { - 'multipleOf', 'maximum', 'exclusiveMaximum', - 'minimum', 'exclusiveMinimum', 'maxLength', - 'minLength', 'pattern', 'maxItems', 'minItems' -} - -ServerVariablesT = Dict[str, str] +ServerVariablesT = dict[str, str] GenericAuthSetting = TypedDict( "GenericAuthSetting", @@ -110,24 +101,20 @@ ) -AuthSettings = TypedDict( - "AuthSettings", - { - }, - total=False, -) +class AuthSettings(TypedDict, total=False): + pass class HostSettingVariable(TypedDict): description: str default_value: str - enum_values: List[str] + enum_values: list[str] class HostSetting(TypedDict): url: str description: str - variables: NotRequired[Dict[str, HostSettingVariable]] + variables: NotRequired[dict[str, HostSettingVariable]] class Configuration: @@ -169,25 +156,24 @@ class Configuration: def __init__( self, - host: Optional[str]=None, - api_key: Optional[Dict[str, str]]=None, - api_key_prefix: Optional[Dict[str, str]]=None, - username: Optional[str]=None, - password: Optional[str]=None, - access_token: Optional[str]=None, - server_index: Optional[int]=None, - server_variables: Optional[ServerVariablesT]=None, - server_operation_index: Optional[Dict[int, int]]=None, - server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None, - ignore_operation_servers: bool=False, - ssl_ca_cert: Optional[str]=None, + host: Optional[str] = None, + api_key: Optional[dict[str, str]] = None, + api_key_prefix: Optional[dict[str, str]] = None, + username: Optional[str] = None, + password: Optional[str] = None, + access_token: Optional[str] = None, + server_index: Optional[int] = None, + server_variables: Optional[ServerVariablesT] = None, + server_operation_index: Optional[dict[int, int]] = None, + server_operation_variables: Optional[dict[int, ServerVariablesT]] = None, + ignore_operation_servers: bool = False, + ssl_ca_cert: Optional[str] = None, retries: Optional[int] = None, ca_cert_data: Optional[Union[str, bytes]] = None, *, debug: Optional[bool] = None, ) -> None: - """Constructor - """ + """Constructor""" self._base_path = "http://localhost" if host is None else host """Default Base url """ @@ -233,7 +219,7 @@ def __init__( """ self.logger["package_logger"] = logging.getLogger("openapi_client") self.logger["urllib3_logger"] = logging.getLogger("urllib3") - self.logger_format = '%(asctime)s %(levelname)s %(message)s' + self.logger_format = "%(asctime)s %(levelname)s %(message)s" """Log format """ self.logger_stream_handler = None @@ -292,7 +278,7 @@ def __init__( self.proxy_headers = None """Proxy headers """ - self.safe_chars_for_path_param = '' + self.safe_chars_for_path_param = "" """Safe chars for path_param """ self.retries = retries @@ -313,12 +299,12 @@ def __init__( """date format """ - def __deepcopy__(self, memo: Dict[int, Any]) -> Self: + def __deepcopy__(self, memo: dict[int, Any]) -> Self: cls = self.__class__ result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): - if k not in ('logger', 'logger_file_handler'): + if k not in ("logger", "logger_file_handler"): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers result.logger = copy.copy(self.logger) @@ -450,7 +436,7 @@ def logger_format(self, value: str) -> None: self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]: + def get_api_key_with_prefix(self, identifier: str, alias: Optional[str] = None) -> Optional[str]: """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. @@ -463,7 +449,7 @@ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> if key: prefix = self.api_key_prefix.get(identifier) if prefix: - return "%s %s" % (prefix, key) + return f"{prefix} {key}" else: return key @@ -480,11 +466,9 @@ def get_basic_auth_token(self) -> Optional[str]: password = "" if self.password is not None: password = self.password - return urllib3.util.make_headers( - basic_auth=username + ':' + password - ).get('authorization') + return urllib3.util.make_headers(basic_auth=username + ":" + password).get("authorization") - def auth_settings(self)-> AuthSettings: + def auth_settings(self) -> AuthSettings: """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. @@ -497,30 +481,25 @@ def to_debug_report(self) -> str: :return: The report for debugging. """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: 1.0.0\n"\ - "SDK Package Version: 1.0.0".\ - format(env=sys.platform, pyversion=sys.version) + return f"Python SDK Debug Report:\nOS: {sys.platform}\nPython Version: {sys.version}\nVersion of the API: 1.0.0\nSDK Package Version: 1.0.0" - def get_host_settings(self) -> List[HostSetting]: + def get_host_settings(self) -> list[HostSetting]: """Gets an array of host settings :return: An array of host settings """ return [ { - 'url': "", - 'description': "No description provided", + "url": "", + "description": "No description provided", } ] def get_host_from_settings( self, index: Optional[int], - variables: Optional[ServerVariablesT]=None, - servers: Optional[List[HostSetting]]=None, + variables: Optional[ServerVariablesT] = None, + servers: Optional[list[HostSetting]] = None, ) -> str: """Gets host URL based on the index and variables :param index: array index of the host settings @@ -537,24 +516,18 @@ def get_host_from_settings( try: server = servers[index] except IndexError: - raise ValueError( - "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers))) + msg = f"Invalid index {index} when selecting the host settings. Must be less than {len(servers)}" + raise ValueError(msg) - url = server['url'] + url = server["url"] # go through variables and replace placeholders - for variable_name, variable in server.get('variables', {}).items(): - used_value = variables.get( - variable_name, variable['default_value']) - - if 'enum_values' in variable \ - and used_value not in variable['enum_values']: - raise ValueError( - "The variable `{0}` in the host URL has invalid value " - "{1}. Must be {2}.".format( - variable_name, variables[variable_name], - variable['enum_values'])) + for variable_name, variable in server.get("variables", {}).items(): + used_value = variables.get(variable_name, variable["default_value"]) + + if "enum_values" in variable and used_value not in variable["enum_values"]: + msg = "The variable `{}` in the host URL has invalid value {}. Must be {}.".format(variable_name, variables[variable_name], variable["enum_values"]) + raise ValueError(msg) url = url.replace("{" + variable_name + "}", used_value) diff --git a/src/codegen/agents/client/openapi_client/exceptions.py b/src/codegen/agents/client/openapi_client/exceptions.py index edec82866..46e8604fa 100644 --- a/src/codegen/agents/client/openapi_client/exceptions.py +++ b/src/codegen/agents/client/openapi_client/exceptions.py @@ -1,27 +1,25 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. -""" # noqa: E501 +Do not edit the class manually. +""" from typing import Any, Optional + from typing_extensions import Self + class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, - key_type=None) -> None: - """ Raises an exception for TypeErrors + def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None: + """Raises an exception for TypeErrors Args: msg (str): the exception message @@ -43,32 +41,29 @@ def __init__(self, msg, path_to_item=None, valid_classes=None, self.key_type = key_type full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiTypeError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiValueError(OpenApiException, ValueError): def __init__(self, msg, path_to_item=None) -> None: - """ - Args: + """Args: msg (str): the exception message Keyword Args: path_to_item (list) the path to the exception in the received_data dict. None if unset """ - self.path_to_item = path_to_item full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiValueError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiAttributeError(OpenApiException, AttributeError): def __init__(self, msg, path_to_item=None) -> None: - """ - Raised when an attribute reference or assignment fails. + """Raised when an attribute reference or assignment fails. Args: msg (str): the exception message @@ -80,14 +75,13 @@ def __init__(self, msg, path_to_item=None) -> None: self.path_to_item = path_to_item full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiAttributeError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiKeyError(OpenApiException, KeyError): def __init__(self, msg, path_to_item=None) -> None: - """ - Args: + """Args: msg (str): the exception message Keyword Args: @@ -97,16 +91,15 @@ def __init__(self, msg, path_to_item=None) -> None: self.path_to_item = path_to_item full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiKeyError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiException(OpenApiException): - def __init__( - self, - status=None, - reason=None, + self, + status=None, + reason=None, http_resp=None, *, body: Optional[str] = None, @@ -125,17 +118,17 @@ def __init__( self.reason = http_resp.reason if self.body is None: try: - self.body = http_resp.data.decode('utf-8') + self.body = http_resp.data.decode("utf-8") except Exception: pass self.headers = http_resp.getheaders() @classmethod def from_response( - cls, - *, - http_resp, - body: Optional[str], + cls, + *, + http_resp, + body: Optional[str], data: Optional[Any], ) -> Self: if http_resp.status == 400: @@ -163,14 +156,12 @@ def from_response( def __str__(self): """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) + error_message = f"({self.status})\nReason: {self.reason}\n" if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) + error_message += f"HTTP response headers: {self.headers}\n" if self.data or self.body: - error_message += "HTTP response body: {0}\n".format(self.data or self.body) + error_message += f"HTTP response body: {self.data or self.body}\n" return error_message @@ -197,11 +188,13 @@ class ServiceException(ApiException): class ConflictException(ApiException): """Exception for HTTP 409 Conflict.""" + pass class UnprocessableEntityException(ApiException): """Exception for HTTP 422 Unprocessable Entity.""" + pass @@ -210,7 +203,7 @@ def render_path(path_to_item): result = "" for pth in path_to_item: if isinstance(pth, int): - result += "[{0}]".format(pth) + result += f"[{pth}]" else: - result += "['{0}']".format(pth) + result += f"['{pth}']" return result diff --git a/src/codegen/agents/client/openapi_client/models/__init__.py b/src/codegen/agents/client/openapi_client/models/__init__.py index 5dd0f3718..6f60d132d 100644 --- a/src/codegen/agents/client/openapi_client/models/__init__.py +++ b/src/codegen/agents/client/openapi_client/models/__init__.py @@ -2,17 +2,16 @@ # flake8: noqa """ - Developer API +Developer API - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. +Do not edit the class manually. """ # noqa: E501 - # import models into model package from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse from codegen.agents.client.openapi_client.models.create_agent_run_input import CreateAgentRunInput diff --git a/src/codegen/agents/client/openapi_client/models/agent_run_response.py b/src/codegen/agents/client/openapi_client/models/agent_run_response.py index 3ae6f333a..10190e84f 100644 --- a/src/codegen/agents/client/openapi_client/models/agent_run_response.py +++ b/src/codegen/agents/client/openapi_client/models/agent_run_response.py @@ -1,38 +1,34 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set from typing_extensions import Self + class AgentRunResponse(BaseModel): - """ - Represents an agent run in API responses - """ # noqa: E501 + """Represents an agent run in API responses""" + id: StrictInt organization_id: StrictInt - status: Optional[StrictStr] = None - created_at: Optional[StrictStr] = None - result: Optional[StrictStr] = None - web_url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "organization_id", "status", "created_at", "result", "web_url"] + status: StrictStr | None = None + created_at: StrictStr | None = None + result: StrictStr | None = None + web_url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "organization_id", "status", "created_at", "result", "web_url"] model_config = ConfigDict( populate_by_name=True, @@ -40,7 +36,6 @@ class AgentRunResponse(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -51,11 +46,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AgentRunResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,8 +60,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -76,22 +70,22 @@ def to_dict(self) -> Dict[str, Any]: # set to None if status (nullable) is None # and model_fields_set contains the field if self.status is None and "status" in self.model_fields_set: - _dict['status'] = None + _dict["status"] = None # set to None if created_at (nullable) is None # and model_fields_set contains the field if self.created_at is None and "created_at" in self.model_fields_set: - _dict['created_at'] = None + _dict["created_at"] = None # set to None if result (nullable) is None # and model_fields_set contains the field if self.result is None and "result" in self.model_fields_set: - _dict['result'] = None + _dict["result"] = None return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AgentRunResponse from a dict""" if obj is None: return None @@ -99,14 +93,14 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "id": obj.get("id"), - "organization_id": obj.get("organization_id"), - "status": obj.get("status"), - "created_at": obj.get("created_at"), - "result": obj.get("result"), - "web_url": obj.get("web_url") - }) + _obj = cls.model_validate( + { + "id": obj.get("id"), + "organization_id": obj.get("organization_id"), + "status": obj.get("status"), + "created_at": obj.get("created_at"), + "result": obj.get("result"), + "web_url": obj.get("web_url"), + } + ) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/create_agent_run_input.py b/src/codegen/agents/client/openapi_client/models/create_agent_run_input.py index 0f04f2245..74469d48f 100644 --- a/src/codegen/agents/client/openapi_client/models/create_agent_run_input.py +++ b/src/codegen/agents/client/openapi_client/models/create_agent_run_input.py @@ -1,33 +1,29 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +API for application developers - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set from typing_extensions import Self + class CreateAgentRunInput(BaseModel): - """ - CreateAgentRunInput - """ # noqa: E501 + """CreateAgentRunInput""" + prompt: StrictStr - __properties: ClassVar[List[str]] = ["prompt"] + __properties: ClassVar[list[str]] = ["prompt"] model_config = ConfigDict( populate_by_name=True, @@ -35,7 +31,6 @@ class CreateAgentRunInput(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -46,11 +41,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of CreateAgentRunInput from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -60,8 +55,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -71,7 +65,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of CreateAgentRunInput from a dict""" if obj is None: return None @@ -79,9 +73,5 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "prompt": obj.get("prompt") - }) + _obj = cls.model_validate({"prompt": obj.get("prompt")}) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/http_validation_error.py b/src/codegen/agents/client/openapi_client/models/http_validation_error.py index 055a24efc..1f9125486 100644 --- a/src/codegen/agents/client/openapi_client/models/http_validation_error.py +++ b/src/codegen/agents/client/openapi_client/models/http_validation_error.py @@ -1,34 +1,31 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional -from codegen.agents.client.openapi_client.models.validation_error import ValidationError -from typing import Optional, Set from typing_extensions import Self +from codegen.agents.client.openapi_client.models.validation_error import ValidationError + + class HTTPValidationError(BaseModel): - """ - HTTPValidationError - """ # noqa: E501 - detail: Optional[List[ValidationError]] = None - __properties: ClassVar[List[str]] = ["detail"] + """HTTPValidationError""" + + detail: list[ValidationError] | None = None + __properties: ClassVar[list[str]] = ["detail"] model_config = ConfigDict( populate_by_name=True, @@ -36,7 +33,6 @@ class HTTPValidationError(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -47,11 +43,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HTTPValidationError from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,8 +57,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -75,11 +70,11 @@ def to_dict(self) -> Dict[str, Any]: for _item_detail in self.detail: if _item_detail: _items.append(_item_detail.to_dict()) - _dict['detail'] = _items + _dict["detail"] = _items return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HTTPValidationError from a dict""" if obj is None: return None @@ -87,9 +82,5 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "detail": [ValidationError.from_dict(_item) for _item in obj["detail"]] if obj.get("detail") is not None else None - }) + _obj = cls.model_validate({"detail": [ValidationError.from_dict(_item) for _item in obj["detail"]] if obj.get("detail") is not None else None}) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/organization_response.py b/src/codegen/agents/client/openapi_client/models/organization_response.py index 35c304970..5912da5f1 100644 --- a/src/codegen/agents/client/openapi_client/models/organization_response.py +++ b/src/codegen/agents/client/openapi_client/models/organization_response.py @@ -1,36 +1,33 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List -from codegen.agents.client.openapi_client.models.organization_settings import OrganizationSettings -from typing import Optional, Set from typing_extensions import Self +from codegen.agents.client.openapi_client.models.organization_settings import OrganizationSettings + + class OrganizationResponse(BaseModel): - """ - Represents an organization in API responses - """ # noqa: E501 + """Represents an organization in API responses""" + id: StrictInt name: StrictStr settings: OrganizationSettings - __properties: ClassVar[List[str]] = ["id", "name", "settings"] + __properties: ClassVar[list[str]] = ["id", "name", "settings"] model_config = ConfigDict( populate_by_name=True, @@ -38,7 +35,6 @@ class OrganizationResponse(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -49,11 +45,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of OrganizationResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,8 +59,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -73,11 +68,11 @@ def to_dict(self) -> Dict[str, Any]: ) # override the default output from pydantic by calling `to_dict()` of settings if self.settings: - _dict['settings'] = self.settings.to_dict() + _dict["settings"] = self.settings.to_dict() return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of OrganizationResponse from a dict""" if obj is None: return None @@ -85,11 +80,5 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name"), - "settings": OrganizationSettings.from_dict(obj["settings"]) if obj.get("settings") is not None else None - }) + _obj = cls.model_validate({"id": obj.get("id"), "name": obj.get("name"), "settings": OrganizationSettings.from_dict(obj["settings"]) if obj.get("settings") is not None else None}) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/organization_settings.py b/src/codegen/agents/client/openapi_client/models/organization_settings.py index 3e4836f8a..d7538126d 100644 --- a/src/codegen/agents/client/openapi_client/models/organization_settings.py +++ b/src/codegen/agents/client/openapi_client/models/organization_settings.py @@ -1,34 +1,30 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictBool -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set from typing_extensions import Self + class OrganizationSettings(BaseModel): - """ - OrganizationSettings - """ # noqa: E501 - enable_pr_creation: Optional[StrictBool] = True - enable_rules_detection: Optional[StrictBool] = True - __properties: ClassVar[List[str]] = ["enable_pr_creation", "enable_rules_detection"] + """OrganizationSettings""" + + enable_pr_creation: StrictBool | None = True + enable_rules_detection: StrictBool | None = True + __properties: ClassVar[list[str]] = ["enable_pr_creation", "enable_rules_detection"] model_config = ConfigDict( populate_by_name=True, @@ -36,7 +32,6 @@ class OrganizationSettings(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -47,11 +42,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of OrganizationSettings from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,8 +56,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -72,7 +66,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of OrganizationSettings from a dict""" if obj is None: return None @@ -80,10 +74,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "enable_pr_creation": obj.get("enable_pr_creation") if obj.get("enable_pr_creation") is not None else True, - "enable_rules_detection": obj.get("enable_rules_detection") if obj.get("enable_rules_detection") is not None else True - }) + _obj = cls.model_validate( + { + "enable_pr_creation": obj.get("enable_pr_creation") if obj.get("enable_pr_creation") is not None else True, + "enable_rules_detection": obj.get("enable_rules_detection") if obj.get("enable_rules_detection") is not None else True, + } + ) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/page_organization_response.py b/src/codegen/agents/client/openapi_client/models/page_organization_response.py index 82c92dedc..1390ac802 100644 --- a/src/codegen/agents/client/openapi_client/models/page_organization_response.py +++ b/src/codegen/agents/client/openapi_client/models/page_organization_response.py @@ -1,38 +1,35 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List -from codegen.agents.client.openapi_client.models.organization_response import OrganizationResponse -from typing import Optional, Set from typing_extensions import Self +from codegen.agents.client.openapi_client.models.organization_response import OrganizationResponse + + class PageOrganizationResponse(BaseModel): - """ - PageOrganizationResponse - """ # noqa: E501 - items: List[OrganizationResponse] + """PageOrganizationResponse""" + + items: list[OrganizationResponse] total: StrictInt page: StrictInt size: StrictInt pages: StrictInt - __properties: ClassVar[List[str]] = ["items", "total", "page", "size", "pages"] + __properties: ClassVar[list[str]] = ["items", "total", "page", "size", "pages"] model_config = ConfigDict( populate_by_name=True, @@ -40,7 +37,6 @@ class PageOrganizationResponse(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -51,11 +47,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of PageOrganizationResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,8 +61,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -79,11 +74,11 @@ def to_dict(self) -> Dict[str, Any]: for _item_items in self.items: if _item_items: _items.append(_item_items.to_dict()) - _dict['items'] = _items + _dict["items"] = _items return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of PageOrganizationResponse from a dict""" if obj is None: return None @@ -91,13 +86,13 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "items": [OrganizationResponse.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, - "total": obj.get("total"), - "page": obj.get("page"), - "size": obj.get("size"), - "pages": obj.get("pages") - }) + _obj = cls.model_validate( + { + "items": [OrganizationResponse.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, + "total": obj.get("total"), + "page": obj.get("page"), + "size": obj.get("size"), + "pages": obj.get("pages"), + } + ) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/page_user_response.py b/src/codegen/agents/client/openapi_client/models/page_user_response.py index dec46b9de..b79c8b7e3 100644 --- a/src/codegen/agents/client/openapi_client/models/page_user_response.py +++ b/src/codegen/agents/client/openapi_client/models/page_user_response.py @@ -1,38 +1,35 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List -from codegen.agents.client.openapi_client.models.user_response import UserResponse -from typing import Optional, Set from typing_extensions import Self +from codegen.agents.client.openapi_client.models.user_response import UserResponse + + class PageUserResponse(BaseModel): - """ - PageUserResponse - """ # noqa: E501 - items: List[UserResponse] + """PageUserResponse""" + + items: list[UserResponse] total: StrictInt page: StrictInt size: StrictInt pages: StrictInt - __properties: ClassVar[List[str]] = ["items", "total", "page", "size", "pages"] + __properties: ClassVar[list[str]] = ["items", "total", "page", "size", "pages"] model_config = ConfigDict( populate_by_name=True, @@ -40,7 +37,6 @@ class PageUserResponse(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -51,11 +47,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of PageUserResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,8 +61,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -79,11 +74,11 @@ def to_dict(self) -> Dict[str, Any]: for _item_items in self.items: if _item_items: _items.append(_item_items.to_dict()) - _dict['items'] = _items + _dict["items"] = _items return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of PageUserResponse from a dict""" if obj is None: return None @@ -91,13 +86,13 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "items": [UserResponse.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, - "total": obj.get("total"), - "page": obj.get("page"), - "size": obj.get("size"), - "pages": obj.get("pages") - }) + _obj = cls.model_validate( + { + "items": [UserResponse.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, + "total": obj.get("total"), + "page": obj.get("page"), + "size": obj.get("size"), + "pages": obj.get("pages"), + } + ) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/user_response.py b/src/codegen/agents/client/openapi_client/models/user_response.py index ea9d4a8be..71aa4cdae 100644 --- a/src/codegen/agents/client/openapi_client/models/user_response.py +++ b/src/codegen/agents/client/openapi_client/models/user_response.py @@ -1,38 +1,34 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set from typing_extensions import Self + class UserResponse(BaseModel): - """ - Represents a user in API responses - """ # noqa: E501 + """Represents a user in API responses""" + id: StrictInt - email: Optional[StrictStr] + email: StrictStr | None github_user_id: StrictStr github_username: StrictStr - avatar_url: Optional[StrictStr] - full_name: Optional[StrictStr] - __properties: ClassVar[List[str]] = ["id", "email", "github_user_id", "github_username", "avatar_url", "full_name"] + avatar_url: StrictStr | None + full_name: StrictStr | None + __properties: ClassVar[list[str]] = ["id", "email", "github_user_id", "github_username", "avatar_url", "full_name"] model_config = ConfigDict( populate_by_name=True, @@ -40,7 +36,6 @@ class UserResponse(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -51,11 +46,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of UserResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,8 +60,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -76,22 +70,22 @@ def to_dict(self) -> Dict[str, Any]: # set to None if email (nullable) is None # and model_fields_set contains the field if self.email is None and "email" in self.model_fields_set: - _dict['email'] = None + _dict["email"] = None # set to None if avatar_url (nullable) is None # and model_fields_set contains the field if self.avatar_url is None and "avatar_url" in self.model_fields_set: - _dict['avatar_url'] = None + _dict["avatar_url"] = None # set to None if full_name (nullable) is None # and model_fields_set contains the field if self.full_name is None and "full_name" in self.model_fields_set: - _dict['full_name'] = None + _dict["full_name"] = None return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of UserResponse from a dict""" if obj is None: return None @@ -99,14 +93,14 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "id": obj.get("id"), - "email": obj.get("email"), - "github_user_id": obj.get("github_user_id"), - "github_username": obj.get("github_username"), - "avatar_url": obj.get("avatar_url"), - "full_name": obj.get("full_name") - }) + _obj = cls.model_validate( + { + "id": obj.get("id"), + "email": obj.get("email"), + "github_user_id": obj.get("github_user_id"), + "github_username": obj.get("github_username"), + "avatar_url": obj.get("avatar_url"), + "full_name": obj.get("full_name"), + } + ) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/validation_error.py b/src/codegen/agents/client/openapi_client/models/validation_error.py index d85c10eff..fab1db703 100644 --- a/src/codegen/agents/client/openapi_client/models/validation_error.py +++ b/src/codegen/agents/client/openapi_client/models/validation_error.py @@ -1,36 +1,33 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers +API for application developers - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from codegen.agents.client.openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner -from typing import Optional, Set from typing_extensions import Self +from codegen.agents.client.openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner + + class ValidationError(BaseModel): - """ - ValidationError - """ # noqa: E501 - loc: List[ValidationErrorLocInner] + """ValidationError""" + + loc: list[ValidationErrorLocInner] msg: StrictStr type: StrictStr - __properties: ClassVar[List[str]] = ["loc", "msg", "type"] + __properties: ClassVar[list[str]] = ["loc", "msg", "type"] model_config = ConfigDict( populate_by_name=True, @@ -38,7 +35,6 @@ class ValidationError(BaseModel): protected_namespaces=(), ) - def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) @@ -49,11 +45,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ValidationError from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,8 +59,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ - ]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -77,11 +72,11 @@ def to_dict(self) -> Dict[str, Any]: for _item_loc in self.loc: if _item_loc: _items.append(_item_loc.to_dict()) - _dict['loc'] = _items + _dict["loc"] = _items return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ValidationError from a dict""" if obj is None: return None @@ -89,11 +84,5 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if not isinstance(obj, dict): return cls.model_validate(obj) - _obj = cls.model_validate({ - "loc": [ValidationErrorLocInner.from_dict(_item) for _item in obj["loc"]] if obj.get("loc") is not None else None, - "msg": obj.get("msg"), - "type": obj.get("type") - }) + _obj = cls.model_validate({"loc": [ValidationErrorLocInner.from_dict(_item) for _item in obj["loc"]] if obj.get("loc") is not None else None, "msg": obj.get("msg"), "type": obj.get("type")}) return _obj - - diff --git a/src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py b/src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py index b44c2ccf3..04a44443e 100644 --- a/src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py +++ b/src/codegen/agents/client/openapi_client/models/validation_error_loc_inner.py @@ -1,44 +1,38 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +API for application developers - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" from __future__ import annotations -from inspect import getfullargspec + import json import pprint import re # noqa: F401 -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, ValidationError, field_validator -from typing import Optional -from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict -from typing_extensions import Literal, Self -from pydantic import Field +from typing import TYPE_CHECKING, Any + +from pydantic import BaseModel, StrictInt, StrictStr, ValidationError, field_validator +from typing_extensions import Self VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS = ["int", "str"] + class ValidationErrorLocInner(BaseModel): - """ - ValidationErrorLocInner - """ + """ValidationErrorLocInner""" # data type: str - anyof_schema_1_validator: Optional[StrictStr] = None + anyof_schema_1_validator: StrictStr | None = None # data type: int - anyof_schema_2_validator: Optional[StrictInt] = None + anyof_schema_2_validator: StrictInt | None = None if TYPE_CHECKING: - actual_instance: Optional[Union[int, str]] = None + actual_instance: int | str | None = None else: actual_instance: Any = None - any_of_schemas: Set[str] = { "int", "str" } + any_of_schemas: set[str] = {"int", "str"} model_config = { "validate_assignment": True, @@ -48,14 +42,16 @@ class ValidationErrorLocInner(BaseModel): def __init__(self, *args, **kwargs) -> None: if args: if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + msg = "If a position argument is used, only 1 is allowed to set `actual_instance`" + raise ValueError(msg) if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") + msg = "If a position argument is used, keyword arguments cannot be used." + raise ValueError(msg) super().__init__(actual_instance=args[0]) else: super().__init__(**kwargs) - @field_validator('actual_instance') + @field_validator("actual_instance") def actual_instance_must_validate_anyof(cls, v): instance = ValidationErrorLocInner.model_construct() error_messages = [] @@ -78,7 +74,7 @@ def actual_instance_must_validate_anyof(cls, v): return v @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: + def from_dict(cls, obj: dict[str, Any]) -> Self: return cls.from_json(json.dumps(obj)) @classmethod @@ -121,7 +117,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: + def to_dict(self) -> dict[str, Any] | int | str | None: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None @@ -134,5 +130,3 @@ def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: def to_str(self) -> str: """Returns the string representation of the actual instance""" return pprint.pformat(self.model_dump()) - - diff --git a/src/codegen/agents/client/openapi_client/rest.py b/src/codegen/agents/client/openapi_client/rest.py index 1b9aa1e76..445c0144c 100644 --- a/src/codegen/agents/client/openapi_client/rest.py +++ b/src/codegen/agents/client/openapi_client/rest.py @@ -1,16 +1,12 @@ -# coding: utf-8 +"""Developer API -""" - Developer API - - API for application developers - - The version of the OpenAPI document: 1.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) +API for application developers - Do not edit the class manually. -""" # noqa: E501 +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) +Do not edit the class manually. +""" import io import json @@ -36,7 +32,6 @@ def is_socks_proxy_url(url): class RESTResponse(io.IOBase): - def __init__(self, resp) -> None: self.response = resp self.status = resp.status @@ -58,12 +53,11 @@ def getheader(self, name, default=None): class RESTClientObject: - def __init__(self, configuration) -> None: # urllib3.PoolManager will pass all kw parameters to connectionpool - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 - # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # cert_reqs if configuration.verify_ssl: @@ -79,22 +73,19 @@ def __init__(self, configuration) -> None: "ca_cert_data": configuration.ca_cert_data, } if configuration.assert_hostname is not None: - pool_args['assert_hostname'] = ( - configuration.assert_hostname - ) + pool_args["assert_hostname"] = configuration.assert_hostname if configuration.retries is not None: - pool_args['retries'] = configuration.retries + pool_args["retries"] = configuration.retries if configuration.tls_server_name: - pool_args['server_hostname'] = configuration.tls_server_name - + pool_args["server_hostname"] = configuration.tls_server_name if configuration.socket_options is not None: - pool_args['socket_options'] = configuration.socket_options + pool_args["socket_options"] = configuration.socket_options if configuration.connection_pool_maxsize is not None: - pool_args['maxsize'] = configuration.connection_pool_maxsize + pool_args["maxsize"] = configuration.connection_pool_maxsize # https pool manager self.pool_manager: urllib3.PoolManager @@ -102,6 +93,7 @@ def __init__(self, configuration) -> None: if configuration.proxy: if is_socks_proxy_url(configuration.proxy): from urllib3.contrib.socks import SOCKSProxyManager + pool_args["proxy_url"] = configuration.proxy pool_args["headers"] = configuration.proxy_headers self.pool_manager = SOCKSProxyManager(**pool_args) @@ -112,15 +104,7 @@ def __init__(self, configuration) -> None: else: self.pool_manager = urllib3.PoolManager(**pool_args) - def request( - self, - method, - url, - headers=None, - body=None, - post_params=None, - _request_timeout=None - ): + def request(self, method, url, headers=None, body=None, post_params=None, _request_timeout=None): """Perform requests. :param method: http request method @@ -136,20 +120,11 @@ def request( (connection, read) timeouts. """ method = method.upper() - assert method in [ - 'GET', - 'HEAD', - 'DELETE', - 'POST', - 'PUT', - 'PATCH', - 'OPTIONS' - ] + assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] if post_params and body: - raise ApiValueError( - "body parameter cannot be used with post_params parameter." - ) + msg = "body parameter cannot be used with post_params parameter." + raise ApiValueError(msg) post_params = post_params or {} headers = headers or {} @@ -158,83 +133,37 @@ def request( if _request_timeout: if isinstance(_request_timeout, (int, float)): timeout = urllib3.Timeout(total=_request_timeout) - elif ( - isinstance(_request_timeout, tuple) - and len(_request_timeout) == 2 - ): - timeout = urllib3.Timeout( - connect=_request_timeout[0], - read=_request_timeout[1] - ) + elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: + timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - + if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: # no content type provided or payload is json - content_type = headers.get('Content-Type') - if ( - not content_type - or re.search('json', content_type, re.IGNORECASE) - ): + content_type = headers.get("Content-Type") + if not content_type or re.search("json", content_type, re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) - r = self.pool_manager.request( - method, - url, - body=request_body, - timeout=timeout, - headers=headers, - preload_content=False - ) - elif content_type == 'application/x-www-form-urlencoded': - r = self.pool_manager.request( - method, - url, - fields=post_params, - encode_multipart=False, - timeout=timeout, - headers=headers, - preload_content=False - ) - elif content_type == 'multipart/form-data': + r = self.pool_manager.request(method, url, body=request_body, timeout=timeout, headers=headers, preload_content=False) + elif content_type == "application/x-www-form-urlencoded": + r = self.pool_manager.request(method, url, fields=post_params, encode_multipart=False, timeout=timeout, headers=headers, preload_content=False) + elif content_type == "multipart/form-data": # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. - del headers['Content-Type'] + del headers["Content-Type"] # Ensures that dict objects are serialized - post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params] - r = self.pool_manager.request( - method, - url, - fields=post_params, - encode_multipart=True, - timeout=timeout, - headers=headers, - preload_content=False - ) + post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a, b) for a, b in post_params] + r = self.pool_manager.request(method, url, fields=post_params, encode_multipart=True, timeout=timeout, headers=headers, preload_content=False) # Pass a `string` parameter directly in the body to support # other content types than JSON when `body` argument is # provided in serialized form. elif isinstance(body, str) or isinstance(body, bytes): - r = self.pool_manager.request( - method, - url, - body=body, - timeout=timeout, - headers=headers, - preload_content=False - ) - elif headers['Content-Type'].startswith('text/') and isinstance(body, bool): + r = self.pool_manager.request(method, url, body=body, timeout=timeout, headers=headers, preload_content=False) + elif headers["Content-Type"].startswith("text/") and isinstance(body, bool): request_body = "true" if body else "false" - r = self.pool_manager.request( - method, - url, - body=request_body, - preload_content=False, - timeout=timeout, - headers=headers) + r = self.pool_manager.request(method, url, body=request_body, preload_content=False, timeout=timeout, headers=headers) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -243,14 +172,7 @@ def request( raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: - r = self.pool_manager.request( - method, - url, - fields={}, - timeout=timeout, - headers=headers, - preload_content=False - ) + r = self.pool_manager.request(method, url, fields={}, timeout=timeout, headers=headers, preload_content=False) except urllib3.exceptions.SSLError as e: msg = "\n".join([type(e).__name__, str(e)]) raise ApiException(status=0, reason=msg) diff --git a/src/codegen/agents/constants.py b/src/codegen/agents/constants.py index 38555c96a..ec94f38e5 100644 --- a/src/codegen/agents/constants.py +++ b/src/codegen/agents/constants.py @@ -1 +1 @@ -CODEGEN_BASE_API_URL = "https://codegen-sh--rest-api.modal.run" \ No newline at end of file +CODEGEN_BASE_API_URL = "https://codegen-sh--rest-api.modal.run" diff --git a/src/codegen/agents/scratch.ipynb b/src/codegen/agents/scratch.ipynb index 7e14276b2..988961311 100644 --- a/src/codegen/agents/scratch.ipynb +++ b/src/codegen/agents/scratch.ipynb @@ -2,24 +2,9 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'openapi_client'", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m AgentsApi\n", - "\u001b[36mFile \u001b[39m\u001b[32m~/dev/codegen-sdk/src/codegen/agents/client/openapi_client/api/__init__.py:4\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# flake8: noqa\u001b[39;00m\n\u001b[32m 2\u001b[39m \n\u001b[32m 3\u001b[39m \u001b[38;5;66;03m# import apis into api package\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m AgentsApi\n\u001b[32m 5\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01morganizations_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m OrganizationsApi\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01musers_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m UsersApi\n", - "\u001b[36mFile \u001b[39m\u001b[32m~/dev/codegen-sdk/src/codegen/agents/client/openapi_client/api/agents_api.py:23\u001b[39m\n\u001b[32m 20\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mtyping\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Any, Optional\n\u001b[32m 21\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mmodels\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mcreate_agent_run_input\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m CreateAgentRunInput\n\u001b[32m---> \u001b[39m\u001b[32m23\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi_client\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ApiClient, RequestSerialized\n\u001b[32m 24\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi_response\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ApiResponse\n\u001b[32m 25\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mrest\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m RESTResponseType\n", - "\u001b[36mFile \u001b[39m\u001b[32m~/dev/codegen-sdk/src/codegen/agents/client/openapi_client/api_client.py:31\u001b[39m\n\u001b[32m 29\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mconfiguration\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Configuration\n\u001b[32m 30\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mapi_response\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m ApiResponse, T \u001b[38;5;28;01mas\u001b[39;00m ApiResponseT\n\u001b[32m---> \u001b[39m\u001b[32m31\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mmodels\u001b[39;00m\n\u001b[32m 32\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m rest\n\u001b[32m 33\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcodegen\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01magents\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mclient\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mopenapi_client\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mexceptions\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m (\n\u001b[32m 34\u001b[39m ApiValueError,\n\u001b[32m 35\u001b[39m ApiException,\n\u001b[32m (...)\u001b[39m\u001b[32m 40\u001b[39m ServiceException\n\u001b[32m 41\u001b[39m )\n", - "\u001b[31mModuleNotFoundError\u001b[39m: No module named 'openapi_client'" - ] - } - ], + "outputs": [], "source": [ "from codegen.agents.client.openapi_client.api.agents_api import AgentsApi" ] diff --git a/tests/unit/codegen/agents/__init__.py b/tests/unit/codegen/agents/__init__.py index e2689cfcf..e84cdd741 100644 --- a/tests/unit/codegen/agents/__init__.py +++ b/tests/unit/codegen/agents/__init__.py @@ -1 +1 @@ -# Unit tests for codegen.agents package \ No newline at end of file +# Unit tests for codegen.agents package diff --git a/tests/unit/codegen/agents/test_agent.py b/tests/unit/codegen/agents/test_agent.py index dfa8787b5..a41a9fea5 100644 --- a/tests/unit/codegen/agents/test_agent.py +++ b/tests/unit/codegen/agents/test_agent.py @@ -1,18 +1,15 @@ -import pytest from unittest.mock import MagicMock, patch -from typing import Dict, Any -import os # Add missing import for os module + +import pytest from codegen.agents.agent import Agent, AgentTask -from codegen.agents.client.openapi_client.api_client import ApiClient -from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse from codegen.agents.client.openapi_client.api.agents_api import AgentsApi from codegen.agents.client.openapi_client.configuration import Configuration +from codegen.agents.client.openapi_client.models.agent_run_response import AgentRunResponse from codegen.agents.constants import CODEGEN_BASE_API_URL class TestAgentTask: - @pytest.fixture def agent_run_response(self): """Create a mock AgentRunResponse""" @@ -22,7 +19,7 @@ def agent_run_response(self): mock_response.result = None mock_response.web_url = "https://example.com/run/123" return mock_response - + @pytest.fixture def api_client(self): """Create a mock ApiClient""" @@ -30,22 +27,22 @@ def api_client(self): mock_client.configuration = MagicMock() # Create configuration attribute mock_client.configuration.access_token = "test-token" return mock_client - + @pytest.fixture def mock_agents_api(self): """Create a proper mock for the AgentsApi""" # Create a proper mock with a get method mock_api = MagicMock(spec=AgentsApi) return mock_api - + @pytest.fixture def agent_task(self, agent_run_response, api_client, mock_agents_api): """Create an AgentTask instance with mock dependencies""" # Patch the AgentsApi constructor to return our mock - with patch('codegen.agents.agent.AgentsApi', return_value=mock_agents_api): + with patch("codegen.agents.agent.AgentsApi", return_value=mock_agents_api): task = AgentTask(agent_run_response, api_client, org_id=42) return task - + def test_init(self, agent_task, agent_run_response, api_client, mock_agents_api): """Test initialization of AgentTask""" assert agent_task.id == "123" @@ -55,56 +52,49 @@ def test_init(self, agent_task, agent_run_response, api_client, mock_agents_api) assert agent_task.web_url == "https://example.com/run/123" assert agent_task._api_client == api_client assert agent_task._agents_api == mock_agents_api - + def test_refresh_without_id(self, agent_task, mock_agents_api): """Test refresh method when job ID is None""" agent_task.id = None # Should return early without making API call agent_task.refresh() mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_not_called() - + def test_refresh_with_id(self, agent_task, mock_agents_api): """Test refresh method updates job status""" # Setup mock API response - mock_updated_response = { - "status": "completed", - "result": {"output": "Success!"} - } + mock_updated_response = {"status": "completed", "result": {"output": "Success!"}} mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_updated_response - + # Call refresh agent_task.refresh() - + # Verify API was called with correct params mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_called_once_with( agent_run_id=123, # Use string ID as stored in agent_task.id org_id=42, - authorization="Bearer test-token" + authorization="Bearer test-token", ) - + # Verify status was updated assert agent_task.status == "completed" assert agent_task.result == {"output": "Success!"} - + def test_refresh_with_dict_response(self, agent_task, mock_agents_api): """Test refresh method when API returns dict instead of object""" # Setup mock API response as dict - mock_updated_response = { - "status": "failed", - "result": {"error": "Something went wrong"} - } + mock_updated_response = {"status": "failed", "result": {"error": "Something went wrong"}} mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_updated_response - + # Call refresh agent_task.refresh() - + # Verify status was updated assert agent_task.status == "failed" assert agent_task.result == {"error": "Something went wrong"} class TestAgent: - @pytest.fixture def mock_api_client(self): """Create a mock ApiClient""" @@ -114,7 +104,7 @@ def mock_api_client(self): mock_client.configuration.access_token = "test-token" mock_client_class.return_value = mock_client yield mock_client - + @pytest.fixture def mock_agents_api(self): """Create a mock AgentsApi""" @@ -122,7 +112,7 @@ def mock_agents_api(self): mock_api = MagicMock(spec=AgentsApi) mock_api_class.return_value = mock_api yield mock_api - + @pytest.fixture def agent(self, mock_api_client, mock_agents_api): """Create an Agent instance with mock dependencies""" @@ -131,7 +121,7 @@ def agent(self, mock_api_client, mock_agents_api): # Verify config initialization mock_config.assert_called_once_with(host=CODEGEN_BASE_API_URL, access_token="test-token") return agent - + def test_init_with_explicit_org_id(self, mock_api_client, mock_agents_api): """Test initialization with explicitly provided org_id""" with patch.object(Configuration, "__init__", return_value=None): @@ -141,21 +131,21 @@ def test_init_with_explicit_org_id(self, mock_api_client, mock_agents_api): assert agent.api_client == mock_api_client assert agent.agents_api == mock_agents_api assert agent.current_job is None - + def test_init_with_default_org_id(self, mock_api_client, mock_agents_api): """Test initialization with default org_id""" with patch.object(Configuration, "__init__", return_value=None): with patch.dict("os.environ", {"CODEGEN_ORG_ID": "99"}): agent = Agent(token="test-token") assert agent.org_id == 99 - + def test_init_with_custom_base_url(self, mock_api_client): """Test initialization with custom base URL""" with patch.object(Configuration, "__init__", return_value=None) as mock_config: custom_url = "https://custom-api.example.com" agent = Agent(token="test-token", org_id=42, base_url=custom_url) mock_config.assert_called_once_with(host=custom_url, access_token="test-token") - + def test_run(self, agent, mock_agents_api): """Test run method creates and returns job""" # Setup mock API response @@ -165,10 +155,10 @@ def test_run(self, agent, mock_agents_api): mock_run_response.result = None mock_run_response.web_url = "https://example.com/run/123" mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.return_value = mock_run_response - + # Call run job = agent.run("Test prompt") - + # Verify API call mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.assert_called_once() call_args = mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.call_args @@ -176,17 +166,17 @@ def test_run(self, agent, mock_agents_api): assert call_args[1]["authorization"] == "Bearer test-token" assert call_args[1]["_headers"] == {"Content-Type": "application/json"} assert call_args[1]["create_agent_run_input"].prompt == "Test prompt" - + # Verify job assert isinstance(job, AgentTask) assert job.id == "123" assert job.status == "running" assert agent.current_job == job - + def test_get_status_with_no_job(self, agent): """Test get_status when no job has been run""" assert agent.get_status() is None - + def test_get_status_with_job(self, agent): """Test get_status returns current job status""" # Setup mock job @@ -195,114 +185,97 @@ def test_get_status_with_job(self, agent): mock_job.status = "completed" mock_job.result = {"output": "Success!"} mock_job.web_url = "https://example.com/run/123" - + agent.current_job = mock_job - + # Call get_status status = agent.get_status() - + # Verify job was refreshed mock_job.refresh.assert_called_once() - + # Verify status - assert status == { - "id": "123", - "status": "completed", - "result": {"output": "Success!"}, - "web_url": "https://example.com/run/123" - } + assert status == {"id": "123", "status": "completed", "result": {"output": "Success!"}, "web_url": "https://example.com/run/123"} # Integration-like tests class TestAgentIntegration: - @pytest.fixture def mock_response(self): """Create a mock response for API calls""" - mock_response = MagicMock() # Remove spec=AgentRunResponse + mock_response = MagicMock() # Remove spec=AgentRunResponse mock_response.id = 987 mock_response.status = "running" mock_response.result = None mock_response.web_url = "https://example.com/run/987" return mock_response - + @pytest.fixture def mock_updated_response(self): """Create a mock updated response for API calls""" - mock_updated = { - "id": 987, - "status": "completed", - "result": {"output": "Task completed successfully"}, - "web_url": "https://example.com/run/987" - } - + mock_updated = {"id": 987, "status": "completed", "result": {"output": "Task completed successfully"}, "web_url": "https://example.com/run/987"} + return mock_updated - + def test_full_workflow(self, mock_response, mock_updated_response): """Test a complete agent workflow from initialization to status check""" - with patch("codegen.agents.agent.ApiClient") as mock_api_client_class, \ - patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, \ - patch.object(Configuration, "__init__", return_value=None): - + with ( + patch("codegen.agents.agent.ApiClient") as mock_api_client_class, + patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, + patch.object(Configuration, "__init__", return_value=None), + ): # Setup mocks mock_api_client = MagicMock() # Remove spec to allow dynamic attributes mock_api_client.configuration = MagicMock() # Create configuration attribute mock_api_client.configuration.access_token = "test-token" mock_api_client_class.return_value = mock_api_client - + # Setup agents API mock mock_agents_api = MagicMock(spec=AgentsApi) mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.return_value = mock_response mock_agents_api_class.return_value = mock_agents_api - + # We're patching the same class for both the Agent and AgentTask mock_inner_agents_api = mock_agents_api mock_inner_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_updated_response - + # Initialize agent agent = Agent(token="test-token", org_id=123) - + # Run agent job = agent.run("Execute this instruction") - + # Verify job properties assert job.id == 987 assert job.status == "running" assert job.result is None - + # Check status status = agent.get_status() - + # Verify API calls - mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_called_once_with( - agent_run_id=987, - org_id=123, - authorization="Bearer test-token" - ) - + mock_agents_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.assert_called_once_with(agent_run_id=987, org_id=123, authorization="Bearer test-token") + # Verify status assert isinstance(status, dict) assert status["id"] == 987 assert status["status"] == "completed" assert status["result"] == {"output": "Task completed successfully"} assert status["web_url"] == "https://example.com/run/987" - + def test_exception_handling(self): """Test handling of API exceptions during agent run""" - with patch("codegen.agents.agent.ApiClient"), \ - patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, \ - patch.object(Configuration, "__init__", return_value=None): - + with patch("codegen.agents.agent.ApiClient"), patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, patch.object(Configuration, "__init__", return_value=None): # Setup API to raise exception mock_agents_api = MagicMock(spec=AgentsApi) mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.side_effect = Exception("API Error") mock_agents_api_class.return_value = mock_agents_api - + # Initialize agent agent = Agent(token="test-token", org_id=123) - + # Run agent and expect exception with pytest.raises(Exception) as excinfo: agent.run("Execute this instruction") - - assert "API Error" in str(excinfo.value) \ No newline at end of file + + assert "API Error" in str(excinfo.value) diff --git a/tests/unit/codegen/agents/test_api_client.py b/tests/unit/codegen/agents/test_api_client.py index e563f98bf..afa774bd6 100644 --- a/tests/unit/codegen/agents/test_api_client.py +++ b/tests/unit/codegen/agents/test_api_client.py @@ -1,15 +1,14 @@ -import pytest -import json import datetime import decimal -from unittest.mock import MagicMock, patch from enum import Enum -from typing import Dict, List, Optional, Tuple, Any, Union +from unittest.mock import MagicMock, patch + +import pytest from pydantic import SecretStr from codegen.agents.client.openapi_client.api_client import ApiClient -from codegen.agents.client.openapi_client.configuration import Configuration from codegen.agents.client.openapi_client.api_response import ApiResponse +from codegen.agents.client.openapi_client.configuration import Configuration from codegen.agents.client.openapi_client.exceptions import ApiException, ApiValueError @@ -22,13 +21,12 @@ class TestModel: def __init__(self, name: str, value: int): self.name = name self.value = value - + def to_dict(self): return {"name": self.name, "value": self.value} class TestApiClient: - @pytest.fixture def api_client(self): config = Configuration() @@ -37,7 +35,7 @@ def api_client(self): client = ApiClient(configuration=config) # Return the client with mocked rest_client yield client - + def test_init_default_configuration(self): """Test initialization with default configuration""" with patch("codegen.agents.client.openapi_client.configuration.Configuration.get_default") as mock_get_default: @@ -46,79 +44,79 @@ def test_init_default_configuration(self): with patch("codegen.agents.client.openapi_client.rest.RESTClientObject"): client = ApiClient() assert client.configuration == mock_config - assert client.user_agent == 'OpenAPI-Generator/1.0.0/python' - + assert client.user_agent == "OpenAPI-Generator/1.0.0/python" + def test_user_agent(self, api_client): """Test user agent getter and setter""" api_client.user_agent = "TestAgent/1.0" assert api_client.user_agent == "TestAgent/1.0" assert api_client.default_headers["User-Agent"] == "TestAgent/1.0" - + def test_set_default_header(self, api_client): """Test setting default header""" api_client.set_default_header("Custom-Header", "Custom-Value") assert api_client.default_headers["Custom-Header"] == "Custom-Value" - + def test_sanitize_for_serialization_none(self, api_client): """Test sanitization of None value""" assert api_client.sanitize_for_serialization(None) is None - + def test_sanitize_for_serialization_enum(self, api_client): """Test sanitization of Enum value""" assert api_client.sanitize_for_serialization(TestEnum.VALUE1) == "value1" - + def test_sanitize_for_serialization_secret_str(self, api_client): """Test sanitization of SecretStr value""" secret = SecretStr("secret_value") assert api_client.sanitize_for_serialization(secret) == "secret_value" - + def test_sanitize_for_serialization_primitive(self, api_client): """Test sanitization of primitive values""" assert api_client.sanitize_for_serialization("string") == "string" assert api_client.sanitize_for_serialization(123) == 123 assert api_client.sanitize_for_serialization(True) == True assert api_client.sanitize_for_serialization(b"bytes") == b"bytes" - + def test_sanitize_for_serialization_list(self, api_client): """Test sanitization of list values""" data = [1, "string", None] assert api_client.sanitize_for_serialization(data) == [1, "string", None] - + def test_sanitize_for_serialization_tuple(self, api_client): """Test sanitization of tuple values""" data = (1, "string", None) assert api_client.sanitize_for_serialization(data) == (1, "string", None) - + def test_sanitize_for_serialization_datetime(self, api_client): """Test sanitization of datetime values""" dt = datetime.datetime(2022, 1, 1, 12, 0, 0) assert api_client.sanitize_for_serialization(dt) == "2022-01-01T12:00:00" - + date = datetime.date(2022, 1, 1) assert api_client.sanitize_for_serialization(date) == "2022-01-01" - + def test_sanitize_for_serialization_decimal(self, api_client): """Test sanitization of Decimal values""" dec = decimal.Decimal("123.45") assert api_client.sanitize_for_serialization(dec) == "123.45" - + def test_sanitize_for_serialization_dict(self, api_client): """Test sanitization of dict values""" data = {"key1": "value1", "key2": 123, "key3": None} assert api_client.sanitize_for_serialization(data) == data - + def test_sanitize_for_serialization_model(self, api_client): """Test sanitization of OpenAPI model""" model = TestModel("test", 123) assert api_client.sanitize_for_serialization(model) == {"name": "test", "value": 123} - + def test_deserialize_primitive(self, api_client): """Test deserialization of primitive values""" # Testing through __deserialize method assert api_client._ApiClient__deserialize_primitive("123", int) == 123 assert api_client._ApiClient__deserialize_primitive("true", bool) == True assert api_client._ApiClient__deserialize_primitive("12.34", float) == 12.34 - + def test_deserialize_date(self, api_client): """Test deserialization of date values""" date_str = "2022-01-01" @@ -127,7 +125,7 @@ def test_deserialize_date(self, api_client): assert result.year == 2022 assert result.month == 1 assert result.day == 1 - + def test_deserialize_datetime(self, api_client): """Test deserialization of datetime values""" dt_str = "2022-01-01T12:00:00Z" @@ -139,165 +137,139 @@ def test_deserialize_datetime(self, api_client): assert result.hour == 12 assert result.minute == 0 assert result.second == 0 - + def test_deserialize_enum(self, api_client): """Test deserialization of enum values""" assert api_client._ApiClient__deserialize_enum("value1", TestEnum) == TestEnum.VALUE1 - + # Test exception case with pytest.raises(ApiException): api_client._ApiClient__deserialize_enum("invalid", TestEnum) - + def test_parameters_to_tuples(self, api_client): """Test parameters_to_tuples method""" # Test with dictionary params = {"param1": "value1", "param2": "value2"} result = api_client.parameters_to_tuples(params, None) assert result == [("param1", "value1"), ("param2", "value2")] - + # Test with list of tuples params = [("param1", "value1"), ("param2", "value2")] result = api_client.parameters_to_tuples(params, None) assert result == params - + # Test with collection format params = {"param1": ["value1", "value2", "value3"]} collection_formats = {"param1": "csv"} result = api_client.parameters_to_tuples(params, collection_formats) assert result == [("param1", "value1,value2,value3")] - + # Test with 'multi' collection format params = {"param1": ["value1", "value2", "value3"]} collection_formats = {"param1": "multi"} result = api_client.parameters_to_tuples(params, collection_formats) assert result == [("param1", "value1"), ("param1", "value2"), ("param1", "value3")] - + def test_parameters_to_url_query(self, api_client): """Test parameters_to_url_query method""" # Test basic parameters params = {"param1": "value1", "param2": "value2"} result = api_client.parameters_to_url_query(params, None) assert result == "param1=value1¶m2=value2" - + # Test with boolean values params = {"param1": True, "param2": False} result = api_client.parameters_to_url_query(params, None) assert result == "param1=true¶m2=false" - + # Test with numeric values params = {"param1": 123, "param2": 45.67} result = api_client.parameters_to_url_query(params, None) assert result == "param1=123¶m2=45.67" - + # Test with dict values (should be JSON serialized) params = {"param1": {"key": "value"}} result = api_client.parameters_to_url_query(params, None) - assert result == 'param1=%7B%22key%22%3A%20%22value%22%7D' - + assert result == "param1=%7B%22key%22%3A%20%22value%22%7D" + # Test with 'multi' collection format params = {"param1": ["value1", "value2", "value3"]} collection_formats = {"param1": "multi"} result = api_client.parameters_to_url_query(params, collection_formats) assert result == "param1=value1¶m1=value2¶m1=value3" - + def test_select_header_accept(self, api_client): """Test select_header_accept method""" # Test empty accepts assert api_client.select_header_accept([]) is None - + # Test with JSON in accepts accepts = ["application/xml", "application/json", "text/plain"] assert api_client.select_header_accept(accepts) == "application/json" - + # Test without JSON in accepts accepts = ["application/xml", "text/plain"] assert api_client.select_header_accept(accepts) == "application/xml" - + def test_select_header_content_type(self, api_client): """Test select_header_content_type method""" # Test empty content types assert api_client.select_header_content_type([]) is None - + # Test with JSON in content types content_types = ["application/xml", "application/json", "text/plain"] assert api_client.select_header_content_type(content_types) == "application/json" - + # Test without JSON in content types content_types = ["application/xml", "text/plain"] assert api_client.select_header_content_type(content_types) == "application/xml" - + def test_update_params_for_auth(self, api_client): """Test update_params_for_auth method""" # Setup mock configuration api_client.configuration = MagicMock() api_client.configuration.auth_settings.return_value = { - "api_key": { - "in": "header", - "key": "X-API-KEY", - "value": "test-api-key", - "type": "apiKey" - }, - "query_param": { - "in": "query", - "key": "api_key", - "value": "test-query-key", - "type": "apiKey" - }, - "cookie_auth": { - "in": "cookie", - "key": "session", - "value": "test-cookie", - "type": "apiKey" - } + "api_key": {"in": "header", "key": "X-API-KEY", "value": "test-api-key", "type": "apiKey"}, + "query_param": {"in": "query", "key": "api_key", "value": "test-query-key", "type": "apiKey"}, + "cookie_auth": {"in": "cookie", "key": "session", "value": "test-cookie", "type": "apiKey"}, } - + # Test authentication in header headers = {} queries = [] api_client.update_params_for_auth(headers, queries, ["api_key"], "", "", None) assert headers == {"X-API-KEY": "test-api-key"} - + # Test authentication in query headers = {} queries = [] api_client.update_params_for_auth(headers, queries, ["query_param"], "", "", None) assert queries == [("api_key", "test-query-key")] - + # Test authentication in cookie headers = {} queries = [] api_client.update_params_for_auth(headers, queries, ["cookie_auth"], "", "", None) assert headers == {"Cookie": "test-cookie"} - + # Test with request_auth override headers = {} queries = [] - request_auth = { - "in": "header", - "key": "X-CUSTOM-KEY", - "value": "custom-value", - "type": "apiKey" - } + request_auth = {"in": "header", "key": "X-CUSTOM-KEY", "value": "custom-value", "type": "apiKey"} api_client.update_params_for_auth(headers, queries, ["api_key"], "", "", None, request_auth) assert headers == {"X-CUSTOM-KEY": "custom-value"} - + # Test with invalid auth location - invalid_auth = { - "in": "invalid", - "key": "x-key", - "value": "value", - "type": "apiKey" - } + invalid_auth = {"in": "invalid", "key": "x-key", "value": "value", "type": "apiKey"} with pytest.raises(ApiValueError): api_client._apply_auth_params({}, [], "", "", None, invalid_auth) - + def test_param_serialize(self, api_client): """Test param_serialize method""" - with patch.object(api_client, 'sanitize_for_serialization') as mock_sanitize, \ - patch.object(api_client, 'default_headers', {}): # Empty the default headers + with patch.object(api_client, "sanitize_for_serialization") as mock_sanitize, patch.object(api_client, "default_headers", {}): # Empty the default headers # Set return values for sanitize_for_serialization mock_sanitize.side_effect = lambda x: x - + # Test with basic parameters method = "GET" resource_path = "/test/{id}" @@ -305,12 +277,9 @@ def test_param_serialize(self, api_client): query_params = {"query": "value"} header_params = {"header": "value"} body = {"body": "content"} - - result = api_client.param_serialize( - method, resource_path, path_params, query_params, - header_params, body, None, None, None, None, None - ) - + + result = api_client.param_serialize(method, resource_path, path_params, query_params, header_params, body, None, None, None, None, None) + # Verify result assert isinstance(result, tuple) assert result[0] == "GET" # method @@ -319,42 +288,30 @@ def test_param_serialize(self, api_client): assert "header" in result[2] # header_params contains 'header' key assert result[2]["header"] == "value" # header_params has correct value assert result[3] == {"body": "content"} # body - + def test_call_api(self, api_client): """Test call_api method""" # Mock the rest_client.request method api_client.rest_client.request = MagicMock() mock_response = MagicMock() api_client.rest_client.request.return_value = mock_response - + # Call the method - response = api_client.call_api( - "GET", - "https://api.example.com/test", - {"header": "value"}, - {"body": "content"}, - [("param", "value")], - 30 - ) - + response = api_client.call_api("GET", "https://api.example.com/test", {"header": "value"}, {"body": "content"}, [("param", "value")], 30) + # Verify the call to rest_client.request api_client.rest_client.request.assert_called_once_with( - "GET", - "https://api.example.com/test", - headers={"header": "value"}, - body={"body": "content"}, - post_params=[("param", "value")], - _request_timeout=30 + "GET", "https://api.example.com/test", headers={"header": "value"}, body={"body": "content"}, post_params=[("param", "value")], _request_timeout=30 ) - + # Verify the result assert response == mock_response - + # Test exception case api_client.rest_client.request.side_effect = ApiException(400) with pytest.raises(ApiException): api_client.call_api("GET", "https://api.example.com/test") - + def test_response_deserialize(self, api_client): """Test response_deserialize method""" # Mock RESTResponse @@ -363,30 +320,27 @@ def test_response_deserialize(self, api_client): response_data.data = b'{"name": "test", "value": 123}' response_data.getheader.return_value = "application/json" response_data.getheaders.return_value = {"Content-Type": "application/json"} - + # Create a mock response to return mock_api_response = MagicMock(spec=ApiResponse) - + # Mock deserialize method and ApiResponse constructor - with patch.object(api_client, 'deserialize') as mock_deserialize, \ - patch("codegen.agents.client.openapi_client.api_client.ApiResponse", return_value=mock_api_response) as mock_api_response_class: + with ( + patch.object(api_client, "deserialize") as mock_deserialize, + patch("codegen.agents.client.openapi_client.api_client.ApiResponse", return_value=mock_api_response) as mock_api_response_class, + ): mock_deserialize.return_value = {"name": "test", "value": 123} - + # Test successful response deserialization response_types_map = {"200": "TestModel"} result = api_client.response_deserialize(response_data, response_types_map) - + # Verify ApiResponse was called with correct params - mock_api_response_class.assert_called_once_with( - status_code=200, - data={"name": "test", "value": 123}, - headers={"Content-Type": "application/json"}, - raw_data=response_data.data - ) - + mock_api_response_class.assert_called_once_with(status_code=200, data={"name": "test", "value": 123}, headers={"Content-Type": "application/json"}, raw_data=response_data.data) + # Verify the result assert result == mock_api_response - + def test_response_deserialize_error(self, api_client): """Test response_deserialize method with error response""" # Mock RESTResponse for error @@ -395,14 +349,13 @@ def test_response_deserialize_error(self, api_client): response_data.data = b'{"error": "Bad Request"}' response_data.getheader.return_value = "application/json" response_data.getheaders.return_value = {"Content-Type": "application/json"} - + # Mock methods - with patch.object(api_client, 'deserialize') as mock_deserialize, \ - patch("codegen.agents.client.openapi_client.exceptions.ApiException.from_response") as mock_exception: + with patch.object(api_client, "deserialize") as mock_deserialize, patch("codegen.agents.client.openapi_client.exceptions.ApiException.from_response") as mock_exception: mock_deserialize.return_value = {"error": "Bad Request"} mock_exception.side_effect = ApiException(400) - + # Test error response response_types_map = {"400": "ErrorModel"} with pytest.raises(ApiException): - api_client.response_deserialize(response_data, response_types_map) \ No newline at end of file + api_client.response_deserialize(response_data, response_types_map) diff --git a/tests/unit/codegen/agents/test_simple_agent.py b/tests/unit/codegen/agents/test_simple_agent.py index dd3d63eb8..522093b87 100644 --- a/tests/unit/codegen/agents/test_simple_agent.py +++ b/tests/unit/codegen/agents/test_simple_agent.py @@ -1,16 +1,18 @@ -""" -Simplified test for the Agent class focusing on public interfaces. +"""Simplified test for the Agent class focusing on public interfaces. This approach avoids the complexity of mocking internal implementations. """ + +from unittest.mock import MagicMock, patch + import pytest -from unittest.mock import MagicMock, patch, ANY + from codegen.agents.agent import Agent from codegen.agents.constants import CODEGEN_BASE_API_URL class TestAgent: """Test the public interface of the Agent class.""" - + @pytest.fixture def mock_agents_api(self): """Create a mock for the AgentsApi.""" @@ -21,57 +23,52 @@ def mock_agents_api(self): mock_create_response.status = "running" mock_create_response.result = None mock_create_response.web_url = "https://example.com/agent/123" - + # Set up response for get_agent_run mock_get_response = MagicMock() mock_get_response.status = "completed" mock_get_response.result = {"output": "Task completed successfully"} - + # Configure the mock methods mock_api.create_agent_run_v1_organizations_org_id_agent_run_post.return_value = mock_create_response mock_api.get_agent_run_v1_organizations_org_id_agent_run_agent_run_id_get.return_value = mock_get_response - + return mock_api - + @pytest.fixture def agent(self, mock_agents_api): """Create an Agent with mocked dependencies.""" - with patch("codegen.agents.agent.ApiClient"), \ - patch("codegen.agents.agent.AgentsApi", return_value=mock_agents_api), \ - patch("codegen.agents.agent.Configuration"): + with patch("codegen.agents.agent.ApiClient"), patch("codegen.agents.agent.AgentsApi", return_value=mock_agents_api), patch("codegen.agents.agent.Configuration"): agent = Agent(token="test-token", org_id=42) return agent - + def test_initialization(self): """Test Agent initialization with different parameters.""" # Test with explicit org_id - with patch("codegen.agents.agent.ApiClient"), \ - patch("codegen.agents.agent.AgentsApi"), \ - patch("codegen.agents.agent.Configuration") as mock_config: - + with patch("codegen.agents.agent.ApiClient"), patch("codegen.agents.agent.AgentsApi"), patch("codegen.agents.agent.Configuration") as mock_config: agent = Agent(token="test-token", org_id=42) assert agent.token == "test-token" assert agent.org_id == 42 assert agent.current_job is None - + # Verify Configuration was initialized correctly mock_config.assert_called_once_with(host=CODEGEN_BASE_API_URL, access_token="test-token") - + # Test with env var for org_id with patch.dict("os.environ", {"CODEGEN_ORG_ID": "99"}): agent = Agent(token="test-token") assert agent.org_id == 99 - + # Test with custom base URL custom_url = "https://custom-api.example.com" agent = Agent(token="test-token", org_id=42, base_url=custom_url) mock_config.assert_called_with(host=custom_url, access_token="test-token") - + def test_run_agent(self, agent, mock_agents_api): """Test running an agent with a prompt.""" # Run the agent job = agent.run("Test prompt") - + # Verify the API was called correctly mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.assert_called_once() call_args = mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.call_args[1] @@ -79,35 +76,31 @@ def test_run_agent(self, agent, mock_agents_api): assert call_args["authorization"] == "Bearer test-token" assert call_args["_headers"] == {"Content-Type": "application/json"} assert call_args["create_agent_run_input"].prompt == "Test prompt" - + # Verify the job properties assert job.id == 123 assert job.status == "running" assert job.result is None assert job.web_url == "https://example.com/agent/123" assert agent.current_job == job - + def test_get_status_no_job(self, agent): """Test get_status when no job has been run.""" assert agent.get_status() is None - - + def test_exception_handling(self): """Test handling of API exceptions during agent run.""" - with patch("codegen.agents.agent.ApiClient"), \ - patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, \ - patch("codegen.agents.agent.Configuration"): - + with patch("codegen.agents.agent.ApiClient"), patch("codegen.agents.agent.AgentsApi") as mock_agents_api_class, patch("codegen.agents.agent.Configuration"): # Setup API to raise exception mock_agents_api = MagicMock() mock_agents_api.create_agent_run_v1_organizations_org_id_agent_run_post.side_effect = Exception("API Error") mock_agents_api_class.return_value = mock_agents_api - + # Initialize agent agent = Agent(token="test-token", org_id=123) - + # Run agent and expect exception with pytest.raises(Exception) as excinfo: agent.run("Execute this instruction") - - assert "API Error" in str(excinfo.value) \ No newline at end of file + + assert "API Error" in str(excinfo.value) From defc6b81f8ef1f09b85056270df3b6dd42837cb4 Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Tue, 8 Apr 2025 11:04:39 -0700 Subject: [PATCH 7/8] fix: remove notebook --- src/codegen/agents/scratch.ipynb | 41 -------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/codegen/agents/scratch.ipynb diff --git a/src/codegen/agents/scratch.ipynb b/src/codegen/agents/scratch.ipynb deleted file mode 100644 index 988961311..000000000 --- a/src/codegen/agents/scratch.ipynb +++ /dev/null @@ -1,41 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from codegen.agents.client.openapi_client.api.agents_api import AgentsApi" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.13.0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} From b53586b47560c49ae4bdfa55e72c8d9f0c1af175 Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Tue, 8 Apr 2025 11:22:00 -0700 Subject: [PATCH 8/8] fix: lint --- tests/unit/codegen/agents/test_api_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/codegen/agents/test_api_client.py b/tests/unit/codegen/agents/test_api_client.py index afa774bd6..ff75e1261 100644 --- a/tests/unit/codegen/agents/test_api_client.py +++ b/tests/unit/codegen/agents/test_api_client.py @@ -89,8 +89,8 @@ def test_sanitize_for_serialization_tuple(self, api_client): def test_sanitize_for_serialization_datetime(self, api_client): """Test sanitization of datetime values""" - dt = datetime.datetime(2022, 1, 1, 12, 0, 0) - assert api_client.sanitize_for_serialization(dt) == "2022-01-01T12:00:00" + dt = datetime.datetime(2022, 1, 1, 12, 0, 0, tzinfo=datetime.timezone.utc) + assert api_client.sanitize_for_serialization(dt) == "2022-01-01T12:00:00+00:00" date = datetime.date(2022, 1, 1) assert api_client.sanitize_for_serialization(date) == "2022-01-01"