-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathapi_drive_file_create.go
86 lines (76 loc) · 4.2 KB
/
api_drive_file_create.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// 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"
)
// CreateDriveFile 该接口用于在云空间指定文件夹中创建电子表格或者多维表格。
//
// 推荐你使用[创建表格](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/sheets-v3/spreadsheet/create)或[创建多维表格](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/bitable-v1/app/create)接口, 能力和权限拆分力度更细。
// 使用限制:
// - 云空间中根目录或文件夹的单层节点上限为 1500 个。超过此限制时, 接口将返回 1062507 错误码。可通过将文件新建到不同文件夹中解决。
// - 云空间中所有层级的节点总和的上限为 40 万个。
// - 该接口不支持并发调用, 且调用频率上限为 5QPS 且 10000次/天。否则会返回 1061045 错误码, 可通过稍后重试解决。
// - 该接口不支持创建[文档](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-overview)(文档类型为 `docx`), 如需创建文档, 请调用[创建文档](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document/create)接口。
//
// doc: https://open.feishu.cn/document/ukTMukTMukTM/uQTNzUjL0UzM14CN1MTN
// new doc: https://open.feishu.cn/document/server-docs/docs/drive-v1/file/create-online-document
func (r *DriveService) CreateDriveFile(ctx context.Context, request *CreateDriveFileReq, options ...MethodOptionFunc) (*CreateDriveFileResp, *Response, error) {
if r.cli.mock.mockDriveCreateDriveFile != nil {
r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#CreateDriveFile mock enable")
return r.cli.mock.mockDriveCreateDriveFile(ctx, request, options...)
}
req := &RawRequestReq{
Scope: "Drive",
API: "CreateDriveFile",
Method: "POST",
URL: r.cli.openBaseURL + "/open-apis/drive/explorer/v2/file/:folderToken",
Body: request,
MethodOption: newMethodOption(options),
NeedTenantAccessToken: true,
NeedUserAccessToken: true,
}
resp := new(createDriveFileResp)
response, err := r.cli.RawRequest(ctx, req, resp)
return resp.Data, response, err
}
// MockDriveCreateDriveFile mock DriveCreateDriveFile method
func (r *Mock) MockDriveCreateDriveFile(f func(ctx context.Context, request *CreateDriveFileReq, options ...MethodOptionFunc) (*CreateDriveFileResp, *Response, error)) {
r.mockDriveCreateDriveFile = f
}
// UnMockDriveCreateDriveFile un-mock DriveCreateDriveFile method
func (r *Mock) UnMockDriveCreateDriveFile() {
r.mockDriveCreateDriveFile = nil
}
// CreateDriveFileReq ...
type CreateDriveFileReq struct {
FolderToken string `path:"folderToken" json:"-"` // 指定新建文件所属的文件夹或云空间根目录的 token。了解如何获取文件夹 token, 参考[文件夹概述](https://open.feishu.cn/document/ukTMukTMukTM/ugTNzUjL4UzM14CO1MTN/folder-overview)。
Title string `json:"title,omitempty"` // 创建的文件的标题。
Type string `json:"type,omitempty"` // 需要创建的文件的类型, 可选值: sheet: 电子表格, bitable: 多维表格
}
// CreateDriveFileResp ...
type CreateDriveFileResp struct {
URL string `json:"url,omitempty"` // 新创建文件的访问链接
Token string `json:"token,omitempty"` // 新创建文件的 token
Revision int64 `json:"revision,omitempty"` // 新创建文件的版本号
}
// createDriveFileResp ...
type createDriveFileResp struct {
Code int64 `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
Data *CreateDriveFileResp `json:"data,omitempty"`
}