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

hub.exec.boto3.client.kinesisanalyticsv2.create_application
hub.exec.boto3.client.kinesisanalyticsv2.delete_application
hub.exec.boto3.client.kinesisanalyticsv2.describe_application
hub.exec.boto3.client.kinesisanalyticsv2.list_applications
hub.exec.boto3.client.kinesisanalyticsv2.rollback_application
hub.exec.boto3.client.kinesisanalyticsv2.start_application
hub.exec.boto3.client.kinesisanalyticsv2.stop_application
hub.exec.boto3.client.kinesisanalyticsv2.update_application
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, application_name: Text, runtime_environment: Text, service_execution_role: Text, application_description: Text = None, application_configuration: Dict = None, cloud_watch_logging_options: List = None, tags: List = None, application_mode: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a Kinesis Data Analytics application. For information about creating a Kinesis Data Analytics
    application, see Creating an Application.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        application_name(Text): The name of your application (for example, sample-app).
        application_description(Text, optional): A summary description of the application. Defaults to None.
        runtime_environment(Text): The runtime environment for the application (SQL-1_0, FLINK-1_6, FLINK-1_8, or FLINK-1_11).
        service_execution_role(Text): The IAM role used by the application to access Kinesis data streams, Kinesis Data Firehose
            delivery streams, Amazon S3 objects, and other external resources.
        application_configuration(Dict, optional): Use this parameter to configure the application. Defaults to None.
        cloud_watch_logging_options(List, optional): Use this parameter to configure an Amazon CloudWatch log stream to monitor application
            configuration errors. Defaults to None.
        tags(List, optional): A list of one or more tags to assign to the application. A tag is a key-value pair that
            identifies an application. Note that the maximum number of application tags includes system
            tags. The maximum number of user-defined application tags is 50. For more information, see Using
            Tagging. Defaults to None.
        application_mode(Text, optional): Use the STREAMING mode to create a Kinesis Data Analytics Studio notebook. To create a Kinesis
            Data Analytics Studio notebook, use the INTERACTIVE mode. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.kinesisanalyticsv2.application.present:
                - name: value
                - application_name: value
                - runtime_environment: value
                - service_execution_role: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.kinesisanalyticsv2.application.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.kinesisanalyticsv2.describe_application(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.kinesisanalyticsv2.create_application(
                ctx,
                
                
                **{"ApplicationName": application_name, "ApplicationDescription": application_description, "RuntimeEnvironment": runtime_environment, "ServiceExecutionRole": service_execution_role, "ApplicationConfiguration": application_configuration, "CloudWatchLoggingOptions": cloud_watch_logging_options, "Tags": tags, "ApplicationMode": application_mode}
            )
            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.kinesisanalyticsv2.describe_application(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, application_name: Text, create_timestamp: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified application. Kinesis Data Analytics halts application execution and deletes the
    application.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        application_name(Text): The name of the application to delete.
        create_timestamp(Text): Use the DescribeApplication operation to get this value.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

