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

hub.exec.boto3.client.apigateway.delete_method_response
hub.exec.boto3.client.apigateway.get_method_response
hub.exec.boto3.client.apigateway.put_method_response
hub.exec.boto3.client.apigateway.update_method_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, response_parameters: Dict = None, response_models: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Adds a MethodResponse to an existing Method resource.

    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] The Resource identifier for the Method resource.
        http_method(Text): [Required] The HTTP verb of the Method resource.
        status_code(Text): [Required] The method response's status code.
        response_parameters(Dict, optional): A key-value map specifying required or optional response parameters that API Gateway can send
            back to the caller. A key defines a method response header name and the associated value is a
            Boolean flag indicating whether the method response parameter is required or not. The method
            response header names must match the pattern of method.response.header.{name}, where name is a
            valid and unique header name. The response parameter names defined here are available in the
            integration response to be mapped from an integration response header expressed in
            integration.response.header.{name}, a static value enclosed within a pair of single quotes
            (e.g., 'application/json'), or a JSON expression from the back-end response payload in the form
            of integration.response.body.{JSON-expression}, where JSON-expression is a valid JSON expression
            without the $ prefix.). Defaults to None.
        response_models(Dict, optional): Specifies the Model resources used for the response's content type. Response models are
            represented as a key/value map, with a content type as the key and a Model name as the value. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.apigateway.method_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.method_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_method_response(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.apigateway.put_method_response(
                ctx,
                
                
                **{"restApiId": rest_api_id, "resourceId": resource_id, "httpMethod": http_method, "statusCode": status_code, "responseParameters": response_parameters, "responseModels": response_models}
            )
            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_method_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**
    
    Deletes an existing MethodResponse resource.

    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] The Resource identifier for the MethodResponse resource.
        http_method(Text): [Required] The HTTP verb of the Method resource.
        status_code(Text): [Required] The status code identifier for the MethodResponse resource.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.apigateway.method_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.method_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_method_response(name)

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

