seguro.common.store.Client¶
- class seguro.common.store.Client(host='localhost', port=9000, tls_cacert='keys/ca.crt', tls_cert='keys/clients/admin.crt', tls_key='keys/clients/admin.key', region='minio', bucket='seguro')[source]¶
Bases:
object
Helper class for S3 object store interaction with the SEGuRo platform
This class provides an abstraction layer for interactions between the S3 data store and the SEGuRo platform.
Connect to an S3 object store using the given credentials and store the returned client handle.
- Parameters:
host (str) – Hostname or IP address of the storage server
port (int) – Network port of the storage server
tls_cert (str) – File containing the TLS client certificate for mutual TLS authentication.
tls_key (str) – File containing the TLS client key for mutual TLS authentication.
tls_cacert (str) – File containing the TLS certificate authority to validate the servers certificate against.
secure – Establish secure connection via TLS
region (str) – The S3 region
bucket (str) – The S3 bucket
- __init__(host='localhost', port=9000, tls_cacert='keys/ca.crt', tls_cert='keys/clients/admin.crt', tls_key='keys/clients/admin.key', region='minio', bucket='seguro')[source]¶
- Parameters:
host (str)
port (int)
tls_cacert (str)
tls_cert (str)
tls_key (str)
region (str)
bucket (str)
Methods
__init__
([host, port, tls_cacert, tls_cert, ...])get_file
(filename, file)Download file from the S3 object store and store it locally.
get_file_contents
(filename)Write to file stored it in the S3Storage.
get_file_url
(filename[, expires, public])get_frame
(filename)Download a Pandas Dataframe as a Parquet file to the store
put_file
(filename, file)Upload local file and store it in the S3Storage.
put_file_contents
(filename, content)Write to file stored it in the S3Storage.
put_frame
(filename, df)Upload a Pandas Dataframe as a Parquet file to the store
remove_file
(filename)Remove a local file from the S3Storage.
watch
(prefix[, events, initial])- param prefix:
str:
watch_async
(prefix, cb[, events, initial])- param prefix:
str:
- get_file(filename, file)[source]¶
Download file from the S3 object store and store it locally.
- Parameters:
filename (str) – Local filename that is used
file (str) – Name of requested file in storage
filename – str:
file – str:
- Returns:
Object Information
- get_file_contents(filename)[source]¶
Write to file stored it in the S3Storage.
- Parameters:
filename (str) – Name of file in storage
content – Content that is written to file
filename – str:
- Return type:
BaseHTTPResponse
Returns:
- get_file_url(filename, expires=datetime.timedelta(days=7), public=True)[source]¶
- Parameters:
filename (str)
public (bool)
- Return type:
str
- get_frame(filename)[source]¶
Download a Pandas Dataframe as a Parquet file to the store
- Parameters:
filename (str) – The filename from which it should be retrieved
- Return type:
DataFrame
Returns:
- put_file(filename, file)[source]¶
Upload local file and store it in the S3Storage.
- Parameters:
filename (str) – Name of uploaded file in storage
file (str) – Local file that is used
filename – str:
file – str:
Returns:
- put_file_contents(filename, content)[source]¶
Write to file stored it in the S3Storage.
- Parameters:
filename (str) – Name of file in storage
content (bytes) – Content that is written to file
filename – str:
content – bytes:
Returns:
- put_frame(filename, df)[source]¶
Upload a Pandas Dataframe as a Parquet file to the store
- Parameters:
filename (str) – The filename at which it should be stored
df (DataFrame) – The Pandas DataFrame
Returns:
- remove_file(filename)[source]¶
Remove a local file from the S3Storage.
- Parameters:
filename (str) – Name of removed file in storage
filename – str:
Returns:
- watch(prefix, events=<Event.CREATED|REMOVED: 6>, initial=False)[source]¶
- Parameters:
prefix (str) – str:
events (Event) – Event: (Default value = Event.CREATED | Event.REMOVED)
initial (bool) – bool: (Default value = False)
Returns: