ansys-openapi-common


Nameansys-openapi-common JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/pyansys/openapi-common
SummaryProvides a helper to create sessions for use with Ansys OpenAPI clients.
upload_time2024-05-02 15:07:09
maintainerANSYS, Inc.
docs_urlNone
authorANSYS, Inc.
requires_python<4.0,>=3.9
licenseMIT
keywords ansys openapi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |pyansys| |python| |pypi| |GH-CI| |MIT| |black| |pre-commit-ci|

.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?labelColor=black&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
   :target: https://docs.pyansys.com/
   :alt: PyAnsys

.. |python| image:: https://img.shields.io/pypi/pyversions/ansys-openapi-common?logo=pypi
   :target: https://pypi.org/project/ansys-openapi-common/
   :alt: Python

.. |pypi| image:: https://img.shields.io/pypi/v/ansys-openapi-common.svg?logo=python&logoColor=white
   :target: https://pypi.org/project/ansys-openapi-common
   :alt: PyPI

.. |GH-CI| image:: https://github.com/pyansys/openapi-common/actions/workflows/ci_cd.yml/badge.svg
   :target: https://github.com/ansys/openapi-common/actions/workflows/ci_cd.yml
   :alt: GH-CI

.. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
   :target: https://opensource.org/licenses/MIT
   :alt: MIT

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
   :target: https://github.com/psf/black
   :alt: Black

.. |pre-commit-ci| image:: https://results.pre-commit.ci/badge/github/ansys/openapi-common/main.svg
   :target: https://results.pre-commit.ci/latest/github/ansys/openapi-common/main
   :alt: pre-commit.ci status


Overview
--------

OpenAPI-Common is intended for use with the custom code generation
template in the `PyAnsys project <https://github.com/pyansys>`_.
It provides the source code for an authentication-aware
client for OpenAPI client libraries.

OpenAPI-Common supports authentication with Basic, Negotiate, NTLM,
and OpenID Connect. Most features of the underlying requests session
are exposed for use. Some basic configuration is also provided by default.

Installation
------------

Install the ``openapi-common`` repository with this code:

.. code::

   pip install ansys-openapi-common

Alternatively, clone and install the repository with this code:

.. code::

   git clone https://github.com/pyansys/openapi-common
   cd openapi-common
   pip install .


Usage
-----

The API client class is intended to be wrapped by code that implements a client library.
You should override the ``__init__()`` or ``connect()`` method to add any
additional behavior that might be required.

Authentication is configured through the ``ApiClientFactory`` object and its ``with_xxx()``
methods. If no authentication is required, you can use the ``with_anonymous()`` method.
You can provide additional configuration with the ``SessionConfiguration`` object.

.. code:: python

   >>> from ansys.openapi.common import ApiClientFactory
   >>> session = ApiClientFactory('https://my-api.com/v1.svc')
   ...           .with_autologon()
   ...           .connect()
   <ApiClient url: https://my-api.com/v1.svc>


Authentication schemes
----------------------

OpenAPI-Common supports API servers configured with no authentication, API keys,
client certificates, and basic authentication schemes.

Windows users can also use Windows Integrated Authentication to connect to Kerberos-enabled
APIs with their Windows credentials and to NTLM where it is supported.

Linux users can make use of Kerberos authentication via the ``[linux-kerberos]`` extra. This
requires a working installation of either MIT Kerberos or Heimdal, as well as some
platform-specific build steps. An additional requirement is a correctly configured ``krb5.keytab``
file on your system.

Windows and Linux users can authenticate with OIDC-enabled APIs by using the ``[oidc]`` extra.
Currently only the Authorization Code authentication flow is supported.

.. list-table:: Authentication methods by platform
   :header-rows: 1

   * - Authentication method
     - Windows
     - Linux
     - Builder method
     - Additional settings
   * - API Key
     - ✔️
     - ✔️
     - ``.with_anonymous()``
     - Set the appropriate header in ``api_session_configuration``
   * - Client Certificate
     - ✔️
     - ✔️
     - Any
     - Provide ``client_cert_path`` and optionally ``client_cert_key`` in ``api_session_configuration``
   * - Basic
     - ✔️
     - ✔️
     - ``.with_credentials()``
     -
   * - NTLM
     - ✔️
     - ❌
     - ``.with_credentials()``
     -
   * - Kerberos
     - ✔️
     - ➕ with ``[linux-kerberos]`` extra
     - ``.with_autologon()``
     -
   * - OIDC
     - ➕ with ``[oidc]`` extra
     - ➕ with ``[oidc]`` extra
     - ``.with_oidc()``
     -

Platform-specific Kerberos configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kerberos authentication should be supported wherever the MIT or Heimdal Kerberos client
can be installed. OpenAPI-Common has been tested on the platforms that follow.
If you manage to use it on another platform, consider contributing installation steps for
your platform by making a pull request.

Ubuntu 20.04
============

Ubuntu requires the ``gssapi`` Python module to be built from source. This requires the
Kerberos headers, Python headers for the version of Python that you are using (here we have
installed python3.10 from the deadsnakes ppa), and a supported compiler. (GCC works well.))

You should then be able to install this module with the ``[linux-kerberos]`` extra.

.. code-block:: bash

   sudo apt install build-essential python3.10-dev libkrb5-dev
   pip install ansys-openapi-common[linux-kerberos]


Once the installation completes, ensure that your ``krb5.conf`` file is set up correctly
for your Kerberos configuration and that you have a valid ``keytab`` file, which is
normally in ``/etc/krb5.keytab``.

License
-------
OpenAPI-Common is provided under the terms of the MIT license. You can find
the license text in the LICENSE file at the root of the repository.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pyansys/openapi-common",
    "name": "ansys-openapi-common",
    "maintainer": "ANSYS, Inc.",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": "pyansys.core@ansys.com",
    "keywords": "Ansys, OpenAPI",
    "author": "ANSYS, Inc.",
    "author_email": "pyansys.core@ansys.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/da/d8f8298d608b1f4604af3e87f8d4ec6a6ce16d08dffbb76e192972fb987e/ansys_openapi_common-2.0.1.tar.gz",
    "platform": null,
    "description": "|pyansys| |python| |pypi| |GH-CI| |MIT| |black| |pre-commit-ci|\n\n.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?labelColor=black&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC\n   :target: https://docs.pyansys.com/\n   :alt: PyAnsys\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/ansys-openapi-common?logo=pypi\n   :target: https://pypi.org/project/ansys-openapi-common/\n   :alt: Python\n\n.. |pypi| image:: https://img.shields.io/pypi/v/ansys-openapi-common.svg?logo=python&logoColor=white\n   :target: https://pypi.org/project/ansys-openapi-common\n   :alt: PyPI\n\n.. |GH-CI| image:: https://github.com/pyansys/openapi-common/actions/workflows/ci_cd.yml/badge.svg\n   :target: https://github.com/ansys/openapi-common/actions/workflows/ci_cd.yml\n   :alt: GH-CI\n\n.. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg\n   :target: https://opensource.org/licenses/MIT\n   :alt: MIT\n\n.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat\n   :target: https://github.com/psf/black\n   :alt: Black\n\n.. |pre-commit-ci| image:: https://results.pre-commit.ci/badge/github/ansys/openapi-common/main.svg\n   :target: https://results.pre-commit.ci/latest/github/ansys/openapi-common/main\n   :alt: pre-commit.ci status\n\n\nOverview\n--------\n\nOpenAPI-Common is intended for use with the custom code generation\ntemplate in the `PyAnsys project <https://github.com/pyansys>`_.\nIt provides the source code for an authentication-aware\nclient for OpenAPI client libraries.\n\nOpenAPI-Common supports authentication with Basic, Negotiate, NTLM,\nand OpenID Connect. Most features of the underlying requests session\nare exposed for use. Some basic configuration is also provided by default.\n\nInstallation\n------------\n\nInstall the ``openapi-common`` repository with this code:\n\n.. code::\n\n   pip install ansys-openapi-common\n\nAlternatively, clone and install the repository with this code:\n\n.. code::\n\n   git clone https://github.com/pyansys/openapi-common\n   cd openapi-common\n   pip install .\n\n\nUsage\n-----\n\nThe API client class is intended to be wrapped by code that implements a client library.\nYou should override the ``__init__()`` or ``connect()`` method to add any\nadditional behavior that might be required.\n\nAuthentication is configured through the ``ApiClientFactory`` object and its ``with_xxx()``\nmethods. If no authentication is required, you can use the ``with_anonymous()`` method.\nYou can provide additional configuration with the ``SessionConfiguration`` object.\n\n.. code:: python\n\n   >>> from ansys.openapi.common import ApiClientFactory\n   >>> session = ApiClientFactory('https://my-api.com/v1.svc')\n   ...           .with_autologon()\n   ...           .connect()\n   <ApiClient url: https://my-api.com/v1.svc>\n\n\nAuthentication schemes\n----------------------\n\nOpenAPI-Common supports API servers configured with no authentication, API keys,\nclient certificates, and basic authentication schemes.\n\nWindows users can also use Windows Integrated Authentication to connect to Kerberos-enabled\nAPIs with their Windows credentials and to NTLM where it is supported.\n\nLinux users can make use of Kerberos authentication via the ``[linux-kerberos]`` extra. This\nrequires a working installation of either MIT Kerberos or Heimdal, as well as some\nplatform-specific build steps. An additional requirement is a correctly configured ``krb5.keytab``\nfile on your system.\n\nWindows and Linux users can authenticate with OIDC-enabled APIs by using the ``[oidc]`` extra.\nCurrently only the Authorization Code authentication flow is supported.\n\n.. list-table:: Authentication methods by platform\n   :header-rows: 1\n\n   * - Authentication method\n     - Windows\n     - Linux\n     - Builder method\n     - Additional settings\n   * - API Key\n     - \u2714\ufe0f\n     - \u2714\ufe0f\n     - ``.with_anonymous()``\n     - Set the appropriate header in ``api_session_configuration``\n   * - Client Certificate\n     - \u2714\ufe0f\n     - \u2714\ufe0f\n     - Any\n     - Provide ``client_cert_path`` and optionally ``client_cert_key`` in ``api_session_configuration``\n   * - Basic\n     - \u2714\ufe0f\n     - \u2714\ufe0f\n     - ``.with_credentials()``\n     -\n   * - NTLM\n     - \u2714\ufe0f\n     - \u274c\n     - ``.with_credentials()``\n     -\n   * - Kerberos\n     - \u2714\ufe0f\n     - \u2795 with ``[linux-kerberos]`` extra\n     - ``.with_autologon()``\n     -\n   * - OIDC\n     - \u2795 with ``[oidc]`` extra\n     - \u2795 with ``[oidc]`` extra\n     - ``.with_oidc()``\n     -\n\nPlatform-specific Kerberos configuration\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nKerberos authentication should be supported wherever the MIT or Heimdal Kerberos client\ncan be installed. OpenAPI-Common has been tested on the platforms that follow.\nIf you manage to use it on another platform, consider contributing installation steps for\nyour platform by making a pull request.\n\nUbuntu 20.04\n============\n\nUbuntu requires the ``gssapi`` Python module to be built from source. This requires the\nKerberos headers, Python headers for the version of Python that you are using (here we have\ninstalled python3.10 from the deadsnakes ppa), and a supported compiler. (GCC works well.))\n\nYou should then be able to install this module with the ``[linux-kerberos]`` extra.\n\n.. code-block:: bash\n\n   sudo apt install build-essential python3.10-dev libkrb5-dev\n   pip install ansys-openapi-common[linux-kerberos]\n\n\nOnce the installation completes, ensure that your ``krb5.conf`` file is set up correctly\nfor your Kerberos configuration and that you have a valid ``keytab`` file, which is\nnormally in ``/etc/krb5.keytab``.\n\nLicense\n-------\nOpenAPI-Common is provided under the terms of the MIT license. You can find\nthe license text in the LICENSE file at the root of the repository.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Provides a helper to create sessions for use with Ansys OpenAPI clients.",
    "version": "2.0.1",
    "project_urls": {
        "Documentation": "https://openapi.docs.pyansys.com",
        "Homepage": "https://github.com/pyansys/openapi-common",
        "Repository": "https://github.com/pyansys/openapi-common"
    },
    "split_keywords": [
        "ansys",
        " openapi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a638592fa963e50db6d4157bba17d89a65abc6cacdfaeea0275aaaa0266ce0c3",
                "md5": "c38286b1b127bd41daccc4e7c0a9ebf7",
                "sha256": "e9719eeb3ca5f3a980543ce085ab30dffc1dd46b3f571609291e2fc2933d05bf"
            },
            "downloads": -1,
            "filename": "ansys_openapi_common-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c38286b1b127bd41daccc4e7c0a9ebf7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 35680,
            "upload_time": "2024-05-02T15:07:02",
            "upload_time_iso_8601": "2024-05-02T15:07:02.926775Z",
            "url": "https://files.pythonhosted.org/packages/a6/38/592fa963e50db6d4157bba17d89a65abc6cacdfaeea0275aaaa0266ce0c3/ansys_openapi_common-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aadad8f8298d608b1f4604af3e87f8d4ec6a6ce16d08dffbb76e192972fb987e",
                "md5": "25135515e3a4e6277c5243d22c9b653e",
                "sha256": "9dbe0024a2d2be230d202000b9fb7689dda221a10bef15852392528c0920d98f"
            },
            "downloads": -1,
            "filename": "ansys_openapi_common-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "25135515e3a4e6277c5243d22c9b653e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 29076,
            "upload_time": "2024-05-02T15:07:09",
            "upload_time_iso_8601": "2024-05-02T15:07:09.763892Z",
            "url": "https://files.pythonhosted.org/packages/aa/da/d8f8298d608b1f4604af3e87f8d4ec6a6ce16d08dffbb76e192972fb987e/ansys_openapi_common-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-02 15:07:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pyansys",
    "github_project": "openapi-common",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ansys-openapi-common"
}
        
Elapsed time: 0.30203s