Skip to content

Commit 4a81628

Browse files
feat(iam): add filtering on multiple IDs on listing endpoints (#3586)
Co-authored-by: Leïla MARABESE <lmarabese@scaleway.com>
1 parent a7073d0 commit 4a81628

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

cmd/scw/testdata/test-all-usage-iam-api-key-list-usage.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ ARGS:
99
[order-by=created_at_asc] Criteria for sorting results (created_at_asc | created_at_desc | updated_at_asc | updated_at_desc | expires_at_asc | expires_at_desc | access_key_asc | access_key_desc)
1010
[editable] Defines whether to filter out editable API keys or not
1111
[expired] Defines whether to filter out expired API keys or not
12-
[access-key] Filter by access key
1312
[description] Filter by description
1413
[bearer-id] Filter by bearer ID
1514
[bearer-type] Filter by type of bearer (unknown_bearer_type | user | application)
15+
[access-keys.{index}] Filter by a list of access keys
1616
organization-id=<retrieved from config> ID of Organization
1717

1818
DEPRECATED ARGS:
1919
[application-id] ID of application that bears the API key
2020
[user-id] ID of user that bears the API key
21+
[access-key] Filter by access key (deprecated in favor of `access_keys`)
2122

2223
FLAGS:
2324
-h, --help help for list

cmd/scw/testdata/test-all-usage-iam-policy-list-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ARGS:
1414
[no-principal] Defines whether or not the policy is attributed to a principal
1515
[policy-name] Name of the policy to fetch
1616
[tag] Filter by tags containing a given string
17+
[policy-ids.{index}] Filter by a list of IDs
1718
[organization-id=<retrieved from config>] Organization ID to use. If none is passed the default organization ID will be used
1819

1920
FLAGS:

docs/commands/iam.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ scw iam api-key list [arg=value ...]
154154
| ~~user-id~~ | Deprecated | ID of user that bears the API key |
155155
| editable | | Defines whether to filter out editable API keys or not |
156156
| expired | | Defines whether to filter out expired API keys or not |
157-
| access-key | | Filter by access key |
157+
| ~~access-key~~ | Deprecated | Filter by access key (deprecated in favor of `access_keys`) |
158158
| description | | Filter by description |
159159
| bearer-id | | Filter by bearer ID |
160160
| bearer-type | One of: `unknown_bearer_type`, `user`, `application` | Filter by type of bearer |
161+
| access-keys.{index} | | Filter by a list of access keys |
161162
| organization-id | Required<br />Default: `<retrieved from config>` | ID of Organization |
162163

163164

@@ -772,6 +773,7 @@ scw iam policy list [arg=value ...]
772773
| no-principal | | Defines whether or not the policy is attributed to a principal |
773774
| policy-name | | Name of the policy to fetch |
774775
| tag | | Filter by tags containing a given string |
776+
| policy-ids.{index} | | Filter by a list of IDs |
775777
| organization-id | Default: `<retrieved from config>` | Organization ID to use. If none is passed the default organization ID will be used |
776778

777779

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/moby/buildkit v0.11.6
2525
github.com/opencontainers/go-digest v1.0.0
2626
github.com/pkg/errors v0.9.1
27-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240104151524-ab214475a5a5
27+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240109155607-70eec6dc9637
2828
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2929
github.com/spf13/cobra v1.8.0
3030
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
387387
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
388388
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
389389
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
390-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240104151524-ab214475a5a5 h1:qoQSzki+34iQa2YStpWCI7qHRRRCxkR7OxaysQCchcI=
391-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240104151524-ab214475a5a5/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
390+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240109155607-70eec6dc9637 h1:F/EUOngL9fqQsi3JHn8S6n8oJasOCFk5J/76D+n3s2g=
391+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240109155607-70eec6dc9637/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
392392
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
393393
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
394394
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=

internal/namespaces/iam/v1alpha1/iam_cli.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,13 @@ func iamPolicyList() *core.Command {
13951395
Deprecated: false,
13961396
Positional: false,
13971397
},
1398+
{
1399+
Name: "policy-ids.{index}",
1400+
Short: `Filter by a list of IDs`,
1401+
Required: false,
1402+
Deprecated: false,
1403+
Positional: false,
1404+
},
13981405
core.OrganizationIDArgSpec(),
13991406
},
14001407
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
@@ -1853,9 +1860,9 @@ func iamAPIKeyList() *core.Command {
18531860
},
18541861
{
18551862
Name: "access-key",
1856-
Short: `Filter by access key`,
1863+
Short: `Filter by access key (deprecated in favor of ` + "`" + `access_keys` + "`" + `)`,
18571864
Required: false,
1858-
Deprecated: false,
1865+
Deprecated: true,
18591866
Positional: false,
18601867
},
18611868
{
@@ -1880,6 +1887,13 @@ func iamAPIKeyList() *core.Command {
18801887
Positional: false,
18811888
EnumValues: []string{"unknown_bearer_type", "user", "application"},
18821889
},
1890+
{
1891+
Name: "access-keys.{index}",
1892+
Short: `Filter by a list of access keys`,
1893+
Required: false,
1894+
Deprecated: false,
1895+
Positional: false,
1896+
},
18831897
{
18841898
Name: "organization-id",
18851899
Short: `ID of Organization`,

0 commit comments

Comments
 (0)