# Generated by the bali-cli 2.x.  DO NOT EDIT!

import logging

from . import (
    {{ filename }}_pb2 as pb2,
    {{ filename }}_pb2_grpc as pb2_grpc,
    {{ filename }}_schema as schemas,
)
from .._config import GRPC_ADDRESS, GRPC_LOGGER, GRPC_CACHE
from .._utils import ClientMixin

__all__ = ["{{ service_cls }}"]

logger = logging.getLogger(GRPC_LOGGER)


class {{ service_cls }}(ClientMixin):
    _service_abbr = {{ service_abbr }}
    pb2 = pb2
    pb2_grpc = pb2_grpc

    logger = logger
    cache = GRPC_CACHE

    s = schemas
    schemas = schemas
{% for method in methods %}
    def {{ method[0] | decamelize }}(self{% if method[1] == "google.protobuf.Empty" %}{% else %}, schema: schemas.{{ method[1] }}{% endif %}, *, fail_silently=False, cache_timeout=0, refresh=False) -> schemas.{{ method[2] }}:
        service, rpc_name, request_protobuf = "{{ service }}", "{{ method[0] }}", "{{ method[1] }}"
        response_schema_cls = schemas.{{ method[2] }}
        schema = {% if method[1] == "google.protobuf.Empty" %}None{% else %}schema{% endif %}
        cache_options = {'timeout': cache_timeout, 'refresh': refresh}
        return self.request(service, rpc_name, request_protobuf, schema, response_schema_cls, fail_silently, cache_options)
{% endfor %}
