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

hub.exec.boto3.client.rds.copy_option_group
hub.exec.boto3.client.rds.create_option_group
hub.exec.boto3.client.rds.delete_option_group
hub.exec.boto3.client.rds.describe_option_groups
hub.exec.boto3.client.rds.modify_option_group
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, option_group_name: Text, engine_name: Text, major_engine_version: Text, option_group_description: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new option group. You can create up to 20 option groups.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        option_group_name(Text): Specifies the name of the option group to be created. Constraints:   Must be 1 to 255 letters,
            numbers, or hyphens   First character must be a letter   Can't end with a hyphen or contain two
            consecutive hyphens   Example: myoptiongroup.
        engine_name(Text): Specifies the name of the engine that this option group should be associated with. Valid Values:
            mariadb     mysql     oracle-ee     oracle-ee-cdb     oracle-se2     oracle-se2-cdb     postgres
            sqlserver-ee     sqlserver-se     sqlserver-ex     sqlserver-web.
        major_engine_version(Text): Specifies the major version of the engine that this option group should be associated with.
        option_group_description(Text): The description of the option group.
        tags(List, optional): Tags to assign to the option group. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.rds.option_group.present:
                - name: value
                - option_group_name: value
                - engine_name: value
                - major_engine_version: value
                - option_group_description: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.rds.option_group.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.rds.describe_option_groups(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.rds.create_option_group(
                ctx,
                
                
                **{"OptionGroupName": option_group_name, "EngineName": engine_name, "MajorEngineVersion": major_engine_version, "OptionGroupDescription": option_group_description, "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.rds.describe_option_groups(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, option_group_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an existing option group.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        option_group_name(Text): The name of the option group to be deleted.  You can't delete default option groups.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

