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

hub.exec.boto3.client.signer.cancel_signing_profile
hub.exec.boto3.client.signer.get_signing_profile
hub.exec.boto3.client.signer.list_signing_profiles
hub.exec.boto3.client.signer.put_signing_profile
hub.exec.boto3.client.signer.revoke_signing_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, profile_name: Text, platform_id: Text, signing_material: Dict = None, signature_validity_period: Dict = None, overrides: Dict = None, signing_parameters: Dict = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a signing profile. A signing profile is a code signing template that can be used to carry out a pre-
    defined signing job. For more information, see http://docs.aws.amazon.com/signer/latest/developerguide/gs-
    profile.html

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        profile_name(Text): The name of the signing profile to be created.
        signing_material(Dict, optional): The AWS Certificate Manager certificate that will be used to sign code with the new signing
            profile. Defaults to None.
        signature_validity_period(Dict, optional): The default validity period override for any signature generated using this signing profile. If
            unspecified, the default is 135 months. Defaults to None.
        platform_id(Text): The ID of the signing platform to be created.
        overrides(Dict, optional): A subfield of platform. This specifies any different configuration options that you want to
            apply to the chosen platform (such as a different hash-algorithm or signing-algorithm). Defaults to None.
        signing_parameters(Dict, optional): Map of key-value pairs for signing. These can include any information that you want to use
            during signing. Defaults to None.
        tags(Dict, optional): Tags to be associated with the signing profile that is being created. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.signer.signing_profile.present:
                - name: value
                - profile_name: value
                - platform_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.signer.signing_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.signer.get_signing_profile(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.signer.put_signing_profile(
                ctx,
                
                
                **{"profileName": profile_name, "signingMaterial": signing_material, "signatureValidityPeriod": signature_validity_period, "platformId": platform_id, "overrides": overrides, "signingParameters": signing_parameters, "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.signer.get_signing_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, profile_name: Text, profile_version: Text, reason: Text, effective_time: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Changes the state of a signing profile to REVOKED. This indicates that signatures generated using the signing
    profile after an effective start date are no longer valid.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        profile_name(Text): The name of the signing profile to be revoked.
        profile_version(Text): The version of the signing profile to be revoked.
        reason(Text): The reason for revoking a signing profile.
        effective_time(Text): A timestamp for when revocation of a Signing Profile should become effective. Signatures
            generated using the signing profile after this timestamp are not trusted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.signer.signing_profile.absent:
                - name: value
                - profile_name: value
                - profile_version: value
                - reason: value
                - effective_time: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.signer.signing_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.signer.get_signing_profile(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.signer.revoke_signing_profile(
                ctx,
                
                
                **{"profileName": profile_name, "profileVersion": profile_version, "reason": reason, "effectiveTime": effective_time}
            )
            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.signer.get_signing_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

