# 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 .i18n_content import I18nContent
from .datasource_field import DatasourceField
from .i18n_content import I18nContent


class Datasource(object):
    _types = {
        "code": str,
        "i18n_names": List[I18nContent],
        "active_status": int,
        "fields": List[DatasourceField],
        "i18n_description": List[I18nContent],
        "data_period_type": int,
    }

    def __init__(self, d=None):
        self.code: Optional[str] = None
        self.i18n_names: Optional[List[I18nContent]] = None
        self.active_status: Optional[int] = None
        self.fields: Optional[List[DatasourceField]] = None
        self.i18n_description: Optional[List[I18nContent]] = None
        self.data_period_type: Optional[int] = None
        init(self, d, self._types)

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


class DatasourceBuilder(object):
    def __init__(self) -> None:
        self._datasource = Datasource()

    def code(self, code: str) -> "DatasourceBuilder":
        self._datasource.code = code
        return self

    def i18n_names(self, i18n_names: List[I18nContent]) -> "DatasourceBuilder":
        self._datasource.i18n_names = i18n_names
        return self

    def active_status(self, active_status: int) -> "DatasourceBuilder":
        self._datasource.active_status = active_status
        return self

    def fields(self, fields: List[DatasourceField]) -> "DatasourceBuilder":
        self._datasource.fields = fields
        return self

    def i18n_description(self, i18n_description: List[I18nContent]) -> "DatasourceBuilder":
        self._datasource.i18n_description = i18n_description
        return self

    def data_period_type(self, data_period_type: int) -> "DatasourceBuilder":
        self._datasource.data_period_type = data_period_type
        return self

    def build(self) -> "Datasource":
        return self._datasource
