Transformers
Transformers' main purpose is to manipulate the state before it goes into the storage provider.
TransformerProtocol
Bases: Protocol
Protocol for state transformation providers.
Every state transformation provider must implement TransformerProtocol
methods - and register to the terraflex.plugins.transformer
entrypoint.
Example
Register encryption transformer - if your project is based on poetry:
[tool.poetry.plugins."terraflex.plugins.transformer"]
encryption = "terraflex.plugins.encryption_transformation.encryption_transformation_provider:EncryptionTransformation"
Source code in terraflex/server/transformation_base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
from_config(raw_config, *, storage_providers, manager, workdir)
async
classmethod
Create an instance of the transformation provider from the configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_config |
Any
|
The raw configuration propagated from the transformer config. |
required |
storage_providers |
dict[str, StorageProviderProtocol]
|
All the initialized storage providers specified in the config file. |
required |
manager |
DependenciesManager
|
The dependencies manager - allows to request a binary path from. |
required |
workdir |
Path
|
The data directory of terraflex - located at |
required |
Source code in terraflex/server/transformation_base.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
transform_read_file_content(file_identifier, content)
async
Transform the content of the file after reading it from the storage provider.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_identifier |
str
|
The identifier of the file - calculated by calling to_string() method of the storage usage params. |
required |
content |
bytes
|
The content of the file. |
required |
Source code in terraflex/server/transformation_base.py
54 55 56 57 58 59 60 61 62 |
|
transform_write_file_content(file_identifier, content)
async
Transform the content of the file before writing it to the storage provider.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_identifier |
str
|
The identifier of the file - calculated by calling to_string() method of the storage usage params. |
required |
content |
bytes
|
The content of the file. |
required |
Source code in terraflex/server/transformation_base.py
44 45 46 47 48 49 50 51 52 |
|