Skip to content

fake-api-server.ci.surveillance.model.action

This module defines the ActionInput class, which represents the input data model for the surveillance action workflow. It handles deserialization of input data and provides methods to retrieve the surveillance configuration.

Classes:

  • ActionInput: Manages input deserialization and configuration handling.

Dependencies:

  • Reads YAML configuration from a file and deserializes it into a SurveillanceConfig.

ActionInput(config_path=str()) dataclass

Bases: _BaseModel

Represents the input data structure for an action.

This class is designed to hold and manage the input configuration path for an action. It provides functionality to deserialize input data into an ActionInput instance and to retrieve the configuration object based on the stored configuration path.

ATTRIBUTE DESCRIPTION
config_path

The path to the configuration file for the action input.

TYPE: str

get_config()

Retrieve and deserialize configuration data from a specified YAML file.

This method reads a YAML file located at the path defined by the config_path attribute. The file is expected to contain serialized data for configuring a SurveillanceConfig object. Upon successful reading and deserialization, a new SurveillanceConfig instance is returned.

RETURNS DESCRIPTION
SurveillanceConfig

A SurveillanceConfig object created from the YAML file's content.

RAISES DESCRIPTION
FileNotFoundError

If the YAML file at config_path does not exist.

ValueError

If the file at config_path contains invalid YAML data or is improperly formatted for SurveillanceConfig.

Source code in fake_api_server_plugin/ci/surveillance/model/action.py
def get_config(self) -> SurveillanceConfig:
    """
    Retrieve and deserialize configuration data from a specified YAML file.

    This method reads a YAML file located at the path defined by the
    `config_path` attribute. The file is expected to contain serialized
    data for configuring a `SurveillanceConfig` object. Upon successful
    reading and deserialization, a new `SurveillanceConfig` instance is returned.

    :raises FileNotFoundError: If the YAML file at `config_path` does not exist.
    :raises ValueError: If the file at `config_path` contains invalid YAML data
        or is improperly formatted for `SurveillanceConfig`.

    :return: A `SurveillanceConfig` object created from the YAML file's content.
    :rtype: SurveillanceConfig
    """
    return SurveillanceConfig.deserialize(YAML().read(self.config_path))