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

hub.exec.boto3.client.sagemaker.create_workteam
hub.exec.boto3.client.sagemaker.delete_workteam
hub.exec.boto3.client.sagemaker.describe_workteam
hub.exec.boto3.client.sagemaker.list_workteams
hub.exec.boto3.client.sagemaker.update_workteam
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, workteam_name: Text, member_definitions: List, description: Text, workforce_name: Text = None, notification_configuration: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new work team for labeling your data. A work team is defined by one or more Amazon Cognito user pools.
    You must first create the user pools before you can create a work team. You cannot create more than 25 work
    teams in an account and region.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        workteam_name(Text): The name of the work team. Use this name to identify the work team.
        workforce_name(Text, optional): The name of the workforce. Defaults to None.
        member_definitions(List): A list of MemberDefinition objects that contains objects that identify the workers that make up
            the work team.  Workforces can be created using Amazon Cognito or your own OIDC Identity
            Provider (IdP). For private workforces created using Amazon Cognito use CognitoMemberDefinition.
            For workforces created using your own OIDC identity provider (IdP) use OidcMemberDefinition. Do
            not provide input for both of these parameters in a single request. For workforces created using
            Amazon Cognito, private work teams correspond to Amazon Cognito user groups within the user pool
            used to create a workforce. All of the CognitoMemberDefinition objects that make up the member
            definition must have the same ClientId and UserPool values. To add a Amazon Cognito user group
            to an existing worker pool, see Adding groups to a User Pool. For more information about user
            pools, see Amazon Cognito User Pools. For workforces created using your own OIDC IdP, specify
            the user groups that you want to include in your private work team in OidcMemberDefinition by
            listing those groups in Groups.
        description(Text): A description of the work team.
        notification_configuration(Dict, optional): Configures notification of workers regarding available or expiring work items. Defaults to None.
        tags(List, optional): An array of key-value pairs. For more information, see Resource Tag and Using Cost Allocation
            Tags in the  Amazon Web Services Billing and Cost Management User Guide. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.sagemaker.workteam.present:
                - name: value
                - workteam_name: value
                - member_definitions: value
                - description: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker.workteam.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.sagemaker.describe_workteam(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_workteam(
                ctx,
                
                
                **{"WorkteamName": workteam_name, "WorkforceName": workforce_name, "MemberDefinitions": member_definitions, "Description": description, "NotificationConfiguration": notification_configuration, "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.sagemaker.describe_workteam(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, workteam_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an existing work team. This operation can't be undone.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        workteam_name(Text): The name of the work team to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

