// Package base 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 larkbase

import (
	"fmt"

	"context"
	"errors"

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

type App struct {
	AppToken *string `json:"app_token,omitempty"` // 多维表格 app token

	Name *string `json:"name,omitempty"` // 多维表格 App 名字

	Revision *int `json:"revision,omitempty"` // 多维表格 App 版本号

	FolderToken *string `json:"folder_token,omitempty"` // 多维表格 App 归属文件夹

	Url *string `json:"url,omitempty"` // 多维表格 App URL

	DefaultTableId *string `json:"default_table_id,omitempty"` // 默认的表格id

	TimeZone *string `json:"time_zone,omitempty"` // 文档时区，说明见：https://bytedance.feishu.cn/docx/YKRndTM7VoyDqpxqqeEcd67MnEf
}

type AppBuilder struct {
	appToken     string // 多维表格 app token
	appTokenFlag bool

	name     string // 多维表格 App 名字
	nameFlag bool

	revision     int // 多维表格 App 版本号
	revisionFlag bool

	folderToken     string // 多维表格 App 归属文件夹
	folderTokenFlag bool

	url     string // 多维表格 App URL
	urlFlag bool

	defaultTableId     string // 默认的表格id
	defaultTableIdFlag bool

	timeZone     string // 文档时区，说明见：https://bytedance.feishu.cn/docx/YKRndTM7VoyDqpxqqeEcd67MnEf
	timeZoneFlag bool
}

func NewAppBuilder() *AppBuilder {
	builder := &AppBuilder{}
	return builder
}

// 多维表格 app token
//
// 示例值：NQRxbRkBMa6OnZsjtERcxhNWnNh
func (builder *AppBuilder) AppToken(appToken string) *AppBuilder {
	builder.appToken = appToken
	builder.appTokenFlag = true
	return builder
}

// 多维表格 App 名字
//
// 示例值：多维表格
func (builder *AppBuilder) Name(name string) *AppBuilder {
	builder.name = name
	builder.nameFlag = true
	return builder
}

// 多维表格 App 版本号
//
// 示例值：1
func (builder *AppBuilder) Revision(revision int) *AppBuilder {
	builder.revision = revision
	builder.revisionFlag = true
	return builder
}

// 多维表格 App 归属文件夹
//
// 示例值：fldbco*****CIMltVc
func (builder *AppBuilder) FolderToken(folderToken string) *AppBuilder {
	builder.folderToken = folderToken
	builder.folderTokenFlag = true
	return builder
}

// 多维表格 App URL
//
// 示例值：https://example.feishu.cn/base/S404b*****e9PQsYDWYcNryFn0g
func (builder *AppBuilder) Url(url string) *AppBuilder {
	builder.url = url
	builder.urlFlag = true
	return builder
}

// 默认的表格id
//
// 示例值：tbl********oumSQ
func (builder *AppBuilder) DefaultTableId(defaultTableId string) *AppBuilder {
	builder.defaultTableId = defaultTableId
	builder.defaultTableIdFlag = true
	return builder
}

// 文档时区，说明见：https://bytedance.feishu.cn/docx/YKRndTM7VoyDqpxqqeEcd67MnEf
//
// 示例值：Asia/Beijing
func (builder *AppBuilder) TimeZone(timeZone string) *AppBuilder {
	builder.timeZone = timeZone
	builder.timeZoneFlag = true
	return builder
}

func (builder *AppBuilder) Build() *App {
	req := &App{}
	if builder.appTokenFlag {
		req.AppToken = &builder.appToken

	}
	if builder.nameFlag {
		req.Name = &builder.name

	}
	if builder.revisionFlag {
		req.Revision = &builder.revision

	}
	if builder.folderTokenFlag {
		req.FolderToken = &builder.folderToken

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

	}
	if builder.defaultTableIdFlag {
		req.DefaultTableId = &builder.defaultTableId

	}
	if builder.timeZoneFlag {
		req.TimeZone = &builder.timeZone

	}
	return req
}

type BlockRole struct {
	BlockId *string `json:"block_id,omitempty"` // Block ID

	BlockPerm *int `json:"block_perm,omitempty"` // Block权限

	BlockType *string `json:"block_type,omitempty"` // Block类型
}

type BlockRoleBuilder struct {
	blockId     string // Block ID
	blockIdFlag bool

	blockPerm     int // Block权限
	blockPermFlag bool

	blockType     string // Block类型
	blockTypeFlag bool
}

func NewBlockRoleBuilder() *BlockRoleBuilder {
	builder := &BlockRoleBuilder{}
	return builder
}

// Block ID
//
// 示例值：blknkqrP3RqUkcAW
func (builder *BlockRoleBuilder) BlockId(blockId string) *BlockRoleBuilder {
	builder.blockId = blockId
	builder.blockIdFlag = true
	return builder
}

// Block权限
//
// 示例值：0
func (builder *BlockRoleBuilder) BlockPerm(blockPerm int) *BlockRoleBuilder {
	builder.blockPerm = blockPerm
	builder.blockPermFlag = true
	return builder
}

// Block类型
//
// 示例值：dashboard
func (builder *BlockRoleBuilder) BlockType(blockType string) *BlockRoleBuilder {
	builder.blockType = blockType
	builder.blockTypeFlag = true
	return builder
}

func (builder *BlockRoleBuilder) Build() *BlockRole {
	req := &BlockRole{}
	if builder.blockIdFlag {
		req.BlockId = &builder.blockId

	}
	if builder.blockPermFlag {
		req.BlockPerm = &builder.blockPerm

	}
	if builder.blockTypeFlag {
		req.BlockType = &builder.blockType

	}
	return req
}

type ConditionGroup struct {
	ConditionType *int `json:"condition_type,omitempty"` // 条件组类型

	Conditions []*RecRuleCondition `json:"conditions,omitempty"` // 条件列表

	Conjunction *string `json:"conjunction,omitempty"` // 条件符
}

type ConditionGroupBuilder struct {
	conditionType     int // 条件组类型
	conditionTypeFlag bool

	conditions     []*RecRuleCondition // 条件列表
	conditionsFlag bool

	conjunction     string // 条件符
	conjunctionFlag bool
}

func NewConditionGroupBuilder() *ConditionGroupBuilder {
	builder := &ConditionGroupBuilder{}
	return builder
}

// 条件组类型
//
// 示例值：and
func (builder *ConditionGroupBuilder) ConditionType(conditionType int) *ConditionGroupBuilder {
	builder.conditionType = conditionType
	builder.conditionTypeFlag = true
	return builder
}

// 条件列表
//
// 示例值：
func (builder *ConditionGroupBuilder) Conditions(conditions []*RecRuleCondition) *ConditionGroupBuilder {
	builder.conditions = conditions
	builder.conditionsFlag = true
	return builder
}

// 条件符
//
// 示例值：or
func (builder *ConditionGroupBuilder) Conjunction(conjunction string) *ConditionGroupBuilder {
	builder.conjunction = conjunction
	builder.conjunctionFlag = true
	return builder
}

func (builder *ConditionGroupBuilder) Build() *ConditionGroup {
	req := &ConditionGroup{}
	if builder.conditionTypeFlag {
		req.ConditionType = &builder.conditionType

	}
	if builder.conditionsFlag {
		req.Conditions = builder.conditions
	}
	if builder.conjunctionFlag {
		req.Conjunction = &builder.conjunction

	}
	return req
}

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 ExtInfo struct {
	SubType *string `json:"sub_type,omitempty"` // docType

	Version *string `json:"version,omitempty"` // 版本

	BgImage *string `json:"bg_image,omitempty"` // 封面图

	TitleColor *string `json:"title_color,omitempty"` // 标题颜色

	GaChatId *string `json:"ga_chat_id,omitempty"` // 群公告文档对应的群ID

	ModifiedTime *string `json:"modified_time,omitempty"` // 最后修改时间

	Icon *Icon `json:"icon,omitempty"` // DeleteFlag use common.DeleteFlag\nObjType use common.ObjType , support doc/sheet/bitable/slide

	IsCopying *bool `json:"is_copying,omitempty"` // 文档副本是否拷贝中
}

type ExtInfoBuilder struct {
	subType     string // docType
	subTypeFlag bool

	version     string // 版本
	versionFlag bool

	bgImage     string // 封面图
	bgImageFlag bool

	titleColor     string // 标题颜色
	titleColorFlag bool

	gaChatId     string // 群公告文档对应的群ID
	gaChatIdFlag bool

	modifiedTime     string // 最后修改时间
	modifiedTimeFlag bool

	icon     *Icon // DeleteFlag use common.DeleteFlag\nObjType use common.ObjType , support doc/sheet/bitable/slide
	iconFlag bool

	isCopying     bool // 文档副本是否拷贝中
	isCopyingFlag bool
}

func NewExtInfoBuilder() *ExtInfoBuilder {
	builder := &ExtInfoBuilder{}
	return builder
}

// docType
//
// 示例值：8
func (builder *ExtInfoBuilder) SubType(subType string) *ExtInfoBuilder {
	builder.subType = subType
	builder.subTypeFlag = true
	return builder
}

// 版本
//
// 示例值：1
func (builder *ExtInfoBuilder) Version(version string) *ExtInfoBuilder {
	builder.version = version
	builder.versionFlag = true
	return builder
}

// 封面图
//
// 示例值：""
func (builder *ExtInfoBuilder) BgImage(bgImage string) *ExtInfoBuilder {
	builder.bgImage = bgImage
	builder.bgImageFlag = true
	return builder
}

// 标题颜色
//
// 示例值：""
func (builder *ExtInfoBuilder) TitleColor(titleColor string) *ExtInfoBuilder {
	builder.titleColor = titleColor
	builder.titleColorFlag = true
	return builder
}

// 群公告文档对应的群ID
//
// 示例值：""
func (builder *ExtInfoBuilder) GaChatId(gaChatId string) *ExtInfoBuilder {
	builder.gaChatId = gaChatId
	builder.gaChatIdFlag = true
	return builder
}

// 最后修改时间
//
// 示例值：""
func (builder *ExtInfoBuilder) ModifiedTime(modifiedTime string) *ExtInfoBuilder {
	builder.modifiedTime = modifiedTime
	builder.modifiedTimeFlag = true
	return builder
}

// DeleteFlag use common.DeleteFlag\nObjType use common.ObjType , support doc/sheet/bitable/slide
//
// 示例值：
func (builder *ExtInfoBuilder) Icon(icon *Icon) *ExtInfoBuilder {
	builder.icon = icon
	builder.iconFlag = true
	return builder
}

// 文档副本是否拷贝中
//
// 示例值：
func (builder *ExtInfoBuilder) IsCopying(isCopying bool) *ExtInfoBuilder {
	builder.isCopying = isCopying
	builder.isCopyingFlag = true
	return builder
}

func (builder *ExtInfoBuilder) Build() *ExtInfo {
	req := &ExtInfo{}
	if builder.subTypeFlag {
		req.SubType = &builder.subType

	}
	if builder.versionFlag {
		req.Version = &builder.version

	}
	if builder.bgImageFlag {
		req.BgImage = &builder.bgImage

	}
	if builder.titleColorFlag {
		req.TitleColor = &builder.titleColor

	}
	if builder.gaChatIdFlag {
		req.GaChatId = &builder.gaChatId

	}
	if builder.modifiedTimeFlag {
		req.ModifiedTime = &builder.modifiedTime

	}
	if builder.iconFlag {
		req.Icon = builder.icon
	}
	if builder.isCopyingFlag {
		req.IsCopying = &builder.isCopying

	}
	return req
}

type Icon struct {
	Type *int `json:"type,omitempty"` // 图标类型，目前有 emoji、图片等类型

	Key *string `json:"key,omitempty"` // emoji 字符或图片类型图标的 KEY

	FsUnit *string `json:"fs_unit,omitempty"` // 图标的资源位置信息
}

type IconBuilder struct {
	type_    int // 图标类型，目前有 emoji、图片等类型
	typeFlag bool

	key     string // emoji 字符或图片类型图标的 KEY
	keyFlag bool

	fsUnit     string // 图标的资源位置信息
	fsUnitFlag bool
}

func NewIconBuilder() *IconBuilder {
	builder := &IconBuilder{}
	return builder
}

// 图标类型，目前有 emoji、图片等类型
//
// 示例值：""
func (builder *IconBuilder) Type(type_ int) *IconBuilder {
	builder.type_ = type_
	builder.typeFlag = true
	return builder
}

// emoji 字符或图片类型图标的 KEY
//
// 示例值：""
func (builder *IconBuilder) Key(key string) *IconBuilder {
	builder.key = key
	builder.keyFlag = true
	return builder
}

// 图标的资源位置信息
//
// 示例值：""
func (builder *IconBuilder) FsUnit(fsUnit string) *IconBuilder {
	builder.fsUnit = fsUnit
	builder.fsUnitFlag = true
	return builder
}

func (builder *IconBuilder) Build() *Icon {
	req := &Icon{}
	if builder.typeFlag {
		req.Type = &builder.type_

	}
	if builder.keyFlag {
		req.Key = &builder.key

	}
	if builder.fsUnitFlag {
		req.FsUnit = &builder.fsUnit

	}
	return req
}

type Meta struct {
	Id *string `json:"id,omitempty"` // ""

	Token *string `json:"token,omitempty"` // ""

	Title *string `json:"title,omitempty"` // ""

	OwnerUid *string `json:"owner_uid,omitempty"` // ""

	EditUid *string `json:"edit_uid,omitempty"` // ""

	CreateTime *string `json:"create_time,omitempty"` // ""

	EditTime *string `json:"edit_time,omitempty"` // ""

	DeleteFlag *string `json:"delete_flag,omitempty"` // ""

	ObjType *string `json:"obj_type,omitempty"` // ""

	Source *string `json:"source,omitempty"` // ""

	ParentId *string `json:"parent_id,omitempty"` // ""

	SubType *string `json:"sub_type,omitempty"` // ""

	RootDocId *string `json:"root_doc_id,omitempty"` // 子文档对应的根文档 ID

	RootBlockId *string `json:"root_block_id,omitempty"` // 子文档对应的根 BlockID

	DocVersion *int `json:"doc_version,omitempty"` // 文档版本

	TenantId *string `json:"tenant_id,omitempty"` // 租户 ID 默认 -999

	MixState *int `json:"mix_state,omitempty"` //

	SecLabelId *string `json:"sec_label_id,omitempty"` // 密级标签 ID

	SecLabelType *int `json:"sec_label_type,omitempty"` // 密级设置的类型

	TitleSecureKeyDeleted *bool `json:"title_secure_key_deleted,omitempty"` // 标题秘钥被删除

	TemplateInfo *TemplateInfo `json:"template_info,omitempty"` // 模板信息

	IconInfo *string `json:"icon_info,omitempty"` // nolint: byted_s_thrift_avoid_id_type_change\n文档自定义icon信息，json marashl后的string，包含filteType, version等额外信息

	Ext *ExtInfo `json:"ext,omitempty"` // ""
}

type MetaBuilder struct {
	id     string // ""
	idFlag bool

	token     string // ""
	tokenFlag bool

	title     string // ""
	titleFlag bool

	ownerUid     string // ""
	ownerUidFlag bool

	editUid     string // ""
	editUidFlag bool

	createTime     string // ""
	createTimeFlag bool

	editTime     string // ""
	editTimeFlag bool

	deleteFlag     string // ""
	deleteFlagFlag bool

	objType     string // ""
	objTypeFlag bool

	source     string // ""
	sourceFlag bool

	parentId     string // ""
	parentIdFlag bool

	subType     string // ""
	subTypeFlag bool

	rootDocId     string // 子文档对应的根文档 ID
	rootDocIdFlag bool

	rootBlockId     string // 子文档对应的根 BlockID
	rootBlockIdFlag bool

	docVersion     int // 文档版本
	docVersionFlag bool

	tenantId     string // 租户 ID 默认 -999
	tenantIdFlag bool

	mixState     int //
	mixStateFlag bool

	secLabelId     string // 密级标签 ID
	secLabelIdFlag bool

	secLabelType     int // 密级设置的类型
	secLabelTypeFlag bool

	titleSecureKeyDeleted     bool // 标题秘钥被删除
	titleSecureKeyDeletedFlag bool

	templateInfo     *TemplateInfo // 模板信息
	templateInfoFlag bool

	iconInfo     string // nolint: byted_s_thrift_avoid_id_type_change\n文档自定义icon信息，json marashl后的string，包含filteType, version等额外信息
	iconInfoFlag bool

	ext     *ExtInfo // ""
	extFlag bool
}

func NewMetaBuilder() *MetaBuilder {
	builder := &MetaBuilder{}
	return builder
}

// ""
//
// 示例值：7369428748755189761
func (builder *MetaBuilder) Id(id string) *MetaBuilder {
	builder.id = id
	builder.idFlag = true
	return builder
}

// ""
//
// 示例值：appbcbWCzen6D8dezhoCH2RpMAh
func (builder *MetaBuilder) Token(token string) *MetaBuilder {
	builder.token = token
	builder.tokenFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) Title(title string) *MetaBuilder {
	builder.title = title
	builder.titleFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) OwnerUid(ownerUid string) *MetaBuilder {
	builder.ownerUid = ownerUid
	builder.ownerUidFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) EditUid(editUid string) *MetaBuilder {
	builder.editUid = editUid
	builder.editUidFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) CreateTime(createTime string) *MetaBuilder {
	builder.createTime = createTime
	builder.createTimeFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) EditTime(editTime string) *MetaBuilder {
	builder.editTime = editTime
	builder.editTimeFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) DeleteFlag(deleteFlag string) *MetaBuilder {
	builder.deleteFlag = deleteFlag
	builder.deleteFlagFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) ObjType(objType string) *MetaBuilder {
	builder.objType = objType
	builder.objTypeFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) Source(source string) *MetaBuilder {
	builder.source = source
	builder.sourceFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) ParentId(parentId string) *MetaBuilder {
	builder.parentId = parentId
	builder.parentIdFlag = true
	return builder
}

// ""
//
// 示例值：""
func (builder *MetaBuilder) SubType(subType string) *MetaBuilder {
	builder.subType = subType
	builder.subTypeFlag = true
	return builder
}

// 子文档对应的根文档 ID
//
// 示例值：""
func (builder *MetaBuilder) RootDocId(rootDocId string) *MetaBuilder {
	builder.rootDocId = rootDocId
	builder.rootDocIdFlag = true
	return builder
}

// 子文档对应的根 BlockID
//
// 示例值：""
func (builder *MetaBuilder) RootBlockId(rootBlockId string) *MetaBuilder {
	builder.rootBlockId = rootBlockId
	builder.rootBlockIdFlag = true
	return builder
}

// 文档版本
//
// 示例值：
func (builder *MetaBuilder) DocVersion(docVersion int) *MetaBuilder {
	builder.docVersion = docVersion
	builder.docVersionFlag = true
	return builder
}

// 租户 ID 默认 -999
//
// 示例值：""
func (builder *MetaBuilder) TenantId(tenantId string) *MetaBuilder {
	builder.tenantId = tenantId
	builder.tenantIdFlag = true
	return builder
}

//
//
// 示例值：
func (builder *MetaBuilder) MixState(mixState int) *MetaBuilder {
	builder.mixState = mixState
	builder.mixStateFlag = true
	return builder
}

// 密级标签 ID
//
// 示例值：""
func (builder *MetaBuilder) SecLabelId(secLabelId string) *MetaBuilder {
	builder.secLabelId = secLabelId
	builder.secLabelIdFlag = true
	return builder
}

// 密级设置的类型
//
// 示例值：
func (builder *MetaBuilder) SecLabelType(secLabelType int) *MetaBuilder {
	builder.secLabelType = secLabelType
	builder.secLabelTypeFlag = true
	return builder
}

// 标题秘钥被删除
//
// 示例值：
func (builder *MetaBuilder) TitleSecureKeyDeleted(titleSecureKeyDeleted bool) *MetaBuilder {
	builder.titleSecureKeyDeleted = titleSecureKeyDeleted
	builder.titleSecureKeyDeletedFlag = true
	return builder
}

// 模板信息
//
// 示例值：
func (builder *MetaBuilder) TemplateInfo(templateInfo *TemplateInfo) *MetaBuilder {
	builder.templateInfo = templateInfo
	builder.templateInfoFlag = true
	return builder
}

// nolint: byted_s_thrift_avoid_id_type_change\n文档自定义icon信息，json marashl后的string，包含filteType, version等额外信息
//
// 示例值：""
func (builder *MetaBuilder) IconInfo(iconInfo string) *MetaBuilder {
	builder.iconInfo = iconInfo
	builder.iconInfoFlag = true
	return builder
}

// ""
//
// 示例值：
func (builder *MetaBuilder) Ext(ext *ExtInfo) *MetaBuilder {
	builder.ext = ext
	builder.extFlag = true
	return builder
}

func (builder *MetaBuilder) Build() *Meta {
	req := &Meta{}
	if builder.idFlag {
		req.Id = &builder.id

	}
	if builder.tokenFlag {
		req.Token = &builder.token

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

	}
	if builder.ownerUidFlag {
		req.OwnerUid = &builder.ownerUid

	}
	if builder.editUidFlag {
		req.EditUid = &builder.editUid

	}
	if builder.createTimeFlag {
		req.CreateTime = &builder.createTime

	}
	if builder.editTimeFlag {
		req.EditTime = &builder.editTime

	}
	if builder.deleteFlagFlag {
		req.DeleteFlag = &builder.deleteFlag

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

	}
	if builder.sourceFlag {
		req.Source = &builder.source

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

	}
	if builder.subTypeFlag {
		req.SubType = &builder.subType

	}
	if builder.rootDocIdFlag {
		req.RootDocId = &builder.rootDocId

	}
	if builder.rootBlockIdFlag {
		req.RootBlockId = &builder.rootBlockId

	}
	if builder.docVersionFlag {
		req.DocVersion = &builder.docVersion

	}
	if builder.tenantIdFlag {
		req.TenantId = &builder.tenantId

	}
	if builder.mixStateFlag {
		req.MixState = &builder.mixState

	}
	if builder.secLabelIdFlag {
		req.SecLabelId = &builder.secLabelId

	}
	if builder.secLabelTypeFlag {
		req.SecLabelType = &builder.secLabelType

	}
	if builder.titleSecureKeyDeletedFlag {
		req.TitleSecureKeyDeleted = &builder.titleSecureKeyDeleted

	}
	if builder.templateInfoFlag {
		req.TemplateInfo = builder.templateInfo
	}
	if builder.iconInfoFlag {
		req.IconInfo = &builder.iconInfo

	}
	if builder.extFlag {
		req.Ext = builder.ext
	}
	return req
}

type OtherRecRule struct {
	Conditions []*RecRuleCondition `json:"conditions,omitempty"` // 记录筛选条件

	Conjunction *string `json:"conjunction,omitempty"` // 多个筛选条件的关系

	Perm *int `json:"perm,omitempty"` // 规则筛选记录对应的权限
}

type OtherRecRuleBuilder struct {
	conditions     []*RecRuleCondition // 记录筛选条件
	conditionsFlag bool

	conjunction     string // 多个筛选条件的关系
	conjunctionFlag bool

	perm     int // 规则筛选记录对应的权限
	permFlag bool
}

func NewOtherRecRuleBuilder() *OtherRecRuleBuilder {
	builder := &OtherRecRuleBuilder{}
	return builder
}

// 记录筛选条件
//
// 示例值：
func (builder *OtherRecRuleBuilder) Conditions(conditions []*RecRuleCondition) *OtherRecRuleBuilder {
	builder.conditions = conditions
	builder.conditionsFlag = true
	return builder
}

// 多个筛选条件的关系
//
// 示例值：and
func (builder *OtherRecRuleBuilder) Conjunction(conjunction string) *OtherRecRuleBuilder {
	builder.conjunction = conjunction
	builder.conjunctionFlag = true
	return builder
}

// 规则筛选记录对应的权限
//
// 示例值：1
func (builder *OtherRecRuleBuilder) Perm(perm int) *OtherRecRuleBuilder {
	builder.perm = perm
	builder.permFlag = true
	return builder
}

func (builder *OtherRecRuleBuilder) Build() *OtherRecRule {
	req := &OtherRecRule{}
	if builder.conditionsFlag {
		req.Conditions = builder.conditions
	}
	if builder.conjunctionFlag {
		req.Conjunction = &builder.conjunction

	}
	if builder.permFlag {
		req.Perm = &builder.perm

	}
	return req
}

type RecRule struct {
	Conditions []*RecRuleCondition `json:"conditions,omitempty"` // 记录筛选条件

	Conjunction *string `json:"conjunction,omitempty"` // 多个筛选条件的关系

	Perm *int `json:"perm,omitempty"` // 规则筛选记录对应的权限

	OtherPerm *int `json:"other_perm,omitempty"` // 其他记录权限，仅在table_perm为2时有效

	ConditionGroups []*ConditionGroup `json:"condition_groups,omitempty"` // 条件组

	DisplayRecRuleVersion *int `json:"display_rec_rule_version,omitempty"` // 条件版本
}

type RecRuleBuilder struct {
	conditions     []*RecRuleCondition // 记录筛选条件
	conditionsFlag bool

	conjunction     string // 多个筛选条件的关系
	conjunctionFlag bool

	perm     int // 规则筛选记录对应的权限
	permFlag bool

	otherPerm     int // 其他记录权限，仅在table_perm为2时有效
	otherPermFlag bool

	conditionGroups     []*ConditionGroup // 条件组
	conditionGroupsFlag bool

	displayRecRuleVersion     int // 条件版本
	displayRecRuleVersionFlag bool
}

func NewRecRuleBuilder() *RecRuleBuilder {
	builder := &RecRuleBuilder{}
	return builder
}

// 记录筛选条件
//
// 示例值：
func (builder *RecRuleBuilder) Conditions(conditions []*RecRuleCondition) *RecRuleBuilder {
	builder.conditions = conditions
	builder.conditionsFlag = true
	return builder
}

// 多个筛选条件的关系
//
// 示例值：and
func (builder *RecRuleBuilder) Conjunction(conjunction string) *RecRuleBuilder {
	builder.conjunction = conjunction
	builder.conjunctionFlag = true
	return builder
}

// 规则筛选记录对应的权限
//
// 示例值：1
func (builder *RecRuleBuilder) Perm(perm int) *RecRuleBuilder {
	builder.perm = perm
	builder.permFlag = true
	return builder
}

// 其他记录权限，仅在table_perm为2时有效
//
// 示例值：1
func (builder *RecRuleBuilder) OtherPerm(otherPerm int) *RecRuleBuilder {
	builder.otherPerm = otherPerm
	builder.otherPermFlag = true
	return builder
}

// 条件组
//
// 示例值：
func (builder *RecRuleBuilder) ConditionGroups(conditionGroups []*ConditionGroup) *RecRuleBuilder {
	builder.conditionGroups = conditionGroups
	builder.conditionGroupsFlag = true
	return builder
}

// 条件版本
//
// 示例值：1
func (builder *RecRuleBuilder) DisplayRecRuleVersion(displayRecRuleVersion int) *RecRuleBuilder {
	builder.displayRecRuleVersion = displayRecRuleVersion
	builder.displayRecRuleVersionFlag = true
	return builder
}

func (builder *RecRuleBuilder) Build() *RecRule {
	req := &RecRule{}
	if builder.conditionsFlag {
		req.Conditions = builder.conditions
	}
	if builder.conjunctionFlag {
		req.Conjunction = &builder.conjunction

	}
	if builder.permFlag {
		req.Perm = &builder.perm

	}
	if builder.otherPermFlag {
		req.OtherPerm = &builder.otherPerm

	}
	if builder.conditionGroupsFlag {
		req.ConditionGroups = builder.conditionGroups
	}
	if builder.displayRecRuleVersionFlag {
		req.DisplayRecRuleVersion = &builder.displayRecRuleVersion

	}
	return req
}

type RecRuleCondition struct {
	FieldName *string `json:"field_name,omitempty"` // 字段名

	Operator *string `json:"operator,omitempty"` // 运算符

	Value []string `json:"value,omitempty"` // 单选或多选字段的选项id

	FieldType *int `json:"field_type,omitempty"` // 字段类型
}

type RecRuleConditionBuilder struct {
	fieldName     string // 字段名
	fieldNameFlag bool

	operator     string // 运算符
	operatorFlag bool

	value     []string // 单选或多选字段的选项id
	valueFlag bool

	fieldType     int // 字段类型
	fieldTypeFlag bool
}

func NewRecRuleConditionBuilder() *RecRuleConditionBuilder {
	builder := &RecRuleConditionBuilder{}
	return builder
}

// 字段名
//
// 示例值：单选
func (builder *RecRuleConditionBuilder) FieldName(fieldName string) *RecRuleConditionBuilder {
	builder.fieldName = fieldName
	builder.fieldNameFlag = true
	return builder
}

// 运算符
//
// 示例值：is
func (builder *RecRuleConditionBuilder) Operator(operator string) *RecRuleConditionBuilder {
	builder.operator = operator
	builder.operatorFlag = true
	return builder
}

// 单选或多选字段的选项id
//
// 示例值：["optbdVHf4q", "optrpd3eIJ"]
func (builder *RecRuleConditionBuilder) Value(value []string) *RecRuleConditionBuilder {
	builder.value = value
	builder.valueFlag = true
	return builder
}

// 字段类型
//
// 示例值：3
func (builder *RecRuleConditionBuilder) FieldType(fieldType int) *RecRuleConditionBuilder {
	builder.fieldType = fieldType
	builder.fieldTypeFlag = true
	return builder
}

func (builder *RecRuleConditionBuilder) Build() *RecRuleCondition {
	req := &RecRuleCondition{}
	if builder.fieldNameFlag {
		req.FieldName = &builder.fieldName

	}
	if builder.operatorFlag {
		req.Operator = &builder.operator

	}
	if builder.valueFlag {
		req.Value = builder.value
	}
	if builder.fieldTypeFlag {
		req.FieldType = &builder.fieldType

	}
	return req
}

type Role struct {
	RoleName *string `json:"role_name,omitempty"` // 自定义权限的名字

	TableRoles []*TableRole `json:"table_roles,omitempty"` // 数据表权限

	RoleId *string `json:"role_id,omitempty"` // 自定义权限的id

	BlockRoles []*BlockRole `json:"block_roles,omitempty"` // block权限

	BaseRule map[string]int `json:"base_rule,omitempty"` // base权限
}

type RoleBuilder struct {
	roleName     string // 自定义权限的名字
	roleNameFlag bool

	tableRoles     []*TableRole // 数据表权限
	tableRolesFlag bool

	roleId     string // 自定义权限的id
	roleIdFlag bool

	blockRoles     []*BlockRole // block权限
	blockRolesFlag bool

	baseRule     map[string]int // base权限
	baseRuleFlag bool
}

func NewRoleBuilder() *RoleBuilder {
	builder := &RoleBuilder{}
	return builder
}

// 自定义权限的名字
//
// 示例值：自定义权限1
func (builder *RoleBuilder) RoleName(roleName string) *RoleBuilder {
	builder.roleName = roleName
	builder.roleNameFlag = true
	return builder
}

// 数据表权限
//
// 示例值：
func (builder *RoleBuilder) TableRoles(tableRoles []*TableRole) *RoleBuilder {
	builder.tableRoles = tableRoles
	builder.tableRolesFlag = true
	return builder
}

// 自定义权限的id
//
// 示例值：roljRpwIUt
func (builder *RoleBuilder) RoleId(roleId string) *RoleBuilder {
	builder.roleId = roleId
	builder.roleIdFlag = true
	return builder
}

// block权限
//
// 示例值：
func (builder *RoleBuilder) BlockRoles(blockRoles []*BlockRole) *RoleBuilder {
	builder.blockRoles = blockRoles
	builder.blockRolesFlag = true
	return builder
}

// base权限
//
// 示例值：{"duplicate": 1, "copy": 2}
func (builder *RoleBuilder) BaseRule(baseRule map[string]int) *RoleBuilder {
	builder.baseRule = baseRule
	builder.baseRuleFlag = true
	return builder
}

func (builder *RoleBuilder) Build() *Role {
	req := &Role{}
	if builder.roleNameFlag {
		req.RoleName = &builder.roleName

	}
	if builder.tableRolesFlag {
		req.TableRoles = builder.tableRoles
	}
	if builder.roleIdFlag {
		req.RoleId = &builder.roleId

	}
	if builder.blockRolesFlag {
		req.BlockRoles = builder.blockRoles
	}
	if builder.baseRuleFlag {
		req.BaseRule = builder.baseRule
	}
	return req
}

type TableRole struct {
	TablePerm *int `json:"table_perm,omitempty"` // 数据表权限

	TableName *string `json:"table_name,omitempty"` // 数据表名

	TableId *string `json:"table_id,omitempty"` // 数据表ID

	RecRule *RecRule `json:"rec_rule,omitempty"` // 记录筛选条件，在table_perm为1或2时有意义，用于指定可编辑或可阅读某些记录

	OtherRecRule *OtherRecRule `json:"other_rec_rule,omitempty"` // 记录筛选条件，在rec_rule.Perm为2时有意义，用于指定剩余可阅读的记录

	FieldPerm map[string]int `json:"field_perm,omitempty"` // 字段权限，仅在table_perm为2时有意义，设置字段可编辑或可阅读

	AllowAddRecord *bool `json:"allow_add_record,omitempty"` // 新增记录权限，仅在table_perm为2时有意义，用于设置记录是否可以新增

	AllowDeleteRecord *bool `json:"allow_delete_record,omitempty"` // 删除记录权限，仅在table_perm为2时有意义，用于设置记录是否可以删除

	ViewPerm *int `json:"view_perm,omitempty"` // 视图权限

	ViewRules map[string]int `json:"view_rules,omitempty"` // 可读的视图集合，仅在view_perm为1时有意义，未设置表示所有视图可读

	FieldActionRules map[string]map[string]int `json:"field_action_rules,omitempty"` // 可读的视图集合，仅在view_perm为1时有意义，未设置表示所有视图可读
}

type TableRoleBuilder struct {
	tablePerm     int // 数据表权限
	tablePermFlag bool

	tableName     string // 数据表名
	tableNameFlag bool

	tableId     string // 数据表ID
	tableIdFlag bool

	recRule     *RecRule // 记录筛选条件，在table_perm为1或2时有意义，用于指定可编辑或可阅读某些记录
	recRuleFlag bool

	otherRecRule     *OtherRecRule // 记录筛选条件，在rec_rule.Perm为2时有意义，用于指定剩余可阅读的记录
	otherRecRuleFlag bool

	fieldPerm     map[string]int // 字段权限，仅在table_perm为2时有意义，设置字段可编辑或可阅读
	fieldPermFlag bool

	allowAddRecord     bool // 新增记录权限，仅在table_perm为2时有意义，用于设置记录是否可以新增
	allowAddRecordFlag bool

	allowDeleteRecord     bool // 删除记录权限，仅在table_perm为2时有意义，用于设置记录是否可以删除
	allowDeleteRecordFlag bool

	viewPerm     int // 视图权限
	viewPermFlag bool

	viewRules     map[string]int // 可读的视图集合，仅在view_perm为1时有意义，未设置表示所有视图可读
	viewRulesFlag bool

	fieldActionRules     map[string]map[string]int // 可读的视图集合，仅在view_perm为1时有意义，未设置表示所有视图可读
	fieldActionRulesFlag bool
}

func NewTableRoleBuilder() *TableRoleBuilder {
	builder := &TableRoleBuilder{}
	return builder
}

// 数据表权限
//
// 示例值：0
func (builder *TableRoleBuilder) TablePerm(tablePerm int) *TableRoleBuilder {
	builder.tablePerm = tablePerm
	builder.tablePermFlag = true
	return builder
}

// 数据表名
//
// 示例值：数据表1
func (builder *TableRoleBuilder) TableName(tableName string) *TableRoleBuilder {
	builder.tableName = tableName
	builder.tableNameFlag = true
	return builder
}

// 数据表ID
//
// 示例值：tblKz5D60T4JlfcT
func (builder *TableRoleBuilder) TableId(tableId string) *TableRoleBuilder {
	builder.tableId = tableId
	builder.tableIdFlag = true
	return builder
}

// 记录筛选条件，在table_perm为1或2时有意义，用于指定可编辑或可阅读某些记录
//
// 示例值：
func (builder *TableRoleBuilder) RecRule(recRule *RecRule) *TableRoleBuilder {
	builder.recRule = recRule
	builder.recRuleFlag = true
	return builder
}

// 记录筛选条件，在rec_rule.Perm为2时有意义，用于指定剩余可阅读的记录
//
// 示例值：
func (builder *TableRoleBuilder) OtherRecRule(otherRecRule *OtherRecRule) *TableRoleBuilder {
	builder.otherRecRule = otherRecRule
	builder.otherRecRuleFlag = true
	return builder
}

// 字段权限，仅在table_perm为2时有意义，设置字段可编辑或可阅读
//
// 示例值：{"姓名": 1, "年龄": 2}
func (builder *TableRoleBuilder) FieldPerm(fieldPerm map[string]int) *TableRoleBuilder {
	builder.fieldPerm = fieldPerm
	builder.fieldPermFlag = true
	return builder
}

// 新增记录权限，仅在table_perm为2时有意义，用于设置记录是否可以新增
//
// 示例值：true
func (builder *TableRoleBuilder) AllowAddRecord(allowAddRecord bool) *TableRoleBuilder {
	builder.allowAddRecord = allowAddRecord
	builder.allowAddRecordFlag = true
	return builder
}

// 删除记录权限，仅在table_perm为2时有意义，用于设置记录是否可以删除
//
// 示例值：true
func (builder *TableRoleBuilder) AllowDeleteRecord(allowDeleteRecord bool) *TableRoleBuilder {
	builder.allowDeleteRecord = allowDeleteRecord
	builder.allowDeleteRecordFlag = true
	return builder
}

// 视图权限
//
// 示例值：2
func (builder *TableRoleBuilder) ViewPerm(viewPerm int) *TableRoleBuilder {
	builder.viewPerm = viewPerm
	builder.viewPermFlag = true
	return builder
}

// 可读的视图集合，仅在view_perm为1时有意义，未设置表示所有视图可读
//
// 示例值：{"vewEYknYcC": 0}
func (builder *TableRoleBuilder) ViewRules(viewRules map[string]int) *TableRoleBuilder {
	builder.viewRules = viewRules
	builder.viewRulesFlag = true
	return builder
}

// 可读的视图集合，仅在view_perm为1时有意义，未设置表示所有视图可读
//
// 示例值：{"select_option_edit": {"字段1"：0}}
func (builder *TableRoleBuilder) FieldActionRules(fieldActionRules map[string]map[string]int) *TableRoleBuilder {
	builder.fieldActionRules = fieldActionRules
	builder.fieldActionRulesFlag = true
	return builder
}

func (builder *TableRoleBuilder) Build() *TableRole {
	req := &TableRole{}
	if builder.tablePermFlag {
		req.TablePerm = &builder.tablePerm

	}
	if builder.tableNameFlag {
		req.TableName = &builder.tableName

	}
	if builder.tableIdFlag {
		req.TableId = &builder.tableId

	}
	if builder.recRuleFlag {
		req.RecRule = builder.recRule
	}
	if builder.otherRecRuleFlag {
		req.OtherRecRule = builder.otherRecRule
	}
	if builder.fieldPermFlag {
		req.FieldPerm = builder.fieldPerm
	}
	if builder.allowAddRecordFlag {
		req.AllowAddRecord = &builder.allowAddRecord

	}
	if builder.allowDeleteRecordFlag {
		req.AllowDeleteRecord = &builder.allowDeleteRecord

	}
	if builder.viewPermFlag {
		req.ViewPerm = &builder.viewPerm

	}
	if builder.viewRulesFlag {
		req.ViewRules = builder.viewRules
	}
	if builder.fieldActionRulesFlag {
		req.FieldActionRules = builder.fieldActionRules
	}
	return req
}

type TemplateInfo struct {
	TemplateType *int `json:"template_type,omitempty"` // 是否是模板

	PublishFlag *int `json:"publish_flag,omitempty"` //
}

type TemplateInfoBuilder struct {
	templateType     int // 是否是模板
	templateTypeFlag bool

	publishFlag     int //
	publishFlagFlag bool
}

func NewTemplateInfoBuilder() *TemplateInfoBuilder {
	builder := &TemplateInfoBuilder{}
	return builder
}

// 是否是模板
//
// 示例值：
func (builder *TemplateInfoBuilder) TemplateType(templateType int) *TemplateInfoBuilder {
	builder.templateType = templateType
	builder.templateTypeFlag = true
	return builder
}

//
//
// 示例值：
func (builder *TemplateInfoBuilder) PublishFlag(publishFlag int) *TemplateInfoBuilder {
	builder.publishFlag = publishFlag
	builder.publishFlagFlag = true
	return builder
}

func (builder *TemplateInfoBuilder) Build() *TemplateInfo {
	req := &TemplateInfo{}
	if builder.templateTypeFlag {
		req.TemplateType = &builder.templateType

	}
	if builder.publishFlagFlag {
		req.PublishFlag = &builder.publishFlag

	}
	return req
}

type CreateAppRoleReqBuilder struct {
	apiReq *larkcore.ApiReq
	role   *Role
}

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

// 多维表格的唯一标识符
//
// 示例值：appbcbWCzen6D8dezhoCH2RpMAh
func (builder *CreateAppRoleReqBuilder) AppToken(appToken string) *CreateAppRoleReqBuilder {
	builder.apiReq.PathParams.Set("app_token", fmt.Sprint(appToken))
	return builder
}

// 新增自定义角色
func (builder *CreateAppRoleReqBuilder) Role(role *Role) *CreateAppRoleReqBuilder {
	builder.role = role
	return builder
}

func (builder *CreateAppRoleReqBuilder) Build() *CreateAppRoleReq {
	req := &CreateAppRoleReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.role
	return req
}

type CreateAppRoleReq struct {
	apiReq *larkcore.ApiReq
	Role   *Role `body:""`
}

type CreateAppRoleRespData struct {
	Role *Role `json:"role,omitempty"` // 自定义权限
}

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

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

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

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

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

// 多维表格的唯一标识符
//
// 示例值：appbcbWCzen6D8dezhoCH2RpMAh
func (builder *ListAppRoleReqBuilder) AppToken(appToken string) *ListAppRoleReqBuilder {
	builder.apiReq.PathParams.Set("app_token", fmt.Sprint(appToken))
	return builder
}

//
//
// 示例值：
func (builder *ListAppRoleReqBuilder) PageSize(pageSize int) *ListAppRoleReqBuilder {
	builder.apiReq.QueryParams.Set("page_size", fmt.Sprint(pageSize))
	return builder
}

//
//
// 示例值：
func (builder *ListAppRoleReqBuilder) PageToken(pageToken string) *ListAppRoleReqBuilder {
	builder.apiReq.QueryParams.Set("page_token", fmt.Sprint(pageToken))
	return builder
}

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

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

}

type ListAppRoleRespData struct {
	Items []*Role `json:"items,omitempty"` // 自定义角色列表

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

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

	Total *int `json:"total,omitempty"` // 总数
}

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

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

type UpdateAppRoleReqBuilder struct {
	apiReq *larkcore.ApiReq
	role   *Role
}

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

// 多维表格的唯一标识符
//
// 示例值：appbcbWCzen6D8dezhoCH2RpMAh
func (builder *UpdateAppRoleReqBuilder) AppToken(appToken string) *UpdateAppRoleReqBuilder {
	builder.apiReq.PathParams.Set("app_token", fmt.Sprint(appToken))
	return builder
}

// 自定义角色的id;
//
// 示例值：roljRpwIUt
func (builder *UpdateAppRoleReqBuilder) RoleId(roleId string) *UpdateAppRoleReqBuilder {
	builder.apiReq.PathParams.Set("role_id", fmt.Sprint(roleId))
	return builder
}

// 更新自定义角色
func (builder *UpdateAppRoleReqBuilder) Role(role *Role) *UpdateAppRoleReqBuilder {
	builder.role = role
	return builder
}

func (builder *UpdateAppRoleReqBuilder) Build() *UpdateAppRoleReq {
	req := &UpdateAppRoleReq{}
	req.apiReq = &larkcore.ApiReq{}
	req.apiReq.PathParams = builder.apiReq.PathParams
	req.apiReq.Body = builder.role
	return req
}

type UpdateAppRoleReq struct {
	apiReq *larkcore.ApiReq
	Role   *Role `body:""`
}

type UpdateAppRoleRespData struct {
	Role *Role `json:"role,omitempty"` // 自定义角色
}

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

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

type ListAppRoleIterator struct {
	nextPageToken *string
	items         []*Role
	index         int
	limit         int
	ctx           context.Context
	req           *ListAppRoleReq
	listFunc      func(ctx context.Context, req *ListAppRoleReq, options ...larkcore.RequestOptionFunc) (*ListAppRoleResp, error)
	options       []larkcore.RequestOptionFunc
	curlNum       int
}

func (iterator *ListAppRoleIterator) Next() (bool, *Role, 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 *ListAppRoleIterator) NextPageToken() *string {
	return iterator.nextPageToken
}
