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

hub.exec.boto3.client.robomaker.cancel_simulation_job
hub.exec.boto3.client.robomaker.create_simulation_job
hub.exec.boto3.client.robomaker.describe_simulation_job
hub.exec.boto3.client.robomaker.list_simulation_jobs
hub.exec.boto3.client.robomaker.restart_simulation_job
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, max_job_duration_in_seconds: int, iam_role: Text, client_request_token: Text = None, output_location: Dict = None, logging_config: Dict = None, failure_behavior: Text = None, robot_applications: List = None, simulation_applications: List = None, data_sources: List = None, tags: Dict = None, vpc_config: Dict = None, compute: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a simulation job.  After 90 days, simulation jobs expire and will be deleted. They will no longer be
    accessible.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_request_token(Text, optional): Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Defaults to None.
        output_location(Dict, optional): Location for output files generated by the simulation job. Defaults to None.
        logging_config(Dict, optional): The logging configuration. Defaults to None.
        max_job_duration_in_seconds(int): The maximum simulation job duration in seconds (up to 14 days or 1,209,600 seconds. When
            maxJobDurationInSeconds is reached, the simulation job will status will transition to Completed.
        iam_role(Text): The IAM role name that allows the simulation instance to call the AWS APIs that are specified in
            its associated policies on your behalf. This is how credentials are passed in to your simulation
            job.
        failure_behavior(Text, optional): The failure behavior the simulation job.  Continue  Restart the simulation job in the same host
            instance.  Fail  Stop the simulation job and terminate the instance. Defaults to None.
        robot_applications(List, optional): The robot application to use in the simulation job. Defaults to None.
        simulation_applications(List, optional): The simulation application to use in the simulation job. Defaults to None.
        data_sources(List, optional): Specify data sources to mount read-only files from S3 into your simulation. These files are
            available under /opt/robomaker/datasources/data_source_name.   There is a limit of 100 files and
            a combined size of 25GB for all DataSourceConfig objects. Defaults to None.
        tags(Dict, optional): A map that contains tag keys and tag values that are attached to the simulation job. Defaults to None.
        vpc_config(Dict, optional): If your simulation job accesses resources in a VPC, you provide this parameter identifying the
            list of security group IDs and subnet IDs. These must belong to the same VPC. You must provide
            at least one security group and one subnet ID. Defaults to None.
        compute(Dict, optional): Compute information for the simulation job. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.robomaker.simulation_job.present:
                - name: value
                - max_job_duration_in_seconds: value
                - iam_role: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.robomaker.simulation_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.robomaker.describe_simulation_job(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.robomaker.create_simulation_job(
                ctx,
                
                
                **{"clientRequestToken": client_request_token, "outputLocation": output_location, "loggingConfig": logging_config, "maxJobDurationInSeconds": max_job_duration_in_seconds, "iamRole": iam_role, "failureBehavior": failure_behavior, "robotApplications": robot_applications, "simulationApplications": simulation_applications, "dataSources": data_sources, "tags": tags, "vpcConfig": vpc_config, "compute": compute}
            )
            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.robomaker.describe_simulation_job(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, job: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Cancels the specified simulation job.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        job(Text): The simulation job ARN to cancel.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.robomaker.simulation_job.absent:
                - name: value
                - job: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.robomaker.simulation_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.robomaker.describe_simulation_job(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.robomaker.cancel_simulation_job(
                ctx,
                
                
                **{"job": job}
            )
            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.robomaker.describe_simulation_job(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

