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

hub.exec.boto3.client.mediatailor.delete_playback_configuration
hub.exec.boto3.client.mediatailor.get_playback_configuration
hub.exec.boto3.client.mediatailor.list_playback_configurations
hub.exec.boto3.client.mediatailor.put_playback_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text = None, ad_decision_server_url: Text = None, avail_suppression: Dict = None, bumper: Dict = None, cdn_configuration: Dict = None, configuration_aliases: Dict = None, dash_configuration: Dict = None, live_pre_roll_configuration: Dict = None, manifest_processing_rules: Dict = None, personalization_threshold_seconds: int = None, slate_ad_url: Text = None, tags: Dict = None, transcode_profile_name: Text = None, video_content_source_url: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Adds a new playback configuration to AWS Elemental MediaTailor.

    Args:
        name(Text, optional): The identifier for the playback configuration. Defaults to None.
        ad_decision_server_url(Text, optional): The URL for the ad decision server (ADS). This includes the specification of static parameters
            and placeholders for dynamic parameters. AWS Elemental MediaTailor substitutes player-specific
            and session-specific parameters as needed when calling the ADS. Alternately, for testing you can
            provide a static VAST URL. The maximum length is 25,000 characters. Defaults to None.
        avail_suppression(Dict, optional): The configuration for avail suppression, also known as ad suppression. For more information
            about ad suppression, see Ad Suppression. Defaults to None.
        bumper(Dict, optional): The configuration for bumpers. Bumpers are short audio or video clips that play at the start or
            before the end of an ad break. To learn more about bumpers, see Bumpers. Defaults to None.
        cdn_configuration(Dict, optional): The configuration for using a content delivery network (CDN), like Amazon CloudFront, for
            content and ad segment management. Defaults to None.
        configuration_aliases(Dict, optional): The player parameters and aliases used as dynamic variables during session initialization. For
            more information, see Domain Variables. Defaults to None.
        dash_configuration(Dict, optional): The configuration for DASH content. Defaults to None.
        live_pre_roll_configuration(Dict, optional): The configuration for pre-roll ad insertion. Defaults to None.
        manifest_processing_rules(Dict, optional): The configuration for manifest processing rules. Manifest processing rules enable customization
            of the personalized manifests created by MediaTailor. Defaults to None.
        personalization_threshold_seconds(int, optional): Defines the maximum duration of underfilled ad time (in seconds) allowed in an ad break. If the
            duration of underfilled ad time exceeds the personalization threshold, then the personalization
            of the ad break is abandoned and the underlying content is shown. This feature applies to ad
            replacement in live and VOD streams, rather than ad insertion, because it relies on an
            underlying content stream. For more information about ad break behavior, including ad
            replacement and insertion, see Ad Behavior in AWS Elemental MediaTailor. Defaults to None.
        slate_ad_url(Text, optional): The URL for a high-quality video asset to transcode and use to fill in time that's not used by
            ads. AWS Elemental MediaTailor shows the slate to fill in gaps in media content. Configuring the
            slate is optional for non-VPAID configurations. For VPAID, the slate is required because
            MediaTailor provides it in the slots that are designated for dynamic ad content. The slate must
            be a high-quality asset that contains both audio and video. Defaults to None.
        tags(Dict, optional): The tags to assign to the playback configuration. Defaults to None.
        transcode_profile_name(Text, optional): The name that is used to associate this playback configuration with a custom transcode profile.
            This overrides the dynamic transcoding defaults of MediaTailor. Use this only if you have
            already set up custom profiles with the help of AWS Support. Defaults to None.
        video_content_source_url(Text, optional): The URL prefix for the parent manifest for the stream, minus the asset ID. The maximum length is
            512 characters. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.mediatailor.playback_configuration.present:
                - 
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.mediatailor.playback_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.mediatailor.get_playback_configuration(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.mediatailor.put_playback_configuration(
                ctx,
                
                
                **{"Name": name, "AdDecisionServerUrl": ad_decision_server_url, "AvailSuppression": avail_suppression, "Bumper": bumper, "CdnConfiguration": cdn_configuration, "ConfigurationAliases": configuration_aliases, "DashConfiguration": dash_configuration, "LivePreRollConfiguration": live_pre_roll_configuration, "ManifestProcessingRules": manifest_processing_rules, "PersonalizationThresholdSeconds": personalization_threshold_seconds, "SlateAdUrl": slate_ad_url, "Tags": tags, "TranscodeProfileName": transcode_profile_name, "VideoContentSourceUrl": video_content_source_url}
            )
            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.mediatailor.get_playback_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the playback configuration for the specified name.

    Args:
        name(Text): The identifier for the playback configuration.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

