添加归档任务

添加归档任务,用于将录音文件或备份文件归档到归档服务器。

请求 URL

POST {base_url}/{api_path}/archive_task/create?access_token={access_token}

请求参数

参数 是否必填 类型 说明
name 是 String 归档任务的名称。
file_type 是 String 归档文件的类型。

取值范围:

  • recording_files:录音文件。
  • backup_files:备份文件。
time_range 是 String 归档文件的时间范围。

取值范围:

  • today:今天
  • yesterday:昨天
  • last_7days:最近 7 天
  • last_30days:最近 30 天
  • this_month:本月
  • last_month:上个月
  • custom:自定义
    注: 如果设置为 custom,必须同时指定 time_begin 和 time_end。
time_begin 否 String 归档时间范围的开始时间,采用系统日期和时间格式。
注: 当 time_range 为 custom 时,此参数必填。
time_end 否 String 归档时间范围的结束时间,采用系统日期和时间格式。
注:
  • 当 time_range 为 custom 时,此参数必填。
  • 此值必须晚于 time_begin,且两者之间的间隔不得超过 31 天。
freq_type 是 String 归档任务的执行频率。

取值范围:

  • now:立即执行一次。
  • daily:每天执行。
  • weekly:每周执行。
  • monthly:每月执行。
freq_week 否 Integer 执行归档任务的星期。

取值范围:

  • 1:星期一。
  • 2:星期二。
  • 3:星期三。
  • 4:星期四。
  • 5:星期五。
  • 6:星期六。
  • 7:星期日。
注: 当 freq_type 为 weekly 时,此参数必填。
freq_day 否 Integer 执行归档任务的日期。

取值范围:1 到 31,其中 -1 表示当月的最后一天。

注: 当 freq_type 为 monthly 时,此参数必填。
freq_time 否 String 归档任务的执行时间,采用 24 小时制。
注: 当 freq_type 不为 now 时,此参数必填。
record_file_format 否 String 录音文件的格式。
注: 当 file_type 为 recording_files 时,此参数必填。

取值范围:

  • wav:WAV 格式。
  • mp3:MP3 格式。
auth_info_id 是 Integer 关联的归档服务器的 ID。
注: 可通过 查询归档服务器列表 接口获取该 ID。
file_path 否 String 归档服务器上的目标文件路径。
注: 仅当关联归档服务器的 server_type 为 ftp 或 sftp 时,此参数才生效。
bucket_name 否 String 存储桶的名称。
注: 仅当关联归档服务器的 server_type 为 amazon_s3 或 google_storage 时,此参数才生效。
bucket_path 否 String 存储桶内的目标路径前缀。
region 否 String 云存储的区域。
site_id 否 String SharePoint 站点的 ID。
注:
  • 仅当关联归档服务器的 server_type 为 sharepoint 时,此参数才生效。
  • 可通过 查询存储桶列表 接口获取该 ID,需将 bucket_info_type 设置为 3。
site_name 否 String SharePoint 站点的名称。
注:
  • 仅当关联归档服务器的 server_type 为 sharepoint 时,此参数才生效。
  • 可通过 查询存储桶列表 接口获取该 ID,需将 bucket_info_type 设置为 3。
drive_id 否 String SharePoint 文档库的 ID。
注:
  • 仅当关联归档服务器的 server_type 为 sharepoint 时,此参数才生效。
  • 可通过 查询存储桶列表 接口获取该 ID,需将 bucket_info_type 设置为 3。
drive_name 否 String SharePoint 文档库的名称。
注:
  • 仅当关联归档服务器的 server_type 为 sharepoint 时,此参数才生效。
  • 可通过 查询存储桶列表 接口获取该 ID,需将 bucket_info_type 设置为 3。
path_id 否 String SharePoint 文件夹的 ID。
注: 仅当关联归档服务器的 server_type 为 sharepoint 时,此参数才生效。
storage_method 否 String 归档文件的存储方式。

取值范围:

  • create_folder_once:在所选路径下创建名为“FileType-TaskName”的文件夹,并将文件存储在该文件夹内。
  • create_folder_each_time:每次任务执行时,在所选路径下创建名为“FileType-TaskName-ExecutionDate”的文件夹,并将文件存储在该文件夹内。
  • create_folder_reuse:首次执行时在所选路径下创建名为“FileType-TaskName”的文件夹,后续执行产生的文件存储在同一文件夹内。
  • direct_save:将归档文件直接保存到所选路径,不创建文件夹。
注: 当 freq_type 不为 now 时,此参数不能设置为 create_folder_once。
enb_skip_achive_file 否 Integer 是否跳过已归档的录音文件。

取值范围:

  • 0:再次归档已归档的录音文件。
  • 1:跳过已归档的录音文件。
enb_delete_local_file 否 Integer 归档后是否删除本地文件。

取值范围:

  • 0:保留本地文件。
  • 1:删除本地文件。
enable_retention 否 Integer 是否启用文件保留策略。

取值范围:

  • 0:禁用文件保留策略。
  • 1:启用文件保留策略。
retention_type 否 String 文件保留方式。
注: 当 enable_retention 为 1 时,此参数必填。

取值范围:

  • quantity:按数量保留文件。
  • days:按天数保留文件。
retention_unit 否 String 保留单位。
注: 当 enable_retention 为 1 时,此参数必填。

取值范围:

  • folder:对文件夹应用保留策略。
    注: 仅当 storage_method 为 create_folder_each_time 时,才支持设置为 folder。
  • file:对文件应用保留策略。
file_rotation_num 否 Integer 保留上限,单位由 retention_type 指定。
注: 仅当 enable_retention 为 1 时,此参数才会生效。
file_organization_by_date 否 Integer 是否按日期分类存储归档文件。

取值范围:

  • 0:不按日期分类存储。
  • 1:按日期分类存储。

响应参数

参数 类型 说明
errcode Integer 返回错误码。
  • 0:请求成功。
  • 非零值:请求失败。
注: 更多错误码和错误信息说明,请参见 错误码 & 错误信息。
errmsg String 返回信息。
  • SUCCESS:请求成功。
  • FAILURE:请求失败。
id Integer 创建的归档任务的 ID。
upper_limited Integer 归档任务的数量上限,当 errcode 为 60002 (达到数量上限) 时返回。

示例

请求示例

POST /openapi/v1.0/archive_task/create?access_token=gwakjgu9ZBUfz36wql4ndsVKkryI0kdj HTTP/1.1

Host: yeastardocs.example.yeastarcloud.com
Content-Type: application/json
{
  "name": "January-Backup",
  "auth_info_id": 9,
  "file_type": "backup_files",
  "time_range": "today",
  "freq_type": "now",
  "storage_method": "create_folder_once",
  "enb_skip_achive_file": 0,
  "enb_delete_local_file": 0,
  "file_organization_by_date": 0
}

响应示例

HTTP/1.1 200 OK
{
  "errcode": 0,
  "errmsg": "SUCCESS",
  "submsg": "",
  "id": 12,
  "upper_limited": 0
}