Package: ansys-openapi-common
OverviewOpenAPI-Common is intended for use with the custom code generation
template in thePyAnsys 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.InstallationInstall theopenapi-commonrepository with this code:pip install ansys-openapi-commonAlternatively, clone and install the repository with this code:git clone https://github.com/pyansys/openapi-common
cd openapi-common
pip install .UsageThe API client class is intended to be wrapped by code that implements a client library.
You should override the__init__()orconnect()method to add any
additional behavior that might be required.Authentication is configured through theApiClientFactoryobject and itswith_xxx()methods. If no authentication is required, you can use thewith_anonymous()method.
You can provide additional configuration with theSessionConfigurationobject.>>>fromansys.openapi.commonimportApiClientFactory>>>session=ApiClientFactory('https://my-api.com/v1.svc')....with_autologon()....connect()<ApiClienturl:https://my-api.com/v1.svc>Authentication schemesOpenAPI-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 configuredkrb5.keytabfile 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 platformAuthentication methodWindowsLinuxBuilder methodAdditional settingsAPI Key✔️✔️.with_anonymous()Set the appropriate header inapi_session_configurationClient Certificate✔️✔️AnyProvideclient_cert_pathand optionallyclient_cert_keyinapi_session_configurationBasic✔️✔️.with_credentials()NTLM✔️❌.with_credentials()Kerberos✔️➕ with[linux-kerberos]extra.with_autologon()OIDC➕ with[oidc]extra➕ with[oidc]extra.with_oidc()Platform-specific Kerberos configurationKerberos 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.04Ubuntu requires thegssapiPython 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.sudoaptinstallbuild-essentialpython3.10-devlibkrb5-devpipinstallansys-openapi-common[linux-kerberos]Once the installation completes, ensure that yourkrb5.conffile is set up correctly
for your Kerberos configuration and that you have a validkeytabfile, which is
normally in/etc/krb5.keytab.LicenseOpenAPI-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.