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

hub.exec.boto3.client.worklink.associate_website_authorization_provider
hub.exec.boto3.client.worklink.disassociate_website_authorization_provider
hub.exec.boto3.client.worklink.list_website_authorization_providers
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, fleet_arn: Text, authorization_provider_type: Text, domain_name: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Associates a website authorization provider with a specified fleet. This is used to authorize users against
    associated websites in the company network.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        fleet_arn(Text): The ARN of the fleet.
        authorization_provider_type(Text): The authorization provider type.
        domain_name(Text, optional): The domain name of the authorization provider. This applies only to SAML-based authorization
            providers. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.worklink.website_authorization_provider.present:
                - name: value
                - fleet_arn: value
                - authorization_provider_type: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.worklink.website_authorization_provider.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.worklink.list_website_authorization_providers(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.worklink.associate_website_authorization_provider(
                ctx,
                
                
                **{"FleetArn": fleet_arn, "AuthorizationProviderType": authorization_provider_type, "DomainName": domain_name}
            )
            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.worklink.list_website_authorization_providers(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, fleet_arn: Text, authorization_provider_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Disassociates a website authorization provider from a specified fleet. After the disassociation, users can't
    load any associated websites that require this authorization provider.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        fleet_arn(Text): The ARN of the fleet.
        authorization_provider_id(Text): A unique identifier for the authorization provider.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.worklink.disassociate_website_authorization_provider(
                ctx,
                
                
                **{"FleetArn": fleet_arn, "AuthorizationProviderId": authorization_provider_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.worklink.list_website_authorization_providers(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

