API reference#
Welcome to PyPIM API documentation. Use the search feature or click the links in the navigation pane to view API documentation.
Entry point for the PIM Python client library.
- ansys.platform.instancemanagement.connect(uri: str | None = None, headers: dict | None = None, security: ConnectionSecurity | None = None) Client#
Create a PyPIM client from the environment or from parameters.
Precedence is parameter-first and all-or-nothing: when
uriis provided, the configuration file is ignored in full and the client is built fromuri/headers/security. Otherwise, when the environment is configured (is_configured()isTrue), the configuration file is used in full.The environment configuration consists in setting the environment variable
ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIGto the path of the PyPIM configuration file. The configuration file is a simple JSON file containing the URI of the PIM API and the headers required to pass information.The configuration file format is:
{ "version": 1, "pim": { "uri": "dns:pim.svc.com:80", "headers": { "metadata-info": "value" }, "tls": false } }
A version 2 file replaces
tlswith asecurityblock selecting the transport. See Security for the version 2 schema and for programmatic configuration with thesecurityparameter below.- Parameters:
- uri
str,optional PIM gRPC service URI. When provided, it takes precedence over the configuration file and all settings are taken from
uri/headers/security.- headers
dict,optional Metadata headers. The default is
None(no headers).- security
ConnectionSecurity,optional Transport security. The default is
None(insecure).
- uri
- Returns:
ClientPyPIM client, which is the main entry point to using this library.
- Raises:
NotConfiguredErrorThere is neither a configuration file nor a
uriparameter.InvalidConfigurationErrorThe configuration is invalid.
Examples
>>> import ansys.platform.instancemanagement as pypim >>> if pypim.is_configured(): >>> client = pypim.connect() >>> # use the client >>> client.close()
>>> import ansys.platform.instancemanagement as pypim >>> if pypim.is_configured(): >>> with pypim.connect() as client: >>> # use client
Connect programmatically with mTLS (no configuration file):
>>> import ansys.platform.instancemanagement as pypim >>> from ansys.platform.instancemanagement import ConnectionSecurity >>> from ansys.tools.common.cyberchannel import CertificateFiles >>> client = pypim.connect( ... uri="dns:pim.svc.com:80", ... headers={"identity": "james"}, ... security=ConnectionSecurity( ... transport="mtls", ... cert_files=CertificateFiles( ... cert_file="client.crt", key_file="client.key", ca_file="ca.crt" ... ), ... ), ... )
- ansys.platform.instancemanagement.is_configured() bool#
Check if the environment is configured to use PyPIM.
- Returns:
- bool
Truewhen the environment is configured to use PyPIM,Falseotherwise.
Provides a high-level client object for interacting with the PIM API. |
|
Provides a definition of a product that can be started using the PIM API. |
|
Provides a remote instance of a product. |
|
Provides an entry point for communicating with a remote product. |
|
Configuration for the PIM client. |
|
Security settings for the client's connection to the PIM server. |
|
Represent a union type |
|
Insecure gRPC channel (no TLS). |
|
Mutual TLS settings. |
|
Individual certificate and key file paths for mTLS. |
|
Unix Domain Socket connection settings. |
|
Windows user-based authentication (Windows only). |
|
Protobuf-free view of the server-resolved security info. |
|
Indicates an attempt was made to use PyPIM without the mandatory configuration. |
|
Indicates an attempt was made to communicate with an instance that is not yet ready. |
|
Indicates an attempt to use an unsupported instance service. |
|
Indicates PyPIM is configured, but the configuration is invalid. |
|
Indicates that the product or version is not supported by the remote server. |