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

hub.exec.boto3.client.workspaces.create_workspace_bundle
hub.exec.boto3.client.workspaces.delete_workspace_bundle
hub.exec.boto3.client.workspaces.describe_workspace_bundles
hub.exec.boto3.client.workspaces.update_workspace_bundle
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, bundle_name: Text, bundle_description: Text, image_id: Text, compute_type: Dict, user_storage: Dict, root_storage: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates the specified WorkSpace bundle. For more information about creating WorkSpace bundles, see  Create a
    Custom WorkSpaces Image and Bundle.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bundle_name(Text): The name of the bundle.
        bundle_description(Text): The description of the bundle.
        image_id(Text): The identifier of the image that is used to create the bundle.
        compute_type(Dict): Describes the compute type of the bundle.
        user_storage(Dict): Describes the user volume for a WorkSpace bundle.
        root_storage(Dict, optional): Describes the root volume for a WorkSpace bundle. Defaults to None.
        tags(List, optional): The tags associated with the bundle.  To add tags at the same time when you're creating the
            bundle, you must create an IAM policy that grants your IAM user permissions to use
            workspaces:CreateTags. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.workspaces.workspace_bundle.present:
                - name: value
                - bundle_name: value
                - bundle_description: value
                - image_id: value
                - compute_type: value
                - user_storage: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.workspaces.workspace_bundle.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.workspaces.describe_workspace_bundles(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.workspaces.create_workspace_bundle(
                ctx,
                
                
                **{"BundleName": bundle_name, "BundleDescription": bundle_description, "ImageId": image_id, "ComputeType": compute_type, "UserStorage": user_storage, "RootStorage": root_storage, "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.workspaces.describe_workspace_bundles(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, bundle_id: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified WorkSpace bundle. For more information about deleting WorkSpace bundles, see  Delete a
    Custom WorkSpaces Bundle or Image.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

