// Package wiki code generated by oapi sdk gen
/*
 * MIT License
 *
 * Copyright (c) 2022 Lark Technologies Pte. Ltd.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package larkwiki

import (
	"fmt"

	"context"
	"errors"

	"github.com/larksuite/oapi-sdk-go/v3/core"
)

const (
	OpenSharingOpen   = "open"   // 打开
	OpenSharingClosed = "closed" // 关闭
)

const (
	ShowLanguageLangZH   = "zh"    // 简体中文
	ShowLanguageLangID   = "id"    // 印尼语
	ShowLanguageLangDE   = "de"    // 德语
	ShowLanguageLangEN   = "en"    // 英语
	ShowLanguageLangES   = "es"    // 西班牙语
	ShowLanguageLangFR   = "fr"    // 法语
	ShowLanguageLangIT   = "it"    // 意大利语
	ShowLanguageLangPT   = "pt"    // 葡萄牙语
	ShowLanguageLangVI   = "vi"    // 越南语
	ShowLanguageLangRU   = "ru"    // 俄语
	ShowLanguageLangHI   = "hi"    // 印地语
	ShowLanguageLangTH   = "th"    // 泰语
	ShowLanguageLangKO   = "ko"    // 韩语
	ShowLanguageLangJA   = "ja"    // 日语
	ShowLanguageLangZHHK = "zh-HK" // 繁体中文（中国香港）
	ShowLanguageLangZHTW = "zh-TW" // 繁体中文（中国台湾）
)

const (
	ObjTypeForQueryObjTypeDoc      = "doc"      // 旧版文档
	ObjTypeForQueryObjTypeDocx     = "docx"     // 新版文档
	ObjTypeForQueryObjTypeSheet    = "sheet"    // 表格
	ObjTypeForQueryObjTypeMindNote = "mindnote" // 思维导图
	ObjTypeForQueryObjTypeBitable  = "bitable"  // 多维表格
	ObjTypeForQueryObjTypeFile     = "file"     // 文件
	ObjTypeForQueryObjTypeSlides   = "slides"   // 幻灯片
	ObjTypeForQueryObjTypeWiki     = "wiki"     // 知识库节点
)

const (
	TypeUser       = "user"       // 用户
	TypeChat       = "chat"       // 群组
	TypeDepartment = "department" // 组织架构
)

const (
	ObjTypeObjTypeDoc      = "doc"      // 旧版文档
	ObjTypeObjTypeSheet    = "sheet"    // 表格
	ObjTypeObjTypeMindNote = "mindnote" // 思维导图
	ObjTypeObjTypeBitable  = "bitable"  // 多维表格
	ObjTypeObjTypeFile     = "file"     // 文件
	ObjTypeObjTypeDocx     = "docx"     // 新版文档
	ObjTypeObjTypeSlides   = "slides"   // 幻灯片
)

const (
	NodeTypeNodeTypeEntity   = "origin"   // 实体
	NodeTypeNodeTypeShortCut = "shortcut" // 快捷方式
)

const (
	MoveDocsToWikiObjTypeObjTypeDoc      = "doc"      // doc（文档）
	MoveDocsToWikiObjTypeObjTypeSheet    = "sheet"    // sheet（表格）
	MoveDocsToWikiObjTypeObjTypeBitable  = "bitable"  // bitable（多维表格）
	MoveDocsToWikiObjTypeObjTypeMindNote = "mindnote" // mindnote（思维导图）
	MoveDocsToWikiObjTypeObjTypeDocx     = "docx"     // docx
	MoveDocsToWikiObjTypeObjTypeFile     = "file"     // file (文件)
	MoveDocsToWikiObjTypeObjTypeSlides   = "slides"   // slides（幻灯片）
)

const (
	TaskTypeMove = "move" // MoveDocsToWiki任务
)

type DepartmentId struct {
	DepartmentId *string `json:"department_id,omitempty"` //

	OpenDepartmentId *string `json:"open_department_id,omitempty"` //
}

type DepartmentIdBuilder struct {
	departmentId     string //
	departmentIdFlag bool

	openDepartmentId     string //
	openDepartmentIdFlag bool
}

func NewDepartmentIdBuilder() *DepartmentIdBuilder {
	builder := &DepartmentIdBuilder{}
	return builder
}

//
//
// 示例值：
func (builder *DepartmentIdBuilder) DepartmentId(departmentId string) *DepartmentIdBuilder {
	builder.departmentId = departmentId
	builder.departmentIdFlag = true
	return builder
}

//
//
// 示例值：
func (builder *DepartmentIdBuilder) OpenDepartmentId(openDepartmentId string) *DepartmentIdBuilder {
	builder.openDepartmentId = openDepartmentId
	builder.openDepartmentIdFlag = true
	return builder
}

func (builder *DepartmentIdBuilder) Build() *DepartmentId {
	req := &DepartmentId{}
	if builder.departmentIdFlag {
		req.DepartmentId = &builder.departmentId

	}
	if builder.openDepartmentIdFlag {
		req.OpenDepartmentId = &builder.openDepartmentId

	}
	return req
}

type Member struct {
	MemberType *string `json:"member_type,omitempty"` // “openchat” - 群id ;;“userid” - 用户id;;“email” - 邮箱;;“opendepartmentid” - 部门id;;“openid” - 应用openid;;“unionid” - [unionid](/:ssltoken/home/user-identity-introduction/union-id;)

	MemberId *string `json:"member_id,omitempty"` // 用户id，值的类型由上面的 member_type 参数决定

	MemberRole *string `json:"member_role,omitempty"` // 角色:;;“admin” - 管理员;;“member” - 成员

	Type *string `json:"type,omitempty"` // 知识库协作者类型
}

type MemberBuilder struct {
	memberType     string // “openchat” - 群id ;;“userid” - 用户id;;“email” - 邮箱;;“opendepartmentid” - 部门id;;“openid” - 应用openid;;“unionid” - [unionid](/:ssltoken/home/user-identity-introduction/union-id;)
	memberTypeFlag bool

	memberId     string // 用户id，值的类型由上面的 member_type 参数决定
	memberIdFlag bool

	memberRole     string // 角色:;;“admin” - 管理员;;“member” - 成员
	memberRoleFlag bool

	type_    string // 知识库协作者类型
	typeFlag bool
}

func NewMemberBuilder() *MemberBuilder {
	builder := &MemberBuilder{}
	return builder
}

// “openchat” - 群id ;;“userid” - 用户id;;“email” - 邮箱;;“opendepartmentid” - 部门id;;“openid” - 应用openid;;“unionid” - [unionid](/:ssltoken/home/user-identity-introduction/union-id;)
//
// 示例值：userid
func (builder *MemberBuilder) MemberType(memberType string) *MemberBuilder {
	builder.memberType = memberType
	builder.memberTypeFlag = true
	return builder
}

// 用户id，值的类型由上面的 member_type 参数决定
//
// 示例值：1565676577122621
func (builder *MemberBuilder) MemberId(memberId string) *MemberBuilder {
	builder.memberId = memberId
	builder.memberIdFlag = true
	return builder
}

// 角色:;;“admin” - 管理员;;“member” - 成员
//
// 示例值：admin
func (builder *MemberBuilder) MemberRole(memberRole string) *MemberBuilder {
	builder.memberRole = memberRole
	builder.memberRoleFlag = true
	return builder
}

// 知识库协作者类型
//
// 示例值：user
func (builder *MemberBuilder) Type(type_ string) *MemberBuilder {
	builder.type_ = type_
	builder.typeFlag = true
	return builder
}

func (builder *MemberBuilder) Build() *Member {
	req := &Member{}
	if builder.memberTypeFlag {
		req.MemberType = &builder.memberType

	}
	if builder.memberIdFlag {
		req.MemberId = &builder.memberId

	}
	if builder.memberRoleFlag {
		req.MemberRole = &builder.memberRole

	}
	if builder.typeFlag {
		req.Type = &builder.type_

	}
	return req
}

type MoveResult struct {
	Node *Node `json:"node,omitempty"` // 移动完成的节点信息

	Status *int `json:"status,omitempty"` // 节点移动状态码

	StatusMsg *string `json:"status_msg,omitempty"` // 节点移动状态信息
}

type MoveResultBuilder struct {
	node     *Node // 移动完成的节点信息
	nodeFlag bool

	status     int // 节点移动状态码
	statusFlag bool

	statusMsg     string // 节点移动状态信息
	statusMsgFlag bool
}

func NewMoveResultBuilder() *MoveResultBuilder {
	builder := &MoveResultBuilder{}
	return builder
}

// 移动完成的节点信息
//
// 示例值：
func (builder *MoveResultBuilder) Node(node *Node) *MoveResultBuilder {
	builder.node = node
	builder.nodeFlag = true
	return builder
}

// 节点移动状态码
//
// 示例值：0
func (builder *MoveResultBuilder) Status(status int) *MoveResultBuilder {
	builder.status = status
	builder.statusFlag = true
	return builder
}

// 节点移动状态信息
//
// 示例值：success
func (builder *MoveResultBuilder) StatusMsg(statusMsg string) *MoveResultBuilder {
	builder.statusMsg = statusMsg
	builder.statusMsgFlag = true
	return builder
}

func (builder *MoveResultBuilder) Build() *MoveResult {
	req := &MoveResult{}
	if builder.nodeFlag {
		req.Node = builder.node
	}
	if builder.statusFlag {
		req.Status = &builder.status

	}
	if builder.statusMsgFlag {
		req.StatusMsg = &builder.statusMsg

	}
	return req
}

type Node struct {
	SpaceId *string `json:"space_id,omitempty"` // 知识空间id;[获取方式](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-overview)

	NodeToken *string `json:"node_token,omitempty"` // 节点token

	ObjToken *string `json:"obj_token,omitempty"` // 对应文档类型的token，可根据 obj_type 判断属于哪种文档类型。

	ObjType *string `json:"obj_type,omitempty"` // 文档类型，对于快捷方式，该字段是对应的实体的obj_type。

	ParentNodeToken *string `json:"parent_node_token,omitempty"` // 父节点 token。若当前节点为一级节点，父节点 token 为空。

	NodeType *string `json:"node_type,omitempty"` // 节点类型

	OriginNodeToken *string `json:"origin_node_token,omitempty"` // 快捷方式对应的实体node_token，当节点为快捷方式时，该值不为空。

	OriginSpaceId *string `json:"origin_space_id,omitempty"` // 快捷方式对应的实体所在的space id

	HasChild *bool `json:"has_child,omitempty"` // 是否有子节点

	Title *string `json:"title,omitempty"` // 文档标题

	ObjCreateTime *string `json:"obj_create_time,omitempty"` // 文档创建时间

	ObjEditTime *string `json:"obj_edit_time,omitempty"` // 文档最近编辑时间

	NodeCreateTime *string `json:"node_create_time,omitempty"` // 节点创建时间

	Creator *string `json:"creator,omitempty"` // 节点创建者

	Owner *string `json:"owner,omitempty"` // 节点所有者

	NodeCreator *string `json:"node_creator,omitempty"` // 节点创建者
}

type NodeBuilder struct {
	spaceId     string // 知识空间id;[获取方式](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-overview)
	spaceIdFlag bool

	nodeToken     string // 节点token
	nodeTokenFlag bool

	objToken     string // 对应文档类型的token，可根据 obj_type 判断属于哪种文档类型。
	objTokenFlag bool

	objType     string // 文档类型，对于快捷方式，该字段是对应的实体的obj_type。
	objTypeFlag bool

	parentNodeToken     string // 父节点 token。若当前节点为一级节点，父节点 token 为空。
	parentNodeTokenFlag bool

	nodeType     string // 节点类型
	nodeTypeFlag bool

	originNodeToken     string // 快捷方式对应的实体node_token，当节点为快捷方式时，该值不为空。
	originNodeTokenFlag bool

	originSpaceId     string // 快捷方式对应的实体所在的space id
	originSpaceIdFlag bool

	hasChild     bool // 是否有子节点
	hasChildFlag bool

	title     string // 文档标题
	titleFlag bool

	objCreateTime     string // 文档创建时间
	objCreateTimeFlag bool

	objEditTime     string // 文档最近编辑时间
	objEditTimeFlag bool

	nodeCreateTime     string // 节点创建时间
	nodeCreateTimeFlag bool

	creator     string // 节点创建者
	creatorFlag bool

	owner     string // 节点所有者
	ownerFlag bool

	nodeCreator     string // 节点创建者
	nodeCreatorFlag bool
}

func NewNodeBuilder() *NodeBuilder {
	builder := &NodeBuilder{}
	return builder
}

// 知识空间id;[获取方式](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-overview)
//
// 示例值：6946843325487912356
func (builder *NodeBuilder) SpaceId(spaceId string) *NodeBuilder {
	builder.spaceId = spaceId
	builder.spaceIdFlag = true
	return builder
}

// 节点token
//
// 示例值：wikcnKQ1k3p******8Vabcef
func (builder *NodeBuilder) NodeToken(nodeToken string) *NodeBuilder {
	builder.nodeToken = nodeToken
	builder.nodeTokenFlag = true
	return builder
}

// 对应文档类型的token，可根据 obj_type 判断属于哪种文档类型。
//
// 示例值：doccnzAaOD******Wabcdef
func (builder *NodeBuilder) ObjToken(objToken string) *NodeBuilder {
	builder.objToken = objToken
	builder.objTokenFlag = true
	return builder
}

// 文档类型，对于快捷方式，该字段是对应的实体的obj_type。
//
// 示例值：doc
func (builder *NodeBuilder) ObjType(objType string) *NodeBuilder {
	builder.objType = objType
	builder.objTypeFlag = true
	return builder
}

// 父节点 token。若当前节点为一级节点，父节点 token 为空。
//
// 示例值：wikcnKQ1k3p******8Vabcef
func (builder *NodeBuilder) ParentNodeToken(parentNodeToken string) *NodeBuilder {
	builder.parentNodeToken = parentNodeToken
	builder.parentNodeTokenFlag = true
	return builder
}

// 节点类型
//
// 示例值：origin
func (builder *NodeBuilder) NodeType(nodeType string) *NodeBuilder {
	builder.nodeType = nodeType
	builder.nodeTypeFlag = true
	return builder
}

// 快捷方式对应的实体node_token，当节点为快捷方式时，该值不为空。
//
// 示例值：wikcnKQ1k3p******8Vabcef
func (builder *NodeBuilder) OriginNodeToken(originNodeToken string) *NodeBuilder {
	builder.originNodeToken = originNodeToken
	builder.originNodeTokenFlag = true
	return builder
}

// 快捷方式对应的实体所在的space id
//
// 示例值：6946843325487912356
func (builder *NodeBuilder) OriginSpaceId(originSpaceId string) *NodeBuilder {
	builder.originSpaceId = originSpaceId
	builder.originSpaceIdFlag = true
	return builder
}

// 是否有子节点
//
// 示例值：false
func (builder *NodeBuilder) HasChild(hasChild bool) *NodeBuilder {
	builder.hasChild = hasChild
	builder.hasChildFlag = true
	return builder
}

// 文档标题
//
// 示例值：标题
func (builder *NodeBuilder) Title(title string) *NodeBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

// 文档创建时间
//
// 示例值：1642402428
func (builder *NodeBuilder) ObjCreateTime(objCreateTime string) *NodeBuilder {
	builder.objCreateTime = objCreateTime
	builder.objCreateTimeFlag = true
	return builder
}

// 文档最近编辑时间
//
// 示例值：1642402428
func (builder *NodeBuilder) ObjEditTime(objEditTime string) *NodeBuilder {
	builder.objEditTime = objEditTime
	builder.objEditTimeFlag = true
	return builder
}

// 节点创建时间
//
// 示例值：1642402428
func (builder *NodeBuilder) NodeCreateTime(nodeCreateTime string) *NodeBuilder {
	builder.nodeCreateTime = nodeCreateTime
	builder.nodeCreateTimeFlag = true
	return builder
}

// 节点创建者
//
// 示例值：ou_xxxxx
func (builder *NodeBuilder) Creator(creator string) *NodeBuilder {
	builder.creator = creator
	builder.creatorFlag = true
	return builder
}

// 节点所有者
//
// 示例值：ou_xxxxx
func (builder *NodeBuilder) Owner(owner string) *NodeBuilder {
	builder.owner = owner
	builder.ownerFlag = true
	return builder
}

// 节点创建者
//
// 示例值：ou_xxxxx
func (builder *NodeBuilder) NodeCreator(nodeCreator string) *NodeBuilder {
	builder.nodeCreator = nodeCreator
	builder.nodeCreatorFlag = true
	return builder
}

func (builder *NodeBuilder) Build() *Node {
	req := &Node{}
	if builder.spaceIdFlag {
		req.SpaceId = &builder.spaceId

	}
	if builder.nodeTokenFlag {
		req.NodeToken = &builder.nodeToken

	}
	if builder.objTokenFlag {
		req.ObjToken = &builder.objToken

	}
	if builder.objTypeFlag {
		req.ObjType = &builder.objType

	}
	if builder.parentNodeTokenFlag {
		req.ParentNodeToken = &builder.parentNodeToken

	}
	if builder.nodeTypeFlag {
		req.NodeType = &builder.nodeType

	}
	if builder.originNodeTokenFlag {
		req.OriginNodeToken = &builder.originNodeToken

	}
	if builder.originSpaceIdFlag {
		req.OriginSpaceId = &builder.originSpaceId

	}
	if builder.hasChildFlag {
		req.HasChild = &builder.hasChild

	}
	if builder.titleFlag {
		req.Title = &builder.title

	}
	if builder.objCreateTimeFlag {
		req.ObjCreateTime = &builder.objCreateTime

	}
	if builder.objEditTimeFlag {
		req.ObjEditTime = &builder.objEditTime

	}
	if builder.nodeCreateTimeFlag {
		req.NodeCreateTime = &builder.nodeCreateTime

	}
	if builder.creatorFlag {
		req.Creator = &builder.creator

	}
	if builder.ownerFlag {
		req.Owner = &builder.owner

	}
	if builder.nodeCreatorFlag {
		req.NodeCreator = &builder.nodeCreator

	}
	return req
}

type NodeSearch struct {
	NodeId *string `json:"node_id,omitempty"` // node的唯一标识

	SpaceId *string `json:"space_id,omitempty"` // 所属空间id

	ParentId *string `json:"parent_id,omitempty"` // 父节点id

	ObjType *int `json:"obj_type,omitempty"` // wiki类型

	Title *string `json:"title,omitempty"` // wiki标题

	Url *string `json:"url,omitempty"` // wiki的访问url

	Icon *string `json:"icon,omitempty"` // wiki对应图标的url

	AreaId *string `json:"area_id,omitempty"` // 所属权限范围id

	SortId *float64 `json:"sort_id,omitempty"` // 序号

	Domain *string `json:"domain,omitempty"` // 所在域名

	ObjToken *string `json:"obj_token,omitempty"` // objToken
}

type NodeSearchBuilder struct {
	nodeId     string // node的唯一标识
	nodeIdFlag bool

	spaceId     string // 所属空间id
	spaceIdFlag bool

	parentId     string // 父节点id
	parentIdFlag bool

	objType     int // wiki类型
	objTypeFlag bool

	title     string // wiki标题
	titleFlag bool

	url     string // wiki的访问url
	urlFlag bool

	icon     string // wiki对应图标的url
	iconFlag bool

	areaId     string // 所属权限范围id
	areaIdFlag bool

	sortId     float64 // 序号
	sortIdFlag bool

	domain     string // 所在域名
	domainFlag bool

	objToken     string // objToken
	objTokenFlag bool
}

func NewNodeSearchBuilder() *NodeSearchBuilder {
	builder := &NodeSearchBuilder{}
	return builder
}

// node的唯一标识
//
// 示例值：wikbcIbccBl4Mik9GQ2KskO6hsf
func (builder *NodeSearchBuilder) NodeId(nodeId string) *NodeSearchBuilder {
	builder.nodeId = nodeId
	builder.nodeIdFlag = true
	return builder
}

// 所属空间id
//
// 示例值：7067522558521770004
func (builder *NodeSearchBuilder) SpaceId(spaceId string) *NodeSearchBuilder {
	builder.spaceId = spaceId
	builder.spaceIdFlag = true
	return builder
}

// 父节点id
//
// 示例值：7067522558521772323
func (builder *NodeSearchBuilder) ParentId(parentId string) *NodeSearchBuilder {
	builder.parentId = parentId
	builder.parentIdFlag = true
	return builder
}

// wiki类型
//
// 示例值：1
func (builder *NodeSearchBuilder) ObjType(objType int) *NodeSearchBuilder {
	builder.objType = objType
	builder.objTypeFlag = true
	return builder
}

// wiki标题
//
// 示例值：文档标题
func (builder *NodeSearchBuilder) Title(title string) *NodeSearchBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

// wiki的访问url
//
// 示例值：https://example.feishu.cn/wiki
func (builder *NodeSearchBuilder) Url(url string) *NodeSearchBuilder {
	builder.url = url
	builder.urlFlag = true
	return builder
}

// wiki对应图标的url
//
// 示例值：https://example.feishu.cn/icon
func (builder *NodeSearchBuilder) Icon(icon string) *NodeSearchBuilder {
	builder.icon = icon
	builder.iconFlag = true
	return builder
}

// 所属权限范围id
//
// 示例值：7067522558521772323
func (builder *NodeSearchBuilder) AreaId(areaId string) *NodeSearchBuilder {
	builder.areaId = areaId
	builder.areaIdFlag = true
	return builder
}

// 序号
//
// 示例值：1
func (builder *NodeSearchBuilder) SortId(sortId float64) *NodeSearchBuilder {
	builder.sortId = sortId
	builder.sortIdFlag = true
	return builder
}

// 所在域名
//
// 示例值：example.feishu.cn
func (builder *NodeSearchBuilder) Domain(domain string) *NodeSearchBuilder {
	builder.domain = domain
	builder.domainFlag = true
	return builder
}

// objToken
//
// 示例值：doxbcBBOM3vQxO5NztUhKpTBNQd
func (builder *NodeSearchBuilder) ObjToken(objToken string) *NodeSearchBuilder {
	builder.objToken = objToken
	builder.objTokenFlag = true
	return builder
}

func (builder *NodeSearchBuilder) Build() *NodeSearch {
	req := &NodeSearch{}
	if builder.nodeIdFlag {
		req.NodeId = &builder.nodeId

	}
	if builder.spaceIdFlag {
		req.SpaceId = &builder.spaceId

	}
	if builder.parentIdFlag {
		req.ParentId = &builder.parentId

	}
	if builder.objTypeFlag {
		req.ObjType = &builder.objType

	}
	if builder.titleFlag {
		req.Title = &builder.title

	}
	if builder.urlFlag {
		req.Url = &builder.url

	}
	if builder.iconFlag {
		req.Icon = &builder.icon

	}
	if builder.areaIdFlag {
		req.AreaId = &builder.areaId

	}
	if builder.sortIdFlag {
		req.SortId = &builder.sortId

	}
	if builder.domainFlag {
		req.Domain = &builder.domain

	}
	if builder.objTokenFlag {
		req.ObjToken = &builder.objToken

	}
	return req
}

type Setting struct {
	CreateSetting *string `json:"create_setting,omitempty"` // 谁可以创建空间的一级页面： "admin_and_member" = 管理员和成员 "admin"  - 仅管理员

	SecuritySetting *string `json:"security_setting,omitempty"` // 可阅读用户可否创建副本/打印/导出/复制： "allow" - 允许 "not_allow" - 不允许

	CommentSetting *string `json:"comment_setting,omitempty"` // 可阅读用户可否评论： "allow" - 允许 "not_allow" - 不允许
}

type SettingBuilder struct {
	createSetting     string // 谁可以创建空间的一级页面： "admin_and_member" = 管理员和成员 "admin"  - 仅管理员
	createSettingFlag bool

	securitySetting     string // 可阅读用户可否创建副本/打印/导出/复制： "allow" - 允许 "not_allow" - 不允许
	securitySettingFlag bool

	commentSetting     string // 可阅读用户可否评论： "allow" - 允许 "not_allow" - 不允许
	commentSettingFlag bool
}

func NewSettingBuilder() *SettingBuilder {
	builder := &SettingBuilder{}
	return builder
}

// 谁可以创建空间的一级页面： "admin_and_member" = 管理员和成员 "admin"  - 仅管理员
//
// 示例值：admin/admin_and_member
func (builder *SettingBuilder) CreateSetting(createSetting string) *SettingBuilder {
	builder.createSetting = createSetting
	builder.createSettingFlag = true
	return builder
}

// 可阅读用户可否创建副本/打印/导出/复制： "allow" - 允许 "not_allow" - 不允许
//
// 示例值：allow/not_allow
func (builder *SettingBuilder) SecuritySetting(securitySetting string) *SettingBuilder {
	builder.securitySetting = securitySetting
	builder.securitySettingFlag = true
	return builder
}

// 可阅读用户可否评论： "allow" - 允许 "not_allow" - 不允许
//
// 示例值：allow/not_allow
func (builder *SettingBuilder) CommentSetting(commentSetting string) *SettingBuilder {
	builder.commentSetting = commentSetting
	builder.commentSettingFlag = true
	return builder
}

func (builder *SettingBuilder) Build() *Setting {
	req := &Setting{}
	if builder.createSettingFlag {
		req.CreateSetting = &builder.createSetting

	}
	if builder.securitySettingFlag {
		req.SecuritySetting = &builder.securitySetting

	}
	if builder.commentSettingFlag {
		req.CommentSetting = &builder.commentSetting

	}
	return req
}

type Space struct {
	Name *string `json:"name,omitempty"` // 知识空间名称

	Description *string `json:"description,omitempty"` // 知识空间描述

	SpaceId *string `json:"space_id,omitempty"` // 知识空间id

	SpaceType *string `json:"space_type,omitempty"` // 表示知识空间类型（团队空间 或 个人空间）

	Visibility *string `json:"visibility,omitempty"` // 表示知识空间可见性（公开空间 或 私有空间）

	OpenSharing *string `json:"open_sharing,omitempty"` // 表示知识空间的分享状态
}

type SpaceBuilder struct {
	name     string // 知识空间名称
	nameFlag bool

	description     string // 知识空间描述
	descriptionFlag bool

	spaceId     string // 知识空间id
	spaceIdFlag bool

	spaceType     string // 表示知识空间类型（团队空间 或 个人空间）
	spaceTypeFlag bool

	visibility     string // 表示知识空间可见性（公开空间 或 私有空间）
	visibilityFlag bool

	openSharing     string // 表示知识空间的分享状态
	openSharingFlag bool
}

func NewSpaceBuilder() *SpaceBuilder {
	builder := &SpaceBuilder{}
	return builder
}

// 知识空间名称
//
// 示例值：知识空间
func (builder *SpaceBuilder) Name(name string) *SpaceBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

// 知识空间描述
//
// 示例值：知识空间描述
func (builder *SpaceBuilder) Description(description string) *SpaceBuilder {
	builder.description = description
	builder.descriptionFlag = true
	return builder
}

// 知识空间id
//
// 示例值：6946843325487456878
func (builder *SpaceBuilder) SpaceId(spaceId string) *SpaceBuilder {
	builder.spaceId = spaceId
	builder.spaceIdFlag = true
	return builder
}

// 表示知识空间类型（团队空间 或 个人空间）
//
// 示例值：team
func (builder *SpaceBuilder) SpaceType(spaceType string) *SpaceBuilder {
	builder.spaceType = spaceType
	builder.spaceTypeFlag = true
	return builder
}

// 表示知识空间可见性（公开空间 或 私有空间）
//
// 示例值：private
func (builder *SpaceBuilder) Visibility(visibility string) *SpaceBuilder {
	builder.visibility = visibility
	builder.visibilityFlag = true
	return builder
}

// 表示知识空间的分享状态
//
// 示例值：open
func (builder *SpaceBuilder) OpenSharing(openSharing string) *SpaceBuilder {
	builder.openSharing = openSharing
	builder.openSharingFlag = true
	return builder
}

func (builder *SpaceBuilder) Build() *Space {
	req := &Space{}
	if builder.nameFlag {
		req.Name = &builder.name

	}
	if builder.descriptionFlag {
		req.Description = &builder.description

	}
	if builder.spaceIdFlag {
		req.SpaceId = &builder.spaceId

	}
	if builder.spaceTypeFlag {
		req.SpaceType = &builder.spaceType

	}
	if builder.visibilityFlag {
		req.Visibility = &builder.visibility

	}
	if builder.openSharingFlag {
		req.OpenSharing = &builder.openSharing

	}
	return req
}

type TaskResult struct {
	TaskId *string `json:"task_id,omitempty"` // 任务id

	MoveResult []*MoveResult `json:"move_result,omitempty"` // [移动云空间文档至知识空间](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/move_docs_to_wiki)任务结果
}

type TaskResultBuilder struct {
	taskId     string // 任务id
	taskIdFlag bool

	moveResult     []*MoveResult // [移动云空间文档至知识空间](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/move_docs_to_wiki)任务结果
	moveResultFlag bool
}

func NewTaskResultBuilder() *TaskResultBuilder {
	builder := &TaskResultBuilder{}
	return builder
}

// 任务id
//
// 示例值：7037044037068177428-075c9481e6a0007c1df689dfbe5b55a08b6b06f7
func (builder *TaskResultBuilder) TaskId(taskId string) *TaskResultBuilder {
	builder.taskId = taskId
	builder.taskIdFlag = true
	return builder
}

// [移动云空间文档至知识空间](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-v2/space-node/move_docs_to_wiki)任务结果
//
// 示例值：
func (builder *TaskResultBuilder) MoveResult(moveResult []*MoveResult) *TaskResultBuilder {
	builder.moveResult = moveResult
	builder.moveResultFlag = true
	return builder
}

func (builder *TaskResultBuilder) Build() *TaskResult {
	req := &TaskResult{}
	if builder.taskIdFlag {
		req.TaskId = &builder.taskId

	}
	if builder.moveResultFlag {
		req.MoveResult = builder.moveResult
	}
	return req
}

type CreateSpaceReqBuilder struct {
	apiReq *larkcore.ApiReq
	space  *Space
}

func NewCreateSpaceReqBuilder() *CreateSpaceReqBuilder {
	builder := &CreateSpaceReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 此接口用于创建知识空间
func (builder *CreateSpaceReqBuilder) Space(space *Space) *CreateSpaceReqBuilder {
	builder.space = space
	return builder
}

func (builder *CreateSpaceReqBuilder) Build() *CreateSpaceReq {
	req := &CreateSpaceReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.Body = builder.space
	return req
}

type CreateSpaceReq struct {
	apiReq *larkcore.ApiReq
	Space  *Space `body:""`
}

type CreateSpaceRespData struct {
	Space *Space `json:"space,omitempty"` // 知识空间
}

type CreateSpaceResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *CreateSpaceRespData `json:"data"` // 业务数据
}

func (resp *CreateSpaceResp) Success() bool {
	return resp.Code == 0
}

type GetSpaceReqBuilder struct {
	apiReq *larkcore.ApiReq
}

func NewGetSpaceReqBuilder() *GetSpaceReqBuilder {
	builder := &GetSpaceReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id
//
// 示例值：6870403571079249922
func (builder *GetSpaceReqBuilder) SpaceId(spaceId string) *GetSpaceReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 当查询个人文档库时，指定返回的文档库名称展示语言。可选值有：zh, id, de, en, es, fr, it, pt, vi, ru, hi, th, ko, ja, zh-HK, zh-TW。
//
// 示例值：zh
func (builder *GetSpaceReqBuilder) Lang(lang string) *GetSpaceReqBuilder {
	builder.apiReq.QueryParams.Set("lang", fmt.Sprint(lang))
	return builder
}

func (builder *GetSpaceReqBuilder) Build() *GetSpaceReq {
	req := &GetSpaceReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type GetSpaceReq struct {
	apiReq *larkcore.ApiReq
}

type GetSpaceRespData struct {
	Space *Space `json:"space,omitempty"` // 知识空间
}

type GetSpaceResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *GetSpaceRespData `json:"data"` // 业务数据
}

func (resp *GetSpaceResp) Success() bool {
	return resp.Code == 0
}

type GetNodeSpaceReqBuilder struct {
	apiReq *larkcore.ApiReq
}

func NewGetNodeSpaceReqBuilder() *GetNodeSpaceReqBuilder {
	builder := &GetNodeSpaceReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 文档的节点token
//
// 示例值：wikcnKQ1k3p******8Vabcef
func (builder *GetNodeSpaceReqBuilder) Token(token string) *GetNodeSpaceReqBuilder {
	builder.apiReq.QueryParams.Set("token", fmt.Sprint(token))
	return builder
}

// 文档类型
//
// 示例值：docx
func (builder *GetNodeSpaceReqBuilder) ObjType(objType string) *GetNodeSpaceReqBuilder {
	builder.apiReq.QueryParams.Set("obj_type", fmt.Sprint(objType))
	return builder
}

func (builder *GetNodeSpaceReqBuilder) Build() *GetNodeSpaceReq {
	req := &GetNodeSpaceReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type GetNodeSpaceReq struct {
	apiReq *larkcore.ApiReq
}

type GetNodeSpaceRespData struct {
	Node *Node `json:"node,omitempty"` // 节点信息
}

type GetNodeSpaceResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *GetNodeSpaceRespData `json:"data"` // 业务数据
}

func (resp *GetNodeSpaceResp) Success() bool {
	return resp.Code == 0
}

type ListSpaceReqBuilder struct {
	apiReq *larkcore.ApiReq
	limit  int // 最大返回多少记录，当使用迭代器访问时才有效
}

func NewListSpaceReqBuilder() *ListSpaceReqBuilder {
	builder := &ListSpaceReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 最大返回多少记录，当使用迭代器访问时才有效
func (builder *ListSpaceReqBuilder) Limit(limit int) *ListSpaceReqBuilder {
	builder.limit = limit
	return builder
}

// 分页大小
//
// 示例值：10
func (builder *ListSpaceReqBuilder) PageSize(pageSize int) *ListSpaceReqBuilder {
	builder.apiReq.QueryParams.Set("page_size", fmt.Sprint(pageSize))
	return builder
}

// 分页标记，第一次请求不填，表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token，下次遍历可采用该 page_token 获取查询结果
//
// 示例值：1565676577122621
func (builder *ListSpaceReqBuilder) PageToken(pageToken string) *ListSpaceReqBuilder {
	builder.apiReq.QueryParams.Set("page_token", fmt.Sprint(pageToken))
	return builder
}

func (builder *ListSpaceReqBuilder) Build() *ListSpaceReq {
	req := &ListSpaceReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.Limit = builder.limit
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type ListSpaceReq struct {
	apiReq *larkcore.ApiReq
	Limit  int // 最多返回多少记录，只有在使用迭代器访问时，才有效

}

type ListSpaceRespData struct {
	Items []*Space `json:"items,omitempty"` // 数据列表

	PageToken *string `json:"page_token,omitempty"` // 分页标记，当 has_more 为 true 时，会同时返回新的 page_token，否则不返回 page_token

	HasMore *bool `json:"has_more,omitempty"` // 是否还有更多项
}

type ListSpaceResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *ListSpaceRespData `json:"data"` // 业务数据
}

func (resp *ListSpaceResp) Success() bool {
	return resp.Code == 0
}

type CreateSpaceMemberReqBuilder struct {
	apiReq *larkcore.ApiReq
	member *Member
}

func NewCreateSpaceMemberReqBuilder() *CreateSpaceMemberReqBuilder {
	builder := &CreateSpaceMemberReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id
//
// 示例值：1565676577122621
func (builder *CreateSpaceMemberReqBuilder) SpaceId(spaceId string) *CreateSpaceMemberReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 添加权限后是否通知对方
//
// 示例值：true
func (builder *CreateSpaceMemberReqBuilder) NeedNotification(needNotification bool) *CreateSpaceMemberReqBuilder {
	builder.apiReq.QueryParams.Set("need_notification", fmt.Sprint(needNotification))
	return builder
}

// 添加知识空间成员或管理员。
func (builder *CreateSpaceMemberReqBuilder) Member(member *Member) *CreateSpaceMemberReqBuilder {
	builder.member = member
	return builder
}

func (builder *CreateSpaceMemberReqBuilder) Build() *CreateSpaceMemberReq {
	req := &CreateSpaceMemberReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	req.apiReq.Body = builder.member
	return req
}

type CreateSpaceMemberReq struct {
	apiReq *larkcore.ApiReq
	Member *Member `body:""`
}

type CreateSpaceMemberRespData struct {
	Member *Member `json:"member,omitempty"` // 知识空间成员
}

type CreateSpaceMemberResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *CreateSpaceMemberRespData `json:"data"` // 业务数据
}

func (resp *CreateSpaceMemberResp) Success() bool {
	return resp.Code == 0
}

type DeleteSpaceMemberReqBuilder struct {
	apiReq *larkcore.ApiReq
	member *Member
}

func NewDeleteSpaceMemberReqBuilder() *DeleteSpaceMemberReqBuilder {
	builder := &DeleteSpaceMemberReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id
//
// 示例值：7008061636015554580
func (builder *DeleteSpaceMemberReqBuilder) SpaceId(spaceId string) *DeleteSpaceMemberReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 成员id，值的类型由请求体的 member_type 参数决定
//
// 示例值：g64fb7g7
func (builder *DeleteSpaceMemberReqBuilder) MemberId(memberId string) *DeleteSpaceMemberReqBuilder {
	builder.apiReq.PathParams.Set("member_id", fmt.Sprint(memberId))
	return builder
}

// 此接口用于删除知识空间成员或管理员。
func (builder *DeleteSpaceMemberReqBuilder) Member(member *Member) *DeleteSpaceMemberReqBuilder {
	builder.member = member
	return builder
}

func (builder *DeleteSpaceMemberReqBuilder) Build() *DeleteSpaceMemberReq {
	req := &DeleteSpaceMemberReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.member
	return req
}

type DeleteSpaceMemberReq struct {
	apiReq *larkcore.ApiReq
	Member *Member `body:""`
}

type DeleteSpaceMemberRespData struct {
	Member *Member `json:"member,omitempty"` // 成员信息
}

type DeleteSpaceMemberResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *DeleteSpaceMemberRespData `json:"data"` // 业务数据
}

func (resp *DeleteSpaceMemberResp) Success() bool {
	return resp.Code == 0
}

type ListSpaceMemberReqBuilder struct {
	apiReq *larkcore.ApiReq
}

func NewListSpaceMemberReqBuilder() *ListSpaceMemberReqBuilder {
	builder := &ListSpaceMemberReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id
//
// 示例值：7375263209671884820
func (builder *ListSpaceMemberReqBuilder) SpaceId(spaceId string) *ListSpaceMemberReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 分页大小
//
// 示例值：1
func (builder *ListSpaceMemberReqBuilder) PageSize(pageSize int) *ListSpaceMemberReqBuilder {
	builder.apiReq.QueryParams.Set("page_size", fmt.Sprint(pageSize))
	return builder
}

// 分页标记，第一次请求不填，表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token，下次遍历可采用该 page_token 获取查询结果
//
// 示例值：ou_12345
func (builder *ListSpaceMemberReqBuilder) PageToken(pageToken string) *ListSpaceMemberReqBuilder {
	builder.apiReq.QueryParams.Set("page_token", fmt.Sprint(pageToken))
	return builder
}

func (builder *ListSpaceMemberReqBuilder) Build() *ListSpaceMemberReq {
	req := &ListSpaceMemberReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type ListSpaceMemberReq struct {
	apiReq *larkcore.ApiReq
}

type ListSpaceMemberRespData struct {
	Members []*Member `json:"members,omitempty"` // 空间成员列表

	PageToken *string `json:"page_token,omitempty"` // 分页标记

	HasMore *bool `json:"has_more,omitempty"` // 是否有下一页
}

type ListSpaceMemberResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *ListSpaceMemberRespData `json:"data"` // 业务数据
}

func (resp *ListSpaceMemberResp) Success() bool {
	return resp.Code == 0
}

type CopySpaceNodeReqBodyBuilder struct {
	targetParentToken     string // 目标父节点token
	targetParentTokenFlag bool

	targetSpaceId     string // 目标知识空间id
	targetSpaceIdFlag bool

	title     string // 复制后的新标题。如果填空，则新标题为空。如果不填，则使用原节点标题。
	titleFlag bool
}

func NewCopySpaceNodeReqBodyBuilder() *CopySpaceNodeReqBodyBuilder {
	builder := &CopySpaceNodeReqBodyBuilder{}
	return builder
}

// 目标父节点token
//
//示例值：wikcnKQ1k3p******8Vabce
func (builder *CopySpaceNodeReqBodyBuilder) TargetParentToken(targetParentToken string) *CopySpaceNodeReqBodyBuilder {
	builder.targetParentToken = targetParentToken
	builder.targetParentTokenFlag = true
	return builder
}

// 目标知识空间id
//
//示例值：6946843325487912356
func (builder *CopySpaceNodeReqBodyBuilder) TargetSpaceId(targetSpaceId string) *CopySpaceNodeReqBodyBuilder {
	builder.targetSpaceId = targetSpaceId
	builder.targetSpaceIdFlag = true
	return builder
}

// 复制后的新标题。如果填空，则新标题为空。如果不填，则使用原节点标题。
//
//示例值：新标题。
func (builder *CopySpaceNodeReqBodyBuilder) Title(title string) *CopySpaceNodeReqBodyBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

func (builder *CopySpaceNodeReqBodyBuilder) Build() *CopySpaceNodeReqBody {
	req := &CopySpaceNodeReqBody{}
	if builder.targetParentTokenFlag {
		req.TargetParentToken = &builder.targetParentToken
	}
	if builder.targetSpaceIdFlag {
		req.TargetSpaceId = &builder.targetSpaceId
	}
	if builder.titleFlag {
		req.Title = &builder.title
	}
	return req
}

type CopySpaceNodePathReqBodyBuilder struct {
	targetParentToken     string
	targetParentTokenFlag bool
	targetSpaceId         string
	targetSpaceIdFlag     bool
	title                 string
	titleFlag             bool
}

func NewCopySpaceNodePathReqBodyBuilder() *CopySpaceNodePathReqBodyBuilder {
	builder := &CopySpaceNodePathReqBodyBuilder{}
	return builder
}

// 目标父节点token
//
// 示例值：wikcnKQ1k3p******8Vabce
func (builder *CopySpaceNodePathReqBodyBuilder) TargetParentToken(targetParentToken string) *CopySpaceNodePathReqBodyBuilder {
	builder.targetParentToken = targetParentToken
	builder.targetParentTokenFlag = true
	return builder
}

// 目标知识空间id
//
// 示例值：6946843325487912356
func (builder *CopySpaceNodePathReqBodyBuilder) TargetSpaceId(targetSpaceId string) *CopySpaceNodePathReqBodyBuilder {
	builder.targetSpaceId = targetSpaceId
	builder.targetSpaceIdFlag = true
	return builder
}

// 复制后的新标题。如果填空，则新标题为空。如果不填，则使用原节点标题。
//
// 示例值：新标题。
func (builder *CopySpaceNodePathReqBodyBuilder) Title(title string) *CopySpaceNodePathReqBodyBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

func (builder *CopySpaceNodePathReqBodyBuilder) Build() (*CopySpaceNodeReqBody, error) {
	req := &CopySpaceNodeReqBody{}
	if builder.targetParentTokenFlag {
		req.TargetParentToken = &builder.targetParentToken
	}
	if builder.targetSpaceIdFlag {
		req.TargetSpaceId = &builder.targetSpaceId
	}
	if builder.titleFlag {
		req.Title = &builder.title
	}
	return req, nil
}

type CopySpaceNodeReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *CopySpaceNodeReqBody
}

func NewCopySpaceNodeReqBuilder() *CopySpaceNodeReqBuilder {
	builder := &CopySpaceNodeReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id
//
// 示例值：6946843325487912356
func (builder *CopySpaceNodeReqBuilder) SpaceId(spaceId string) *CopySpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 节点token
//
// 示例值：wikcnKQ1k3p******8Vabce
func (builder *CopySpaceNodeReqBuilder) NodeToken(nodeToken string) *CopySpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("node_token", fmt.Sprint(nodeToken))
	return builder
}

// 此接口用于在知识空间创建节点副本到指定位置。
func (builder *CopySpaceNodeReqBuilder) Body(body *CopySpaceNodeReqBody) *CopySpaceNodeReqBuilder {
	builder.body = body
	return builder
}

func (builder *CopySpaceNodeReqBuilder) Build() *CopySpaceNodeReq {
	req := &CopySpaceNodeReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.body
	return req
}

type CopySpaceNodeReqBody struct {
	TargetParentToken *string `json:"target_parent_token,omitempty"` // 目标父节点token

	TargetSpaceId *string `json:"target_space_id,omitempty"` // 目标知识空间id

	Title *string `json:"title,omitempty"` // 复制后的新标题。如果填空，则新标题为空。如果不填，则使用原节点标题。
}

type CopySpaceNodeReq struct {
	apiReq *larkcore.ApiReq
	Body   *CopySpaceNodeReqBody `body:""`
}

type CopySpaceNodeRespData struct {
	Node *Node `json:"node,omitempty"` // 创建副本后的新节点
}

type CopySpaceNodeResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *CopySpaceNodeRespData `json:"data"` // 业务数据
}

func (resp *CopySpaceNodeResp) Success() bool {
	return resp.Code == 0
}

type CreateSpaceNodeReqBuilder struct {
	apiReq *larkcore.ApiReq
	node   *Node
}

func NewCreateSpaceNodeReqBuilder() *CreateSpaceNodeReqBuilder {
	builder := &CreateSpaceNodeReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id;[获取方式](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-overview)
//
// 示例值：6704147935988285963
func (builder *CreateSpaceNodeReqBuilder) SpaceId(spaceId string) *CreateSpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 此接口用于在知识节点里创建[节点](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/wiki-overview)到指定位置。
func (builder *CreateSpaceNodeReqBuilder) Node(node *Node) *CreateSpaceNodeReqBuilder {
	builder.node = node
	return builder
}

func (builder *CreateSpaceNodeReqBuilder) Build() *CreateSpaceNodeReq {
	req := &CreateSpaceNodeReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.node
	return req
}

type CreateSpaceNodeReq struct {
	apiReq *larkcore.ApiReq
	Node   *Node `body:""`
}

type CreateSpaceNodeRespData struct {
	Node *Node `json:"node,omitempty"` // 节点
}

type CreateSpaceNodeResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *CreateSpaceNodeRespData `json:"data"` // 业务数据
}

func (resp *CreateSpaceNodeResp) Success() bool {
	return resp.Code == 0
}

type ListSpaceNodeReqBuilder struct {
	apiReq *larkcore.ApiReq
	limit  int // 最大返回多少记录，当使用迭代器访问时才有效
}

func NewListSpaceNodeReqBuilder() *ListSpaceNodeReqBuilder {
	builder := &ListSpaceNodeReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 最大返回多少记录，当使用迭代器访问时才有效
func (builder *ListSpaceNodeReqBuilder) Limit(limit int) *ListSpaceNodeReqBuilder {
	builder.limit = limit
	return builder
}

// 知识空间id
//
// 示例值：6946843325487906839
func (builder *ListSpaceNodeReqBuilder) SpaceId(spaceId string) *ListSpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 分页大小
//
// 示例值：10
func (builder *ListSpaceNodeReqBuilder) PageSize(pageSize int) *ListSpaceNodeReqBuilder {
	builder.apiReq.QueryParams.Set("page_size", fmt.Sprint(pageSize))
	return builder
}

// 分页标记，第一次请求不填，表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token，下次遍历可采用该 page_token 获取查询结果
//
// 示例值：6946843325487456878
func (builder *ListSpaceNodeReqBuilder) PageToken(pageToken string) *ListSpaceNodeReqBuilder {
	builder.apiReq.QueryParams.Set("page_token", fmt.Sprint(pageToken))
	return builder
}

// 父节点token
//
// 示例值：wikcnKQ1k3p******8Vabce
func (builder *ListSpaceNodeReqBuilder) ParentNodeToken(parentNodeToken string) *ListSpaceNodeReqBuilder {
	builder.apiReq.QueryParams.Set("parent_node_token", fmt.Sprint(parentNodeToken))
	return builder
}

func (builder *ListSpaceNodeReqBuilder) Build() *ListSpaceNodeReq {
	req := &ListSpaceNodeReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.Limit = builder.limit
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type ListSpaceNodeReq struct {
	apiReq *larkcore.ApiReq
	Limit  int // 最多返回多少记录，只有在使用迭代器访问时，才有效

}

type ListSpaceNodeRespData struct {
	Items []*Node `json:"items,omitempty"` // 数据列表

	PageToken *string `json:"page_token,omitempty"` // 分页Token

	HasMore *bool `json:"has_more,omitempty"` // 是否还有数据
}

type ListSpaceNodeResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *ListSpaceNodeRespData `json:"data"` // 业务数据
}

func (resp *ListSpaceNodeResp) Success() bool {
	return resp.Code == 0
}

type MoveSpaceNodeReqBodyBuilder struct {
	targetParentToken     string // 移动到的父节点token
	targetParentTokenFlag bool

	targetSpaceId     string // 移动到的知识空间ID
	targetSpaceIdFlag bool
}

func NewMoveSpaceNodeReqBodyBuilder() *MoveSpaceNodeReqBodyBuilder {
	builder := &MoveSpaceNodeReqBodyBuilder{}
	return builder
}

// 移动到的父节点token
//
//示例值：wikbcd6ydSUyOEzbdlt1BfpA5Yc
func (builder *MoveSpaceNodeReqBodyBuilder) TargetParentToken(targetParentToken string) *MoveSpaceNodeReqBodyBuilder {
	builder.targetParentToken = targetParentToken
	builder.targetParentTokenFlag = true
	return builder
}

// 移动到的知识空间ID
//
//示例值：7008061636015512345
func (builder *MoveSpaceNodeReqBodyBuilder) TargetSpaceId(targetSpaceId string) *MoveSpaceNodeReqBodyBuilder {
	builder.targetSpaceId = targetSpaceId
	builder.targetSpaceIdFlag = true
	return builder
}

func (builder *MoveSpaceNodeReqBodyBuilder) Build() *MoveSpaceNodeReqBody {
	req := &MoveSpaceNodeReqBody{}
	if builder.targetParentTokenFlag {
		req.TargetParentToken = &builder.targetParentToken
	}
	if builder.targetSpaceIdFlag {
		req.TargetSpaceId = &builder.targetSpaceId
	}
	return req
}

type MoveSpaceNodePathReqBodyBuilder struct {
	targetParentToken     string
	targetParentTokenFlag bool
	targetSpaceId         string
	targetSpaceIdFlag     bool
}

func NewMoveSpaceNodePathReqBodyBuilder() *MoveSpaceNodePathReqBodyBuilder {
	builder := &MoveSpaceNodePathReqBodyBuilder{}
	return builder
}

// 移动到的父节点token
//
// 示例值：wikbcd6ydSUyOEzbdlt1BfpA5Yc
func (builder *MoveSpaceNodePathReqBodyBuilder) TargetParentToken(targetParentToken string) *MoveSpaceNodePathReqBodyBuilder {
	builder.targetParentToken = targetParentToken
	builder.targetParentTokenFlag = true
	return builder
}

// 移动到的知识空间ID
//
// 示例值：7008061636015512345
func (builder *MoveSpaceNodePathReqBodyBuilder) TargetSpaceId(targetSpaceId string) *MoveSpaceNodePathReqBodyBuilder {
	builder.targetSpaceId = targetSpaceId
	builder.targetSpaceIdFlag = true
	return builder
}

func (builder *MoveSpaceNodePathReqBodyBuilder) Build() (*MoveSpaceNodeReqBody, error) {
	req := &MoveSpaceNodeReqBody{}
	if builder.targetParentTokenFlag {
		req.TargetParentToken = &builder.targetParentToken
	}
	if builder.targetSpaceIdFlag {
		req.TargetSpaceId = &builder.targetSpaceId
	}
	return req, nil
}

type MoveSpaceNodeReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *MoveSpaceNodeReqBody
}

func NewMoveSpaceNodeReqBuilder() *MoveSpaceNodeReqBuilder {
	builder := &MoveSpaceNodeReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id
//
// 示例值：7008061636015512345
func (builder *MoveSpaceNodeReqBuilder) SpaceId(spaceId string) *MoveSpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 需要迁移的节点token
//
// 示例值：wikbcd6ydSUyOEzbdlt1BfpA5Yc
func (builder *MoveSpaceNodeReqBuilder) NodeToken(nodeToken string) *MoveSpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("node_token", fmt.Sprint(nodeToken))
	return builder
}

// 此方法用于在Wiki内移动节点，支持跨知识空间移动。如果有子节点，会携带子节点一起移动。
func (builder *MoveSpaceNodeReqBuilder) Body(body *MoveSpaceNodeReqBody) *MoveSpaceNodeReqBuilder {
	builder.body = body
	return builder
}

func (builder *MoveSpaceNodeReqBuilder) Build() *MoveSpaceNodeReq {
	req := &MoveSpaceNodeReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.body
	return req
}

type MoveSpaceNodeReqBody struct {
	TargetParentToken *string `json:"target_parent_token,omitempty"` // 移动到的父节点token

	TargetSpaceId *string `json:"target_space_id,omitempty"` // 移动到的知识空间ID
}

type MoveSpaceNodeReq struct {
	apiReq *larkcore.ApiReq
	Body   *MoveSpaceNodeReqBody `body:""`
}

type MoveSpaceNodeRespData struct {
	Node *Node `json:"node,omitempty"` // 移动后的节点信息
}

type MoveSpaceNodeResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *MoveSpaceNodeRespData `json:"data"` // 业务数据
}

func (resp *MoveSpaceNodeResp) Success() bool {
	return resp.Code == 0
}

type MoveDocsToWikiSpaceNodeReqBodyBuilder struct {
	parentWikiToken     string // 节点的父亲token。;;传空或不传时将移动为知识空间一级节点。
	parentWikiTokenFlag bool

	objType     string // 文档类型
	objTypeFlag bool

	objToken     string // 文档token
	objTokenFlag bool

	apply     bool // 没有权限时，是否申请移动文档。;;如果申请移动，文档将在处理人同意时自动移动至指定位置。
	applyFlag bool
}

func NewMoveDocsToWikiSpaceNodeReqBodyBuilder() *MoveDocsToWikiSpaceNodeReqBodyBuilder {
	builder := &MoveDocsToWikiSpaceNodeReqBodyBuilder{}
	return builder
}

// 节点的父亲token。;;传空或不传时将移动为知识空间一级节点。
//
//示例值：wikcnKQ1k3p******8Vabce
func (builder *MoveDocsToWikiSpaceNodeReqBodyBuilder) ParentWikiToken(parentWikiToken string) *MoveDocsToWikiSpaceNodeReqBodyBuilder {
	builder.parentWikiToken = parentWikiToken
	builder.parentWikiTokenFlag = true
	return builder
}

// 文档类型
//
//示例值：doc
func (builder *MoveDocsToWikiSpaceNodeReqBodyBuilder) ObjType(objType string) *MoveDocsToWikiSpaceNodeReqBodyBuilder {
	builder.objType = objType
	builder.objTypeFlag = true
	return builder
}

// 文档token
//
//示例值：doccnzAaOD******Wabcdef
func (builder *MoveDocsToWikiSpaceNodeReqBodyBuilder) ObjToken(objToken string) *MoveDocsToWikiSpaceNodeReqBodyBuilder {
	builder.objToken = objToken
	builder.objTokenFlag = true
	return builder
}

// 没有权限时，是否申请移动文档。;;如果申请移动，文档将在处理人同意时自动移动至指定位置。
//
//示例值：true
func (builder *MoveDocsToWikiSpaceNodeReqBodyBuilder) Apply(apply bool) *MoveDocsToWikiSpaceNodeReqBodyBuilder {
	builder.apply = apply
	builder.applyFlag = true
	return builder
}

func (builder *MoveDocsToWikiSpaceNodeReqBodyBuilder) Build() *MoveDocsToWikiSpaceNodeReqBody {
	req := &MoveDocsToWikiSpaceNodeReqBody{}
	if builder.parentWikiTokenFlag {
		req.ParentWikiToken = &builder.parentWikiToken
	}
	if builder.objTypeFlag {
		req.ObjType = &builder.objType
	}
	if builder.objTokenFlag {
		req.ObjToken = &builder.objToken
	}
	if builder.applyFlag {
		req.Apply = &builder.apply
	}
	return req
}

type MoveDocsToWikiSpaceNodePathReqBodyBuilder struct {
	parentWikiToken     string
	parentWikiTokenFlag bool
	objType             string
	objTypeFlag         bool
	objToken            string
	objTokenFlag        bool
	apply               bool
	applyFlag           bool
}

func NewMoveDocsToWikiSpaceNodePathReqBodyBuilder() *MoveDocsToWikiSpaceNodePathReqBodyBuilder {
	builder := &MoveDocsToWikiSpaceNodePathReqBodyBuilder{}
	return builder
}

// 节点的父亲token。;;传空或不传时将移动为知识空间一级节点。
//
// 示例值：wikcnKQ1k3p******8Vabce
func (builder *MoveDocsToWikiSpaceNodePathReqBodyBuilder) ParentWikiToken(parentWikiToken string) *MoveDocsToWikiSpaceNodePathReqBodyBuilder {
	builder.parentWikiToken = parentWikiToken
	builder.parentWikiTokenFlag = true
	return builder
}

// 文档类型
//
// 示例值：doc
func (builder *MoveDocsToWikiSpaceNodePathReqBodyBuilder) ObjType(objType string) *MoveDocsToWikiSpaceNodePathReqBodyBuilder {
	builder.objType = objType
	builder.objTypeFlag = true
	return builder
}

// 文档token
//
// 示例值：doccnzAaOD******Wabcdef
func (builder *MoveDocsToWikiSpaceNodePathReqBodyBuilder) ObjToken(objToken string) *MoveDocsToWikiSpaceNodePathReqBodyBuilder {
	builder.objToken = objToken
	builder.objTokenFlag = true
	return builder
}

// 没有权限时，是否申请移动文档。;;如果申请移动，文档将在处理人同意时自动移动至指定位置。
//
// 示例值：true
func (builder *MoveDocsToWikiSpaceNodePathReqBodyBuilder) Apply(apply bool) *MoveDocsToWikiSpaceNodePathReqBodyBuilder {
	builder.apply = apply
	builder.applyFlag = true
	return builder
}

func (builder *MoveDocsToWikiSpaceNodePathReqBodyBuilder) Build() (*MoveDocsToWikiSpaceNodeReqBody, error) {
	req := &MoveDocsToWikiSpaceNodeReqBody{}
	if builder.parentWikiTokenFlag {
		req.ParentWikiToken = &builder.parentWikiToken
	}
	if builder.objTypeFlag {
		req.ObjType = &builder.objType
	}
	if builder.objTokenFlag {
		req.ObjToken = &builder.objToken
	}
	if builder.applyFlag {
		req.Apply = &builder.apply
	}
	return req, nil
}

type MoveDocsToWikiSpaceNodeReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *MoveDocsToWikiSpaceNodeReqBody
}

func NewMoveDocsToWikiSpaceNodeReqBuilder() *MoveDocsToWikiSpaceNodeReqBuilder {
	builder := &MoveDocsToWikiSpaceNodeReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识库id
//
// 示例值：1565676577122621
func (builder *MoveDocsToWikiSpaceNodeReqBuilder) SpaceId(spaceId string) *MoveDocsToWikiSpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 该接口允许移动云空间文档至知识空间，并挂载在指定位置
func (builder *MoveDocsToWikiSpaceNodeReqBuilder) Body(body *MoveDocsToWikiSpaceNodeReqBody) *MoveDocsToWikiSpaceNodeReqBuilder {
	builder.body = body
	return builder
}

func (builder *MoveDocsToWikiSpaceNodeReqBuilder) Build() *MoveDocsToWikiSpaceNodeReq {
	req := &MoveDocsToWikiSpaceNodeReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.body
	return req
}

type MoveDocsToWikiSpaceNodeReqBody struct {
	ParentWikiToken *string `json:"parent_wiki_token,omitempty"` // 节点的父亲token。;;传空或不传时将移动为知识空间一级节点。

	ObjType *string `json:"obj_type,omitempty"` // 文档类型

	ObjToken *string `json:"obj_token,omitempty"` // 文档token

	Apply *bool `json:"apply,omitempty"` // 没有权限时，是否申请移动文档。;;如果申请移动，文档将在处理人同意时自动移动至指定位置。
}

type MoveDocsToWikiSpaceNodeReq struct {
	apiReq *larkcore.ApiReq
	Body   *MoveDocsToWikiSpaceNodeReqBody `body:""`
}

type MoveDocsToWikiSpaceNodeRespData struct {
	WikiToken *string `json:"wiki_token,omitempty"` // 移动后的知识库token

	TaskId *string `json:"task_id,omitempty"` // 任务id

	Applied *bool `json:"applied,omitempty"` // 是否提交了文档迁入申请
}

type MoveDocsToWikiSpaceNodeResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *MoveDocsToWikiSpaceNodeRespData `json:"data"` // 业务数据
}

func (resp *MoveDocsToWikiSpaceNodeResp) Success() bool {
	return resp.Code == 0
}

type UpdateTitleSpaceNodeReqBodyBuilder struct {
	title     string // 节点新标题
	titleFlag bool
}

func NewUpdateTitleSpaceNodeReqBodyBuilder() *UpdateTitleSpaceNodeReqBodyBuilder {
	builder := &UpdateTitleSpaceNodeReqBodyBuilder{}
	return builder
}

// 节点新标题
//
//示例值：新标题
func (builder *UpdateTitleSpaceNodeReqBodyBuilder) Title(title string) *UpdateTitleSpaceNodeReqBodyBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

func (builder *UpdateTitleSpaceNodeReqBodyBuilder) Build() *UpdateTitleSpaceNodeReqBody {
	req := &UpdateTitleSpaceNodeReqBody{}
	if builder.titleFlag {
		req.Title = &builder.title
	}
	return req
}

type UpdateTitleSpaceNodePathReqBodyBuilder struct {
	title     string
	titleFlag bool
}

func NewUpdateTitleSpaceNodePathReqBodyBuilder() *UpdateTitleSpaceNodePathReqBodyBuilder {
	builder := &UpdateTitleSpaceNodePathReqBodyBuilder{}
	return builder
}

// 节点新标题
//
// 示例值：新标题
func (builder *UpdateTitleSpaceNodePathReqBodyBuilder) Title(title string) *UpdateTitleSpaceNodePathReqBodyBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

func (builder *UpdateTitleSpaceNodePathReqBodyBuilder) Build() (*UpdateTitleSpaceNodeReqBody, error) {
	req := &UpdateTitleSpaceNodeReqBody{}
	if builder.titleFlag {
		req.Title = &builder.title
	}
	return req, nil
}

type UpdateTitleSpaceNodeReqBuilder struct {
	apiReq *larkcore.ApiReq
	body   *UpdateTitleSpaceNodeReqBody
}

func NewUpdateTitleSpaceNodeReqBuilder() *UpdateTitleSpaceNodeReqBuilder {
	builder := &UpdateTitleSpaceNodeReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间ID
//
// 示例值：6946843325487912356
func (builder *UpdateTitleSpaceNodeReqBuilder) SpaceId(spaceId string) *UpdateTitleSpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 节点token
//
// 示例值：wikcnKQ1k3pcuo5uSK4t8Vabcef
func (builder *UpdateTitleSpaceNodeReqBuilder) NodeToken(nodeToken string) *UpdateTitleSpaceNodeReqBuilder {
	builder.apiReq.PathParams.Set("node_token", fmt.Sprint(nodeToken))
	return builder
}

// 此接口用于更新节点标题
func (builder *UpdateTitleSpaceNodeReqBuilder) Body(body *UpdateTitleSpaceNodeReqBody) *UpdateTitleSpaceNodeReqBuilder {
	builder.body = body
	return builder
}

func (builder *UpdateTitleSpaceNodeReqBuilder) Build() *UpdateTitleSpaceNodeReq {
	req := &UpdateTitleSpaceNodeReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.body
	return req
}

type UpdateTitleSpaceNodeReqBody struct {
	Title *string `json:"title,omitempty"` // 节点新标题
}

type UpdateTitleSpaceNodeReq struct {
	apiReq *larkcore.ApiReq
	Body   *UpdateTitleSpaceNodeReqBody `body:""`
}

type UpdateTitleSpaceNodeResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
}

func (resp *UpdateTitleSpaceNodeResp) Success() bool {
	return resp.Code == 0
}

type UpdateSpaceSettingReqBuilder struct {
	apiReq  *larkcore.ApiReq
	setting *Setting
}

func NewUpdateSpaceSettingReqBuilder() *UpdateSpaceSettingReqBuilder {
	builder := &UpdateSpaceSettingReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 知识空间id
//
// 示例值：1565676577122621
func (builder *UpdateSpaceSettingReqBuilder) SpaceId(spaceId string) *UpdateSpaceSettingReqBuilder {
	builder.apiReq.PathParams.Set("space_id", fmt.Sprint(spaceId))
	return builder
}

// 根据space_id更新知识空间公共设置
func (builder *UpdateSpaceSettingReqBuilder) Setting(setting *Setting) *UpdateSpaceSettingReqBuilder {
	builder.setting = setting
	return builder
}

func (builder *UpdateSpaceSettingReqBuilder) Build() *UpdateSpaceSettingReq {
	req := &UpdateSpaceSettingReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.setting
	return req
}

type UpdateSpaceSettingReq struct {
	apiReq  *larkcore.ApiReq
	Setting *Setting `body:""`
}

type UpdateSpaceSettingRespData struct {
	Setting *Setting `json:"setting,omitempty"` // 知识空间设置
}

type UpdateSpaceSettingResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *UpdateSpaceSettingRespData `json:"data"` // 业务数据
}

func (resp *UpdateSpaceSettingResp) Success() bool {
	return resp.Code == 0
}

type GetTaskReqBuilder struct {
	apiReq *larkcore.ApiReq
}

func NewGetTaskReqBuilder() *GetTaskReqBuilder {
	builder := &GetTaskReqBuilder{}
	builder.apiReq = &larkcore.ApiReq{
		PathParams:  larkcore.PathParams{},
		QueryParams: larkcore.QueryParams{},
	}
	return builder
}

// 任务id
//
// 示例值：7037044037068177428-075c9481e6a0007c1df689dfbe5b55a08b6b06f7
func (builder *GetTaskReqBuilder) TaskId(taskId string) *GetTaskReqBuilder {
	builder.apiReq.PathParams.Set("task_id", fmt.Sprint(taskId))
	return builder
}

// 任务类型
//
// 示例值：move
func (builder *GetTaskReqBuilder) TaskType(taskType string) *GetTaskReqBuilder {
	builder.apiReq.QueryParams.Set("task_type", fmt.Sprint(taskType))
	return builder
}

func (builder *GetTaskReqBuilder) Build() *GetTaskReq {
	req := &GetTaskReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.QueryParams = builder.apiReq.QueryParams
	return req
}

type GetTaskReq struct {
	apiReq *larkcore.ApiReq
}

type GetTaskRespData struct {
	Task *TaskResult `json:"task,omitempty"` // 任务结果
}

type GetTaskResp struct {
	*larkcore.ApiResp `json:"-"`
	larkcore.CodeError
	Data *GetTaskRespData `json:"data"` // 业务数据
}

func (resp *GetTaskResp) Success() bool {
	return resp.Code == 0
}

type ListSpaceIterator struct {
	nextPageToken *string
	items         []*Space
	index         int
	limit         int
	ctx           context.Context
	req           *ListSpaceReq
	listFunc      func(ctx context.Context, req *ListSpaceReq, options ...larkcore.RequestOptionFunc) (*ListSpaceResp, error)
	options       []larkcore.RequestOptionFunc
	curlNum       int
}

func (iterator *ListSpaceIterator) Next() (bool, *Space, error) {
	// 达到最大量，则返回
	if iterator.limit > 0 && iterator.curlNum >= iterator.limit {
		return false, nil, nil
	}

	// 为0则拉取数据
	if iterator.index == 0 || iterator.index >= len(iterator.items) {
		if iterator.index != 0 && iterator.nextPageToken == nil {
			return false, nil, nil
		}
		if iterator.nextPageToken != nil {
			iterator.req.apiReq.QueryParams.Set("page_token", *iterator.nextPageToken)
		}
		resp, err := iterator.listFunc(iterator.ctx, iterator.req, iterator.options...)
		if err != nil {
			return false, nil, err
		}

		if resp.Code != 0 {
			return false, nil, errors.New(fmt.Sprintf("Code:%d,Msg:%s", resp.Code, resp.Msg))
		}

		if len(resp.Data.Items) == 0 {
			return false, nil, nil
		}

		iterator.nextPageToken = resp.Data.PageToken
		iterator.items = resp.Data.Items
		iterator.index = 0
	}

	block := iterator.items[iterator.index]
	iterator.index++
	iterator.curlNum++
	return true, block, nil
}

func (iterator *ListSpaceIterator) NextPageToken() *string {
	return iterator.nextPageToken
}

type ListSpaceNodeIterator struct {
	nextPageToken *string
	items         []*Node
	index         int
	limit         int
	ctx           context.Context
	req           *ListSpaceNodeReq
	listFunc      func(ctx context.Context, req *ListSpaceNodeReq, options ...larkcore.RequestOptionFunc) (*ListSpaceNodeResp, error)
	options       []larkcore.RequestOptionFunc
	curlNum       int
}

func (iterator *ListSpaceNodeIterator) Next() (bool, *Node, error) {
	// 达到最大量，则返回
	if iterator.limit > 0 && iterator.curlNum >= iterator.limit {
		return false, nil, nil
	}

	// 为0则拉取数据
	if iterator.index == 0 || iterator.index >= len(iterator.items) {
		if iterator.index != 0 && iterator.nextPageToken == nil {
			return false, nil, nil
		}
		if iterator.nextPageToken != nil {
			iterator.req.apiReq.QueryParams.Set("page_token", *iterator.nextPageToken)
		}
		resp, err := iterator.listFunc(iterator.ctx, iterator.req, iterator.options...)
		if err != nil {
			return false, nil, err
		}

		if resp.Code != 0 {
			return false, nil, errors.New(fmt.Sprintf("Code:%d,Msg:%s", resp.Code, resp.Msg))
		}

		if len(resp.Data.Items) == 0 {
			return false, nil, nil
		}

		iterator.nextPageToken = resp.Data.PageToken
		iterator.items = resp.Data.Items
		iterator.index = 0
	}

	block := iterator.items[iterator.index]
	iterator.index++
	iterator.curlNum++
	return true, block, nil
}

func (iterator *ListSpaceNodeIterator) NextPageToken() *string {
	return iterator.nextPageToken
}
