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

hub.exec.boto3.client.apigatewayv2.create_route_response
hub.exec.boto3.client.apigatewayv2.delete_route_response
hub.exec.boto3.client.apigatewayv2.get_route_responses
hub.exec.boto3.client.apigatewayv2.update_route_response
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, api_id: Text, route_id: Text, route_response_key: Text, model_selection_expression: Text = None, response_models: Dict = None, response_parameters: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a RouteResponse for a Route.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        api_id(Text): The API identifier.
        model_selection_expression(Text, optional): The model selection expression for the route response. Supported only for WebSocket APIs. Defaults to None.
        response_models(Dict, optional): The response models for the route response. Defaults to None.
        response_parameters(Dict, optional): The route response parameters. Defaults to None.
        route_id(Text): The route ID.
        route_response_key(Text): The route response key.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.apigatewayv2.route_response.present:
                - name: value
                - api_id: value
                - route_id: value
                - route_response_key: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.apigatewayv2.route_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.apigatewayv2.get_route_responses(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.apigatewayv2.create_route_response(
                ctx,
                
                
                **{"ApiId": api_id, "ModelSelectionExpression": model_selection_expression, "ResponseModels": response_models, "ResponseParameters": response_parameters, "RouteId": route_id, "RouteResponseKey": route_response_key}
            )
            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.apigatewayv2.get_route_responses(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, api_id: Text, route_id: Text, route_response_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a RouteResponse.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        api_id(Text): The API identifier.
        route_id(Text): The route ID.
        route_response_id(Text): The route response ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.apigatewayv2.route_response.absent:
                - name: value
                - api_id: value
                - route_id: value
                - route_response_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.apigatewayv2.route_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.apigatewayv2.get_route_responses(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.apigatewayv2.delete_route_response(
                ctx,
                
                
                **{"ApiId": api_id, "RouteId": route_id, "RouteResponseId": route_response_id}
            )
            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.apigatewayv2.get_route_responses(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

