# Code generated by lark_sdk_gen. DO NOT EDIT.

from pylark.lark_request import RawRequestReq, _new_method_option
import attr
import typing
import io


@attr.s
class CreateBitableFieldReqPropertyOption(object):
    name: str = attr.ib(default="", metadata={"req_type": "json"})  # 选项名, 示例值："红色"
    id: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 选项id, 示例值："optKl35lnG"


@attr.s
class CreateBitableFieldReqProperty(object):
    options: typing.List[CreateBitableFieldReqPropertyOption] = attr.ib(
        factory=lambda: [], metadata={"req_type": "json"}
    )  # 单选/多选字段的选项信息
    formatter: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 数字字段的数字显示格式, 示例值："0"
    date_format: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 日期格式, 示例值："yyyy/MM/dd"
    time_format: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 时间格式, 示例值："HH:mm"
    auto_fill: bool = attr.ib(
        default=None, metadata={"req_type": "json"}
    )  # 是否自动填入创建时间, 示例值：false
    multiple: bool = attr.ib(
        default=None, metadata={"req_type": "json"}
    )  # 多选标记, 示例值：false
    table_id: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 关联字段中关联表的id, 示例值："tblsRc9GRRXKqhvW"
    view_id: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 关联字段中关联表的视图id, 示例值："vewOVMEXPF"
    fields: typing.List[str] = attr.ib(
        factory=lambda: [], metadata={"req_type": "json"}
    )  # 关联字段要展示的字段, 示例值：["fldSiTwIqy"]


@attr.s
class CreateBitableFieldReqUserIDType(object):
    pass


@attr.s
class CreateBitableFieldReq(object):
    user_id_type: CreateBitableFieldReqUserIDType = attr.ib(
        default=None, metadata={"req_type": "query"}
    )  # 用户 ID 类型, 示例值："open_id", 可选值有: `open_id`：用户的 open id, `union_id`：用户的 union id, `user_id`：用户的 user id, 默认值: `open_id`,, 当值为 `user_id`, 字段权限要求: 获取用户 userid
    app_token: str = attr.ib(
        default="", metadata={"req_type": "path"}
    )  # bitable app token, 示例值："appbcbWCzen6D8dezhoCH2RpMAh"
    table_id: str = attr.ib(
        default="", metadata={"req_type": "path"}
    )  # table id, 示例值："tblsRc9GRRXKqhvW"
    field_name: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 多维表格字段名, 示例值："多行文本"
    type: int = attr.ib(default=0, metadata={"req_type": "json"})  # 多维表格字段类型, 示例值：1
    property: CreateBitableFieldReqProperty = attr.ib(
        default=None, metadata={"req_type": "json"}
    )  # 字段属性, 具体参考: [Property说明](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/bitable/development-guide/bitable-structure#b286b4ee)


@attr.s
class CreateBitableFieldRespFieldPropertyOption(object):
    name: str = attr.ib(default="", metadata={"req_type": "json"})  # 选项名
    id: str = attr.ib(default="", metadata={"req_type": "json"})  # 选项id


@attr.s
class CreateBitableFieldRespFieldProperty(object):
    options: typing.List[CreateBitableFieldRespFieldPropertyOption] = attr.ib(
        factory=lambda: [], metadata={"req_type": "json"}
    )  # 单选/多选字段的选项信息
    formatter: str = attr.ib(default="", metadata={"req_type": "json"})  # 数字字段的数字显示格式
    date_format: str = attr.ib(default="", metadata={"req_type": "json"})  # 日期格式
    time_format: str = attr.ib(default="", metadata={"req_type": "json"})  # 时间格式
    auto_fill: bool = attr.ib(
        factory=lambda: bool(), metadata={"req_type": "json"}
    )  # 是否自动填入创建时间
    multiple: bool = attr.ib(
        factory=lambda: bool(), metadata={"req_type": "json"}
    )  # 多选标记
    table_id: str = attr.ib(default="", metadata={"req_type": "json"})  # 关联字段中关联表的id
    view_id: str = attr.ib(default="", metadata={"req_type": "json"})  # 关联字段中关联表的视图id
    fields: typing.List[str] = attr.ib(
        factory=lambda: [], metadata={"req_type": "json"}
    )  # 关联字段要展示的字段


@attr.s
class CreateBitableFieldRespField(object):
    field_id: str = attr.ib(default="", metadata={"req_type": "json"})  # 多维表格字段 id
    field_name: str = attr.ib(default="", metadata={"req_type": "json"})  # 多维表格字段名
    type: int = attr.ib(default=0, metadata={"req_type": "json"})  # 多维表格字段类型
    property: CreateBitableFieldRespFieldProperty = attr.ib(
        default=None, metadata={"req_type": "json"}
    )  # 字段属性, 具体参考: [Property说明](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/bitable/development-guide/bitable-structure#b286b4ee)


@attr.s
class CreateBitableFieldResp(object):
    field: CreateBitableFieldRespField = attr.ib(
        default=None, metadata={"req_type": "json"}
    )  # 字段


def _gen_create_bitable_field_req(request, options) -> RawRequestReq:
    return RawRequestReq(
        dataclass=CreateBitableFieldResp,
        scope="Bitable",
        api="CreateBitableField",
        method="POST",
        url="https://open.feishu.cn/open-apis/bitable/v1/apps/:app_token/tables/:table_id/fields",
        body=request,
        method_option=_new_method_option(options),
        need_tenant_access_token=True,
        need_user_access_token=True,
    )
