Skip to content

Commit

Permalink
add archive ir
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSen-qn committed Nov 24, 2023
1 parent 95f9382 commit 9f1f593
Show file tree
Hide file tree
Showing 22 changed files with 74 additions and 47 deletions.
5 changes: 3 additions & 2 deletions cmd/asyncfetch.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/qiniu/qshell/v2/docs"
"github.com/qiniu/qshell/v2/iqshell"
"github.com/qiniu/qshell/v2/iqshell/storage/object/operations"
"github.com/spf13/cobra"
)

func asyncFetchCmdBuilder(cfg *iqshell.Config) *cobra.Command {
Expand Down Expand Up @@ -32,7 +33,7 @@ func asyncFetchCmdBuilder(cfg *iqshell.Config) *cobra.Command {
cmd.Flags().StringVarP(&info.CallbackBody, "callback-body", "b", "", "callback body")
cmd.Flags().StringVarP(&info.CallbackHost, "callback-host", "T", "", "callback HOST")

cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "storage type, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage")
cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "storage type, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage, 4:ARCHIVE_IR storage")
cmd.Flags().IntVarP(&info.FileType, "storage-type", "g", 0, "storage type, same to --file-type")
_ = cmd.Flags().MarkDeprecated("storage-type", "use --file-type instead") // 废弃 storage-type

Expand Down
5 changes: 3 additions & 2 deletions cmd/bucket.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/qiniu/qshell/v2/docs"
"github.com/qiniu/qshell/v2/iqshell"
"github.com/qiniu/qshell/v2/iqshell/common/data"
"github.com/qiniu/qshell/v2/iqshell/storage/bucket/operations"
"github.com/spf13/cobra"
)

var domainsCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
Expand Down Expand Up @@ -136,7 +137,7 @@ var listBucketCmd2Builder = func(cfg *iqshell.Config) *cobra.Command {
cmd.Flags().StringVarP(&info.StartDate, "start", "s", "", "start date with format yyyy-mm-dd-hh-MM-ss, all files will be listed according to the prefix and then filtered.")
cmd.Flags().StringVarP(&info.EndDate, "end", "e", "", "end date with format yyyy-mm-dd-hh-MM-ss, all files will be listed according to the prefix and then filtered.")

cmd.Flags().StringVarP(&info.FileTypes, "file-types", "", "", "Specify storage type, separated by comma, all files will be listed according to the prefix and then filtered. 0:STANDARD storage, 1:IA storage, 2 means ARCHIVE storage. 3:DEEP_ARCHIVE storage")
cmd.Flags().StringVarP(&info.FileTypes, "file-types", "", "", "Specify storage type, separated by comma, all files will be listed according to the prefix and then filtered. 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage 4:ARCHIVE_IR storage")
cmd.Flags().StringVarP(&info.FileTypes, "storages", "", "", "Specify storage type, same to --file-types")
_ = cmd.Flags().MarkDeprecated("storages", "use --file-types instead") // 废弃 storages

Expand Down
11 changes: 7 additions & 4 deletions cmd/rs.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cmd

import (
"github.com/spf13/cobra"

"github.com/qiniu/qshell/v2/docs"
"github.com/qiniu/qshell/v2/iqshell"
"github.com/qiniu/qshell/v2/iqshell/storage/object/operations"
"github.com/spf13/cobra"
)

var statCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
Expand Down Expand Up @@ -88,8 +89,9 @@ var changeLifecycleCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
},
}
cmd.Flags().IntVarP(&info.ToIAAfterDays, "to-ia-after-days", "", 0, "to IA storage after some days. the range is -1 or bigger than 0. -1 means cancel to IA storage")
cmd.Flags().IntVarP(&info.ToArchiveAfterDays, "to-archive-after-days", "", 0, "to archive storage after some days. the range is -1 or bigger than 0. -1 means cancel to archive storage")
cmd.Flags().IntVarP(&info.ToDeepArchiveAfterDays, "to-deep-archive-after-days", "", 0, "to deep archive storage after some days. the range is -1 or bigger than 0. -1 means cancel to deep archive storage")
cmd.Flags().IntVarP(&info.ToArchiveIRAfterDays, "to-archive-ir-after-days", "", 0, "to ARCHIVE_IR storage after some days. the range is -1 or bigger than 0. -1 means cancel to ARCHIVE_IR storage")
cmd.Flags().IntVarP(&info.ToArchiveAfterDays, "to-archive-after-days", "", 0, "to ARCHIVE storage after some days. the range is -1 or bigger than 0. -1 means cancel to ARCHIVE storage")
cmd.Flags().IntVarP(&info.ToDeepArchiveAfterDays, "to-deep-archive-after-days", "", 0, "to DEEP_ARCHIVE storage after some days. the range is -1 or bigger than 0. -1 means cancel to DEEP_ARCHIVE storage")
cmd.Flags().IntVarP(&info.DeleteAfterDays, "delete-after-days", "", 0, "delete after some days. the range is -1 or bigger than 0. -1 means cancel to delete")
return cmd
}
Expand Down Expand Up @@ -242,7 +244,8 @@ var changeTypeCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
And 0 means STANDARD storage,
while 1 means IA storage,
while 2 means ARCHIVE storage.
while 3 means DEEP_ARCHIVE storage.`,
while 3 means DEEP_ARCHIVE storage.
while 4 means ARCHIVE_IR storage.`,
Example: `change storage type of A.png(bucket:bucketA key:A.png) to ARCHIVE storage
qshell chtype bucketA A.png 2
and you can check result by command:
Expand Down
5 changes: 3 additions & 2 deletions cmd/rsbatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ Lifecycle value must great than or equal to -1, unit: day.
},
}
cmd.Flags().IntVarP(&info.ToIAAfterDays, "to-ia-after-days", "", 0, "to IA storage after some days. the range is -1 or bigger than 0. -1 means cancel to IA storage")
cmd.Flags().IntVarP(&info.ToArchiveAfterDays, "to-archive-after-days", "", 0, "to archive storage after some days. the range is -1 or bigger than 0. -1 means cancel to archive storage")
cmd.Flags().IntVarP(&info.ToDeepArchiveAfterDays, "to-deep-archive-after-days", "", 0, "to deep archive storage after some days. the range is -1 or bigger than 0. -1 means cancel to deep archive storage")
cmd.Flags().IntVarP(&info.ToArchiveIRAfterDays, "to-archive-ir-after-days", "", 0, "to ARCHIVE_IR storage after some days. the range is -1 or bigger than 0. -1 means cancel to ARCHIVE_IR storage")
cmd.Flags().IntVarP(&info.ToArchiveAfterDays, "to-archive-after-days", "", 0, "to ARCHIVE storage after some days. the range is -1 or bigger than 0. -1 means cancel to ARCHIVE storage")
cmd.Flags().IntVarP(&info.ToDeepArchiveAfterDays, "to-deep-archive-after-days", "", 0, "to DEEP_ARCHIVE storage after some days. the range is -1 or bigger than 0. -1 means cancel to DEEP_ARCHIVE storage")
cmd.Flags().IntVarP(&info.DeleteAfterDays, "delete-after-days", "", 0, "delete after some days. the range is -1 or bigger than 0. -1 means cancel to delete")
setBatchCmdDefaultFlags(cmd, &info.BatchInfo)
return cmd
Expand Down
8 changes: 4 additions & 4 deletions cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var upload2CmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
cmd.Flags().StringVar(&LogLevel, "log-level", "debug", "log level")
cmd.Flags().IntVar(&LogRotate, "log-rotate", 7, "log rotate days")

cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage")
cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage, 4:ARCHIVE_IR storage")
cmd.Flags().IntVarP(&info.FileType, "storage", "", 0, "set storage type of file, same to --file-type")
_ = cmd.Flags().MarkDeprecated("storage", "use --file-type instead") // 废弃 storage

Expand Down Expand Up @@ -135,7 +135,7 @@ var syncCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
cmd.Flags().Int64VarP(&info.ChunkSize, "resumable-api-v2-part-size", "", data.BLOCK_SIZE, "the part size when use resumable upload v2 APIs to upload, default 4M")
cmd.Flags().StringVarP(&info.UpHost, "up-host", "u", "", "upload host")

cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage")
cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage, 4:ARCHIVE_IR storage")
cmd.Flags().IntVarP(&info.FileType, "storage", "s", 0, "set storage type of file, same to --file-type")
_ = cmd.Flags().MarkDeprecated("storage", "use --file-type instead") // 废弃 storage

Expand Down Expand Up @@ -169,7 +169,7 @@ var formUploadCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
cmd.Flags().BoolVarP(&info.Overwrite, "overwrite", "", false, "overwrite the file of same key in bucket")
cmd.Flags().StringVarP(&info.MimeType, "mimetype", "t", "", "file mime type")

cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage")
cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage, 4:ARCHIVE_IR storage")
cmd.Flags().IntVarP(&info.FileType, "storage", "s", 0, "set storage type of file, same to --file-type")
_ = cmd.Flags().MarkDeprecated("storage", "use --file-type instead") // 废弃 storage

Expand Down Expand Up @@ -211,7 +211,7 @@ var resumeUploadCmdBuilder = func(cfg *iqshell.Config) *cobra.Command {
cmd.Flags().Int64VarP(&info.ChunkSize, "v2-part-size", "", data.BLOCK_SIZE, "the part size when use resumable upload v2 APIs to upload, same to --resumable-api-v2-part-size")
_ = cmd.Flags().MarkDeprecated("v2-part-size", "use --resumable-api-v2-part-size instead")

cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage")
cmd.Flags().IntVarP(&info.FileType, "file-type", "", 0, "set storage type of file, 0:STANDARD storage, 1:IA storage, 2:ARCHIVE storage, 3:DEEP_ARCHIVE storage, 4:ARCHIVE_IR storage")
cmd.Flags().IntVarP(&info.FileType, "storage", "s", 0, "set storage type of file, same to --file-type")
_ = cmd.Flags().MarkDeprecated("storage", "use --file-type instead") // 废弃 storage

Expand Down
2 changes: 1 addition & 1 deletion docs/abfetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ qshell abfetch --doc
- -b/--callback-body:回调的 http Body。 【可选】
- -T/--callback-host:回调时的 HOST 头。 【可选】
- -a/--callback-url:回调的请求地址。 【可选】
- --file-type:抓取的资源存储在七牛存储空间的类型,0:普通存储 1:低频存储 2:归档存储 3:深度归档, 默认为: 0。 【可选】
- --file-type:抓取的资源存储在七牛存储空间的类型,0:普通存储 1:低频存储 2:归档存储 3:深度归档 4:归档直读存储, 默认为: 0。 【可选】
- -c/--thread-count:指定抓取时使用的线程数目,默认:20。 【可选】
- --overwrite:是否覆盖空间已有文件,默认为 `false`。 【可选】
- -s/--success-list:指定一个文件的路径,如果资源抓取成功,则将资源信息写入此文件;默认不导出。 【可选】
Expand Down
14 changes: 8 additions & 6 deletions docs/batchchlifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
* 大于 0: 设置相关的生命周期
2. 生命周期时间大小规则如下(在相关生命周期时间值大于 0 时需满足):
```
转低频存储时间 < 转归档存储时间 < 转深度归档存储时间
转低频存储时间 < 转归档直读存储时间 < 转归档存储时间 < 转深度归档存储时间
```
3. 转低频存储时间、转归档存储时间、转深度归档存储时间 和 过期删除时间 至少配置一个
3. 转低频存储时间、转归档直读存储时间、转归档存储时间、转深度归档存储时间 和 过期删除时间 至少配置一个

# 格式
```
qshell batchchlifecycle [--force] [--success-list <SuccessFileName>] [--failure-list <FailureFileName>] [--sep <Separator>] [--worker <WorkerCount>] [--to-ia-after-days <ToIAAfterDays>] [--to-archive-after-days <ToArchiveAfterDays>] [--to-deep-archive-after-days <ToDeepArchiveAfterDays>] [--delete-after-days <DeleteAfterDays>] <Bucket> <-i KeysFile>
qshell batchchlifecycle [--force] [--success-list <SuccessFileName>] [--failure-list <FailureFileName>] [--sep <Separator>] [--worker <WorkerCount>] [--to-ia-after-days <ToIAAfterDays>] [--to-archive-ir-after-days <ToArchiveAfterDays>] [--to-archive-after-days <ToArchiveAfterDays>] [--to-deep-archive-after-days <ToDeepArchiveAfterDays>] [--delete-after-days <DeleteAfterDays>] <Bucket> <-i KeysFile>
```

# 帮助文档
Expand Down Expand Up @@ -44,9 +44,10 @@ $ qshell batchchlifecycle --doc
<Key><Sep><Other> // <Key>:文件名,<Sep>:分割符,<Other> 其他无效内容
```
- --to-ia-after-days:指定文件上传后并在设置的时间后转换到 `低频存储类型`;值范围为 -1 或者大于 0,设置为 -1 表示取消已设置的转 `低频存储` 的生命周期规则,单位:天【可选】
- --to-archive-ir-after-days:指定文件上传后并在设置的时间后转换到 `归档直读存储类型`;值范围为 -1 或者大于 0,设置为 -1 表示取消已设置的转 `归档直读存储` 的生命周期规则,单位:天【可选】
- --to-archive-after-days:指定文件上传后并在设置的时间后转换到 `归档存储类型`;值范围为 -1 或者大于 0,设置为 -1 表示取消已设置的转 `归档存储` 的生命周期规则,单位:天【可选】
- --to-deep-archive-after-days:指定文件上传后并在设置的时间后转换到 `深度归档存储类型`;值范围为 -1 或者大于 0,设置为 -1 表示取消已设置的转 `深度归档存储` 的生命周期规则,单位:天【可选】
- --delete-after-days:指定文件上传后并在设置的时间后进行 `过期删除`,删除后不可恢复;值范围为 -1 或者大于 0,设置为 -1 表示取消已设置的 `过期删除` 的生命周期规则,单位:天【可选】
- --delete-after-days:指定文件上传后并在设置的时间后进行 `过期删除`,删除后不可恢复;值范围为 -1 或者大于 0,设置为 -1 表示取消已设置的 `过期删除` 的生命周期规则,单位:天【可选】
- -y/--force:该选项控制工具的默认行为。默认情况下,对于批量操作,工具会要求使用者输入一个验证码,确认下要进行批量文件操作了,避免操作失误的发生。如果不需要这个验证码的提示过程可以使用此选项。【可选】
- -s/--success-list:该选项指定一个文件,程序会把操作成功的资源信息导入到该文件;默认不导出。【可选】
- -e/--failure-list:该选项指定一个文件,程序会把操作失败的资源信息加上错误信息导入该文件;默认不导出。【可选】
Expand All @@ -58,7 +59,7 @@ $ qshell batchchlifecycle --doc
- --record-redo-while-error:依赖于 --enable-record;命令重新执行时,命令中所有任务会从头到尾重新执行;每个任务执行前会根据记录先查看当前任务是否已经执行,如果任务已执行且失败,则再执行一次;默认为 false,当任务执行失败则跳过不再重新执行。 【可选】

# 示例
1 比如我们要将空间 `if-pbl` 里面一些文件的生命周期改为 30 天后转低频存储,60 天后转归档存储,180 天后转深度归档存储,365 天后过期删除;我们可以指定如下的 `KeysFile` 的内容:
1 比如我们要将空间 `if-pbl` 里面一些文件的生命周期改为 30 天后转低频存储,60 天后转归档直读存储,120 天后转归档存储,180 天后转深度归档存储,365 天后过期删除;我们可以指定如下的 `KeysFile` 的内容:
```
2015/03/22/qiniu.png
2015/photo.jpg
Expand All @@ -68,7 +69,8 @@ $ qshell batchchlifecycle --doc
```
$ qshell batchchlifecycle if-pbl -i lifecycle.txt \
--to-ia-after-days 30 \
--to-archive-after-days 60 \
--to-archive-ir-after-days 60 \
--to-archive-after-days 120 \
--to-deep-archive-after-days 180 \
--delete-after-days 365
```
Expand Down
4 changes: 2 additions & 2 deletions docs/batchchtype.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 简介
`batchchtype` 命令用来为空间中的文件设置存储类型。该操作发生在同一个空间中。(将文件设置为 **深度归档存储** 或者 **归档存储** 或者 **低频存储** 或者 **普通存储**,默认:文件为 **普通存储**
`batchchtype` 命令用来为空间中的文件设置存储类型。该操作发生在同一个空间中。(将文件设置为 **深度归档存储** 或者 **归档存储** 或者 **归档直读存储** 或者 **低频存储** 或者 **普通存储**,默认:文件为 **普通存储**

# 格式
```
Expand All @@ -23,7 +23,7 @@ $ qshell batchchtype --doc
- Bucket:空间名,可以为公开空间或私有空间。【必选】

# 选项
- -i/--input-file:接受一个文件, 文件内容每行包含 `原文件名``存储类型`,存储类型用数字表示,0 为普通存储,1 为低频存储,2 为归档存储,3 为深度归档存储。每行多个元素名之间用分割符分隔(默认 tab 制表符); 如果需要自定义分割符,可以使用 `-F``--sep` 选项指定自定义的分隔符。如果没有通过该选项指定该文件参数, 从标准输入读取内容。每行包含 `文件名``存储类型`;具体格式如下:(【可选】)
- -i/--input-file:接受一个文件, 文件内容每行包含 `原文件名``存储类型`,存储类型用数字表示,0 为普通存储,1 为低频存储,2 为归档存储,3 为深度归档存储,4 为归档直读存储。每行多个元素名之间用分割符分隔(默认 tab 制表符); 如果需要自定义分割符,可以使用 `-F``--sep` 选项指定自定义的分隔符。如果没有通过该选项指定该文件参数, 从标准输入读取内容。每行包含 `文件名``存储类型`;具体格式如下:(【可选】)
```
<Key><Sep>1 // <Key>:文件名,<Sep>:分割符,1:低频存储。
```
Expand Down
Loading

0 comments on commit 9f1f593

Please sign in to comment.