Skip to content

Yaml Configuration Helpers

This page contains the documentation for the helper .py files with the helper functionality for custom yaml configuration options for Resource Nodes.

yaml_config

Includes the pydantic definitions for the YAML configuration options.

find_and_parse_yaml_services()

Searches and finds the defined yaml files in the YAML_SERVICES_DIRECTORY directory that are not starting with '_'

Returns:

Type Description
List[YamlService]

List[YamlService]: List of found YamlServices, created from yaml files

parse_yaml_file_to_service(yaml_file_path)

Parses given YAML file and returns a pydantic model: YamlService object

Parameters:

Name Type Description Default
yaml_file_path str

Filepath for the yaml file

required

Returns:

Name Type Description
YamlService YamlService

Input data parsed as a pydantic YamlService object

Union[Exception, None]

Exception or None: Exception if raised during parsing, or None if successful

yaml_validators

Yaml parsers and helper functions.

YamlComplementApiParameterAction

Bases: BaseModel

Defines the add and remove options for complement_api_parameters in YamlResourceNodeOperation

Source code in balcony/yaml_validators.py
class YamlComplementApiParameterAction(BaseModel):
    """Defines the `add` and `remove` options for complement_api_parameters in YamlResourceNodeOperation"""
    _ACTION_TYPES = ("add", "remove")

    action: str
    data: Optional[Dict[str, Any]]
    keys: Optional[List[str]]

    @validator("action")
    def action_must_be_valid(cls, v):
        """Validates the action field. Must be 'add' or 'remove'"""
        if v not in cls._ACTION_TYPES:
            raise ValueError("action must be 'add' or 'remove'")
        return v

action_must_be_valid(v)

Validates the action field. Must be 'add' or 'remove'

Source code in balcony/yaml_validators.py
@validator("action")
def action_must_be_valid(cls, v):
    """Validates the action field. Must be 'add' or 'remove'"""
    if v not in cls._ACTION_TYPES:
        raise ValueError("action must be 'add' or 'remove'")
    return v

YamlResourceNodeOperation

Bases: BaseModel

Defines the customizations for a specific operation in a Resource Node.

Source code in balcony/yaml_validators.py
class YamlResourceNodeOperation(BaseModel):
    """Defines the customizations for a specific operation in a Resource Node."""
    operation_name: str
    jmespath_selector: Optional[str]
    complement_api_parameters: Optional[List[YamlComplementApiParameterAction]]
    explicit_relations: Optional[List[YamlRelation]]
    override_api_parameters: Optional[List[Dict[str, Any]]]
    pagination_token_mapping: Optional[Dict[str, str]]
    required_parameters: Optional[List[str]]

YamlService

Bases: BaseModel

Defines a Service in a Yaml file. It can have multiple Resource Nodes

Source code in balcony/yaml_validators.py
class YamlService(BaseModel):
    """Defines a Service in a Yaml file. It can have multiple Resource Nodes"""
    service_name: str
    resource_nodes: Optional[List[YamlServiceResourceNode]]

YamlServiceResourceNode

Bases: BaseModel

Defines a Resource Node in a Service. It can have extra_relations and list of operations

Source code in balcony/yaml_validators.py
class YamlServiceResourceNode(BaseModel):
    """Defines a Resource Node in a Service. It can have extra_relations and list of operations"""
    resource_node_name: str
    extra_relations: Optional[List[YamlRelation]]
    operations: Optional[List[YamlResourceNodeOperation]]