@@ -29,7 +29,7 @@ const (
2929type inputModel struct {
3030 * globalflags.GlobalFlagModel
3131 Limit * int64
32- Immutable bool
32+ Immutable * string
3333}
3434
3535func NewCmd (params * types.CmdParams ) * cobra.Command {
@@ -44,8 +44,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
4444 "$ stackit beta sfs snapshot-policy list" ,
4545 ),
4646 examples .NewExample (
47- `List all immutable snapshot policies` ,
48- "$ stackit beta sfs snapshot-policy list --immutable" ,
47+ `List only mutable snapshot policies` ,
48+ "$ stackit beta sfs snapshot-policy list --immutable mutable-only" ,
49+ ),
50+ examples .NewExample (
51+ `List only immutable snapshot policies` ,
52+ "$ stackit beta sfs snapshot-policy list --immutable immutable-only" ,
4953 ),
5054 examples .NewExample (
5155 `List up to 10 snapshot policies` ,
@@ -95,8 +99,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
9599}
96100
97101func configureFlags (cmd * cobra.Command ) {
102+ immutableOptions := []string {"all" , "immutable-only" , "mutable-only" }
103+ cmd .Flags ().Var (flags .EnumFlag (true , "all" , immutableOptions ... ), immutableFlag , fmt .Sprintf ("Immutable snapshot policy, one of %q" , immutableOptions ))
98104 cmd .Flags ().Int64 (limitFlag , 0 , "Maximum number of entries to list" )
99- cmd .Flags ().Bool (immutableFlag , false , "Immutable snapshot policy" )
100105}
101106
102107func parseInput (p * print.Printer , cmd * cobra.Command , _ []string ) (* inputModel , error ) {
@@ -116,7 +121,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
116121 model := inputModel {
117122 GlobalFlagModel : globalFlags ,
118123 Limit : limit ,
119- Immutable : flags .FlagToBoolValue (p , cmd , immutableFlag ),
124+ Immutable : flags .FlagToStringPointer (p , cmd , immutableFlag ),
120125 }
121126
122127 p .DebugInputModel (model )
@@ -125,8 +130,16 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
125130
126131func buildRequest (ctx context.Context , model * inputModel , apiClient * sfs.APIClient ) sfs.ApiListSnapshotPoliciesRequest {
127132 req := apiClient .DefaultAPI .ListSnapshotPolicies (ctx , model .ProjectId )
128- if model .Immutable {
129- req = req .Immutable (true )
133+
134+ if model .Immutable != nil {
135+ switch * model .Immutable {
136+ case "all" :
137+ return req
138+ case "mutable-only" :
139+ req = req .Immutable (false )
140+ case "immutable-only" :
141+ req = req .Immutable (true )
142+ }
130143 }
131144 return req
132145}
0 commit comments