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

hub.exec.boto3.client.license_manager.create_license_configuration
hub.exec.boto3.client.license_manager.delete_license_configuration
hub.exec.boto3.client.license_manager.get_license_configuration
hub.exec.boto3.client.license_manager.list_license_configurations
hub.exec.boto3.client.license_manager.update_license_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, license_counting_type: Text, description: Text = None, license_count: int = None, license_count_hard_limit: bool = None, license_rules: List = None, tags: List = None, disassociate_when_not_found: bool = None, product_information_list: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a license configuration. A license configuration is an abstraction of a customer license agreement that
    can be consumed and enforced by License Manager. Components include specifications for the license type
    (licensing by instance, socket, CPU, or vCPU), allowed tenancy (shared tenancy, Dedicated Instance, Dedicated
    Host, or all of these), license affinity to host (how long a license must be associated with a host), and the
    number of licenses purchased and used.

    Args:
        name(Text): Name of the license configuration.
        description(Text, optional): Description of the license configuration. Defaults to None.
        license_counting_type(Text): Dimension used to track the license inventory.
        license_count(int, optional): Number of licenses managed by the license configuration. Defaults to None.
        license_count_hard_limit(bool, optional): Indicates whether hard or soft license enforcement is used. Exceeding a hard limit blocks the
            launch of new instances. Defaults to None.
        license_rules(List, optional): License rules. The syntax is #name=value (for example, #allowedTenancy=EC2-DedicatedHost). The
            available rules vary by dimension, as follows.    Cores dimension: allowedTenancy |
            licenseAffinityToHost | maximumCores | minimumCores     Instances dimension: allowedTenancy |
            maximumCores | minimumCores | maximumSockets | minimumSockets | maximumVcpus | minimumVcpus
            Sockets dimension: allowedTenancy | licenseAffinityToHost | maximumSockets | minimumSockets
            vCPUs dimension: allowedTenancy | honorVcpuOptimization | maximumVcpus | minimumVcpus    The
            unit for licenseAffinityToHost is days and the range is 1 to 180. The possible values for
            allowedTenancy are EC2-Default, EC2-DedicatedHost, and EC2-DedicatedInstance. The possible
            values for honorVcpuOptimization are True and False. Defaults to None.
        tags(List, optional): Tags to add to the license configuration. Defaults to None.
        disassociate_when_not_found(bool, optional): When true, disassociates a resource when software is uninstalled. Defaults to None.
        product_information_list(List, optional): Product information. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.license_manager.license_configuration.present:
                - name: value
                - license_counting_type: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.license_manager.license_configuration.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.license_manager.get_license_configuration(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.license_manager.create_license_configuration(
                ctx,
                
                
                **{"Name": name, "Description": description, "LicenseCountingType": license_counting_type, "LicenseCount": license_count, "LicenseCountHardLimit": license_count_hard_limit, "LicenseRules": license_rules, "Tags": tags, "DisassociateWhenNotFound": disassociate_when_not_found, "ProductInformationList": product_information_list}
            )
            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.license_manager.get_license_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, license_configuration_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified license configuration. You cannot delete a license configuration that is in use.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        license_configuration_arn(Text): ID of the license configuration.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

