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

hub.exec.boto3.client.sms.delete_app_launch_configuration
hub.exec.boto3.client.sms.get_app_launch_configuration
hub.exec.boto3.client.sms.put_app_launch_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, app_id: Text = None, role_name: Text = None, auto_launch: bool = None, server_group_launch_configurations: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates or updates the launch configuration for the specified application.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        app_id(Text, optional): The ID of the application. Defaults to None.
        role_name(Text, optional): The name of service role in the customer's account that AWS CloudFormation uses to launch the
            application. Defaults to None.
        auto_launch(bool, optional): Indicates whether the application is configured to launch automatically after replication is
            complete. Defaults to None.
        server_group_launch_configurations(List, optional): Information about the launch configurations for server groups in the application. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sms.put_app_launch_configuration(
                ctx,
                
                
                **{"appId": app_id, "roleName": role_name, "autoLaunch": auto_launch, "serverGroupLaunchConfigurations": server_group_launch_configurations}
            )
            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.sms.get_app_launch_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, app_id: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the launch configuration for the specified application.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        app_id(Text, optional): The ID of the application. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

