# 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 CreateApprovalInstanceReqNodeApproverOpenIDList(object):
    pass


@attr.s
class CreateApprovalInstanceReqNodeApproverUserIDList(object):
    pass


@attr.s
class CreateApprovalInstanceReqForm(object):
    id: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 控件 ID，也可以使用自定义 ID custom_id 的值
    type: str = attr.ib(default="", metadata={"req_type": "json"})  # 控件类型
    value: str = attr.ib(default="", metadata={"req_type": "json"})  # 控件值，不同类型的值格式不一样


@attr.s
class CreateApprovalInstanceReq(object):
    approval_code: str = attr.ib(default="", metadata={"req_type": "json"})  # 审批定义 code
    user_id: str = attr.ib(default="", metadata={"req_type": "json"})  # 发起审批用户
    tenant_id: str = attr.ib(default="", metadata={"req_type": "json"})  # 平台租户ID
    open_id: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 发起审批用户 open id, 如果传了 user_id 则优先使用 user_id
    department_id: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 发起审批用户部门，如果用户只属于一个部门，可以不填，如果属于多个部门，必须填其中一个部门
    form: CreateApprovalInstanceReqForm = attr.ib(
        factory=lambda: CreateApprovalInstanceReqForm(), metadata={"req_type": "json"}
    )  # json 数组，**控件值**
    node_approver_user_id_list: CreateApprovalInstanceReqNodeApproverUserIDList = attr.ib(
        factory=lambda: CreateApprovalInstanceReqNodeApproverUserIDList(),
        metadata={"req_type": "json"},
    )  # 如果有发起人自选节点，则需要填写对应节点的审批人<br>key:  node id 或 custom node id , 通过 [查看审批定义](https://open.feishu.cn/document/ukTMukTMukTM/uADNyUjLwQjM14CM0ITN) 获取<br> value: 审批人列表
    node_approver_open_id_list: CreateApprovalInstanceReqNodeApproverOpenIDList = (
        attr.ib(
            factory=lambda: CreateApprovalInstanceReqNodeApproverOpenIDList(),
            metadata={"req_type": "json"},
        )
    )  # 发起人自选 open id
    uuid: str = attr.ib(
        default="", metadata={"req_type": "json"}
    )  # 审批实例 uuid，用于幂等操作，同一个 uuid 只能用于创建一个审批实例，如果冲突，返回错误码 60012 ，格式必须为 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX，不区分大小写


@attr.s
class CreateApprovalInstanceResp(object):
    instance_code: str = attr.ib(default="", metadata={"req_type": "json"})  # 审批实例 Code


def _gen_create_approval_instance_req(request, options) -> RawRequestReq:
    return RawRequestReq(
        dataclass=CreateApprovalInstanceResp,
        scope="Approval",
        api="CreateApprovalInstance",
        method="POST",
        url="https://www.feishu.cn/approval/openapi/v2/instance/create",
        body=request,
        method_option=_new_method_option(options),
        need_tenant_access_token=True,
    )
