ds_provider_unimicro_py_lib.linked_service.unimicro¶
File: unimicro.py
Region: ds_provider_unimicro_py_lib/linked_service/unimicro
Unimicro Linked Service.
This module defines the Unimicro linked service, which is used to connect to the Unimicro API. It includes the necessary configuration and authentication details required to establish a connection with the Unimicro service.
Example
>>> from uuid import UUID
>>> linked_service = UnimicroLinkedService(
... id=UUID("52fa4cf5-c1c6-45b1-aaca-3b02206302de"),
... name="unimicro-linked-service",
... version="v1.0.0",
... settings=UnimicroLinkedServiceSettings(
...
... ),
... )
>>> linked_service.connect()
Attributes¶
Classes¶
Unimicro linked service settings. |
|
Unimicro linked service. |
Module Contents¶
- ds_provider_unimicro_py_lib.linked_service.unimicro.logger¶
- class ds_provider_unimicro_py_lib.linked_service.unimicro.UnimicroLinkedServiceSettings[source]¶
Bases:
ds_protocol_http_py_lib.HttpLinkedServiceSettingsUnimicro linked service settings.
This class extends the HttpLinkedServiceSettings and includes the necessary configuration for connecting to the Unimicro API.
- certificate: str¶
Base64-encoded PKCS#12 certificate used for authentication.
- certificate_password: str¶
The password for the certificate used for authenticating with the Unimicro API.
- client_id: str¶
The client ID for the Unimicro API.
- company_key: str | None = None¶
The company key used for fetching data from Unimicro.
- scope: str = 'AppFramework'¶
The scope for the Unimicro API authentication.
- auth_url: str = 'https://login.unimicro.no'¶
The URL for the Unimicro authentication service used for authentication.
- host: str = 'https://app.unimicro.no'¶
The URL for the Unimicro API host.
- auth_type: ds_protocol_http_py_lib.enums.AuthType¶
Authentication type for Unimicro API.
- custom: ds_protocol_http_py_lib.linked_service.CustomAuthSettings | None = None¶
Custom authentication settings for Unimicro API.
- ds_provider_unimicro_py_lib.linked_service.unimicro.UnimicroLinkedServiceSettingsType¶
- class ds_provider_unimicro_py_lib.linked_service.unimicro.UnimicroLinkedService[source]¶
Bases:
ds_protocol_http_py_lib.HttpLinkedService[UnimicroLinkedServiceSettingsType],Generic[UnimicroLinkedServiceSettingsType]Unimicro linked service.
This class represents the Unimicro linked service, which is used to connect to the Unimicro API. It extends the HttpLinkedService and uses the UnimicroLinkedServiceSettings for its configuration.
- settings: UnimicroLinkedServiceSettingsType¶
The settings for the Unimicro linked service.
- property type: ds_provider_unimicro_py_lib.enums.ResourceType¶
Get the resource type for Unimicro linked service.
- Returns:
The resource type for Unimicro linked service.
- Return type:
- __post_init__() None[source]¶
Post-initialization for the Unimicro linked service.
This method is called after the dataclass is initialized. It can be used to perform any additional setup or validation for the Unimicro linked service.
- _configure_custom_auth(http: ds_protocol_http_py_lib.utils.http.Http) None[source]¶
Configure custom authentication.
Calls the configured token endpoint and extracts an access token from the JSON response using common token key names. The resulting token is stored in the session Authorization header.
- Parameters:
http – The Http client instance to configure.
- Raises:
AuthenticationError – If the token is missing in the response.
LinkedServiceException – If custom auth settings are missing.
- _get_private_key() cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey[source]¶
Get the private key used for authenticating with the Unimicro API. The certificate and certificate password are used to generate the private key for authentication.
- Returns:
The private key used for authentication.
- Return type:
RSAPrivateKey
- _create_client_token(client_id: str, private_key: cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey, token_endpoint: str) str[source]¶
Create a client token for the Unimicro API using the provided client ID and private key.
- Parameters:
client_id (str) – The client ID for the Unimicro API.
private_key (RSAPrivateKey) – The private key used for authentication.
token_endpoint (str) – The token endpoint URL for the Unimicro API.
- Returns:
The generated client token.
- Return type:
str