Name | api-compose JSON |
Version |
0.0.20
JSON |
| download |
home_page | |
Summary | A Framework for orchestrating, asserting and reporting on API calls with templates |
upload_time | 2023-10-02 11:46:33 |
maintainer | |
docs_url | None |
author | Ken |
requires_python | >=3.9 |
license | Apache License 2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
.. |NAME| replace:: API Compose
.. |CLI_NAME| replace:: acp
.. |PACKAGE_NAME| replace:: api-compose
|NAME|
~~~~~~~~~~~~~~~~~~~~
.. image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/kenho811/api_compose.git/HEAD?labpath=tutorials
Tutorials
=====================
On Binder.org
----------------------
A tutorial series as jupyter notebook is uploaded to binder.org. Please free to try it out there first!
Link: https://mybinder.org/v2/gh/kenho811/api_compose.git/HEAD?labpath=tutorials
Local
----------------------
.. code-block::
docker compose -f ./tutorials/docker-compose.yaml up
Installation
=====================
`PyPI Package <https://pypi.org/project/api-compose>`_
.. parsed-literal::
pip install |PACKAGE_NAME|
Get Started
------------------
.. parsed-literal::
# creates a sample project for you to build on
|CLI_NAME| scaffold <your_project_name>
Run the programme
-------------------------
.. parsed-literal::
|CLI_NAME| run
- Explore the CLI's capabilities by running `acp` or `acp --help`
Examples
============================
- Examples are in **./examples** folder
`API Examples <https://github.com/kenho811/api_compose/tree/main/examples>`_
Features
=====================
Declaration-based API Call Composition
--------------------------------------------------
- Allows API calls to be declared as Models.
- Distinguishes between **Compile Time Rendering** and **Run Time Rendering**
- Leverages networkx to determine the execution order of each API call.
- Exposes decorator **@FunctionsRegistry** to for users to register user-defined jinja functions (Globals, Filters and Tests)
Useful Builtin Jinja Globals
----------------------------------------
Builtin Jinja Globals allow users to specify which part (e.g. headers, body etc.) of an API action (e.g. login, get_images etc.) to use.
.. code-block::
## Get the value of the field field_one of the returned body from the login_action API call
{{ action('login_action')| output_body| jpath('$.field_one') }}
## Get the value of the field field_one of the input headers from the login_action API call
{{ action('login_action')| input_headers | jpath('$.field_one') }}
## Get the rendered body of the current API call
{{ action('self')| config_body }}
Supported API Calls Type - Adapters
----------------------------------------
- Below is the table which breaks down the type of API Call by
- Protocol (Column)
- Data Format (Row)
.. table::
+------+------+-----------+-----+
| | HTTP | WebSocket | FIX |
+======+======+===========+=====+
| json | True | WIP | TBD |
+------+------+-----------+-----+
| xml | True | TBD | TBD |
+------+------+-----------+-----+
- WIP means Working in Progress. It means it is being worked on now.
- TBD means to be determined. It means it will be planned in the future.
Schema Validation
---------------------------
- Leverages **jsonschema** and **xmlschema** to validate returned json and xml data respectively.
Assertion
---------------------------
- Allows users to use Jinja to make assertions between API Calls Result
.. code-block::
# assert that value of a the field 'field_one' in the output body of action 'action_one' equals 1
{{ action('action_one')| output_body| jpath('$.field_one') == 1 }}
# assert that value of a the field 'field_one' in the output body of action 'action_one' equals 'a'
{{ action('action_two')| output_body| xpath('/field_one/text()') == 'a' }}
Reporting
---------------------------
- Presents Test Results nicely in HTML reports
Architectural Diagram
===========================
.. figure:: ./diagrams/framework_architecture.png
:scale: 70%
:align: center
:alt: API Compose Framwork Architecture
The above is the Programme Architecture.
Lucid Chart here: `https://lucid.app/lucidchart/f8d1f9f9-bc93-46ec-8e4f-6561a4c822c3/edit?beaconFlowId=70D4EDD3B7971E6C&invitationId=inv_c7b45baf-050c-480b-923e-2979440ce4c8&page=0_0#`
.. figure:: ./diagrams/framework_building_blocks.png
Hierarchical structure of the models
Lucid Chart here: https://lucid.app/lucidchart/f8d1f9f9-bc93-46ec-8e4f-6561a4c822c3/edit?beaconFlowId=70D4EDD3B7971E6C&invitationId=inv_c7b45baf-050c-480b-923e-2979440ce4c8&page=p0OVapsRWlkY#
Jinja Templating
============================
Compile Time Rendering
--------------------------------
- To make templates reusable, the programme exposes the means to render template files using the below syntax:
.. code-block::
block_start_string='[%'
block_end_string='%]'
variable_start_string='[['
variable_end_string=']]'
comment_start_string='[#'
comment_end_string='#]'
Run Time Rendering
--------------------------------
- To allow for inter-API Call dependencies within a given scenario, the programme also exposes the means to render templated fields using the below syntax:
.. code-block::
block_start_string='{%'
block_end_string='%}'
variable_start_string='{{'
variable_end_string='}}'
comment_start_string='{#'
comment_end_string='#}'
Raw data
{
"_id": null,
"home_page": "",
"name": "api-compose",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "",
"author": "Ken",
"author_email": "kenho811job@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/99/48/3d87116a77a3e64d21986c8b3330340201d59d86436a57c7613e5ddea0e6/api_compose-0.0.20.tar.gz",
"platform": null,
"description": ".. |NAME| replace:: API Compose\n.. |CLI_NAME| replace:: acp\n.. |PACKAGE_NAME| replace:: api-compose\n\n\n|NAME|\n~~~~~~~~~~~~~~~~~~~~\n\n.. image:: https://mybinder.org/badge_logo.svg\n :target: https://mybinder.org/v2/gh/kenho811/api_compose.git/HEAD?labpath=tutorials\n\n\nTutorials\n=====================\n\nOn Binder.org\n----------------------\n\nA tutorial series as jupyter notebook is uploaded to binder.org. Please free to try it out there first!\n\nLink: https://mybinder.org/v2/gh/kenho811/api_compose.git/HEAD?labpath=tutorials\n\nLocal\n----------------------\n\n.. code-block::\n\n docker compose -f ./tutorials/docker-compose.yaml up\n\n\nInstallation\n=====================\n\n`PyPI Package <https://pypi.org/project/api-compose>`_\n\n.. parsed-literal::\n\n pip install |PACKAGE_NAME|\n\nGet Started\n------------------\n\n.. parsed-literal::\n\n # creates a sample project for you to build on\n |CLI_NAME| scaffold <your_project_name>\n\nRun the programme\n-------------------------\n\n.. parsed-literal::\n\n |CLI_NAME| run\n\n- Explore the CLI's capabilities by running `acp` or `acp --help`\n\n\nExamples\n============================\n- Examples are in **./examples** folder\n\n`API Examples <https://github.com/kenho811/api_compose/tree/main/examples>`_\n\n\nFeatures\n=====================\n\nDeclaration-based API Call Composition\n--------------------------------------------------\n\n- Allows API calls to be declared as Models.\n\n- Distinguishes between **Compile Time Rendering** and **Run Time Rendering**\n\n- Leverages networkx to determine the execution order of each API call.\n\n- Exposes decorator **@FunctionsRegistry** to for users to register user-defined jinja functions (Globals, Filters and Tests)\n\n\nUseful Builtin Jinja Globals\n----------------------------------------\n\nBuiltin Jinja Globals allow users to specify which part (e.g. headers, body etc.) of an API action (e.g. login, get_images etc.) to use.\n\n.. code-block::\n\n ## Get the value of the field field_one of the returned body from the login_action API call\n {{ action('login_action')| output_body| jpath('$.field_one') }}\n\n ## Get the value of the field field_one of the input headers from the login_action API call\n {{ action('login_action')| input_headers | jpath('$.field_one') }}\n\n ## Get the rendered body of the current API call\n {{ action('self')| config_body }}\n\nSupported API Calls Type - Adapters\n----------------------------------------\n\n- Below is the table which breaks down the type of API Call by\n\n - Protocol (Column)\n - Data Format (Row)\n\n\n.. table::\n\n +------+------+-----------+-----+\n | | HTTP | WebSocket | FIX |\n +======+======+===========+=====+\n | json | True | WIP | TBD |\n +------+------+-----------+-----+\n | xml | True | TBD | TBD |\n +------+------+-----------+-----+\n\n- WIP means Working in Progress. It means it is being worked on now.\n\n- TBD means to be determined. It means it will be planned in the future.\n\n\nSchema Validation\n---------------------------\n- Leverages **jsonschema** and **xmlschema** to validate returned json and xml data respectively.\n\nAssertion\n---------------------------\n\n- Allows users to use Jinja to make assertions between API Calls Result\n\n.. code-block::\n\n # assert that value of a the field 'field_one' in the output body of action 'action_one' equals 1\n {{ action('action_one')| output_body| jpath('$.field_one') == 1 }}\n\n # assert that value of a the field 'field_one' in the output body of action 'action_one' equals 'a'\n {{ action('action_two')| output_body| xpath('/field_one/text()') == 'a' }}\n\n\nReporting\n---------------------------\n\n- Presents Test Results nicely in HTML reports\n\n\n\nArchitectural Diagram\n===========================\n\n.. figure:: ./diagrams/framework_architecture.png\n :scale: 70%\n :align: center\n :alt: API Compose Framwork Architecture\n\n The above is the Programme Architecture.\n\n Lucid Chart here: `https://lucid.app/lucidchart/f8d1f9f9-bc93-46ec-8e4f-6561a4c822c3/edit?beaconFlowId=70D4EDD3B7971E6C&invitationId=inv_c7b45baf-050c-480b-923e-2979440ce4c8&page=0_0#`\n\n\n.. figure:: ./diagrams/framework_building_blocks.png\n\n Hierarchical structure of the models\n\n Lucid Chart here: https://lucid.app/lucidchart/f8d1f9f9-bc93-46ec-8e4f-6561a4c822c3/edit?beaconFlowId=70D4EDD3B7971E6C&invitationId=inv_c7b45baf-050c-480b-923e-2979440ce4c8&page=p0OVapsRWlkY#\n\n\n\nJinja Templating\n============================\n\nCompile Time Rendering\n--------------------------------\n\n- To make templates reusable, the programme exposes the means to render template files using the below syntax:\n\n.. code-block::\n\n block_start_string='[%'\n block_end_string='%]'\n variable_start_string='[['\n variable_end_string=']]'\n comment_start_string='[#'\n comment_end_string='#]'\n\nRun Time Rendering\n--------------------------------\n\n- To allow for inter-API Call dependencies within a given scenario, the programme also exposes the means to render templated fields using the below syntax:\n\n.. code-block::\n\n block_start_string='{%'\n block_end_string='%}'\n variable_start_string='{{'\n variable_end_string='}}'\n comment_start_string='{#'\n comment_end_string='#}'\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "A Framework for orchestrating, asserting and reporting on API calls with templates",
"version": "0.0.20",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "99483d87116a77a3e64d21986c8b3330340201d59d86436a57c7613e5ddea0e6",
"md5": "8733099dfbffa3e17809559df9a4aea9",
"sha256": "266428f447f3096f1ea862d57bb3999ea88414f4ec86f5a3cfad8e0fe67088ef"
},
"downloads": -1,
"filename": "api_compose-0.0.20.tar.gz",
"has_sig": false,
"md5_digest": "8733099dfbffa3e17809559df9a4aea9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 84238,
"upload_time": "2023-10-02T11:46:33",
"upload_time_iso_8601": "2023-10-02T11:46:33.711627Z",
"url": "https://files.pythonhosted.org/packages/99/48/3d87116a77a3e64d21986c8b3330340201d59d86436a57c7613e5ddea0e6/api_compose-0.0.20.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-02 11:46:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "api-compose"
}