singer_sdk.InlineMapper¶
- class singer_sdk.InlineMapper[source]¶
Bases:
PluginBase
,SimpleSingerReader
,SimpleSingerWriter
Abstract base class for inline mappers.
- __init__(*, config=None, parse_env_config=False, validate_config=True)[source]¶
Create the tap or target.
- Parameters:
config (dict | PurePath | str | list[PurePath | str] | None) – May be one or more paths, either as str or PurePath objects, or it can be a predetermined config dict.
parse_env_config (bool) – True to parse settings from env vars.
validate_config (bool) – True to require validation of config settings.
- Raises:
ValueError – If config is not a dict or path string.
- Return type:
None
- classmethod append_builtin_config(config_jsonschema)[source]¶
Appends built-in config to config_jsonschema if not already set.
To customize or disable this behavior, developers may either override this class method or override the capabilities property to disabled any unwanted built-in capabilities.
For all except very advanced use cases, we recommend leaving these implementations “as-is”, since this provides the most choice to users and is the most “future proof” in terms of taking advantage of built-in capabilities which may be added in the future.
- Parameters:
config_jsonschema (dict) – [description]
- Return type:
None
- classmethod cb_version(ctx, param, value)[source]¶
CLI callback to print the plugin version and exit.
- Parameters:
ctx (Context) – Click context.
param (Option) – Click parameter.
value (bool) – Boolean indicating whether to print the version.
- Return type:
None
- format_message(message)[source]¶
Format a message as a JSON string.
- Parameters:
message (M) – The message to format.
- Returns:
The formatted message.
- Return type:
T
- classmethod get_plugin_version()[source]¶
Return the package version number.
- Returns:
The package version number.
- Return type:
- classmethod get_sdk_version()[source]¶
Return the package version number.
- Returns:
The package version number.
- Return type:
- classmethod get_singer_command()[source]¶
Execute standard CLI handler for inline mappers.
- Returns:
A click.Command object.
- Return type:
Command
- classmethod invoke(*, about=False, about_format=None, config=(), file_input=None)[source]¶
Invoke the mapper.
- Parameters:
about (bool) – Display package metadata and settings.
about_format (str | None) – Specify output style for –about.
config (tuple[str, ...]) – Configuration file location or ‘ENV’ to use environment variables. Accepts multiple inputs as a tuple.
file_input (IO[str] | None) – Optional file to read input from.
- Return type:
None
- listen(file_input=None)[source]¶
Read from input until all messages are processed.
- Parameters:
file_input (IO[T] | None) – Readable stream of messages. Defaults to standard in.
- Return type:
None
- abstract map_activate_version_message(message_dict)[source]¶
Map a version message to zero or more new messages.
- Parameters:
message_dict (dict) – An ACTIVATE_VERSION message JSON dictionary.
- Return type:
t.Iterable[singer.Message]
- map_batch_message(message_dict)[source]¶
Map a batch message to zero or more new messages.
- Parameters:
message_dict (dict) – A BATCH message JSON dictionary.
- Raises:
NotImplementedError – if not implemented by subclass.
- Return type:
t.Iterable[singer.Message]
- abstract map_record_message(message_dict)[source]¶
Map a record message to zero or more new messages.
- Parameters:
message_dict (dict) – A RECORD message JSON dictionary.
- Return type:
t.Iterable[singer.Message]
- abstract map_schema_message(message_dict)[source]¶
Map a schema message to zero or more new messages.
- Parameters:
message_dict (dict) – A SCHEMA message JSON dictionary.
- Return type:
t.Iterable[singer.Message]
- abstract map_state_message(message_dict)[source]¶
Map a state message to zero or more new messages.
- Parameters:
message_dict (dict) – A STATE message JSON dictionary.
- Return type:
t.Iterable[singer.Message]
- classmethod print_about(output_format=None)[source]¶
Print capabilities and other tap metadata.
- Parameters:
output_format (str | None) – Render option for the plugin information.
- Return type:
None
- serialize_message(message)[source]¶
Serialize a dictionary into a line of json.
- Parameters:
message (Message) – A Singer message object.
- Returns:
A string of serialized json.
- Return type:
- write_message(message)[source]¶
Write a message to stdout.
- Parameters:
message (Message) – The message to write.
- Return type:
None
- property config: Mapping[str, Any][source]¶
Get config.
- Returns:
A frozen (read-only) config dictionary map.
- property initialized_at: int[source]¶
Start time of the plugin.
- Returns:
The start time of the plugin.
- property mapper: PluginMapper[source]¶
Plugin mapper for this tap.
- Returns:
A PluginMapper object.
- Raises:
MapperNotInitialized – If the mapper has not been initialized.
- property state: dict[source]¶
Get state.
- Raises:
NotImplementedError – If the derived plugin doesn’t override this method.