diff --git a/api_drive_wiki_node_search.go b/api_drive_wiki_node_search.go new file mode 100644 index 00000000..a483caf0 --- /dev/null +++ b/api_drive_wiki_node_search.go @@ -0,0 +1,91 @@ +// Code generated by lark_sdk_gen. DO NOT EDIT. +/** + * Copyright 2022 chyroc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package lark + +import ( + "context" +) + +// SearchWikiNode 搜索 Wiki, 用户通过关键词查询 Wiki, 只能查找自己可见的 wiki +// +// 注: Wiki 存在, 但用户搜索不到并不一定是搜索有问题, 可能是用户没有查看该 Wiki 的权限 +// +// doc: https://open.feishu.cn/document/ukTMukTMukTM/uEzN0YjLxcDN24SM3QjN/search_wiki +// new doc: https://open.feishu.cn/document/server-docs/docs/wiki-v2/search_wiki +func (r *DriveService) SearchWikiNode(ctx context.Context, request *SearchWikiNodeReq, options ...MethodOptionFunc) (*SearchWikiNodeResp, *Response, error) { + if r.cli.mock.mockDriveSearchWikiNode != nil { + r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#SearchWikiNode mock enable") + return r.cli.mock.mockDriveSearchWikiNode(ctx, request, options...) + } + + req := &RawRequestReq{ + Scope: "Drive", + API: "SearchWikiNode", + Method: "POST", + URL: r.cli.openBaseURL + "/open-apis/wiki/v2/nodes/search", + Body: request, + MethodOption: newMethodOption(options), + } + resp := new(searchWikiNodeResp) + + response, err := r.cli.RawRequest(ctx, req, resp) + return resp.Data, response, err +} + +// MockDriveSearchWikiNode mock DriveSearchWikiNode method +func (r *Mock) MockDriveSearchWikiNode(f func(ctx context.Context, request *SearchWikiNodeReq, options ...MethodOptionFunc) (*SearchWikiNodeResp, *Response, error)) { + r.mockDriveSearchWikiNode = f +} + +// UnMockDriveSearchWikiNode un-mock DriveSearchWikiNode method +func (r *Mock) UnMockDriveSearchWikiNode() { + r.mockDriveSearchWikiNode = nil +} + +// SearchWikiNodeReq ... +type SearchWikiNodeReq struct { + PageToken *string `query:"page_token" json:"-"` // 下一页的分页 token, 首页不需要填写, 根据返回的 token 获取下一页数据 + PageSize *int64 `query:"page_size" json:"-"` // 本页返回数量的最大值 0 < page_size <= 50 默认 20 + Query string `json:"query,omitempty"` // 搜索关键词, 长度不超过50个字符 + SpaceID *string `json:"space_id,omitempty"` // 文档所属的知识空间ID, 为空搜索全部知识空间 + NodeID *string `json:"node_id,omitempty"` // 不为空搜索该节点及其所有子节点, 为空搜索所有 wiki(使用 node_id 过滤必须传入 space_id) +} + +// SearchWikiNodeResp ... +type SearchWikiNodeResp struct { + Items []interface{} `json:"items,omitempty"` // wiki 信息数组 + NodeID string `json:"node_id,omitempty"` // wiki 节点的 token + SpaceID string `json:"space_id,omitempty"` // wiki 所属知识空间 Id + ObjType int64 `json:"obj_type,omitempty"` // wiki 类型, 参考文档类型表 + ObjToken string `json:"obj_token,omitempty"` // 节点的真实文档的 token, 如果要获取或编辑节点内容, 需要使用此 token 调用对应的接口 + ParentID string `json:"parent_id,omitempty"` // 暂未生效, 一律返回空 + SortID int64 `json:"sort_id,omitempty"` // 该知识库文档的序号, 从 1 开始计数 + Title string `json:"title,omitempty"` // wiki 标题 + URL string `json:"url,omitempty"` // wiki 的访问 url + Icon string `json:"icon,omitempty"` // wiki 对应图标的 url + PageToken string `json:"page_token,omitempty"` // 如果 has_more 为 true 则返回下一页的 token + HasMore bool `json:"has_more,omitempty"` // 是否还有下一页数据 +} + +// searchWikiNodeResp ... +type searchWikiNodeResp struct { + Code int64 `json:"code,omitempty"` // 错误码, 非 0 表示失败 + Msg string `json:"msg,omitempty"` // 错误描述 + Data *SearchWikiNodeResp `json:"data,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` +} diff --git a/mock.go b/mock.go index 5a74771c..51e6157a 100644 --- a/mock.go +++ b/mock.go @@ -26,6 +26,7 @@ type Mock struct { mockRawRequest func(ctx context.Context, req *RawRequestReq, resp interface{}) (response *Response, err error) mockGetTenantAccessToken func(ctx context.Context) (*TokenExpire, *Response, error) mockGetAppAccessToken func(ctx context.Context) (*TokenExpire, *Response, error) + mockDriveSearchWikiNode func(ctx context.Context, request *SearchWikiNodeReq, options ...MethodOptionFunc) (*SearchWikiNodeResp, *Response, error) mockACSCreateACSRuleExternal func(ctx context.Context, request *CreateACSRuleExternalReq, options ...MethodOptionFunc) (*CreateACSRuleExternalResp, *Response, error) mockACSCreateACSVisitor func(ctx context.Context, request *CreateACSVisitorReq, options ...MethodOptionFunc) (*CreateACSVisitorResp, *Response, error) mockACSDeleteACSRuleExternal func(ctx context.Context, request *DeleteACSRuleExternalReq, options ...MethodOptionFunc) (*DeleteACSRuleExternalResp, *Response, error)