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

hub.exec.boto3.client.devicefarm.create_remote_access_session
hub.exec.boto3.client.devicefarm.delete_remote_access_session
hub.exec.boto3.client.devicefarm.get_remote_access_session
hub.exec.boto3.client.devicefarm.list_remote_access_sessions
hub.exec.boto3.client.devicefarm.stop_remote_access_session
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, project_arn: Text, device_arn: Text, name: Text = None, instance_arn: Text = None, ssh_public_key: Text = None, remote_debug_enabled: bool = None, remote_record_enabled: bool = None, remote_record_app_arn: Text = None, client_id: Text = None, configuration: Dict = None, interaction_mode: Text = None, skip_app_resign: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Specifies and starts a remote access session.

    Args:
        name(Text, optional): The name of the remote access session to create. Defaults to None.
        project_arn(Text): The Amazon Resource Name (ARN) of the project for which you want to create a remote access
            session.
        device_arn(Text): The ARN of the device for which you want to create a remote access session.
        instance_arn(Text, optional): The Amazon Resource Name (ARN) of the device instance for which you want to create a remote
            access session. Defaults to None.
        ssh_public_key(Text, optional): Ignored. The public key of the ssh key pair you want to use for connecting to remote devices in
            your remote debugging session. This key is required only if remoteDebugEnabled is set to true.
            Remote debugging is no longer supported. Defaults to None.
        remote_debug_enabled(bool, optional): Set to true if you want to access devices remotely for debugging in your remote access session.
            Remote debugging is no longer supported. Defaults to None.
        remote_record_enabled(bool, optional): Set to true to enable remote recording for the remote access session. Defaults to None.
        remote_record_app_arn(Text, optional): The Amazon Resource Name (ARN) for the app to be recorded in the remote access session. Defaults to None.
        client_id(Text, optional): Unique identifier for the client. If you want access to multiple devices on the same client, you
            should pass the same clientId value in each call to CreateRemoteAccessSession. This identifier
            is required only if remoteDebugEnabled is set to true. Remote debugging is no longer supported. Defaults to None.
        configuration(Dict, optional): The configuration information for the remote access session request. Defaults to None.
        interaction_mode(Text, optional): The interaction mode of the remote access session. Valid values are:   INTERACTIVE: You can
            interact with the iOS device by viewing, touching, and rotating the screen. You cannot run
            XCUITest framework-based tests in this mode.   NO_VIDEO: You are connected to the device, but
            cannot interact with it or view the screen. This mode has the fastest test execution speed. You
            can run XCUITest framework-based tests in this mode.   VIDEO_ONLY: You can view the screen, but
            cannot touch or rotate it. You can run XCUITest framework-based tests and watch the screen in
            this mode. Defaults to None.
        skip_app_resign(bool, optional): When set to true, for private devices, Device Farm does not sign your app again. For public
            devices, Device Farm always signs your apps again. For more information on how Device Farm
            modifies your uploads during tests, see Do you modify my app?. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.devicefarm.remote_access_session.present:
                - project_arn: value
                - device_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.devicefarm.remote_access_session.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.devicefarm.get_remote_access_session(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.devicefarm.create_remote_access_session(
                ctx,
                
                
                **{"Name": name, "projectArn": project_arn, "deviceArn": device_arn, "instanceArn": instance_arn, "sshPublicKey": ssh_public_key, "remoteDebugEnabled": remote_debug_enabled, "remoteRecordEnabled": remote_record_enabled, "remoteRecordAppArn": remote_record_app_arn, "clientId": client_id, "configuration": configuration, "interactionMode": interaction_mode, "skipAppResign": skip_app_resign}
            )
            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.devicefarm.get_remote_access_session(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a completed remote access session and its results.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        arn(Text): The Amazon Resource Name (ARN) of the session for which you want to delete remote access.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.devicefarm.remote_access_session.absent:
                - name: value
                - arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.devicefarm.remote_access_session.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.devicefarm.get_remote_access_session(name)

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

