AAS HTTP Client Documentation
Loading...
Searching...
No Matches
aas_client Namespace Reference

Classes

class  AasHttpClient
 Represents a AasHttpClient to communicate with a REST API. More...
 

Functions

AasHttpClient|None create_client_by_url (str base_url, str basic_auth_username="", str basic_auth_password="", str o_auth_client_id="", str o_auth_client_secret="", str o_auth_token_url="", str bearer_auth_token="", str http_proxy="", str https_proxy="", int time_out=200, int connection_time_out=60, bool ssl_verify=True, bool trust_env=True, bool encoded_ids=True)
 Create a HTTP client for a AAS server connection from the given parameters.
 
AasHttpClient|None create_client_by_dict (dict configuration, str basic_auth_password="", str o_auth_client_secret="", str bearer_auth_token="")
 Create a HTTP client for a AAS server connection from the given configuration.
 
AasHttpClient|None create_client_by_config (Path config_file, str basic_auth_password="", str o_auth_client_secret="", str bearer_auth_token="")
 Create a HTTP client for a AAS server connection from a given configuration file.
 
AasHttpClient|None _create_client (str config_string, str basic_auth_password, str o_auth_client_secret, str bearer_auth_token)
 Create and initialize an AAS HTTP client from configuration string.
 
bool _connect_to_api (AasHttpClient client)
 Test the connection to the AAS server API with retry logic.
 

Variables

 logger = logging.getLogger(__name__)
 

Function Documentation

◆ _connect_to_api()

bool aas_client._connect_to_api ( AasHttpClient  client)
protected

Test the connection to the AAS server API with retry logic.

This internal method attempts to establish a connection to the AAS server by calling the get_root() method. It retries the connection for the duration specified in the client's connection_time_out setting, sleeping 1 second between attempts.

Parameters
clientThe AasHttpClient instance to test the connection for
Returns
True if connection is successful, False otherwise :raises TimeoutError: If connection attempts fail for the entire timeout duration

Definition at line 458 of file aas_client.py.

Here is the caller graph for this function:

◆ _create_client()

AasHttpClient | None aas_client._create_client ( str  config_string,
str  basic_auth_password,
str  o_auth_client_secret,
str  bearer_auth_token 
)
protected

Create and initialize an AAS HTTP client from configuration string.

This internal method validates the configuration, sets authentication credentials, initializes the client, and tests the connection to the AAS server.

Parameters
config_stringJSON configuration string containing AAS server settings
basic_auth_passwordPassword for basic authentication, defaults to ""
o_auth_client_secretClient secret for OAuth authentication, defaults to ""
bearer_auth_tokenBearer token for authentication, defaults to ""
Returns
An initialized and connected AasHttpClient instance or None if connection fails :raises ValidationError: If the configuration string is invalid :raises TimeoutError: If connection to the server times out

Definition at line 415 of file aas_client.py.

Here is the call graph for this function:

◆ create_client_by_config()

AasHttpClient | None aas_client.create_client_by_config ( Path  config_file,
str   basic_auth_password = "",
str   o_auth_client_secret = "",
str   bearer_auth_token = "" 
)

Create a HTTP client for a AAS server connection from a given configuration file.

Parameters
config_filePath to the configuration file containing the AAS server connection settings
basic_auth_passwordPassword for the AAS server basic authentication, defaults to ""
o_auth_client_secretClient secret for OAuth authentication, defaults to ""
bearer_auth_tokenBearer token for authentication, defaults to ""
Returns
An instance of AasHttpClient initialized with the provided parameters or None if validation fails

Definition at line 385 of file aas_client.py.

◆ create_client_by_dict()

AasHttpClient | None aas_client.create_client_by_dict ( dict  configuration,
str   basic_auth_password = "",
str   o_auth_client_secret = "",
str   bearer_auth_token = "" 
)

Create a HTTP client for a AAS server connection from the given configuration.

Parameters
configurationDictionary containing the AAS server connection settings
basic_auth_passwordPassword for the AAS server basic authentication, defaults to ""
o_auth_client_secretClient secret for OAuth authentication, defaults to ""
bearer_auth_tokenBearer token for authentication, defaults to ""
Returns
An instance of AasHttpClient initialized with the provided parameters or None if validation fails

Definition at line 368 of file aas_client.py.

◆ create_client_by_url()

AasHttpClient | None aas_client.create_client_by_url ( str  base_url,
str   basic_auth_username = "",
str   basic_auth_password = "",
str   o_auth_client_id = "",
str   o_auth_client_secret = "",
str   o_auth_token_url = "",
str   bearer_auth_token = "",
str   http_proxy = "",
str   https_proxy = "",
int   time_out = 200,
int   connection_time_out = 60,
bool   ssl_verify = True,
bool   trust_env = True,
bool   encoded_ids = True 
)

Create a HTTP client for a AAS server connection from the given parameters.

Parameters
base_urlBase URL of the AAS server, e.g. "http://basyx_python_server:80/"
basic_auth_usernameUsername for the AAS server basic authentication, defaults to ""
basic_auth_passwordPassword for the AAS server basic authentication, defaults to ""
o_auth_client_idClient ID for OAuth authentication, defaults to ""
o_auth_client_secretClient secret for OAuth authentication, defaults to ""
o_auth_token_urlToken URL for OAuth authentication, defaults to ""
bearer_auth_tokenBearer token for authentication, defaults to ""
http_proxyHTTP proxy URL, defaults to ""
https_proxyHTTPS proxy URL, defaults to ""
time_outTimeout for the API calls, defaults to 200
connection_time_outTimeout for the connection to the API, defaults to 60
ssl_verifyWhether to verify SSL certificates, defaults to True
trust_envWhether to trust environment variables for proxy settings, defaults to True
encoded_idsIf enabled, all IDs used in API requests have to be base64-encoded
Returns
An instance of AasHttpClient initialized with the provided parameters or None if connection fails

Definition at line 322 of file aas_client.py.

Variable Documentation

◆ logger

aas_client.logger = logging.getLogger(__name__)

Definition at line 32 of file aas_client.py.