From 826b1e979d822cfff84d84add1dcf4ef4c78e775 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 1 Jan 2026 15:37:20 +0100 Subject: [PATCH] Forgot to join deps --- .../.github/workflows/python.yml | 38 + .../api-resources/auth-components/.gitignore | 66 ++ .../auth-components/.gitlab-ci.yml | 31 + .../auth-components/.openapi-generator-ignore | 23 + .../auth-components/.openapi-generator/FILES | 36 + .../.openapi-generator/VERSION | 1 + .../api-resources/auth-components/.travis.yml | 17 + .../api-resources/auth-components/README.md | 108 +++ .../auth-components/board_mate/__init__.py | 0 .../board_mate/auth/__init__.py | 36 + .../board_mate/auth/api/__init__.py | 5 + .../board_mate/auth/api/auth_api.py | 187 +++++ .../board_mate/auth/api_client.py | 758 ++++++++++++++++++ .../board_mate/auth/api_response.py | 25 + .../board_mate/auth/configuration.py | 434 ++++++++++ .../board_mate/auth/exceptions.py | 166 ++++ .../board_mate/auth/models/__init__.py | 19 + .../auth/models/auth_request_dto.py | 73 ++ .../auth/models/auth_response_dto.py | 77 ++ .../models/response_body_auth_response_dto.py | 75 ++ .../auth-components/board_mate/auth/py.typed | 0 .../auth-components/board_mate/auth/rest.py | 303 +++++++ .../auth-components/docs/AuthApi.md | 75 ++ .../auth-components/docs/AuthRequestDto.md | 29 + .../auth-components/docs/AuthResponseDto.md | 31 + .../docs/ResponseBodyAuthResponseDto.md | 30 + .../api-resources/auth-components/git_push.sh | 57 ++ .../auth-components/pyproject.toml | 30 + .../auth-components/requirements.txt | 5 + .../api-resources/auth-components/setup.cfg | 2 + .../api-resources/auth-components/setup.py | 49 ++ .../auth-components/test-requirements.txt | 3 + .../auth-components/test/__init__.py | 0 .../auth-components/test/test_auth_api.py | 38 + .../test/test_auth_request_dto.py | 53 ++ .../test/test_auth_response_dto.py | 55 ++ .../test_response_body_auth_response_dto.py | 54 ++ .../api-resources/auth-components/tox.ini | 9 + .../.github/workflows/python.yml | 38 + .../client-components/.gitignore | 66 ++ .../client-components/.gitlab-ci.yml | 31 + .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 33 + .../.openapi-generator/VERSION | 1 + .../client-components/.travis.yml | 17 + .../api-resources/client-components/README.md | 107 +++ .../client-components/board_mate/__init__.py | 0 .../board_mate/client/__init__.py | 35 + .../board_mate/client/api/__init__.py | 5 + .../board_mate/client/api/client_api.py | 187 +++++ .../board_mate/client/api_client.py | 758 ++++++++++++++++++ .../board_mate/client/api_response.py | 25 + .../board_mate/client/configuration.py | 434 ++++++++++ .../board_mate/client/exceptions.py | 166 ++++ .../board_mate/client/models/__init__.py | 18 + .../board_mate/client/models/client_dto.py | 75 ++ .../client/models/response_body_string.py | 75 ++ .../board_mate/client/py.typed | 0 .../board_mate/client/rest.py | 303 +++++++ .../client-components/docs/ClientApi.md | 75 ++ .../client-components/docs/ClientDto.md | 30 + .../docs/ResponseBodyString.md | 30 + .../client-components/git_push.sh | 57 ++ .../client-components/pyproject.toml | 30 + .../client-components/requirements.txt | 5 + .../api-resources/client-components/setup.cfg | 2 + .../api-resources/client-components/setup.py | 49 ++ .../client-components/test-requirements.txt | 3 + .../client-components/test/__init__.py | 0 .../client-components/test/test_client_api.py | 38 + .../client-components/test/test_client_dto.py | 54 ++ .../test/test_response_body_string.py | 54 ++ .../api-resources/client-components/tox.ini | 9 + .../.github/workflows/python.yml | 38 + .../api-resources/game-components/.gitignore | 66 ++ .../game-components/.gitlab-ci.yml | 31 + .../game-components/.openapi-generator-ignore | 23 + .../game-components/.openapi-generator/FILES | 39 + .../.openapi-generator/VERSION | 1 + .../api-resources/game-components/.travis.yml | 17 + .../api-resources/game-components/README.md | 112 +++ .../game-components/board_mate/__init__.py | 0 .../board_mate/game/__init__.py | 37 + .../board_mate/game/api/__init__.py | 5 + .../board_mate/game/api/game_api.py | 482 +++++++++++ .../board_mate/game/api_client.py | 758 ++++++++++++++++++ .../board_mate/game/api_response.py | 25 + .../board_mate/game/configuration.py | 434 ++++++++++ .../board_mate/game/exceptions.py | 166 ++++ .../board_mate/game/models/__init__.py | 20 + .../board_mate/game/models/game_dto.py | 77 ++ .../board_mate/game/models/move_dto.py | 71 ++ .../game/models/response_body_game_dto.py | 75 ++ .../game/models/response_body_string.py | 75 ++ .../game-components/board_mate/game/py.typed | 0 .../game-components/board_mate/game/rest.py | 303 +++++++ .../game-components/docs/GameApi.md | 210 +++++ .../game-components/docs/GameDto.md | 31 + .../game-components/docs/MoveDto.md | 28 + .../docs/ResponseBodyGameDto.md | 30 + .../docs/ResponseBodyString.md | 30 + .../api-resources/game-components/git_push.sh | 57 ++ .../game-components/pyproject.toml | 30 + .../game-components/requirements.txt | 5 + .../api-resources/game-components/setup.cfg | 2 + .../api-resources/game-components/setup.py | 49 ++ .../game-components/test-requirements.txt | 3 + .../game-components/test/__init__.py | 0 .../game-components/test/test_game_api.py | 52 ++ .../game-components/test/test_game_dto.py | 55 ++ .../game-components/test/test_move_dto.py | 52 ++ .../test/test_response_body_game_dto.py | 54 ++ .../test/test_response_body_string.py | 54 ++ .../api-resources/game-components/tox.ini | 9 + 114 files changed, 9437 insertions(+) create mode 100644 api-customer/api-resources/auth-components/.github/workflows/python.yml create mode 100644 api-customer/api-resources/auth-components/.gitignore create mode 100644 api-customer/api-resources/auth-components/.gitlab-ci.yml create mode 100644 api-customer/api-resources/auth-components/.openapi-generator-ignore create mode 100644 api-customer/api-resources/auth-components/.openapi-generator/FILES create mode 100644 api-customer/api-resources/auth-components/.openapi-generator/VERSION create mode 100644 api-customer/api-resources/auth-components/.travis.yml create mode 100644 api-customer/api-resources/auth-components/README.md create mode 100644 api-customer/api-resources/auth-components/board_mate/__init__.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/__init__.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/api/__init__.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/api/auth_api.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/api_client.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/api_response.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/configuration.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/exceptions.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/models/__init__.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/models/auth_request_dto.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/models/auth_response_dto.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/models/response_body_auth_response_dto.py create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/py.typed create mode 100644 api-customer/api-resources/auth-components/board_mate/auth/rest.py create mode 100644 api-customer/api-resources/auth-components/docs/AuthApi.md create mode 100644 api-customer/api-resources/auth-components/docs/AuthRequestDto.md create mode 100644 api-customer/api-resources/auth-components/docs/AuthResponseDto.md create mode 100644 api-customer/api-resources/auth-components/docs/ResponseBodyAuthResponseDto.md create mode 100644 api-customer/api-resources/auth-components/git_push.sh create mode 100644 api-customer/api-resources/auth-components/pyproject.toml create mode 100644 api-customer/api-resources/auth-components/requirements.txt create mode 100644 api-customer/api-resources/auth-components/setup.cfg create mode 100644 api-customer/api-resources/auth-components/setup.py create mode 100644 api-customer/api-resources/auth-components/test-requirements.txt create mode 100644 api-customer/api-resources/auth-components/test/__init__.py create mode 100644 api-customer/api-resources/auth-components/test/test_auth_api.py create mode 100644 api-customer/api-resources/auth-components/test/test_auth_request_dto.py create mode 100644 api-customer/api-resources/auth-components/test/test_auth_response_dto.py create mode 100644 api-customer/api-resources/auth-components/test/test_response_body_auth_response_dto.py create mode 100644 api-customer/api-resources/auth-components/tox.ini create mode 100644 api-customer/api-resources/client-components/.github/workflows/python.yml create mode 100644 api-customer/api-resources/client-components/.gitignore create mode 100644 api-customer/api-resources/client-components/.gitlab-ci.yml create mode 100644 api-customer/api-resources/client-components/.openapi-generator-ignore create mode 100644 api-customer/api-resources/client-components/.openapi-generator/FILES create mode 100644 api-customer/api-resources/client-components/.openapi-generator/VERSION create mode 100644 api-customer/api-resources/client-components/.travis.yml create mode 100644 api-customer/api-resources/client-components/README.md create mode 100644 api-customer/api-resources/client-components/board_mate/__init__.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/__init__.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/api/__init__.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/api/client_api.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/api_client.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/api_response.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/configuration.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/exceptions.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/models/__init__.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/models/client_dto.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/models/response_body_string.py create mode 100644 api-customer/api-resources/client-components/board_mate/client/py.typed create mode 100644 api-customer/api-resources/client-components/board_mate/client/rest.py create mode 100644 api-customer/api-resources/client-components/docs/ClientApi.md create mode 100644 api-customer/api-resources/client-components/docs/ClientDto.md create mode 100644 api-customer/api-resources/client-components/docs/ResponseBodyString.md create mode 100644 api-customer/api-resources/client-components/git_push.sh create mode 100644 api-customer/api-resources/client-components/pyproject.toml create mode 100644 api-customer/api-resources/client-components/requirements.txt create mode 100644 api-customer/api-resources/client-components/setup.cfg create mode 100644 api-customer/api-resources/client-components/setup.py create mode 100644 api-customer/api-resources/client-components/test-requirements.txt create mode 100644 api-customer/api-resources/client-components/test/__init__.py create mode 100644 api-customer/api-resources/client-components/test/test_client_api.py create mode 100644 api-customer/api-resources/client-components/test/test_client_dto.py create mode 100644 api-customer/api-resources/client-components/test/test_response_body_string.py create mode 100644 api-customer/api-resources/client-components/tox.ini create mode 100644 api-customer/api-resources/game-components/.github/workflows/python.yml create mode 100644 api-customer/api-resources/game-components/.gitignore create mode 100644 api-customer/api-resources/game-components/.gitlab-ci.yml create mode 100644 api-customer/api-resources/game-components/.openapi-generator-ignore create mode 100644 api-customer/api-resources/game-components/.openapi-generator/FILES create mode 100644 api-customer/api-resources/game-components/.openapi-generator/VERSION create mode 100644 api-customer/api-resources/game-components/.travis.yml create mode 100644 api-customer/api-resources/game-components/README.md create mode 100644 api-customer/api-resources/game-components/board_mate/__init__.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/__init__.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/api/__init__.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/api/game_api.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/api_client.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/api_response.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/configuration.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/exceptions.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/models/__init__.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/models/game_dto.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/models/move_dto.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/models/response_body_game_dto.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/models/response_body_string.py create mode 100644 api-customer/api-resources/game-components/board_mate/game/py.typed create mode 100644 api-customer/api-resources/game-components/board_mate/game/rest.py create mode 100644 api-customer/api-resources/game-components/docs/GameApi.md create mode 100644 api-customer/api-resources/game-components/docs/GameDto.md create mode 100644 api-customer/api-resources/game-components/docs/MoveDto.md create mode 100644 api-customer/api-resources/game-components/docs/ResponseBodyGameDto.md create mode 100644 api-customer/api-resources/game-components/docs/ResponseBodyString.md create mode 100644 api-customer/api-resources/game-components/git_push.sh create mode 100644 api-customer/api-resources/game-components/pyproject.toml create mode 100644 api-customer/api-resources/game-components/requirements.txt create mode 100644 api-customer/api-resources/game-components/setup.cfg create mode 100644 api-customer/api-resources/game-components/setup.py create mode 100644 api-customer/api-resources/game-components/test-requirements.txt create mode 100644 api-customer/api-resources/game-components/test/__init__.py create mode 100644 api-customer/api-resources/game-components/test/test_game_api.py create mode 100644 api-customer/api-resources/game-components/test/test_game_dto.py create mode 100644 api-customer/api-resources/game-components/test/test_move_dto.py create mode 100644 api-customer/api-resources/game-components/test/test_response_body_game_dto.py create mode 100644 api-customer/api-resources/game-components/test/test_response_body_string.py create mode 100644 api-customer/api-resources/game-components/tox.ini diff --git a/api-customer/api-resources/auth-components/.github/workflows/python.yml b/api-customer/api-resources/auth-components/.github/workflows/python.yml new file mode 100644 index 00000000..36262fa7 --- /dev/null +++ b/api-customer/api-resources/auth-components/.github/workflows/python.yml @@ -0,0 +1,38 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: board_mate.auth Python package + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/api-customer/api-resources/auth-components/.gitignore b/api-customer/api-resources/auth-components/.gitignore new file mode 100644 index 00000000..43995bd4 --- /dev/null +++ b/api-customer/api-resources/auth-components/.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/api-customer/api-resources/auth-components/.gitlab-ci.yml b/api-customer/api-resources/auth-components/.gitlab-ci.yml new file mode 100644 index 00000000..662793bc --- /dev/null +++ b/api-customer/api-resources/auth-components/.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=board_mate.auth + +pytest-3.7: + extends: .pytest + image: python:3.7-alpine +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 diff --git a/api-customer/api-resources/auth-components/.openapi-generator-ignore b/api-customer/api-resources/auth-components/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/api-customer/api-resources/auth-components/.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/api-customer/api-resources/auth-components/.openapi-generator/FILES b/api-customer/api-resources/auth-components/.openapi-generator/FILES new file mode 100644 index 00000000..c2c0d52f --- /dev/null +++ b/api-customer/api-resources/auth-components/.openapi-generator/FILES @@ -0,0 +1,36 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.openapi-generator-ignore +.travis.yml +README.md +board_mate/__init__.py +board_mate/auth/__init__.py +board_mate/auth/api/__init__.py +board_mate/auth/api/auth_api.py +board_mate/auth/api_client.py +board_mate/auth/api_response.py +board_mate/auth/configuration.py +board_mate/auth/exceptions.py +board_mate/auth/models/__init__.py +board_mate/auth/models/auth_request_dto.py +board_mate/auth/models/auth_response_dto.py +board_mate/auth/models/response_body_auth_response_dto.py +board_mate/auth/py.typed +board_mate/auth/rest.py +docs/AuthApi.md +docs/AuthRequestDto.md +docs/AuthResponseDto.md +docs/ResponseBodyAuthResponseDto.md +git_push.sh +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +test/test_auth_api.py +test/test_auth_request_dto.py +test/test_auth_response_dto.py +test/test_response_body_auth_response_dto.py +tox.ini diff --git a/api-customer/api-resources/auth-components/.openapi-generator/VERSION b/api-customer/api-resources/auth-components/.openapi-generator/VERSION new file mode 100644 index 00000000..73a86b19 --- /dev/null +++ b/api-customer/api-resources/auth-components/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.0.1 \ No newline at end of file diff --git a/api-customer/api-resources/auth-components/.travis.yml b/api-customer/api-resources/auth-components/.travis.yml new file mode 100644 index 00000000..f59d9508 --- /dev/null +++ b/api-customer/api-resources/auth-components/.travis.yml @@ -0,0 +1,17 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + # uncomment the following if needed + #- "3.11-dev" # 3.11 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=board_mate.auth diff --git a/api-customer/api-resources/auth-components/README.md b/api-customer/api-resources/auth-components/README.md new file mode 100644 index 00000000..ff348f73 --- /dev/null +++ b/api-customer/api-resources/auth-components/README.md @@ -0,0 +1,108 @@ +# board-mate.auth +boardmate_api API + +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 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen + +## Requirements. + +Python 3.7+ + +## 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 board_mate.auth +``` + +### 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 board_mate.auth +``` + +### Tests + +Execute `pytest` to run the tests. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python + +import time +import board_mate.auth +from board_mate.auth.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.auth.Configuration( + host = "https://boardmate_api" +) + + + +# Enter a context with an instance of the API client +with board_mate.auth.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.auth.AuthApi(api_client) + auth_request_dto = board_mate.auth.AuthRequestDto() # AuthRequestDto | + + try: + # POST authenticate + api_response = api_instance.login(auth_request_dto) + print("The response of AuthApi->login:\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling AuthApi->login: %s\n" % e) + +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://boardmate_api* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AuthApi* | [**login**](docs/AuthApi.md#login) | **POST** /authenticate | POST authenticate + + +## Documentation For Models + + - [AuthRequestDto](docs/AuthRequestDto.md) + - [AuthResponseDto](docs/AuthResponseDto.md) + - [ResponseBodyAuthResponseDto](docs/ResponseBodyAuthResponseDto.md) + + + +## Documentation For Authorization + +Endpoints do not require authorization. + + +## Author + + + + diff --git a/api-customer/api-resources/auth-components/board_mate/__init__.py b/api-customer/api-resources/auth-components/board_mate/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/auth-components/board_mate/auth/__init__.py b/api-customer/api-resources/auth-components/board_mate/auth/__init__.py new file mode 100644 index 00000000..a2a31daf --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/__init__.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +# flake8: noqa + +""" + boardmate_api API + + boardmate_api API + + 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 board_mate.auth.api.auth_api import AuthApi + +# import ApiClient +from board_mate.auth.api_response import ApiResponse +from board_mate.auth.api_client import ApiClient +from board_mate.auth.configuration import Configuration +from board_mate.auth.exceptions import OpenApiException +from board_mate.auth.exceptions import ApiTypeError +from board_mate.auth.exceptions import ApiValueError +from board_mate.auth.exceptions import ApiKeyError +from board_mate.auth.exceptions import ApiAttributeError +from board_mate.auth.exceptions import ApiException + +# import models into sdk package +from board_mate.auth.models.auth_request_dto import AuthRequestDto +from board_mate.auth.models.auth_response_dto import AuthResponseDto +from board_mate.auth.models.response_body_auth_response_dto import ResponseBodyAuthResponseDto diff --git a/api-customer/api-resources/auth-components/board_mate/auth/api/__init__.py b/api-customer/api-resources/auth-components/board_mate/auth/api/__init__.py new file mode 100644 index 00000000..9e64d4a1 --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/api/__init__.py @@ -0,0 +1,5 @@ +# flake8: noqa + +# import apis into api package +from board_mate.auth.api.auth_api import AuthApi + diff --git a/api-customer/api-resources/auth-components/board_mate/auth/api/auth_api.py b/api-customer/api-resources/auth-components/board_mate/auth/api/auth_api.py new file mode 100644 index 00000000..f85ea323 --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/api/auth_api.py @@ -0,0 +1,187 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from board_mate.auth.models.auth_request_dto import AuthRequestDto +from board_mate.auth.models.response_body_auth_response_dto import ResponseBodyAuthResponseDto + +from board_mate.auth.api_client import ApiClient +from board_mate.auth.api_response import ApiResponse +from board_mate.auth.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class AuthApi: + """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_arguments + def login(self, auth_request_dto : AuthRequestDto, **kwargs) -> ResponseBodyAuthResponseDto: # noqa: E501 + """POST authenticate # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.login(auth_request_dto, async_req=True) + >>> result = thread.get() + + :param auth_request_dto: (required) + :type auth_request_dto: AuthRequestDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ResponseBodyAuthResponseDto + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the login_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.login_with_http_info(auth_request_dto, **kwargs) # noqa: E501 + + @validate_arguments + def login_with_http_info(self, auth_request_dto : AuthRequestDto, **kwargs) -> ApiResponse: # noqa: E501 + """POST authenticate # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.login_with_http_info(auth_request_dto, async_req=True) + >>> result = thread.get() + + :param auth_request_dto: (required) + :type auth_request_dto: AuthRequestDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :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. + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ResponseBodyAuthResponseDto, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'auth_request_dto' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method login" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['auth_request_dto'] is not None: + _body_params = _params['auth_request_dto'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "ResponseBodyAuthResponseDto", + } + + return self.api_client.call_api( + '/authenticate', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/api-customer/api-resources/auth-components/board_mate/auth/api_client.py b/api-customer/api-resources/auth-components/board_mate/auth/api_client.py new file mode 100644 index 00000000..7cb45031 --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/api_client.py @@ -0,0 +1,758 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 atexit +import datetime +from dateutil.parser import parse +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +from urllib.parse import quote + +from board_mate.auth.configuration import Configuration +from board_mate.auth.api_response import ApiResponse +import board_mate.auth.models +from board_mate.auth import rest +from board_mate.auth.exceptions import ApiValueError, ApiException + + +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 + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + 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, + 'object': object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + self.pool_threads = pool_threads + + 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): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @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 __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_types_map=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None, + _request_auth=None): + + 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) + 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: + 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 + + try: + # perform request and return response + response_data = self.request( + method, url, + query_params=query_params, + headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + if e.body: + e.body = e.body.decode('utf-8') + raise e + + self.last_response = response_data + + return_data = None # assuming derialization is not needed + # data needs deserialization or returns HTTP data (deserialized) only + if _preload_content or _return_http_data_only: + 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) + + if response_type == "bytearray": + response_data.data = response_data.data + else: + 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_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type == "bytearray": + return_data = response_data.data + elif response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + + if _return_http_data_only: + return return_data + else: + 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 str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + 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, 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() + + if 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. + obj_dict = obj.to_dict() + + return {key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items()} + + def deserialize(self, response, response_type): + """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. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + 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['): + sub_kls = re.match(r'List\[(.*)]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).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(board_mate.auth.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) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_types_map=None, auth_settings=None, + async_req=None, _return_http_data_only=None, + collection_formats=None, _preload_content=True, + _request_timeout=None, _host=None, _request_auth=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :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 response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :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. + :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_token: dict, optional + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_types_map, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _request_auth) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_types_map, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _request_auth)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.get_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.head_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.options_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + elif method == "POST": + return self.rest_client.post_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.put_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.patch_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.delete_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + 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 = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + 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 = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, bool): + v = str(v).lower() + 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, 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(item) for item in new_params]) + + def files_parameters(self, files=None): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if files: + for k, v in files.items(): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + 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): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + 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): + """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) + return + + 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): + """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. + + :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: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).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_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/api-customer/api-resources/auth-components/board_mate/auth/api_response.py b/api-customer/api-resources/auth-components/board_mate/auth/api_response.py new file mode 100644 index 00000000..a0b62b95 --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/api_response.py @@ -0,0 +1,25 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Any, Dict, Optional +from pydantic import Field, StrictInt, StrictStr + +class ApiResponse: + """ + API response object + """ + + status_code: Optional[StrictInt] = Field(None, description="HTTP status code") + headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + data: Optional[Any] = Field(None, description="Deserialized data given the data type") + raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)") + + def __init__(self, + status_code=None, + headers=None, + data=None, + raw_data=None) -> None: + self.status_code = status_code + self.headers = headers + self.data = data + self.raw_data = raw_data diff --git a/api-customer/api-resources/auth-components/board_mate/auth/configuration.py b/api-customer/api-resources/auth-components/board_mate/auth/configuration.py new file mode 100644 index 00000000..43626fac --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/configuration.py @@ -0,0 +1,434 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 logging +import multiprocessing +import sys +import urllib3 + +import http.client as httplib + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :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. + + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + access_token=None, + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ) -> None: + """Constructor + """ + self._base_path = "https://boardmate_api" 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.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("board_mate.auth") + 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 = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + 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.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 = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """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): + 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, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """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): + """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): + """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 = Configuration() + return cls._default + + @property + def logger_file(self): + """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): + """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): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """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): + """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): + """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, alias=None): + """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 + + def get_basic_auth_token(self): + """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): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + return auth + + def to_debug_report(self): + """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): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "https://boardmate_api", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """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): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/api-customer/api-resources/auth-components/board_mate/auth/exceptions.py b/api-customer/api-resources/auth-components/board_mate/auth/exceptions.py new file mode 100644 index 00000000..e2dc6456 --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/exceptions.py @@ -0,0 +1,166 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 + + +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) -> None: + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + 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.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + +class BadRequestException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(BadRequestException, self).__init__(status, reason, http_resp) + +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ServiceException, self).__init__(status, reason, http_resp) + + +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/api-customer/api-resources/auth-components/board_mate/auth/models/__init__.py b/api-customer/api-resources/auth-components/board_mate/auth/models/__init__.py new file mode 100644 index 00000000..a71bc067 --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/models/__init__.py @@ -0,0 +1,19 @@ +# coding: utf-8 + +# flake8: noqa +""" + boardmate_api API + + boardmate_api API + + 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 board_mate.auth.models.auth_request_dto import AuthRequestDto +from board_mate.auth.models.auth_response_dto import AuthResponseDto +from board_mate.auth.models.response_body_auth_response_dto import ResponseBodyAuthResponseDto diff --git a/api-customer/api-resources/auth-components/board_mate/auth/models/auth_request_dto.py b/api-customer/api-resources/auth-components/board_mate/auth/models/auth_request_dto.py new file mode 100644 index 00000000..9333b26a --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/models/auth_request_dto.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Optional +from pydantic import BaseModel, StrictStr + +class AuthRequestDto(BaseModel): + """ + AuthRequestDto + """ + username: Optional[StrictStr] = None + key: Optional[StrictStr] = None + __properties = ["username", "key"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AuthRequestDto: + """Create an instance of AuthRequestDto from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AuthRequestDto: + """Create an instance of AuthRequestDto from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AuthRequestDto.parse_obj(obj) + + _obj = AuthRequestDto.parse_obj({ + "username": obj.get("username"), + "key": obj.get("key") + }) + return _obj + + diff --git a/api-customer/api-resources/auth-components/board_mate/auth/models/auth_response_dto.py b/api-customer/api-resources/auth-components/board_mate/auth/models/auth_response_dto.py new file mode 100644 index 00000000..9802ab3c --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/models/auth_response_dto.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Optional +from pydantic import BaseModel, Field, StrictStr + +class AuthResponseDto(BaseModel): + """ + AuthResponseDto + """ + client_id: Optional[StrictStr] = Field(None, alias="clientId") + name: Optional[StrictStr] = None + username: Optional[StrictStr] = None + auth_token: Optional[StrictStr] = Field(None, alias="authToken") + __properties = ["clientId", "name", "username", "authToken"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AuthResponseDto: + """Create an instance of AuthResponseDto from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AuthResponseDto: + """Create an instance of AuthResponseDto from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AuthResponseDto.parse_obj(obj) + + _obj = AuthResponseDto.parse_obj({ + "client_id": obj.get("clientId"), + "name": obj.get("name"), + "username": obj.get("username"), + "auth_token": obj.get("authToken") + }) + return _obj + + diff --git a/api-customer/api-resources/auth-components/board_mate/auth/models/response_body_auth_response_dto.py b/api-customer/api-resources/auth-components/board_mate/auth/models/response_body_auth_response_dto.py new file mode 100644 index 00000000..708da98d --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/models/response_body_auth_response_dto.py @@ -0,0 +1,75 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Any, Dict, Optional +from pydantic import BaseModel, StrictBool, StrictStr + +class ResponseBodyAuthResponseDto(BaseModel): + """ + ResponseBodyAuthResponseDto + """ + data: Optional[Dict[str, Any]] = None + message: Optional[StrictStr] = None + success: Optional[StrictBool] = None + __properties = ["data", "message", "success"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ResponseBodyAuthResponseDto: + """Create an instance of ResponseBodyAuthResponseDto from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ResponseBodyAuthResponseDto: + """Create an instance of ResponseBodyAuthResponseDto from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ResponseBodyAuthResponseDto.parse_obj(obj) + + _obj = ResponseBodyAuthResponseDto.parse_obj({ + "data": obj.get("data"), + "message": obj.get("message"), + "success": obj.get("success") + }) + return _obj + + diff --git a/api-customer/api-resources/auth-components/board_mate/auth/py.typed b/api-customer/api-resources/auth-components/board_mate/auth/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/auth-components/board_mate/auth/rest.py b/api-customer/api-resources/auth-components/board_mate/auth/rest.py new file mode 100644 index 00000000..0a1beba5 --- /dev/null +++ b/api-customer/api-resources/auth-components/board_mate/auth/rest.py @@ -0,0 +1,303 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 logging +import re +import ssl + +from urllib.parse import urlencode, quote_plus +import urllib3 + +from board_mate.auth.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration, pools_size=4, maxsize=None) -> 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 + # maxsize is the number of requests to host that are allowed in parallel # 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 + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.tls_server_name: + addition_pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the 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 _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :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 {} + # url already contains the URL query string + # so reset query_params to empty dict + query_params = {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int,float)): # noqa: E501,F821 + 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 + if not headers.get('Content-Type') or re.search('json', headers['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, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['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'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # 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): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + 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={}, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + if r.status == 400: + raise BadRequestException(http_resp=r) + + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + + raise ApiException(http_resp=r) + + return r + + def get_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def head_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def options_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def delete_request(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def post_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def put_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def patch_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/api-customer/api-resources/auth-components/docs/AuthApi.md b/api-customer/api-resources/auth-components/docs/AuthApi.md new file mode 100644 index 00000000..846dbfa0 --- /dev/null +++ b/api-customer/api-resources/auth-components/docs/AuthApi.md @@ -0,0 +1,75 @@ +# board_mate.auth.AuthApi + +All URIs are relative to *https://boardmate_api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**login**](AuthApi.md#login) | **POST** /authenticate | POST authenticate + + +# **login** +> ResponseBodyAuthResponseDto login(auth_request_dto) + +POST authenticate + +### Example + +```python +import time +import os +import board_mate.auth +from board_mate.auth.models.auth_request_dto import AuthRequestDto +from board_mate.auth.models.response_body_auth_response_dto import ResponseBodyAuthResponseDto +from board_mate.auth.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.auth.Configuration( + host = "https://boardmate_api" +) + + +# Enter a context with an instance of the API client +with board_mate.auth.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.auth.AuthApi(api_client) + auth_request_dto = board_mate.auth.AuthRequestDto() # AuthRequestDto | + + try: + # POST authenticate + api_response = api_instance.login(auth_request_dto) + print("The response of AuthApi->login:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling AuthApi->login: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **auth_request_dto** | [**AuthRequestDto**](AuthRequestDto.md)| | + +### Return type + +[**ResponseBodyAuthResponseDto**](ResponseBodyAuthResponseDto.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/api-customer/api-resources/auth-components/docs/AuthRequestDto.md b/api-customer/api-resources/auth-components/docs/AuthRequestDto.md new file mode 100644 index 00000000..12439ee7 --- /dev/null +++ b/api-customer/api-resources/auth-components/docs/AuthRequestDto.md @@ -0,0 +1,29 @@ +# AuthRequestDto + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**username** | **str** | | [optional] +**key** | **str** | | [optional] + +## Example + +```python +from board_mate.auth.models.auth_request_dto import AuthRequestDto + +# TODO update the JSON string below +json = "{}" +# create an instance of AuthRequestDto from a JSON string +auth_request_dto_instance = AuthRequestDto.from_json(json) +# print the JSON string representation of the object +print AuthRequestDto.to_json() + +# convert the object into a dict +auth_request_dto_dict = auth_request_dto_instance.to_dict() +# create an instance of AuthRequestDto from a dict +auth_request_dto_form_dict = auth_request_dto.from_dict(auth_request_dto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/auth-components/docs/AuthResponseDto.md b/api-customer/api-resources/auth-components/docs/AuthResponseDto.md new file mode 100644 index 00000000..1ae4b95b --- /dev/null +++ b/api-customer/api-resources/auth-components/docs/AuthResponseDto.md @@ -0,0 +1,31 @@ +# AuthResponseDto + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client_id** | **str** | | [optional] +**name** | **str** | | [optional] +**username** | **str** | | [optional] +**auth_token** | **str** | | [optional] + +## Example + +```python +from board_mate.auth.models.auth_response_dto import AuthResponseDto + +# TODO update the JSON string below +json = "{}" +# create an instance of AuthResponseDto from a JSON string +auth_response_dto_instance = AuthResponseDto.from_json(json) +# print the JSON string representation of the object +print AuthResponseDto.to_json() + +# convert the object into a dict +auth_response_dto_dict = auth_response_dto_instance.to_dict() +# create an instance of AuthResponseDto from a dict +auth_response_dto_form_dict = auth_response_dto.from_dict(auth_response_dto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/auth-components/docs/ResponseBodyAuthResponseDto.md b/api-customer/api-resources/auth-components/docs/ResponseBodyAuthResponseDto.md new file mode 100644 index 00000000..64dfe818 --- /dev/null +++ b/api-customer/api-resources/auth-components/docs/ResponseBodyAuthResponseDto.md @@ -0,0 +1,30 @@ +# ResponseBodyAuthResponseDto + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | **object** | | [optional] +**message** | **str** | | [optional] +**success** | **bool** | | [optional] + +## Example + +```python +from board_mate.auth.models.response_body_auth_response_dto import ResponseBodyAuthResponseDto + +# TODO update the JSON string below +json = "{}" +# create an instance of ResponseBodyAuthResponseDto from a JSON string +response_body_auth_response_dto_instance = ResponseBodyAuthResponseDto.from_json(json) +# print the JSON string representation of the object +print ResponseBodyAuthResponseDto.to_json() + +# convert the object into a dict +response_body_auth_response_dto_dict = response_body_auth_response_dto_instance.to_dict() +# create an instance of ResponseBodyAuthResponseDto from a dict +response_body_auth_response_dto_form_dict = response_body_auth_response_dto.from_dict(response_body_auth_response_dto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/auth-components/git_push.sh b/api-customer/api-resources/auth-components/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/api-customer/api-resources/auth-components/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/api-customer/api-resources/auth-components/pyproject.toml b/api-customer/api-resources/auth-components/pyproject.toml new file mode 100644 index 00000000..8ce42594 --- /dev/null +++ b/api-customer/api-resources/auth-components/pyproject.toml @@ -0,0 +1,30 @@ +[tool.poetry] +name = "board_mate.auth" +version = "1.0.0" +description = "boardmate_api API" +authors = ["OpenAPI Generator Community "] +license = "NoLicense" +readme = "README.md" +repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" +keywords = ["OpenAPI", "OpenAPI-Generator", "boardmate_api API"] +include = ["board_mate.auth/py.typed"] + +[tool.poetry.dependencies] +python = "^3.7" + +urllib3 = ">= 1.25.3" +python-dateutil = ">=2.8.2" +pydantic = "^1.10.5, <2" +aenum = ">=3.1.11" + +[tool.poetry.dev-dependencies] +pytest = ">=7.2.1" +tox = ">=3.9.0" +flake8 = ">=4.0.0" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" diff --git a/api-customer/api-resources/auth-components/requirements.txt b/api-customer/api-resources/auth-components/requirements.txt new file mode 100644 index 00000000..258c179c --- /dev/null +++ b/api-customer/api-resources/auth-components/requirements.txt @@ -0,0 +1,5 @@ +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.25.3, < 2.1.0 +pydantic >= 1.10.5, < 2 +aenum >= 3.1.11 diff --git a/api-customer/api-resources/auth-components/setup.cfg b/api-customer/api-resources/auth-components/setup.cfg new file mode 100644 index 00000000..11433ee8 --- /dev/null +++ b/api-customer/api-resources/auth-components/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/api-customer/api-resources/auth-components/setup.py b/api-customer/api-resources/auth-components/setup.py new file mode 100644 index 00000000..63cdc293 --- /dev/null +++ b/api-customer/api-resources/auth-components/setup.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 = "board-mate.auth" +VERSION = "1.0.0" +PYTHON_REQUIRES = ">=3.7" +REQUIRES = [ + "urllib3 >= 1.25.3, < 2.1.0", + "python-dateutil", + "pydantic >= 1.10.5, < 2", + "aenum" +] + +setup( + name=NAME, + version=VERSION, + description="boardmate_api API", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "boardmate_api API"], + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + long_description_content_type='text/markdown', + long_description="""\ + boardmate_api API + """, # noqa: E501 + package_data={"board_mate.auth": ["py.typed"]}, +) diff --git a/api-customer/api-resources/auth-components/test-requirements.txt b/api-customer/api-resources/auth-components/test-requirements.txt new file mode 100644 index 00000000..3a0d0b93 --- /dev/null +++ b/api-customer/api-resources/auth-components/test-requirements.txt @@ -0,0 +1,3 @@ +pytest~=7.1.3 +pytest-cov>=2.8.1 +pytest-randomly>=3.12.0 diff --git a/api-customer/api-resources/auth-components/test/__init__.py b/api-customer/api-resources/auth-components/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/auth-components/test/test_auth_api.py b/api-customer/api-resources/auth-components/test/test_auth_api.py new file mode 100644 index 00000000..663a23e6 --- /dev/null +++ b/api-customer/api-resources/auth-components/test/test_auth_api.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest + +from board_mate.auth.api.auth_api import AuthApi # noqa: E501 + + +class TestAuthApi(unittest.TestCase): + """AuthApi unit test stubs""" + + def setUp(self) -> None: + self.api = AuthApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_login(self) -> None: + """Test case for login + + POST authenticate # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/auth-components/test/test_auth_request_dto.py b/api-customer/api-resources/auth-components/test/test_auth_request_dto.py new file mode 100644 index 00000000..fcb30b87 --- /dev/null +++ b/api-customer/api-resources/auth-components/test/test_auth_request_dto.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.auth.models.auth_request_dto import AuthRequestDto # noqa: E501 + +class TestAuthRequestDto(unittest.TestCase): + """AuthRequestDto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> AuthRequestDto: + """Test AuthRequestDto + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `AuthRequestDto` + """ + model = AuthRequestDto() # noqa: E501 + if include_optional: + return AuthRequestDto( + username = '', + key = '' + ) + else: + return AuthRequestDto( + ) + """ + + def testAuthRequestDto(self): + """Test AuthRequestDto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/auth-components/test/test_auth_response_dto.py b/api-customer/api-resources/auth-components/test/test_auth_response_dto.py new file mode 100644 index 00000000..72a96abe --- /dev/null +++ b/api-customer/api-resources/auth-components/test/test_auth_response_dto.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.auth.models.auth_response_dto import AuthResponseDto # noqa: E501 + +class TestAuthResponseDto(unittest.TestCase): + """AuthResponseDto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> AuthResponseDto: + """Test AuthResponseDto + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `AuthResponseDto` + """ + model = AuthResponseDto() # noqa: E501 + if include_optional: + return AuthResponseDto( + client_id = '', + name = '', + username = '', + auth_token = '' + ) + else: + return AuthResponseDto( + ) + """ + + def testAuthResponseDto(self): + """Test AuthResponseDto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/auth-components/test/test_response_body_auth_response_dto.py b/api-customer/api-resources/auth-components/test/test_response_body_auth_response_dto.py new file mode 100644 index 00000000..cba8dcea --- /dev/null +++ b/api-customer/api-resources/auth-components/test/test_response_body_auth_response_dto.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.auth.models.response_body_auth_response_dto import ResponseBodyAuthResponseDto # noqa: E501 + +class TestResponseBodyAuthResponseDto(unittest.TestCase): + """ResponseBodyAuthResponseDto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ResponseBodyAuthResponseDto: + """Test ResponseBodyAuthResponseDto + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ResponseBodyAuthResponseDto` + """ + model = ResponseBodyAuthResponseDto() # noqa: E501 + if include_optional: + return ResponseBodyAuthResponseDto( + data = None, + message = '', + success = True + ) + else: + return ResponseBodyAuthResponseDto( + ) + """ + + def testResponseBodyAuthResponseDto(self): + """Test ResponseBodyAuthResponseDto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/auth-components/tox.ini b/api-customer/api-resources/auth-components/tox.ini new file mode 100644 index 00000000..b879d018 --- /dev/null +++ b/api-customer/api-resources/auth-components/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=board_mate.auth diff --git a/api-customer/api-resources/client-components/.github/workflows/python.yml b/api-customer/api-resources/client-components/.github/workflows/python.yml new file mode 100644 index 00000000..ab65db0f --- /dev/null +++ b/api-customer/api-resources/client-components/.github/workflows/python.yml @@ -0,0 +1,38 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: board_mate.client Python package + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/api-customer/api-resources/client-components/.gitignore b/api-customer/api-resources/client-components/.gitignore new file mode 100644 index 00000000..43995bd4 --- /dev/null +++ b/api-customer/api-resources/client-components/.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/api-customer/api-resources/client-components/.gitlab-ci.yml b/api-customer/api-resources/client-components/.gitlab-ci.yml new file mode 100644 index 00000000..6ecb5970 --- /dev/null +++ b/api-customer/api-resources/client-components/.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=board_mate.client + +pytest-3.7: + extends: .pytest + image: python:3.7-alpine +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 diff --git a/api-customer/api-resources/client-components/.openapi-generator-ignore b/api-customer/api-resources/client-components/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/api-customer/api-resources/client-components/.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/api-customer/api-resources/client-components/.openapi-generator/FILES b/api-customer/api-resources/client-components/.openapi-generator/FILES new file mode 100644 index 00000000..86b4831c --- /dev/null +++ b/api-customer/api-resources/client-components/.openapi-generator/FILES @@ -0,0 +1,33 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.openapi-generator-ignore +.travis.yml +README.md +board_mate/__init__.py +board_mate/client/__init__.py +board_mate/client/api/__init__.py +board_mate/client/api/client_api.py +board_mate/client/api_client.py +board_mate/client/api_response.py +board_mate/client/configuration.py +board_mate/client/exceptions.py +board_mate/client/models/__init__.py +board_mate/client/models/client_dto.py +board_mate/client/models/response_body_string.py +board_mate/client/py.typed +board_mate/client/rest.py +docs/ClientApi.md +docs/ClientDto.md +docs/ResponseBodyString.md +git_push.sh +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +test/test_client_api.py +test/test_client_dto.py +test/test_response_body_string.py +tox.ini diff --git a/api-customer/api-resources/client-components/.openapi-generator/VERSION b/api-customer/api-resources/client-components/.openapi-generator/VERSION new file mode 100644 index 00000000..73a86b19 --- /dev/null +++ b/api-customer/api-resources/client-components/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.0.1 \ No newline at end of file diff --git a/api-customer/api-resources/client-components/.travis.yml b/api-customer/api-resources/client-components/.travis.yml new file mode 100644 index 00000000..06dd2a9d --- /dev/null +++ b/api-customer/api-resources/client-components/.travis.yml @@ -0,0 +1,17 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + # uncomment the following if needed + #- "3.11-dev" # 3.11 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=board_mate.client diff --git a/api-customer/api-resources/client-components/README.md b/api-customer/api-resources/client-components/README.md new file mode 100644 index 00000000..847b36d8 --- /dev/null +++ b/api-customer/api-resources/client-components/README.md @@ -0,0 +1,107 @@ +# board-mate.client +boardmate_api API + +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 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen + +## Requirements. + +Python 3.7+ + +## 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 board_mate.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 board_mate.client +``` + +### Tests + +Execute `pytest` to run the tests. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python + +import time +import board_mate.client +from board_mate.client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.client.Configuration( + host = "https://boardmate_api" +) + + + +# Enter a context with an instance of the API client +with board_mate.client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.client.ClientApi(api_client) + client_dto = board_mate.client.ClientDto() # ClientDto | + + try: + # POST client/create + api_response = api_instance.create(client_dto) + print("The response of ClientApi->create:\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling ClientApi->create: %s\n" % e) + +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://boardmate_api* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*ClientApi* | [**create**](docs/ClientApi.md#create) | **POST** /client/create | POST client/create + + +## Documentation For Models + + - [ClientDto](docs/ClientDto.md) + - [ResponseBodyString](docs/ResponseBodyString.md) + + + +## Documentation For Authorization + +Endpoints do not require authorization. + + +## Author + + + + diff --git a/api-customer/api-resources/client-components/board_mate/__init__.py b/api-customer/api-resources/client-components/board_mate/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/client-components/board_mate/client/__init__.py b/api-customer/api-resources/client-components/board_mate/client/__init__.py new file mode 100644 index 00000000..6ab780a9 --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/__init__.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +# flake8: noqa + +""" + boardmate_api API + + boardmate_api API + + 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 board_mate.client.api.client_api import ClientApi + +# import ApiClient +from board_mate.client.api_response import ApiResponse +from board_mate.client.api_client import ApiClient +from board_mate.client.configuration import Configuration +from board_mate.client.exceptions import OpenApiException +from board_mate.client.exceptions import ApiTypeError +from board_mate.client.exceptions import ApiValueError +from board_mate.client.exceptions import ApiKeyError +from board_mate.client.exceptions import ApiAttributeError +from board_mate.client.exceptions import ApiException + +# import models into sdk package +from board_mate.client.models.client_dto import ClientDto +from board_mate.client.models.response_body_string import ResponseBodyString diff --git a/api-customer/api-resources/client-components/board_mate/client/api/__init__.py b/api-customer/api-resources/client-components/board_mate/client/api/__init__.py new file mode 100644 index 00000000..54ea4eab --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/api/__init__.py @@ -0,0 +1,5 @@ +# flake8: noqa + +# import apis into api package +from board_mate.client.api.client_api import ClientApi + diff --git a/api-customer/api-resources/client-components/board_mate/client/api/client_api.py b/api-customer/api-resources/client-components/board_mate/client/api/client_api.py new file mode 100644 index 00000000..3074b62f --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/api/client_api.py @@ -0,0 +1,187 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from board_mate.client.models.client_dto import ClientDto +from board_mate.client.models.response_body_string import ResponseBodyString + +from board_mate.client.api_client import ApiClient +from board_mate.client.api_response import ApiResponse +from board_mate.client.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class ClientApi: + """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_arguments + def create(self, client_dto : ClientDto, **kwargs) -> ResponseBodyString: # noqa: E501 + """POST client/create # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create(client_dto, async_req=True) + >>> result = thread.get() + + :param client_dto: (required) + :type client_dto: ClientDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ResponseBodyString + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_with_http_info(client_dto, **kwargs) # noqa: E501 + + @validate_arguments + def create_with_http_info(self, client_dto : ClientDto, **kwargs) -> ApiResponse: # noqa: E501 + """POST client/create # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_with_http_info(client_dto, async_req=True) + >>> result = thread.get() + + :param client_dto: (required) + :type client_dto: ClientDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :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. + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ResponseBodyString, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'client_dto' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['client_dto'] is not None: + _body_params = _params['client_dto'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "ResponseBodyString", + } + + return self.api_client.call_api( + '/client/create', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/api-customer/api-resources/client-components/board_mate/client/api_client.py b/api-customer/api-resources/client-components/board_mate/client/api_client.py new file mode 100644 index 00000000..772a9eec --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/api_client.py @@ -0,0 +1,758 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 atexit +import datetime +from dateutil.parser import parse +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +from urllib.parse import quote + +from board_mate.client.configuration import Configuration +from board_mate.client.api_response import ApiResponse +import board_mate.client.models +from board_mate.client import rest +from board_mate.client.exceptions import ApiValueError, ApiException + + +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 + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + 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, + 'object': object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + self.pool_threads = pool_threads + + 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): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @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 __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_types_map=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None, + _request_auth=None): + + 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) + 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: + 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 + + try: + # perform request and return response + response_data = self.request( + method, url, + query_params=query_params, + headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + if e.body: + e.body = e.body.decode('utf-8') + raise e + + self.last_response = response_data + + return_data = None # assuming derialization is not needed + # data needs deserialization or returns HTTP data (deserialized) only + if _preload_content or _return_http_data_only: + 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) + + if response_type == "bytearray": + response_data.data = response_data.data + else: + 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_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type == "bytearray": + return_data = response_data.data + elif response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + + if _return_http_data_only: + return return_data + else: + 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 str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + 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, 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() + + if 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. + obj_dict = obj.to_dict() + + return {key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items()} + + def deserialize(self, response, response_type): + """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. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + 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['): + sub_kls = re.match(r'List\[(.*)]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).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(board_mate.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) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_types_map=None, auth_settings=None, + async_req=None, _return_http_data_only=None, + collection_formats=None, _preload_content=True, + _request_timeout=None, _host=None, _request_auth=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :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 response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :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. + :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_token: dict, optional + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_types_map, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _request_auth) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_types_map, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _request_auth)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.get_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.head_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.options_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + elif method == "POST": + return self.rest_client.post_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.put_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.patch_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.delete_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + 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 = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + 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 = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, bool): + v = str(v).lower() + 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, 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(item) for item in new_params]) + + def files_parameters(self, files=None): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if files: + for k, v in files.items(): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + 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): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + 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): + """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) + return + + 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): + """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. + + :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: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).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_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/api-customer/api-resources/client-components/board_mate/client/api_response.py b/api-customer/api-resources/client-components/board_mate/client/api_response.py new file mode 100644 index 00000000..a0b62b95 --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/api_response.py @@ -0,0 +1,25 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Any, Dict, Optional +from pydantic import Field, StrictInt, StrictStr + +class ApiResponse: + """ + API response object + """ + + status_code: Optional[StrictInt] = Field(None, description="HTTP status code") + headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + data: Optional[Any] = Field(None, description="Deserialized data given the data type") + raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)") + + def __init__(self, + status_code=None, + headers=None, + data=None, + raw_data=None) -> None: + self.status_code = status_code + self.headers = headers + self.data = data + self.raw_data = raw_data diff --git a/api-customer/api-resources/client-components/board_mate/client/configuration.py b/api-customer/api-resources/client-components/board_mate/client/configuration.py new file mode 100644 index 00000000..e34fd4e5 --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/configuration.py @@ -0,0 +1,434 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 logging +import multiprocessing +import sys +import urllib3 + +import http.client as httplib + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :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. + + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + access_token=None, + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ) -> None: + """Constructor + """ + self._base_path = "https://boardmate_api" 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.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("board_mate.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 = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + 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.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 = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """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): + 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, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """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): + """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): + """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 = Configuration() + return cls._default + + @property + def logger_file(self): + """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): + """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): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """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): + """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): + """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, alias=None): + """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 + + def get_basic_auth_token(self): + """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): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + return auth + + def to_debug_report(self): + """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): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "https://boardmate_api", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """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): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/api-customer/api-resources/client-components/board_mate/client/exceptions.py b/api-customer/api-resources/client-components/board_mate/client/exceptions.py new file mode 100644 index 00000000..e2dc6456 --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/exceptions.py @@ -0,0 +1,166 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 + + +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) -> None: + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + 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.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + +class BadRequestException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(BadRequestException, self).__init__(status, reason, http_resp) + +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ServiceException, self).__init__(status, reason, http_resp) + + +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/api-customer/api-resources/client-components/board_mate/client/models/__init__.py b/api-customer/api-resources/client-components/board_mate/client/models/__init__.py new file mode 100644 index 00000000..15ac7b03 --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/models/__init__.py @@ -0,0 +1,18 @@ +# coding: utf-8 + +# flake8: noqa +""" + boardmate_api API + + boardmate_api API + + 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 board_mate.client.models.client_dto import ClientDto +from board_mate.client.models.response_body_string import ResponseBodyString diff --git a/api-customer/api-resources/client-components/board_mate/client/models/client_dto.py b/api-customer/api-resources/client-components/board_mate/client/models/client_dto.py new file mode 100644 index 00000000..22ff38b7 --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/models/client_dto.py @@ -0,0 +1,75 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Optional +from pydantic import BaseModel, StrictStr + +class ClientDto(BaseModel): + """ + ClientDto + """ + name: Optional[StrictStr] = None + username: Optional[StrictStr] = None + key: Optional[StrictStr] = None + __properties = ["name", "username", "key"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ClientDto: + """Create an instance of ClientDto from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ClientDto: + """Create an instance of ClientDto from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ClientDto.parse_obj(obj) + + _obj = ClientDto.parse_obj({ + "name": obj.get("name"), + "username": obj.get("username"), + "key": obj.get("key") + }) + return _obj + + diff --git a/api-customer/api-resources/client-components/board_mate/client/models/response_body_string.py b/api-customer/api-resources/client-components/board_mate/client/models/response_body_string.py new file mode 100644 index 00000000..e5f9e8fb --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/models/response_body_string.py @@ -0,0 +1,75 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Optional +from pydantic import BaseModel, StrictBool, StrictStr + +class ResponseBodyString(BaseModel): + """ + ResponseBodyString + """ + data: Optional[StrictStr] = None + message: Optional[StrictStr] = None + success: Optional[StrictBool] = None + __properties = ["data", "message", "success"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ResponseBodyString: + """Create an instance of ResponseBodyString from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ResponseBodyString: + """Create an instance of ResponseBodyString from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ResponseBodyString.parse_obj(obj) + + _obj = ResponseBodyString.parse_obj({ + "data": obj.get("data"), + "message": obj.get("message"), + "success": obj.get("success") + }) + return _obj + + diff --git a/api-customer/api-resources/client-components/board_mate/client/py.typed b/api-customer/api-resources/client-components/board_mate/client/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/client-components/board_mate/client/rest.py b/api-customer/api-resources/client-components/board_mate/client/rest.py new file mode 100644 index 00000000..4a2a8ad2 --- /dev/null +++ b/api-customer/api-resources/client-components/board_mate/client/rest.py @@ -0,0 +1,303 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 logging +import re +import ssl + +from urllib.parse import urlencode, quote_plus +import urllib3 + +from board_mate.client.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration, pools_size=4, maxsize=None) -> 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 + # maxsize is the number of requests to host that are allowed in parallel # 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 + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.tls_server_name: + addition_pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the 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 _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :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 {} + # url already contains the URL query string + # so reset query_params to empty dict + query_params = {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int,float)): # noqa: E501,F821 + 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 + if not headers.get('Content-Type') or re.search('json', headers['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, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['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'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # 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): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + 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={}, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + if r.status == 400: + raise BadRequestException(http_resp=r) + + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + + raise ApiException(http_resp=r) + + return r + + def get_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def head_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def options_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def delete_request(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def post_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def put_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def patch_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/api-customer/api-resources/client-components/docs/ClientApi.md b/api-customer/api-resources/client-components/docs/ClientApi.md new file mode 100644 index 00000000..08325ebf --- /dev/null +++ b/api-customer/api-resources/client-components/docs/ClientApi.md @@ -0,0 +1,75 @@ +# board_mate.client.ClientApi + +All URIs are relative to *https://boardmate_api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create**](ClientApi.md#create) | **POST** /client/create | POST client/create + + +# **create** +> ResponseBodyString create(client_dto) + +POST client/create + +### Example + +```python +import time +import os +import board_mate.client +from board_mate.client.models.client_dto import ClientDto +from board_mate.client.models.response_body_string import ResponseBodyString +from board_mate.client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.client.Configuration( + host = "https://boardmate_api" +) + + +# Enter a context with an instance of the API client +with board_mate.client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.client.ClientApi(api_client) + client_dto = board_mate.client.ClientDto() # ClientDto | + + try: + # POST client/create + api_response = api_instance.create(client_dto) + print("The response of ClientApi->create:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ClientApi->create: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client_dto** | [**ClientDto**](ClientDto.md)| | + +### Return type + +[**ResponseBodyString**](ResponseBodyString.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/api-customer/api-resources/client-components/docs/ClientDto.md b/api-customer/api-resources/client-components/docs/ClientDto.md new file mode 100644 index 00000000..3d765e75 --- /dev/null +++ b/api-customer/api-resources/client-components/docs/ClientDto.md @@ -0,0 +1,30 @@ +# ClientDto + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] +**username** | **str** | | [optional] +**key** | **str** | | [optional] + +## Example + +```python +from board_mate.client.models.client_dto import ClientDto + +# TODO update the JSON string below +json = "{}" +# create an instance of ClientDto from a JSON string +client_dto_instance = ClientDto.from_json(json) +# print the JSON string representation of the object +print ClientDto.to_json() + +# convert the object into a dict +client_dto_dict = client_dto_instance.to_dict() +# create an instance of ClientDto from a dict +client_dto_form_dict = client_dto.from_dict(client_dto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/client-components/docs/ResponseBodyString.md b/api-customer/api-resources/client-components/docs/ResponseBodyString.md new file mode 100644 index 00000000..5d15e40e --- /dev/null +++ b/api-customer/api-resources/client-components/docs/ResponseBodyString.md @@ -0,0 +1,30 @@ +# ResponseBodyString + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | **str** | | [optional] +**message** | **str** | | [optional] +**success** | **bool** | | [optional] + +## Example + +```python +from board_mate.client.models.response_body_string import ResponseBodyString + +# TODO update the JSON string below +json = "{}" +# create an instance of ResponseBodyString from a JSON string +response_body_string_instance = ResponseBodyString.from_json(json) +# print the JSON string representation of the object +print ResponseBodyString.to_json() + +# convert the object into a dict +response_body_string_dict = response_body_string_instance.to_dict() +# create an instance of ResponseBodyString from a dict +response_body_string_form_dict = response_body_string.from_dict(response_body_string_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/client-components/git_push.sh b/api-customer/api-resources/client-components/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/api-customer/api-resources/client-components/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/api-customer/api-resources/client-components/pyproject.toml b/api-customer/api-resources/client-components/pyproject.toml new file mode 100644 index 00000000..5b2abd4b --- /dev/null +++ b/api-customer/api-resources/client-components/pyproject.toml @@ -0,0 +1,30 @@ +[tool.poetry] +name = "board_mate.client" +version = "1.0.0" +description = "boardmate_api API" +authors = ["OpenAPI Generator Community "] +license = "NoLicense" +readme = "README.md" +repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" +keywords = ["OpenAPI", "OpenAPI-Generator", "boardmate_api API"] +include = ["board_mate.client/py.typed"] + +[tool.poetry.dependencies] +python = "^3.7" + +urllib3 = ">= 1.25.3" +python-dateutil = ">=2.8.2" +pydantic = "^1.10.5, <2" +aenum = ">=3.1.11" + +[tool.poetry.dev-dependencies] +pytest = ">=7.2.1" +tox = ">=3.9.0" +flake8 = ">=4.0.0" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" diff --git a/api-customer/api-resources/client-components/requirements.txt b/api-customer/api-resources/client-components/requirements.txt new file mode 100644 index 00000000..258c179c --- /dev/null +++ b/api-customer/api-resources/client-components/requirements.txt @@ -0,0 +1,5 @@ +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.25.3, < 2.1.0 +pydantic >= 1.10.5, < 2 +aenum >= 3.1.11 diff --git a/api-customer/api-resources/client-components/setup.cfg b/api-customer/api-resources/client-components/setup.cfg new file mode 100644 index 00000000..11433ee8 --- /dev/null +++ b/api-customer/api-resources/client-components/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/api-customer/api-resources/client-components/setup.py b/api-customer/api-resources/client-components/setup.py new file mode 100644 index 00000000..b201ce96 --- /dev/null +++ b/api-customer/api-resources/client-components/setup.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 = "board-mate.client" +VERSION = "1.0.0" +PYTHON_REQUIRES = ">=3.7" +REQUIRES = [ + "urllib3 >= 1.25.3, < 2.1.0", + "python-dateutil", + "pydantic >= 1.10.5, < 2", + "aenum" +] + +setup( + name=NAME, + version=VERSION, + description="boardmate_api API", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "boardmate_api API"], + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + long_description_content_type='text/markdown', + long_description="""\ + boardmate_api API + """, # noqa: E501 + package_data={"board_mate.client": ["py.typed"]}, +) diff --git a/api-customer/api-resources/client-components/test-requirements.txt b/api-customer/api-resources/client-components/test-requirements.txt new file mode 100644 index 00000000..3a0d0b93 --- /dev/null +++ b/api-customer/api-resources/client-components/test-requirements.txt @@ -0,0 +1,3 @@ +pytest~=7.1.3 +pytest-cov>=2.8.1 +pytest-randomly>=3.12.0 diff --git a/api-customer/api-resources/client-components/test/__init__.py b/api-customer/api-resources/client-components/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/client-components/test/test_client_api.py b/api-customer/api-resources/client-components/test/test_client_api.py new file mode 100644 index 00000000..9c15e5b7 --- /dev/null +++ b/api-customer/api-resources/client-components/test/test_client_api.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest + +from board_mate.client.api.client_api import ClientApi # noqa: E501 + + +class TestClientApi(unittest.TestCase): + """ClientApi unit test stubs""" + + def setUp(self) -> None: + self.api = ClientApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_create(self) -> None: + """Test case for create + + POST client/create # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/client-components/test/test_client_dto.py b/api-customer/api-resources/client-components/test/test_client_dto.py new file mode 100644 index 00000000..b3c934c0 --- /dev/null +++ b/api-customer/api-resources/client-components/test/test_client_dto.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.client.models.client_dto import ClientDto # noqa: E501 + +class TestClientDto(unittest.TestCase): + """ClientDto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ClientDto: + """Test ClientDto + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ClientDto` + """ + model = ClientDto() # noqa: E501 + if include_optional: + return ClientDto( + name = '', + username = '', + key = '' + ) + else: + return ClientDto( + ) + """ + + def testClientDto(self): + """Test ClientDto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/client-components/test/test_response_body_string.py b/api-customer/api-resources/client-components/test/test_response_body_string.py new file mode 100644 index 00000000..8b15e2c8 --- /dev/null +++ b/api-customer/api-resources/client-components/test/test_response_body_string.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.client.models.response_body_string import ResponseBodyString # noqa: E501 + +class TestResponseBodyString(unittest.TestCase): + """ResponseBodyString unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ResponseBodyString: + """Test ResponseBodyString + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ResponseBodyString` + """ + model = ResponseBodyString() # noqa: E501 + if include_optional: + return ResponseBodyString( + data = '', + message = '', + success = True + ) + else: + return ResponseBodyString( + ) + """ + + def testResponseBodyString(self): + """Test ResponseBodyString""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/client-components/tox.ini b/api-customer/api-resources/client-components/tox.ini new file mode 100644 index 00000000..06edfea1 --- /dev/null +++ b/api-customer/api-resources/client-components/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=board_mate.client diff --git a/api-customer/api-resources/game-components/.github/workflows/python.yml b/api-customer/api-resources/game-components/.github/workflows/python.yml new file mode 100644 index 00000000..a52ad6ef --- /dev/null +++ b/api-customer/api-resources/game-components/.github/workflows/python.yml @@ -0,0 +1,38 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: board_mate.game Python package + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/api-customer/api-resources/game-components/.gitignore b/api-customer/api-resources/game-components/.gitignore new file mode 100644 index 00000000..43995bd4 --- /dev/null +++ b/api-customer/api-resources/game-components/.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/api-customer/api-resources/game-components/.gitlab-ci.yml b/api-customer/api-resources/game-components/.gitlab-ci.yml new file mode 100644 index 00000000..a3bee654 --- /dev/null +++ b/api-customer/api-resources/game-components/.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=board_mate.game + +pytest-3.7: + extends: .pytest + image: python:3.7-alpine +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 diff --git a/api-customer/api-resources/game-components/.openapi-generator-ignore b/api-customer/api-resources/game-components/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/api-customer/api-resources/game-components/.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/api-customer/api-resources/game-components/.openapi-generator/FILES b/api-customer/api-resources/game-components/.openapi-generator/FILES new file mode 100644 index 00000000..f9422bb0 --- /dev/null +++ b/api-customer/api-resources/game-components/.openapi-generator/FILES @@ -0,0 +1,39 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.openapi-generator-ignore +.travis.yml +README.md +board_mate/__init__.py +board_mate/game/__init__.py +board_mate/game/api/__init__.py +board_mate/game/api/game_api.py +board_mate/game/api_client.py +board_mate/game/api_response.py +board_mate/game/configuration.py +board_mate/game/exceptions.py +board_mate/game/models/__init__.py +board_mate/game/models/game_dto.py +board_mate/game/models/move_dto.py +board_mate/game/models/response_body_game_dto.py +board_mate/game/models/response_body_string.py +board_mate/game/py.typed +board_mate/game/rest.py +docs/GameApi.md +docs/GameDto.md +docs/MoveDto.md +docs/ResponseBodyGameDto.md +docs/ResponseBodyString.md +git_push.sh +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +test/test_game_api.py +test/test_game_dto.py +test/test_move_dto.py +test/test_response_body_game_dto.py +test/test_response_body_string.py +tox.ini diff --git a/api-customer/api-resources/game-components/.openapi-generator/VERSION b/api-customer/api-resources/game-components/.openapi-generator/VERSION new file mode 100644 index 00000000..73a86b19 --- /dev/null +++ b/api-customer/api-resources/game-components/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.0.1 \ No newline at end of file diff --git a/api-customer/api-resources/game-components/.travis.yml b/api-customer/api-resources/game-components/.travis.yml new file mode 100644 index 00000000..ddc9ad89 --- /dev/null +++ b/api-customer/api-resources/game-components/.travis.yml @@ -0,0 +1,17 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + # uncomment the following if needed + #- "3.11-dev" # 3.11 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=board_mate.game diff --git a/api-customer/api-resources/game-components/README.md b/api-customer/api-resources/game-components/README.md new file mode 100644 index 00000000..e34719e2 --- /dev/null +++ b/api-customer/api-resources/game-components/README.md @@ -0,0 +1,112 @@ +# board-mate.game +boardmate_api API + +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 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen + +## Requirements. + +Python 3.7+ + +## 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 board_mate.game +``` + +### 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 board_mate.game +``` + +### Tests + +Execute `pytest` to run the tests. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python + +import time +import board_mate.game +from board_mate.game.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.game.Configuration( + host = "https://boardmate_api" +) + + + +# Enter a context with an instance of the API client +with board_mate.game.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.game.GameApi(api_client) + game_id = 'game_id_example' # str | + move_dto = board_mate.game.MoveDto() # MoveDto | + + try: + # POST moves/add/{gameId} + api_response = api_instance.add_move(game_id, move_dto) + print("The response of GameApi->add_move:\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling GameApi->add_move: %s\n" % e) + +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://boardmate_api* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*GameApi* | [**add_move**](docs/GameApi.md#add_move) | **POST** /moves/add/{gameId} | POST moves/add/{gameId} +*GameApi* | [**create_party**](docs/GameApi.md#create_party) | **POST** /create | POST create +*GameApi* | [**retrieve_games**](docs/GameApi.md#retrieve_games) | **GET** /games/{id} | GET games/{id} + + +## Documentation For Models + + - [GameDto](docs/GameDto.md) + - [MoveDto](docs/MoveDto.md) + - [ResponseBodyGameDto](docs/ResponseBodyGameDto.md) + - [ResponseBodyString](docs/ResponseBodyString.md) + + + +## Documentation For Authorization + +Endpoints do not require authorization. + + +## Author + + + + diff --git a/api-customer/api-resources/game-components/board_mate/__init__.py b/api-customer/api-resources/game-components/board_mate/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/game-components/board_mate/game/__init__.py b/api-customer/api-resources/game-components/board_mate/game/__init__.py new file mode 100644 index 00000000..6c79e569 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/__init__.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +# flake8: noqa + +""" + boardmate_api API + + boardmate_api API + + 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 board_mate.game.api.game_api import GameApi + +# import ApiClient +from board_mate.game.api_response import ApiResponse +from board_mate.game.api_client import ApiClient +from board_mate.game.configuration import Configuration +from board_mate.game.exceptions import OpenApiException +from board_mate.game.exceptions import ApiTypeError +from board_mate.game.exceptions import ApiValueError +from board_mate.game.exceptions import ApiKeyError +from board_mate.game.exceptions import ApiAttributeError +from board_mate.game.exceptions import ApiException + +# import models into sdk package +from board_mate.game.models.game_dto import GameDto +from board_mate.game.models.move_dto import MoveDto +from board_mate.game.models.response_body_game_dto import ResponseBodyGameDto +from board_mate.game.models.response_body_string import ResponseBodyString diff --git a/api-customer/api-resources/game-components/board_mate/game/api/__init__.py b/api-customer/api-resources/game-components/board_mate/game/api/__init__.py new file mode 100644 index 00000000..bc84a189 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/api/__init__.py @@ -0,0 +1,5 @@ +# flake8: noqa + +# import apis into api package +from board_mate.game.api.game_api import GameApi + diff --git a/api-customer/api-resources/game-components/board_mate/game/api/game_api.py b/api-customer/api-resources/game-components/board_mate/game/api/game_api.py new file mode 100644 index 00000000..7bc056f1 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/api/game_api.py @@ -0,0 +1,482 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 re # noqa: F401 +import io +import warnings + +from pydantic import validate_arguments, ValidationError + +from pydantic import StrictStr + +from board_mate.game.models.game_dto import GameDto +from board_mate.game.models.move_dto import MoveDto +from board_mate.game.models.response_body_game_dto import ResponseBodyGameDto +from board_mate.game.models.response_body_string import ResponseBodyString + +from board_mate.game.api_client import ApiClient +from board_mate.game.api_response import ApiResponse +from board_mate.game.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class GameApi: + """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_arguments + def add_move(self, game_id : StrictStr, move_dto : MoveDto, **kwargs) -> ResponseBodyString: # noqa: E501 + """POST moves/add/{gameId} # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.add_move(game_id, move_dto, async_req=True) + >>> result = thread.get() + + :param game_id: (required) + :type game_id: str + :param move_dto: (required) + :type move_dto: MoveDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ResponseBodyString + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the add_move_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.add_move_with_http_info(game_id, move_dto, **kwargs) # noqa: E501 + + @validate_arguments + def add_move_with_http_info(self, game_id : StrictStr, move_dto : MoveDto, **kwargs) -> ApiResponse: # noqa: E501 + """POST moves/add/{gameId} # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.add_move_with_http_info(game_id, move_dto, async_req=True) + >>> result = thread.get() + + :param game_id: (required) + :type game_id: str + :param move_dto: (required) + :type move_dto: MoveDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :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. + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ResponseBodyString, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'game_id', + 'move_dto' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method add_move" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['game_id']: + _path_params['gameId'] = _params['game_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['move_dto'] is not None: + _body_params = _params['move_dto'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "ResponseBodyString", + } + + return self.api_client.call_api( + '/moves/add/{gameId}', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def create_party(self, game_dto : GameDto, **kwargs) -> ResponseBodyString: # noqa: E501 + """POST create # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_party(game_dto, async_req=True) + >>> result = thread.get() + + :param game_dto: (required) + :type game_dto: GameDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ResponseBodyString + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_party_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_party_with_http_info(game_dto, **kwargs) # noqa: E501 + + @validate_arguments + def create_party_with_http_info(self, game_dto : GameDto, **kwargs) -> ApiResponse: # noqa: E501 + """POST create # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_party_with_http_info(game_dto, async_req=True) + >>> result = thread.get() + + :param game_dto: (required) + :type game_dto: GameDto + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :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. + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ResponseBodyString, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'game_dto' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_party" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['game_dto'] is not None: + _body_params = _params['game_dto'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "ResponseBodyString", + } + + return self.api_client.call_api( + '/create', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def retrieve_games(self, id : StrictStr, **kwargs) -> ResponseBodyGameDto: # noqa: E501 + """GET games/{id} # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.retrieve_games(id, async_req=True) + >>> result = thread.get() + + :param id: (required) + :type id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :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. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ResponseBodyGameDto + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the retrieve_games_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.retrieve_games_with_http_info(id, **kwargs) # noqa: E501 + + @validate_arguments + def retrieve_games_with_http_info(self, id : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """GET games/{id} # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.retrieve_games_with_http_info(id, async_req=True) + >>> result = thread.get() + + :param id: (required) + :type id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :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. + :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 + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ResponseBodyGameDto, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'id' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method retrieve_games" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['id']: + _path_params['id'] = _params['id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "ResponseBodyGameDto", + } + + return self.api_client.call_api( + '/games/{id}', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/api-customer/api-resources/game-components/board_mate/game/api_client.py b/api-customer/api-resources/game-components/board_mate/game/api_client.py new file mode 100644 index 00000000..4a8d98ba --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/api_client.py @@ -0,0 +1,758 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 atexit +import datetime +from dateutil.parser import parse +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +from urllib.parse import quote + +from board_mate.game.configuration import Configuration +from board_mate.game.api_response import ApiResponse +import board_mate.game.models +from board_mate.game import rest +from board_mate.game.exceptions import ApiValueError, ApiException + + +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 + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + 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, + 'object': object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + self.pool_threads = pool_threads + + 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): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @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 __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_types_map=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None, + _request_auth=None): + + 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) + 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: + 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 + + try: + # perform request and return response + response_data = self.request( + method, url, + query_params=query_params, + headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + if e.body: + e.body = e.body.decode('utf-8') + raise e + + self.last_response = response_data + + return_data = None # assuming derialization is not needed + # data needs deserialization or returns HTTP data (deserialized) only + if _preload_content or _return_http_data_only: + 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) + + if response_type == "bytearray": + response_data.data = response_data.data + else: + 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_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type == "bytearray": + return_data = response_data.data + elif response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + + if _return_http_data_only: + return return_data + else: + 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 str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + 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, 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() + + if 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. + obj_dict = obj.to_dict() + + return {key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items()} + + def deserialize(self, response, response_type): + """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. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + 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['): + sub_kls = re.match(r'List\[(.*)]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).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(board_mate.game.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) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_types_map=None, auth_settings=None, + async_req=None, _return_http_data_only=None, + collection_formats=None, _preload_content=True, + _request_timeout=None, _host=None, _request_auth=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :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 response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :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. + :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_token: dict, optional + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_types_map, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _request_auth) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_types_map, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _request_auth)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.get_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.head_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.options_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + elif method == "POST": + return self.rest_client.post_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.put_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.patch_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.delete_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + 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 = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + 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 = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, bool): + v = str(v).lower() + 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, 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(item) for item in new_params]) + + def files_parameters(self, files=None): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if files: + for k, v in files.items(): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + 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): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + 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): + """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) + return + + 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): + """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. + + :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: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).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_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/api-customer/api-resources/game-components/board_mate/game/api_response.py b/api-customer/api-resources/game-components/board_mate/game/api_response.py new file mode 100644 index 00000000..a0b62b95 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/api_response.py @@ -0,0 +1,25 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Any, Dict, Optional +from pydantic import Field, StrictInt, StrictStr + +class ApiResponse: + """ + API response object + """ + + status_code: Optional[StrictInt] = Field(None, description="HTTP status code") + headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + data: Optional[Any] = Field(None, description="Deserialized data given the data type") + raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)") + + def __init__(self, + status_code=None, + headers=None, + data=None, + raw_data=None) -> None: + self.status_code = status_code + self.headers = headers + self.data = data + self.raw_data = raw_data diff --git a/api-customer/api-resources/game-components/board_mate/game/configuration.py b/api-customer/api-resources/game-components/board_mate/game/configuration.py new file mode 100644 index 00000000..e7aa2340 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/configuration.py @@ -0,0 +1,434 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 logging +import multiprocessing +import sys +import urllib3 + +import http.client as httplib + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :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. + + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + access_token=None, + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ) -> None: + """Constructor + """ + self._base_path = "https://boardmate_api" 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.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("board_mate.game") + 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 = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + 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.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 = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """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): + 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, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """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): + """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): + """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 = Configuration() + return cls._default + + @property + def logger_file(self): + """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): + """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): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """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): + """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): + """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, alias=None): + """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 + + def get_basic_auth_token(self): + """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): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + return auth + + def to_debug_report(self): + """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): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "https://boardmate_api", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """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): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/api-customer/api-resources/game-components/board_mate/game/exceptions.py b/api-customer/api-resources/game-components/board_mate/game/exceptions.py new file mode 100644 index 00000000..e2dc6456 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/exceptions.py @@ -0,0 +1,166 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 + + +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) -> None: + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + 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.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + +class BadRequestException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(BadRequestException, self).__init__(status, reason, http_resp) + +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ServiceException, self).__init__(status, reason, http_resp) + + +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/api-customer/api-resources/game-components/board_mate/game/models/__init__.py b/api-customer/api-resources/game-components/board_mate/game/models/__init__.py new file mode 100644 index 00000000..bd03b0f6 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/models/__init__.py @@ -0,0 +1,20 @@ +# coding: utf-8 + +# flake8: noqa +""" + boardmate_api API + + boardmate_api API + + 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 board_mate.game.models.game_dto import GameDto +from board_mate.game.models.move_dto import MoveDto +from board_mate.game.models.response_body_game_dto import ResponseBodyGameDto +from board_mate.game.models.response_body_string import ResponseBodyString diff --git a/api-customer/api-resources/game-components/board_mate/game/models/game_dto.py b/api-customer/api-resources/game-components/board_mate/game/models/game_dto.py new file mode 100644 index 00000000..5d8a849a --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/models/game_dto.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class GameDto(BaseModel): + """ + GameDto + """ + white_name: Optional[StrictStr] = Field(None, alias="whiteName") + black_name: Optional[StrictStr] = Field(None, alias="blackName") + time_value: Optional[StrictInt] = Field(None, alias="timeValue") + increment: Optional[StrictInt] = None + __properties = ["whiteName", "blackName", "timeValue", "increment"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> GameDto: + """Create an instance of GameDto from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> GameDto: + """Create an instance of GameDto from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return GameDto.parse_obj(obj) + + _obj = GameDto.parse_obj({ + "white_name": obj.get("whiteName"), + "black_name": obj.get("blackName"), + "time_value": obj.get("timeValue"), + "increment": obj.get("increment") + }) + return _obj + + diff --git a/api-customer/api-resources/game-components/board_mate/game/models/move_dto.py b/api-customer/api-resources/game-components/board_mate/game/models/move_dto.py new file mode 100644 index 00000000..c67f8b83 --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/models/move_dto.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Optional +from pydantic import BaseModel, StrictStr + +class MoveDto(BaseModel): + """ + MoveDto + """ + notation: Optional[StrictStr] = None + __properties = ["notation"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> MoveDto: + """Create an instance of MoveDto from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> MoveDto: + """Create an instance of MoveDto from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return MoveDto.parse_obj(obj) + + _obj = MoveDto.parse_obj({ + "notation": obj.get("notation") + }) + return _obj + + diff --git a/api-customer/api-resources/game-components/board_mate/game/models/response_body_game_dto.py b/api-customer/api-resources/game-components/board_mate/game/models/response_body_game_dto.py new file mode 100644 index 00000000..ff5ef07e --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/models/response_body_game_dto.py @@ -0,0 +1,75 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Any, Dict, Optional +from pydantic import BaseModel, StrictBool, StrictStr + +class ResponseBodyGameDto(BaseModel): + """ + ResponseBodyGameDto + """ + data: Optional[Dict[str, Any]] = None + message: Optional[StrictStr] = None + success: Optional[StrictBool] = None + __properties = ["data", "message", "success"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ResponseBodyGameDto: + """Create an instance of ResponseBodyGameDto from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ResponseBodyGameDto: + """Create an instance of ResponseBodyGameDto from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ResponseBodyGameDto.parse_obj(obj) + + _obj = ResponseBodyGameDto.parse_obj({ + "data": obj.get("data"), + "message": obj.get("message"), + "success": obj.get("success") + }) + return _obj + + diff --git a/api-customer/api-resources/game-components/board_mate/game/models/response_body_string.py b/api-customer/api-resources/game-components/board_mate/game/models/response_body_string.py new file mode 100644 index 00000000..e5f9e8fb --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/models/response_body_string.py @@ -0,0 +1,75 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 typing import Optional +from pydantic import BaseModel, StrictBool, StrictStr + +class ResponseBodyString(BaseModel): + """ + ResponseBodyString + """ + data: Optional[StrictStr] = None + message: Optional[StrictStr] = None + success: Optional[StrictBool] = None + __properties = ["data", "message", "success"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ResponseBodyString: + """Create an instance of ResponseBodyString from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ResponseBodyString: + """Create an instance of ResponseBodyString from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ResponseBodyString.parse_obj(obj) + + _obj = ResponseBodyString.parse_obj({ + "data": obj.get("data"), + "message": obj.get("message"), + "success": obj.get("success") + }) + return _obj + + diff --git a/api-customer/api-resources/game-components/board_mate/game/py.typed b/api-customer/api-resources/game-components/board_mate/game/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/game-components/board_mate/game/rest.py b/api-customer/api-resources/game-components/board_mate/game/rest.py new file mode 100644 index 00000000..18c073da --- /dev/null +++ b/api-customer/api-resources/game-components/board_mate/game/rest.py @@ -0,0 +1,303 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 logging +import re +import ssl + +from urllib.parse import urlencode, quote_plus +import urllib3 + +from board_mate.game.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration, pools_size=4, maxsize=None) -> 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 + # maxsize is the number of requests to host that are allowed in parallel # 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 + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.tls_server_name: + addition_pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the 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 _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :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 {} + # url already contains the URL query string + # so reset query_params to empty dict + query_params = {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int,float)): # noqa: E501,F821 + 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 + if not headers.get('Content-Type') or re.search('json', headers['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, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['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'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # 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): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + 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={}, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + if r.status == 400: + raise BadRequestException(http_resp=r) + + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + + raise ApiException(http_resp=r) + + return r + + def get_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def head_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def options_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def delete_request(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def post_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def put_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def patch_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/api-customer/api-resources/game-components/docs/GameApi.md b/api-customer/api-resources/game-components/docs/GameApi.md new file mode 100644 index 00000000..aa110d79 --- /dev/null +++ b/api-customer/api-resources/game-components/docs/GameApi.md @@ -0,0 +1,210 @@ +# board_mate.game.GameApi + +All URIs are relative to *https://boardmate_api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_move**](GameApi.md#add_move) | **POST** /moves/add/{gameId} | POST moves/add/{gameId} +[**create_party**](GameApi.md#create_party) | **POST** /create | POST create +[**retrieve_games**](GameApi.md#retrieve_games) | **GET** /games/{id} | GET games/{id} + + +# **add_move** +> ResponseBodyString add_move(game_id, move_dto) + +POST moves/add/{gameId} + +### Example + +```python +import time +import os +import board_mate.game +from board_mate.game.models.move_dto import MoveDto +from board_mate.game.models.response_body_string import ResponseBodyString +from board_mate.game.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.game.Configuration( + host = "https://boardmate_api" +) + + +# Enter a context with an instance of the API client +with board_mate.game.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.game.GameApi(api_client) + game_id = 'game_id_example' # str | + move_dto = board_mate.game.MoveDto() # MoveDto | + + try: + # POST moves/add/{gameId} + api_response = api_instance.add_move(game_id, move_dto) + print("The response of GameApi->add_move:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling GameApi->add_move: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **game_id** | **str**| | + **move_dto** | [**MoveDto**](MoveDto.md)| | + +### Return type + +[**ResponseBodyString**](ResponseBodyString.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_party** +> ResponseBodyString create_party(game_dto) + +POST create + +### Example + +```python +import time +import os +import board_mate.game +from board_mate.game.models.game_dto import GameDto +from board_mate.game.models.response_body_string import ResponseBodyString +from board_mate.game.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.game.Configuration( + host = "https://boardmate_api" +) + + +# Enter a context with an instance of the API client +with board_mate.game.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.game.GameApi(api_client) + game_dto = board_mate.game.GameDto() # GameDto | + + try: + # POST create + api_response = api_instance.create_party(game_dto) + print("The response of GameApi->create_party:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling GameApi->create_party: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **game_dto** | [**GameDto**](GameDto.md)| | + +### Return type + +[**ResponseBodyString**](ResponseBodyString.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **retrieve_games** +> ResponseBodyGameDto retrieve_games(id) + +GET games/{id} + +### Example + +```python +import time +import os +import board_mate.game +from board_mate.game.models.response_body_game_dto import ResponseBodyGameDto +from board_mate.game.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://boardmate_api +# See configuration.py for a list of all supported configuration parameters. +configuration = board_mate.game.Configuration( + host = "https://boardmate_api" +) + + +# Enter a context with an instance of the API client +with board_mate.game.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = board_mate.game.GameApi(api_client) + id = 'id_example' # str | + + try: + # GET games/{id} + api_response = api_instance.retrieve_games(id) + print("The response of GameApi->retrieve_games:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling GameApi->retrieve_games: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **str**| | + +### Return type + +[**ResponseBodyGameDto**](ResponseBodyGameDto.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/api-customer/api-resources/game-components/docs/GameDto.md b/api-customer/api-resources/game-components/docs/GameDto.md new file mode 100644 index 00000000..eaa7a8c2 --- /dev/null +++ b/api-customer/api-resources/game-components/docs/GameDto.md @@ -0,0 +1,31 @@ +# GameDto + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**white_name** | **str** | | [optional] +**black_name** | **str** | | [optional] +**time_value** | **int** | | [optional] +**increment** | **int** | | [optional] + +## Example + +```python +from board_mate.game.models.game_dto import GameDto + +# TODO update the JSON string below +json = "{}" +# create an instance of GameDto from a JSON string +game_dto_instance = GameDto.from_json(json) +# print the JSON string representation of the object +print GameDto.to_json() + +# convert the object into a dict +game_dto_dict = game_dto_instance.to_dict() +# create an instance of GameDto from a dict +game_dto_form_dict = game_dto.from_dict(game_dto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/game-components/docs/MoveDto.md b/api-customer/api-resources/game-components/docs/MoveDto.md new file mode 100644 index 00000000..8ff9e8ef --- /dev/null +++ b/api-customer/api-resources/game-components/docs/MoveDto.md @@ -0,0 +1,28 @@ +# MoveDto + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**notation** | **str** | | [optional] + +## Example + +```python +from board_mate.game.models.move_dto import MoveDto + +# TODO update the JSON string below +json = "{}" +# create an instance of MoveDto from a JSON string +move_dto_instance = MoveDto.from_json(json) +# print the JSON string representation of the object +print MoveDto.to_json() + +# convert the object into a dict +move_dto_dict = move_dto_instance.to_dict() +# create an instance of MoveDto from a dict +move_dto_form_dict = move_dto.from_dict(move_dto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/game-components/docs/ResponseBodyGameDto.md b/api-customer/api-resources/game-components/docs/ResponseBodyGameDto.md new file mode 100644 index 00000000..f981365f --- /dev/null +++ b/api-customer/api-resources/game-components/docs/ResponseBodyGameDto.md @@ -0,0 +1,30 @@ +# ResponseBodyGameDto + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | **object** | | [optional] +**message** | **str** | | [optional] +**success** | **bool** | | [optional] + +## Example + +```python +from board_mate.game.models.response_body_game_dto import ResponseBodyGameDto + +# TODO update the JSON string below +json = "{}" +# create an instance of ResponseBodyGameDto from a JSON string +response_body_game_dto_instance = ResponseBodyGameDto.from_json(json) +# print the JSON string representation of the object +print ResponseBodyGameDto.to_json() + +# convert the object into a dict +response_body_game_dto_dict = response_body_game_dto_instance.to_dict() +# create an instance of ResponseBodyGameDto from a dict +response_body_game_dto_form_dict = response_body_game_dto.from_dict(response_body_game_dto_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/game-components/docs/ResponseBodyString.md b/api-customer/api-resources/game-components/docs/ResponseBodyString.md new file mode 100644 index 00000000..1219fb66 --- /dev/null +++ b/api-customer/api-resources/game-components/docs/ResponseBodyString.md @@ -0,0 +1,30 @@ +# ResponseBodyString + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | **str** | | [optional] +**message** | **str** | | [optional] +**success** | **bool** | | [optional] + +## Example + +```python +from board_mate.game.models.response_body_string import ResponseBodyString + +# TODO update the JSON string below +json = "{}" +# create an instance of ResponseBodyString from a JSON string +response_body_string_instance = ResponseBodyString.from_json(json) +# print the JSON string representation of the object +print ResponseBodyString.to_json() + +# convert the object into a dict +response_body_string_dict = response_body_string_instance.to_dict() +# create an instance of ResponseBodyString from a dict +response_body_string_form_dict = response_body_string.from_dict(response_body_string_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api-customer/api-resources/game-components/git_push.sh b/api-customer/api-resources/game-components/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/api-customer/api-resources/game-components/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/api-customer/api-resources/game-components/pyproject.toml b/api-customer/api-resources/game-components/pyproject.toml new file mode 100644 index 00000000..0de087ea --- /dev/null +++ b/api-customer/api-resources/game-components/pyproject.toml @@ -0,0 +1,30 @@ +[tool.poetry] +name = "board_mate.game" +version = "1.0.0" +description = "boardmate_api API" +authors = ["OpenAPI Generator Community "] +license = "NoLicense" +readme = "README.md" +repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" +keywords = ["OpenAPI", "OpenAPI-Generator", "boardmate_api API"] +include = ["board_mate.game/py.typed"] + +[tool.poetry.dependencies] +python = "^3.7" + +urllib3 = ">= 1.25.3" +python-dateutil = ">=2.8.2" +pydantic = "^1.10.5, <2" +aenum = ">=3.1.11" + +[tool.poetry.dev-dependencies] +pytest = ">=7.2.1" +tox = ">=3.9.0" +flake8 = ">=4.0.0" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" diff --git a/api-customer/api-resources/game-components/requirements.txt b/api-customer/api-resources/game-components/requirements.txt new file mode 100644 index 00000000..258c179c --- /dev/null +++ b/api-customer/api-resources/game-components/requirements.txt @@ -0,0 +1,5 @@ +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.25.3, < 2.1.0 +pydantic >= 1.10.5, < 2 +aenum >= 3.1.11 diff --git a/api-customer/api-resources/game-components/setup.cfg b/api-customer/api-resources/game-components/setup.cfg new file mode 100644 index 00000000..11433ee8 --- /dev/null +++ b/api-customer/api-resources/game-components/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/api-customer/api-resources/game-components/setup.py b/api-customer/api-resources/game-components/setup.py new file mode 100644 index 00000000..63ca90c6 --- /dev/null +++ b/api-customer/api-resources/game-components/setup.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 = "board-mate.game" +VERSION = "1.0.0" +PYTHON_REQUIRES = ">=3.7" +REQUIRES = [ + "urllib3 >= 1.25.3, < 2.1.0", + "python-dateutil", + "pydantic >= 1.10.5, < 2", + "aenum" +] + +setup( + name=NAME, + version=VERSION, + description="boardmate_api API", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "boardmate_api API"], + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + long_description_content_type='text/markdown', + long_description="""\ + boardmate_api API + """, # noqa: E501 + package_data={"board_mate.game": ["py.typed"]}, +) diff --git a/api-customer/api-resources/game-components/test-requirements.txt b/api-customer/api-resources/game-components/test-requirements.txt new file mode 100644 index 00000000..3a0d0b93 --- /dev/null +++ b/api-customer/api-resources/game-components/test-requirements.txt @@ -0,0 +1,3 @@ +pytest~=7.1.3 +pytest-cov>=2.8.1 +pytest-randomly>=3.12.0 diff --git a/api-customer/api-resources/game-components/test/__init__.py b/api-customer/api-resources/game-components/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api-customer/api-resources/game-components/test/test_game_api.py b/api-customer/api-resources/game-components/test/test_game_api.py new file mode 100644 index 00000000..94357f06 --- /dev/null +++ b/api-customer/api-resources/game-components/test/test_game_api.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest + +from board_mate.game.api.game_api import GameApi # noqa: E501 + + +class TestGameApi(unittest.TestCase): + """GameApi unit test stubs""" + + def setUp(self) -> None: + self.api = GameApi() # noqa: E501 + + def tearDown(self) -> None: + pass + + def test_add_move(self) -> None: + """Test case for add_move + + POST moves/add/{gameId} # noqa: E501 + """ + pass + + def test_create_party(self) -> None: + """Test case for create_party + + POST create # noqa: E501 + """ + pass + + def test_retrieve_games(self) -> None: + """Test case for retrieve_games + + GET games/{id} # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/game-components/test/test_game_dto.py b/api-customer/api-resources/game-components/test/test_game_dto.py new file mode 100644 index 00000000..81e1a281 --- /dev/null +++ b/api-customer/api-resources/game-components/test/test_game_dto.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.game.models.game_dto import GameDto # noqa: E501 + +class TestGameDto(unittest.TestCase): + """GameDto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> GameDto: + """Test GameDto + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `GameDto` + """ + model = GameDto() # noqa: E501 + if include_optional: + return GameDto( + white_name = '', + black_name = '', + time_value = 56, + increment = 56 + ) + else: + return GameDto( + ) + """ + + def testGameDto(self): + """Test GameDto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/game-components/test/test_move_dto.py b/api-customer/api-resources/game-components/test/test_move_dto.py new file mode 100644 index 00000000..49a649f9 --- /dev/null +++ b/api-customer/api-resources/game-components/test/test_move_dto.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.game.models.move_dto import MoveDto # noqa: E501 + +class TestMoveDto(unittest.TestCase): + """MoveDto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> MoveDto: + """Test MoveDto + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `MoveDto` + """ + model = MoveDto() # noqa: E501 + if include_optional: + return MoveDto( + notation = '' + ) + else: + return MoveDto( + ) + """ + + def testMoveDto(self): + """Test MoveDto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/game-components/test/test_response_body_game_dto.py b/api-customer/api-resources/game-components/test/test_response_body_game_dto.py new file mode 100644 index 00000000..d602c2cc --- /dev/null +++ b/api-customer/api-resources/game-components/test/test_response_body_game_dto.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.game.models.response_body_game_dto import ResponseBodyGameDto # noqa: E501 + +class TestResponseBodyGameDto(unittest.TestCase): + """ResponseBodyGameDto unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ResponseBodyGameDto: + """Test ResponseBodyGameDto + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ResponseBodyGameDto` + """ + model = ResponseBodyGameDto() # noqa: E501 + if include_optional: + return ResponseBodyGameDto( + data = None, + message = '', + success = True + ) + else: + return ResponseBodyGameDto( + ) + """ + + def testResponseBodyGameDto(self): + """Test ResponseBodyGameDto""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/game-components/test/test_response_body_string.py b/api-customer/api-resources/game-components/test/test_response_body_string.py new file mode 100644 index 00000000..855e195f --- /dev/null +++ b/api-customer/api-resources/game-components/test/test_response_body_string.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + boardmate_api API + + boardmate_api API + + 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 unittest +import datetime + +from board_mate.game.models.response_body_string import ResponseBodyString # noqa: E501 + +class TestResponseBodyString(unittest.TestCase): + """ResponseBodyString unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ResponseBodyString: + """Test ResponseBodyString + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ResponseBodyString` + """ + model = ResponseBodyString() # noqa: E501 + if include_optional: + return ResponseBodyString( + data = '', + message = '', + success = True + ) + else: + return ResponseBodyString( + ) + """ + + def testResponseBodyString(self): + """Test ResponseBodyString""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/api-customer/api-resources/game-components/tox.ini b/api-customer/api-resources/game-components/tox.ini new file mode 100644 index 00000000..3aae9aef --- /dev/null +++ b/api-customer/api-resources/game-components/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=board_mate.game