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

hub.exec.boto3.client.apigateway.delete_integration_response
hub.exec.boto3.client.apigateway.get_integration_response
hub.exec.boto3.client.apigateway.put_integration_response
hub.exec.boto3.client.apigateway.update_integration_response
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, rest_api_id: Text, resource_id: Text, http_method: Text, status_code: Text, selection_pattern: Text = None, response_parameters: Dict = None, response_templates: Dict = None, content_handling: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Represents a put integration.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        rest_api_id(Text): [Required] The string identifier of the associated RestApi.
        resource_id(Text): [Required] Specifies a put integration response request's resource identifier.
        http_method(Text): [Required] Specifies a put integration response request's HTTP method.
        status_code(Text): [Required] Specifies the status code that is used to map the integration response to an existing
            MethodResponse.
        selection_pattern(Text, optional): Specifies the selection pattern of a put integration response. Defaults to None.
        response_parameters(Dict, optional): A key-value map specifying response parameters that are passed to the method response from the
            back end. The key is a method response header parameter name and the mapped value is an
            integration response header value, a static value enclosed within a pair of single quotes, or a
            JSON expression from the integration response body. The mapping key must match the pattern of
            method.response.header.{name}, where name is a valid and unique header name. The mapped non-
            static value must match the pattern of integration.response.header.{name} or
            integration.response.body.{JSON-expression}, where name must be a valid and unique response
            header name and JSON-expression a valid JSON expression without the $ prefix. Defaults to None.
        response_templates(Dict, optional): Specifies a put integration response's templates. Defaults to None.
        content_handling(Text, optional): Specifies how to handle response payload content type conversions. Supported values are
            CONVERT_TO_BINARY and CONVERT_TO_TEXT, with the following behaviors:  CONVERT_TO_BINARY:
            Converts a response payload from a Base64-encoded string to the corresponding binary blob.
            CONVERT_TO_TEXT: Converts a response payload from a binary blob to a Base64-encoded string.  If
            this property is not defined, the response payload will be passed through from the integration
            response to the method response without modification. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.apigateway.integration_response.present:
                - name: value
                - rest_api_id: value
                - resource_id: value
                - http_method: value
                - status_code: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.apigateway.integration_response.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.apigateway.get_integration_response(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.apigateway.put_integration_response(
                ctx,
                
                
                **{"restApiId": rest_api_id, "resourceId": resource_id, "httpMethod": http_method, "statusCode": status_code, "selectionPattern": selection_pattern, "responseParameters": response_parameters, "responseTemplates": response_templates, "contentHandling": content_handling}
            )
            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.apigateway.get_integration_response(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, rest_api_id: Text, resource_id: Text, http_method: Text, status_code: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Represents a delete integration response.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        rest_api_id(Text): [Required] The string identifier of the associated RestApi.
        resource_id(Text): [Required] Specifies a delete integration response request's resource identifier.
        http_method(Text): [Required] Specifies a delete integration response request's HTTP method.
        status_code(Text): [Required] Specifies a delete integration response request's status code.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.apigateway.integration_response.absent:
                - name: value
                - rest_api_id: value
                - resource_id: value
                - http_method: value
                - status_code: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.apigateway.integration_response.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.apigateway.get_integration_response(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.apigateway.delete_integration_response(
                ctx,
                
                
                **{"restApiId": rest_api_id, "resourceId": resource_id, "httpMethod": http_method, "statusCode": status_code}
            )
            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.apigateway.get_integration_response(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

