Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exabel_data_sdk/client/api/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ def __init__(self, config: ClientConfig):
assert config.api_key is not None
self.metadata.append(("x-api-key", config.api_key))
self.channel = grpc.secure_channel(
config.host + ":" + str(config.port), grpc.ssl_channel_credentials()
config.host + ":" + str(config.port),
grpc.ssl_channel_credentials(root_certificates=config.root_certificates),
)
15 changes: 10 additions & 5 deletions exabel_data_sdk/client/client_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Optional


class DefaultConfig:
Expand All @@ -12,6 +13,7 @@ def __init__(self) -> None:
self.host = os.getenv("EXABEL_HOST", "data.api.exabel.com")
self.port = int(os.getenv("EXABEL_PORT", "21443"))
self.timeout = int(os.getenv("EXABEL_TIMEOUT", "30"))
self.root_certificates: Optional[str] = None


class ClientConfig(DefaultConfig):
Expand All @@ -26,16 +28,18 @@ def __init__(
host: str = None,
port: int = None,
timeout: int = None,
root_certificates: str = None,
):
"""
Initialize a new client configuration.

Args:
api_key: API key to use.
client_name: Name of this client.
host: Exabel API host.
port: Exabel API port.
timeout: Default timeout in seconds to use for API requests.
api_key: API key to use.
client_name: Name of this client.
host: Exabel API host.
port: Exabel API port.
timeout: Default timeout in seconds to use for API requests.
root_certificates: Additional allowed root certificates for verifying TLS connection.
"""
super().__init__()

Expand All @@ -44,6 +48,7 @@ def __init__(
self.host = host or self.host
self.port = port or self.port
self.timeout = timeout or self.timeout
self.root_certificates = root_certificates or self.root_certificates

if not self.api_key:
raise ValueError("No API key given. Use of the Exabel SDK requires an API key.")
20 changes: 11 additions & 9 deletions exabel_data_sdk/client/exabel_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ def __init__(
host: str = None,
port: int = None,
timeout: int = None,
root_certificates: str = None,
):
"""
Initialize a new client.

Args:
api_key: API key to use. If not set, the API key must be set using the
environment variable EXABEL_API_KEY. If set to the value 'NO_KEY',
the client will use an insecure channel, typically used for local
testing.
client_name: Override name of this client. Default name is "Exabel Python SDK".
host: Override default Exabel API host.
port: Override default Exabel API port.
timeout: Override default timeout in seconds to use for API requests.
api_key: API key to use. If not set, the API key must be set using the
environment variable EXABEL_API_KEY. If set to the value 'NO_KEY',
the client will use an insecure channel, typically used for local
testing.
client_name: Override name of this client. Default name is "Exabel Python SDK".
host: Override default Exabel API host.
port: Override default Exabel API port.
timeout: Override default timeout in seconds to use for API requests.
root_certificates: Additional allowed root certificates for verifying TLS connection.
"""
config = ClientConfig(api_key, client_name, host, port, timeout)
config = ClientConfig(api_key, client_name, host, port, timeout, root_certificates)

self.entity_api = EntityApi(config)
self.signal_api = SignalApi(config)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="exabel-data-sdk",
version="0.0.10",
version="0.0.11",
author="Exabel",
author_email="[email protected]",
description="Python SDK for the Exabel Data API",
Expand Down