Authentication API
Use this API to provision an authenticated session with the EGS Controller.
Syntax
egs.authenticate(<endpoint>, <api_key>, sdk_default=false)
The authentication session object should be used in all subsequent SDK operations.
Parameters
Parameter | Parameter Type | Description | Required |
---|---|---|---|
<endpoint> | String | The endpoint to the EGS Core APIs service from Kubernetes cluster where the EGS Core APIs deployment is running. | Mandatory |
<api_key> | String | The API key provided to the end-user to interact with the EGS Controller. | Mandatory |
sdk_default | Boolean | The default value is false . Setting this parameter to true will make the provisioned authenticated session as the default session that will be used by other SDK operations, which are provided without authenticated session. When it is set to false , the authenticated session is not treated as SDK default. The returned authenticated session must be passed in subsequent SDK operations. | Optional |
Response Object Returned
Returns | Description |
---|---|
class AuthenticatedSession | The object of the AuthenticatedSession class containing all the relevant fields and operations required to successfully authenticate with the EGS Controller. |
Exceptions Raised
Exception | Description |
---|---|
exceptions.ServerUnreachable | This exception is raised when the EGS Core APIs endpoint is not reachable from the Python environment. |
exceptions.ApiKeyNotFound | This exception is raised when the provided API key is not found on the EGS Controller. |
exceptions.ApiKeyExpired | This exception is raised when the provided API key has expired. |
exceptions.ApiKeyInvalid | This exception is raised when the provided API key is found, but role information is not properly associated with the API key. |
Example
import egs
from egs.exceptions import ApiKeyInvalid, ApiKeyNotFound
try:
# Authenticate the EGS
auth = egs.authenticate("https://egs-core-apis.example.com", "5067bd55-1aef-4c84-8987-3e966e917f07")
print(auth)
except ApiKeyInvalid as e:
# Do something when API key is not found
print("API Key is Invalid")
print(e)
except ApiKeyNotFound as e:
# Do something when API key is not found
print("API Key not found")
print(e)
except Exception as e:
print(e)
print(f"Exception: {e}")