github.com/minio/mc@v0.0.0-20240503112107-b471de8d1882/cmd/ilm-deprecated-cmds.go (about)

     1  // Copyright (c) 2022 MinIO, Inc.
     2  //
     3  // This file is part of MinIO Object Storage stack
     4  //
     5  // This program is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Affero General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // This program is distributed in the hope that it will be useful
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  // GNU Affero General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Affero General Public License
    16  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package cmd
    19  
    20  import "github.com/minio/cli"
    21  
    22  var ilmDepCmds = []cli.Command{
    23  	ilmDepAddCmd,
    24  	ilmDepEditCmd,
    25  	ilmDepLsCmd,
    26  	ilmDepRmCmd,
    27  	ilmDepExportCmd,
    28  	ilmDepImportCmd,
    29  }
    30  
    31  var (
    32  	ilmDepAddCmd = cli.Command{
    33  		Name:         "add",
    34  		Usage:        "add a lifecycle configuration rule for a bucket",
    35  		Action:       mainILMAdd,
    36  		Hidden:       true, // to avoid being listed in `mc ilm`
    37  		OnUsageError: onUsageError,
    38  		Before:       setGlobalsFromContext,
    39  		Flags:        append(ilmAddFlags, globalFlags...),
    40  		CustomHelpTemplate: `NAME:
    41    {{.HelpName}} - {{.Usage}}
    42  
    43  USAGE:
    44    {{.HelpName}} [COMMAND FLAGS] TARGET
    45  
    46  FLAGS:
    47    {{range .VisibleFlags}}{{.}}
    48    {{end}}
    49  DESCRIPTION:
    50    Add a lifecycle configuration rule.
    51  
    52  EXAMPLES:
    53    1. Add a lifecycle rule with an expiration action for all objects in mybucket.
    54       {{.Prompt}} {{.HelpName}} --expire-days "200" myminio/mybucket
    55  
    56    2. Add a lifecycle rule with a transition and a noncurrent version transition action for objects with prefix doc/ in mybucket.
    57       Tiers must exist in MinIO. Use existing tiers or add new tiers.
    58       {{.Prompt}} mc tier add minio myminio MINIOTIER-1 --endpoint https://warm-minio-1.com \
    59           --access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket1 --prefix prefix1
    60  
    61       {{.Prompt}} mc tier add minio myminio MINIOTIER-2 --endpoint https://warm-minio-2.com \
    62           --access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket2 --prefix prefix2
    63  
    64       {{.Prompt}} {{.HelpName}} --prefix "doc/" --transition-days "90" --transition-tier "MINIOTIER-1" \
    65            --noncurrent-transition-days "45" --noncurrent-transition-tier "MINIOTIER-2" \
    66            myminio/mybucket/
    67  
    68    3. Add a lifecycle rule with an expiration and a noncurrent version expiration action for all objects with prefix doc/ in mybucket.
    69       {{.Prompt}} {{.HelpName}} --prefix "doc/" --expire-days "300" --noncurrent-expire-days "100" \
    70            myminio/mybucket/
    71  `,
    72  	}
    73  	ilmDepRmCmd = cli.Command{
    74  		Name:         "rm",
    75  		Usage:        "remove (if any) existing lifecycle configuration rule",
    76  		Action:       mainILMRemove,
    77  		Hidden:       true, // to avoid being listed in `mc ilm`
    78  		OnUsageError: onUsageError,
    79  		Before:       setGlobalsFromContext,
    80  		Flags:        append(ilmRemoveFlags, globalFlags...),
    81  		CustomHelpTemplate: `NAME:
    82    {{.HelpName}} - {{.Usage}}
    83  
    84  USAGE:
    85    {{.HelpName}} [FLAGS] TARGET
    86  
    87  FLAGS:
    88    {{range .VisibleFlags}}{{.}}
    89    {{end}}
    90  DESCRIPTION:
    91    Remove a lifecycle configuration rule for the bucket by ID, optionally you can remove
    92    all the lifecycle rules on a bucket with '--all --force' option.
    93  
    94  EXAMPLES:
    95    1. Remove the lifecycle management configuration rule given by ID "bgrt1ghju" for mybucket on alias 'myminio'. ID is case sensitive.
    96       {{.Prompt}} {{.HelpName}} --id "bgrt1ghju" myminio/mybucket
    97  
    98    2. Remove ALL the lifecycle management configuration rules for mybucket on alias 'myminio'.
    99       Because the result is complete removal, the use of --force flag is enforced.
   100       {{.Prompt}} {{.HelpName}} --all --force myminio/mybucket
   101  `,
   102  	}
   103  
   104  	ilmDepEditCmd = cli.Command{
   105  		Name:         "edit",
   106  		Usage:        "modify a lifecycle configuration rule with given id",
   107  		Action:       mainILMEdit,
   108  		Hidden:       true, // to avoid being listed in `mc ilm`
   109  		OnUsageError: onUsageError,
   110  		Before:       setGlobalsFromContext,
   111  		Flags:        append(ilmEditFlags, globalFlags...),
   112  		CustomHelpTemplate: `NAME:
   113    {{.HelpName}} - {{.Usage}}
   114  
   115  USAGE:
   116    {{.HelpName}} [COMMAND FLAGS] TARGET
   117  
   118  FLAGS:
   119    {{range .VisibleFlags}}{{.}}
   120    {{end}}
   121  DESCRIPTION:
   122    Modify a lifecycle configuration rule with given id.
   123  
   124  EXAMPLES:
   125    1. Modify the expiration date for an existing rule with id "rHTY.a123".
   126       {{.Prompt}} {{.HelpName}} --id "rHTY.a123" --expiry-date "2020-09-17" s3/mybucket
   127  
   128    2. Modify the expiration and transition days for an existing rule with id "hGHKijqpo123".
   129       {{.Prompt}} {{.HelpName}} --id "hGHKijqpo123" --expiry-days "300" \
   130            --transition-days "200" --storage-class "GLACIER" s3/mybucket
   131  
   132    3. Disable the rule with id "rHTY.a123".
   133       {{.Prompt}} {{.HelpName}} --id "rHTY.a123" --disable s3/mybucket
   134  
   135  `,
   136  	}
   137  
   138  	ilmDepLsCmd = cli.Command{
   139  		Name:         "ls",
   140  		Usage:        "lists lifecycle configuration rules set on a bucket",
   141  		Action:       mainILMList,
   142  		Hidden:       true, // to avoid being listed in `mc ilm`
   143  		OnUsageError: onUsageError,
   144  		Before:       setGlobalsFromContext,
   145  		Flags:        append(ilmListFlags, globalFlags...),
   146  		CustomHelpTemplate: `NAME:
   147    {{.HelpName}} - {{.Usage}}
   148  
   149  USAGE:
   150    {{.HelpName}} [FLAGS] TARGET
   151  
   152  FLAGS:
   153    {{range .VisibleFlags}}{{.}}
   154    {{end}}
   155  DESCRIPTION:
   156    List lifecycle configuration rules set on a bucket.
   157  
   158  EXAMPLES:
   159    1. List the lifecycle management rules (all fields) for mybucket on alias 'myminio'.
   160       {{.Prompt}} {{.HelpName}} myminio/mybucket
   161  
   162    2. List the lifecycle management rules (expration date/days fields) for mybucket on alias 'myminio'.
   163       {{.Prompt}} {{.HelpName}} --expiry myminio/mybucket
   164  
   165    3. List the lifecycle management rules (transition date/days, storage class fields) for mybucket on alias 'myminio'.
   166       {{.Prompt}} {{.HelpName}} --transition myminio/mybucket
   167  
   168    4. List the lifecycle management rules in JSON format for mybucket on alias 'myminio'.
   169       {{.Prompt}} {{.HelpName}} --json myminio/mybucket
   170  `,
   171  	}
   172  
   173  	ilmDepExportCmd = cli.Command{
   174  		Name:         "export",
   175  		Usage:        "export lifecycle configuration in JSON format",
   176  		Action:       mainILMExport,
   177  		Hidden:       true, // to avoid being listed in `mc ilm`
   178  		OnUsageError: onUsageError,
   179  		Before:       setGlobalsFromContext,
   180  		Flags:        globalFlags,
   181  		CustomHelpTemplate: `NAME:
   182    {{.HelpName}} - {{.Usage}}
   183  
   184  USAGE:
   185    {{.HelpName}} TARGET
   186  
   187  DESCRIPTION:
   188    Exports lifecycle configuration in JSON format to STDOUT.
   189  
   190  EXAMPLES:
   191    1. Export lifecycle configuration for 'mybucket' to 'lifecycle.json' file.
   192       {{.Prompt}} {{.HelpName}} myminio/mybucket > lifecycle.json
   193  
   194    2. Print lifecycle configuration for 'mybucket' to STDOUT.
   195       {{.Prompt}} {{.HelpName}} play/mybucket
   196  `,
   197  	}
   198  
   199  	ilmDepImportCmd = cli.Command{
   200  		Name:         "import",
   201  		Usage:        "import lifecycle configuration in JSON format",
   202  		Action:       mainILMImport,
   203  		Hidden:       true, // to avoid being listed in `mc ilm`
   204  		OnUsageError: onUsageError,
   205  		Before:       setGlobalsFromContext,
   206  		Flags:        globalFlags,
   207  		CustomHelpTemplate: `NAME:
   208    {{.HelpName}} - {{.Usage}}
   209  
   210  USAGE:
   211    {{.HelpName}} TARGET
   212  
   213  DESCRIPTION:
   214    Import entire lifecycle configuration from STDIN, input file is expected to be in JSON format.
   215  
   216  EXAMPLES:
   217    1. Set lifecycle configuration for the mybucket on alias 'myminio' to the rules imported from lifecycle.json
   218       {{.Prompt}} {{.HelpName}} myminio/mybucket < lifecycle.json
   219  
   220    2. Set lifecycle configuration for the mybucket on alias 'myminio'. User is expected to enter the JSON contents on STDIN
   221       {{.Prompt}} {{.HelpName}} myminio/mybucket
   222  `,
   223  	}
   224  )