-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathapi_drive_export_task_create.go
79 lines (69 loc) · 4.82 KB
/
api_drive_export_task_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
// 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"
)
// CreateDriveExportTask 该接口用于创建导出文件的任务, 并返回导出任务 ID。导出文件指将飞书文档、电子表格、多维表格导出为本地文件。该接口为异步接口, 需要继续调用[查询导出任务结果](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/export_task/get)接口获取导出结果。了解完整的导出文件步骤, 参考[导出飞书云文档概述](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/export_task/export-user-guide)。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/export_task/create
// new doc: https://open.feishu.cn/document/server-docs/docs/drive-v1/export_task/create
func (r *DriveService) CreateDriveExportTask(ctx context.Context, request *CreateDriveExportTaskReq, options ...MethodOptionFunc) (*CreateDriveExportTaskResp, *Response, error) {
if r.cli.mock.mockDriveCreateDriveExportTask != nil {
r.cli.Log(ctx, LogLevelDebug, "[lark] Drive#CreateDriveExportTask mock enable")
return r.cli.mock.mockDriveCreateDriveExportTask(ctx, request, options...)
}
req := &RawRequestReq{
Scope: "Drive",
API: "CreateDriveExportTask",
Method: "POST",
URL: r.cli.openBaseURL + "/open-apis/drive/v1/export_tasks",
Body: request,
MethodOption: newMethodOption(options),
NeedTenantAccessToken: true,
NeedUserAccessToken: true,
}
resp := new(createDriveExportTaskResp)
response, err := r.cli.RawRequest(ctx, req, resp)
return resp.Data, response, err
}
// MockDriveCreateDriveExportTask mock DriveCreateDriveExportTask method
func (r *Mock) MockDriveCreateDriveExportTask(f func(ctx context.Context, request *CreateDriveExportTaskReq, options ...MethodOptionFunc) (*CreateDriveExportTaskResp, *Response, error)) {
r.mockDriveCreateDriveExportTask = f
}
// UnMockDriveCreateDriveExportTask un-mock DriveCreateDriveExportTask method
func (r *Mock) UnMockDriveCreateDriveExportTask() {
r.mockDriveCreateDriveExportTask = nil
}
// CreateDriveExportTaskReq ...
type CreateDriveExportTaskReq struct {
FileExtension string `json:"file_extension,omitempty"` // 将云文档导出为本地文件后, 本地文件的扩展名。了解各类云文档支持导出的文件格式, 参考[导出飞书云文档概述](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/export_task/export-user-guide), 示例值: "csv", 可选值有: docx: Microsoft Word 格式, pdf: PDF 格式, xlsx: Microsoft Excel 格式, csv: CSV 格式
Token string `json:"token,omitempty"` // 要导出的云文档的 token。获取方式参考 [如何获取云文档相关 token](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#08bb5df6), 示例值: "shtcnxe5OxxxxxxxSNdsJviENsk", 最大长度: `27` 字符
Type string `json:"type,omitempty"` // 要导出的云文档的类型 。可通过云文档的链接判断, 示例值: "sheet", 可选值有: doc: 旧版飞书文档。支持导出扩展名为 docx 和 pdf 的文件。, sheet: 飞书电子表格。支持导出扩展名为 xlsx 和 csv 的文件。, bitable: 飞书多维表格。支持导出扩展名为 xlsx 和 csv 格式的文件。, docx: 新版飞书文档。支持导出扩展名为 docx 和 pdf 格式的文件。
SubID *string `json:"sub_id,omitempty"` // 导出飞书电子表格为 CSV 文件时, 需传入电子表格子表的 ID, 你需调用, [获取工作表](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/sheets-v3/spreadsheet-sheet/query) 接口获取返回的 `sheet_id` 的值作为该参数的值, 示例值: "tblKz5D60T4abcef"
}
// CreateDriveExportTaskResp ...
type CreateDriveExportTaskResp struct {
Ticket string `json:"ticket,omitempty"` // 导出任务的 ID
}
// createDriveExportTaskResp ...
type createDriveExportTaskResp struct {
Code int64 `json:"code,omitempty"` // 错误码, 非 0 表示失败
Msg string `json:"msg,omitempty"` // 错误描述
Data *CreateDriveExportTaskResp `json:"data,omitempty"`
Error *ErrorDetail `json:"error,omitempty"`
}