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

hub.exec.boto3.client.devicefarm.create_network_profile
hub.exec.boto3.client.devicefarm.delete_network_profile
hub.exec.boto3.client.devicefarm.get_network_profile
hub.exec.boto3.client.devicefarm.list_network_profiles
hub.exec.boto3.client.devicefarm.update_network_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, project_arn: Text, description: Text = None, type_: Text = None, uplink_bandwidth_bits: int = None, downlink_bandwidth_bits: int = None, uplink_delay_ms: int = None, downlink_delay_ms: int = None, uplink_jitter_ms: int = None, downlink_jitter_ms: int = None, uplink_loss_percent: int = None, downlink_loss_percent: int = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a network profile.

    Args:
        name(Text): The name for the new network profile.
        project_arn(Text): The Amazon Resource Name (ARN) of the project for which you want to create a network profile.
        description(Text, optional): The description of the network profile. Defaults to None.
        type_(Text, optional): The type of network profile to create. Valid values are listed here. Defaults to None.
        uplink_bandwidth_bits(int, optional): The data throughput rate in bits per second, as an integer from 0 to 104857600. Defaults to None.
        downlink_bandwidth_bits(int, optional): The data throughput rate in bits per second, as an integer from 0 to 104857600. Defaults to None.
        uplink_delay_ms(int, optional): Delay time for all packets to destination in milliseconds as an integer from 0 to 2000. Defaults to None.
        downlink_delay_ms(int, optional): Delay time for all packets to destination in milliseconds as an integer from 0 to 2000. Defaults to None.
        uplink_jitter_ms(int, optional): Time variation in the delay of received packets in milliseconds as an integer from 0 to 2000. Defaults to None.
        downlink_jitter_ms(int, optional): Time variation in the delay of received packets in milliseconds as an integer from 0 to 2000. Defaults to None.
        uplink_loss_percent(int, optional): Proportion of transmitted packets that fail to arrive from 0 to 100 percent. Defaults to None.
        downlink_loss_percent(int, optional): Proportion of received packets that fail to arrive from 0 to 100 percent. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.devicefarm.create_network_profile(
                ctx,
                
                
                **{"Name": name, "projectArn": project_arn, "description": description, "type": type_, "uplinkBandwidthBits": uplink_bandwidth_bits, "downlinkBandwidthBits": downlink_bandwidth_bits, "uplinkDelayMs": uplink_delay_ms, "downlinkDelayMs": downlink_delay_ms, "uplinkJitterMs": uplink_jitter_ms, "downlinkJitterMs": downlink_jitter_ms, "uplinkLossPercent": uplink_loss_percent, "downlinkLossPercent": downlink_loss_percent}
            )
            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.devicefarm.get_network_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a network profile.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        arn(Text): The ARN of the network profile to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

