# Generated by {{source_script}} at {{time}}
from typing import Literal
{%- macro generate_resource_search(resource_request) %}
class {{ resource_request.resource_type }}BooleanEnd:
    def __init__(self, search_string: str):
        self.search_string = search_string

    def AND(self):
        search_string = self.search_string + "&"
        return {{ resource_request.resource_type }}SearchBuilder(search_string=search_string)

    def OR(self):
        search_string = self.search_string + "|"
        return {{ resource_request.resource_type }}SearchBuilder(search_string=search_string)
    
    def build(self):
        return self.search_string


class {{ resource_request.resource_type }}Value:
    def __init__(self, search_string: str):
        self.search_string = search_string

    def eq(self, value: str, comparator: Literal{{ comparators }} = ""):
        search_string = self.search_string + f"={comparator}{value}"
        return {{ resource_request.resource_type }}BooleanEnd(search_string=search_string)


class {{ resource_request.resource_type }}SearchBuilder:
    def __init__(self, search_string: str):
        self.search_string = search_string

    def param(
        self,
        value: Literal{{ resource_request.params }},
        modifier: Literal{{ modifiers }} = "",
    ):
        search_string = self.search_string + value
        if modifier:
            search_string = search_string + f":{modifier}"
        return {{ resource_request.resource_type }}Value(search_string=search_string)
    
    def include(self, 
        value: Literal{{ resource_request.includes }},
        modifier: Literal{{ modifiers }} = "",):
        if modifier:
            search_string = self.search_string + f"_include:{modifier}={value}"
        else:
            search_string = self.search_string + f"_include={value}"
        return {{ resource_request.resource_type }}BooleanEnd(search_string=search_string)

    def revinclude(self,
        value: Literal{{ resource_request.revincludes }},
        modifier: Literal{{ modifiers }} = "",):
        if modifier:
            search_string = self.search_string + f"_revinclude:{modifier}={value}"
        else:
            search_string = self.search_string + f"_revinclude={value}"
        return {{ resource_request.resource_type }}BooleanEnd(search_string=search_string)

{% endmacro %}

{%- for resource_request in resource_requests %}
{{ generate_resource_search(resource_request) }}
{% endfor %}
