"""
Autogenerated state module using `pop-create-idem <https://gitlab.com/saltstack/pop/pop-create-idem>`__

hub.exec.boto3.client.forecast.create_predictor_backtest_export_job
hub.exec.boto3.client.forecast.delete_predictor_backtest_export_job
hub.exec.boto3.client.forecast.describe_predictor_backtest_export_job
hub.exec.boto3.client.forecast.list_predictor_backtest_export_jobs
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, predictor_backtest_export_job_name: Text, predictor_arn: Text, destination: Dict, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Exports backtest forecasts and accuracy metrics generated by the CreatePredictor operation. Two folders
    containing CSV files are exported to your specified S3 bucket.  The export file names will match the following
    conventions:  <ExportJobName>_<ExportTimestamp>_<PartNumber>.csv  The <ExportTimestamp> component is in Java
    SimpleDate format (yyyy-MM-ddTHH-mm-ssZ). You must specify a DataDestination object that includes an Amazon S3
    bucket and an AWS Identity and Access Management (IAM) role that Amazon Forecast can assume to access the Amazon
    S3 bucket. For more information, see aws-forecast-iam-roles.  The Status of the export job must be ACTIVE before
    you can access the export in your Amazon S3 bucket. To get the status, use the
    DescribePredictorBacktestExportJob operation.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        predictor_backtest_export_job_name(Text): The name for the backtest export job.
        predictor_arn(Text): The Amazon Resource Name (ARN) of the predictor that you want to export.
        destination(Dict): The destination for an export job. Provide an S3 path, an AWS Identity and Access Management
            (IAM) role that allows Amazon Forecast to access the location, and an AWS Key Management Service
            (KMS) key (optional).
        tags(List, optional): Optional metadata to help you categorize and organize your backtests. Each tag consists of a key
            and an optional value, both of which you define. Tag keys and values are case sensitive. The
            following restrictions apply to tags:   For each resource, each tag key must be unique and each
            tag key must have one value.   Maximum number of tags per resource: 50.   Maximum key length:
            128 Unicode characters in UTF-8.   Maximum value length: 256 Unicode characters in UTF-8.
            Accepted characters: all letters and numbers, spaces representable in UTF-8, and + - = . _ : /
            @. If your tagging schema is used across other services and resources, the character
            restrictions of those services also apply.    Key prefixes cannot include any upper or lowercase
            combination of aws: or AWS:. Values can have this prefix. If a tag value has aws as its prefix
            but the key does not, Forecast considers it to be a user tag and will count against the limit of
            50 tags. Tags with only the key prefix of aws do not count against your tags per resource limit.
            You cannot edit or delete tag keys with this prefix. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.forecast.predictor_backtest_export_job.present:
                - name: value
                - predictor_backtest_export_job_name: value
                - predictor_arn: value
                - destination: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.forecast.predictor_backtest_export_job.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    
    before = await hub.exec.boto3.client.forecast.describe_predictor_backtest_export_job(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.forecast.create_predictor_backtest_export_job(
                ctx,
                
                
                **{"PredictorBacktestExportJobName": predictor_backtest_export_job_name, "PredictorArn": predictor_arn, "Destination": destination, "Tags": tags}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            ret["comment"] = f"Created '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    
    # TODO perform other modifications as needed here
    ...

    after = await hub.exec.boto3.client.forecast.describe_predictor_backtest_export_job(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, predictor_backtest_export_job_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a predictor backtest export job.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        predictor_backtest_export_job_arn(Text): The Amazon Resource Name (ARN) of the predictor backtest export job to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.forecast.predictor_backtest_export_job.absent:
                - name: value
                - predictor_backtest_export_job_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.forecast.predictor_backtest_export_job.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    

    before = await hub.exec.boto3.client.forecast.describe_predictor_backtest_export_job(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.forecast.delete_predictor_backtest_export_job(
                ctx,
                
                
                **{"PredictorBacktestExportJobArn": predictor_backtest_export_job_arn}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            result["comment"] = f"Deleted '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    

    after = await hub.exec.boto3.client.forecast.describe_predictor_backtest_export_job(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

