ds_provider_unimicro_py_lib.linked_service

File: __init__.py Region: ds_provider_unimicro_py_lib/linked_service

Unimicro Linked Service

This module defines the Unimicro linked service for the Unimicro provider.

Example

>>> from uuid import UUID
>>> linked_service = UnimicroLinkedService(
...     id=UUID("12345678-1234-5678-1234-1234567890ab"),
...     name="unimicro-linked-service",
...     version="v1.0.0",
...     settings=UnimicroLinkedServiceSettings(
...         company_key="my-company-id",
...         client_id="my-client-id",
...         certificate="my-certificate",
...         certificate_password="my-certificate-password",
...     ),
... )
>>> linked_service.connect()
>>> linked_service.test_connection()

Submodules

Classes

UnimicroLinkedService

Unimicro linked service.

UnimicroLinkedServiceSettings

Unimicro linked service settings.

Package Contents

class ds_provider_unimicro_py_lib.linked_service.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:

ResourceType

__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

_get_token_endpoint() → str[source]

Get the token endpoint URL for the Unimicro API.

Returns:

The token endpoint URL.

Return type:

str

class ds_provider_unimicro_py_lib.linked_service.UnimicroLinkedServiceSettings[source]

Bases: ds_protocol_http_py_lib.HttpLinkedServiceSettings

Unimicro 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.