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

hub.exec.boto3.client.nimble.create_studio_component
hub.exec.boto3.client.nimble.delete_studio_component
hub.exec.boto3.client.nimble.get_studio_component
hub.exec.boto3.client.nimble.list_studio_components
hub.exec.boto3.client.nimble.update_studio_component
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, studio_id: Text, type_: Text, client_token: Text = None, configuration: Dict = None, description: Text = None, ec2_security_group_ids: List = None, initialization_scripts: List = None, script_parameters: List = None, subtype: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a studio component resource.

    Args:
        name(Text): The name for the studio component.
        client_token(Text, optional): To make an idempotent API request using one of these actions, specify a client token in the
            request. You should not reuse the same client token for other API requests. If you retry a
            request that completed successfully using the same client token and the same parameters, the
            retry succeeds without performing any further actions. If you retry a successful request using
            the same client token, but one or more of the parameters are different, the retry fails with a
            ValidationException error. Defaults to None.
        configuration(Dict, optional): The configuration of the studio component, based on component type. Defaults to None.
        description(Text, optional): The description. Defaults to None.
        ec2_security_group_ids(List, optional): The EC2 security groups that control access to the studio component. Defaults to None.
        initialization_scripts(List, optional): Initialization scripts for studio components. Defaults to None.
        script_parameters(List, optional): Parameters for the studio component scripts. Defaults to None.
        studio_id(Text): The studio ID.
        subtype(Text, optional): The specific subtype of a studio component. Defaults to None.
        tags(Dict, optional): A collection of labels, in the form of key:value pairs, that apply to this resource. Defaults to None.
        type_(Text): The type of the studio component.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.nimble.create_studio_component(
                ctx,
                
                
                **{"Name": name, "clientToken": client_token, "configuration": configuration, "description": description, "ec2SecurityGroupIds": ec2_security_group_ids, "initializationScripts": initialization_scripts, "scriptParameters": script_parameters, "studioId": studio_id, "subtype": subtype, "tags": tags, "type": type_}
            )
            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.nimble.get_studio_component(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, studio_component_id: Text, studio_id: Text, client_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a studio component resource.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_token(Text, optional): To make an idempotent API request using one of these actions, specify a client token in the
            request. You should not reuse the same client token for other API requests. If you retry a
            request that completed successfully using the same client token and the same parameters, the
            retry succeeds without performing any further actions. If you retry a successful request using
            the same client token, but one or more of the parameters are different, the retry fails with a
            ValidationException error. Defaults to None.
        studio_component_id(Text): The studio component ID.
        studio_id(Text): The studio ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.nimble.delete_studio_component(
                ctx,
                
                
                **{"clientToken": client_token, "studioComponentId": studio_component_id, "studioId": studio_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.nimble.get_studio_component(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

