def _get_yaml_contents(yml: str) -> str:
    """
    Returns the YAML contents from an object. If a path ending with .yaml or
    .yml is passed, it will be read for its contents. If a string containing
    YAML is passed, that will be returned.

    Args:
        yml: Path of YAML file or string containing YAML

    Returns:
        String object containing YAML
    """
    if (
        isinstance(yml, str)
        and yml.count("\n") == 0
        and (".yaml" in yml.lower() or ".yml" in yml.lower())
    ):
        with open(yml, "r") as f:
            yml_content = f.read()

    elif isinstance(yml, str):
        yml_content = yml
    else:
        raise Exception(
            f"Invalid YAML provided. Please provide either a file path or YAML string: ${yml}"
        )
    return yml_content