Skip to main content

Overview

OpenAPI-Common is intended for use with the custom code generation template in the PyAnsys project. 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:

pip install ansys-openapi-common

Alternatively, clone and install the repository with this 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.

>>> 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.

Authentication methods by platform

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.

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.

Metadata

Release files for ansys-openapi-common 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansys-openapi-common 1.5.1
File Size Uploaded
ansys_openapi_common-1.5.1.tar.gz 26.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ansys-openapi-common 1.5.1
File Interpreter ABI Platform
ansys_openapi_common-1.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 55.0 kB

Release files / ansys_openapi_common-1.5.1.tar.gz

Download URL ansys_openapi_common-1.5.1.tar.gz
Size 26.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3f3c5383cb1dbc29b349f398f2bd605f0e87b65561c0c36bd0177a59bb06cc04
BLAKE2b-256 checksum
How to use checksums
8ae9f2658b312f585b9bed4b6f5c63336e91644fe8f47356b6c20bc7cc355504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Release files / ansys_openapi_common-1.5.1-py3-none-any.whl

Download URL ansys_openapi_common-1.5.1-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21fce6529cfab5150ce66c0623624bc1f200a49a8895bf1baacd6782238fcad9
BLAKE2b-256 checksum
How to use checksums
757e7d15dc35e618ed908fad9a7b8fd2396b0444dd16c85a32a4d9d735f42948
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.13

Release history Release notifications | RSS feed

2.4.1

2 release files

2.4.0

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

This release

1.5.1 This release

2 release files

1.5.0

2 release files

1.4.0

1 release file

1.3.0

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page