# Code generated by Lark OpenAPI.

from typing import Any, Optional, Union, Dict, List, Set, IO, Callable, Type
from lark_oapi.core.construct import init
from .rec_rule import RecRule
from .other_rec_rule import OtherRecRule


class TableRole(object):
    _types = {
        "table_perm": int,
        "table_name": str,
        "table_id": str,
        "rec_rule": RecRule,
        "other_rec_rule": OtherRecRule,
        "field_perm": Dict[str, int],
        "allow_add_record": bool,
        "allow_delete_record": bool,
        "view_perm": int,
        "view_rules": Dict[str, int],
        "field_action_rules": Dict[str, Dict[str, int]],
    }

    def __init__(self, d=None):
        self.table_perm: Optional[int] = None
        self.table_name: Optional[str] = None
        self.table_id: Optional[str] = None
        self.rec_rule: Optional[RecRule] = None
        self.other_rec_rule: Optional[OtherRecRule] = None
        self.field_perm: Optional[Dict[str, int]] = None
        self.allow_add_record: Optional[bool] = None
        self.allow_delete_record: Optional[bool] = None
        self.view_perm: Optional[int] = None
        self.view_rules: Optional[Dict[str, int]] = None
        self.field_action_rules: Optional[Dict[str, Dict[str, int]]] = None
        init(self, d, self._types)

    @staticmethod
    def builder() -> "TableRoleBuilder":
        return TableRoleBuilder()


class TableRoleBuilder(object):
    def __init__(self) -> None:
        self._table_role = TableRole()

    def table_perm(self, table_perm: int) -> "TableRoleBuilder":
        self._table_role.table_perm = table_perm
        return self

    def table_name(self, table_name: str) -> "TableRoleBuilder":
        self._table_role.table_name = table_name
        return self

    def table_id(self, table_id: str) -> "TableRoleBuilder":
        self._table_role.table_id = table_id
        return self

    def rec_rule(self, rec_rule: RecRule) -> "TableRoleBuilder":
        self._table_role.rec_rule = rec_rule
        return self

    def other_rec_rule(self, other_rec_rule: OtherRecRule) -> "TableRoleBuilder":
        self._table_role.other_rec_rule = other_rec_rule
        return self

    def field_perm(self, field_perm: Dict[str, int]) -> "TableRoleBuilder":
        self._table_role.field_perm = field_perm
        return self

    def allow_add_record(self, allow_add_record: bool) -> "TableRoleBuilder":
        self._table_role.allow_add_record = allow_add_record
        return self

    def allow_delete_record(self, allow_delete_record: bool) -> "TableRoleBuilder":
        self._table_role.allow_delete_record = allow_delete_record
        return self

    def view_perm(self, view_perm: int) -> "TableRoleBuilder":
        self._table_role.view_perm = view_perm
        return self

    def view_rules(self, view_rules: Dict[str, int]) -> "TableRoleBuilder":
        self._table_role.view_rules = view_rules
        return self

    def field_action_rules(self, field_action_rules: Dict[str, Dict[str, int]]) -> "TableRoleBuilder":
        self._table_role.field_action_rules = field_action_rules
        return self

    def build(self) -> "TableRole":
        return self._table_role
