Granta MI connection#
Connection builder#
- class Connection(servicelayer_url, session_configuration=None)#
Connects to a Granta MI ServerAPI instance.
This is a subclass of the
ansys.openapi.common.ApiClientFactoryclass. All methods in this class are documented as returningApiClientFactoryclass instances of theansys.grantami.system.Connectionclass instead.- Parameters:
- servicelayer_url
str Base URL of the Granta MI Service Layer application.
- session_configuration
SessionConfiguration, optional Additional configuration settings for the requests session. The default is
None, in which case theSessionConfigurationclass with default parameters is used.
- servicelayer_url
Notes
For advanced usage, including configuring session-specific properties and timeouts, see the ansys-openapi-common API reference. Specifically, see the documentation for the
ApiClientFactorybase class and theSessionConfigurationclass.Create the connection builder object and specify the server to connect to.
Specify the authentication method to use for the connection and provide credentials if required.
Connect to the server, which returns the client object.
The examples show this process for different authentication methods.
Examples
>>> client = Connection("http://my_mi_server/mi_servicelayer").with_autologon().connect() >>> client <SystemApiClient: url=http://my_mi_server/mi_servicelayer> >>> client = ( ... Connection("http://my_mi_server/mi_servicelayer") ... .with_credentials(username="my_username", password="my_password") ... .connect() ... ) >>> client <SystemApiClient: url: http://my_mi_server/mi_servicelayer>
- with_autologon()#
Set up client authentication for use with Kerberos (also known as integrated Windows authentication).
The default operation of this method is to attempt to connect to the API and to use the provided
WWW-Authenticateheader to determine if Negotiate authentication is supported by the server. If so, Negotiate will then be used for authentication.If Negotiate authentication is not supported by the server, an exception is raised.
- Returns:
ApiClientFactoryCurrent client factory object.
- Raises:
ConnectionErrorIf the server does not support Negotiate authentication.
Notes
Requires the user to have a valid Kerberos Ticket-Granting-Ticket (TGT).
On Windows, this is provided by default.
On Linux, this requires the
[linux-kerberos]extension to be installed and your Kerberos installation to be configured correctly.
- with_credentials(username, password, domain=None, authentication_scheme=AuthenticationScheme.AUTO)#
Set up client authentication for use with provided credentials.
The default operation of this method is to attempt to connect to the API and to use the provided
WWW-Authenticateheader to determine whether NTLM or Basic Authentication should be used. The selected authentication scheme will then be configured for use.- Parameters:
- username
str Username for the connection.
- password
str Password for the connection.
- domain
str, optional Domain to use for connection if required. The default is
None.- authentication_scheme
AuthenticationScheme The authentication scheme to use.
Tip
Added to
ApiClientFactory.with_credentialsin version 2.1 ofansys-openapi-common.
- username
- Returns:
ApiClientFactoryOriginal client factory object.
- Raises:
ConnectionErrorIf the server does not support Basic or NTLM authentication (Windows clients only).
Notes
NTLM authentication is not currently supported on Linux.
- with_oidc(idp_session_configuration=None)#
Set up client authentication for use with OpenID Connect.
- Parameters:
- idp_session_configuration
SessionConfiguration, optional Additional configuration settings for the requests session when connected to the OpenID identity provider.
- idp_session_configuration
- Returns:
OIDCSessionBuilderBuilder object to authenticate via OIDC.
Notes
OIDC Authentication requires the
[oidc]extra to be installed.
- with_anonymous()#
Set up client authentication for anonymous use.
This does not configure any authentication or authorization headers. Users must provide any authentication information required themselves.
Clients relying on custom authentication such as client certificates or non-standard tokens should use this method.
- Returns:
ApiClientFactoryOriginal client factory object.
- connect()#
Finalize the
SystemApiClientclient and return it for use.Authentication must be configured for this method to succeed.
- Returns:
SystemApiClientClient object that can be used to connect to Granta MI and interact with the Granta MI System API. The client object is a subtype of
SystemApiClient. The subtype returned depends on the Granta MI server version.
PyGranta System client#
- class SystemApiClient(session, service_layer_url, configuration)#
Communicates with Granta MI.
Methods are only implemented if the underlying functionality is supported by the Granta MI server version. If the functionality is not available, a
NotImplementedErroris raised.This class should not be instantiated directly. New sessions are created with the
Connectionclass.- Other Parameters:
- session
requests.Session A requests.Session object.
- service_layer_url
str The Granta MI Service Layer URL.
- configuration
ansys.openapi.common.SessionConfiguration The configuration to apply to the client.
- session
- get_activity_report(page_size=1000)#
Get all activity information from the Granta MI server.
- Parameters:
- page_size
int, optional The number of items to include in a single response. Defaults to 1000.
- page_size
- Returns:
IteratorofActivityItemAn iterator containing the returned activity information.
Warning
Activity information is updated on the Granta MI server at midnight server time. If a request is made while the activity report is being updated, duplicate results may be retrieved from the server.
Avoid making requests while the server is updating the activity report.
- get_activity_report_where(filter_, page_size=1000)#
Get activity information from the Granta MI server that matches a filter.
- Parameters:
- filter_
ActivityReportFilter The filter to apply to the request.
- page_size
int|None, optional The number of items to include in a single response. Defaults to 1000.
- filter_
- Returns:
IteratorofActivityItemAn iterator containing the returned activity information.
Warning
Activity information is updated on the Granta MI server at midnight server time. If a request is made while the activity report is being updated, duplicate results may be retrieved from the server.
Avoid making requests while the server is updating the activity report.
- get_granta_mi_version()#
Get the version of Granta MI running on the server.
- Returns:
GrantaMIVersionGranta MI version information.