redhat-developer / app-services-cli

Command Line Interface for RHOAS
https://redhat-developer.github.io/app-services-website/
Apache License 2.0
42 stars 72 forks source link

feat(service-account): add pagination to list command #1771

Closed rkpattnaik780 closed 2 years ago

rkpattnaik780 commented 2 years ago

Add pagination to rhoas service-account list command.

As users are used to running rhoas service-account list | grep <username> to get their service accounts, the default size has been set to 100.

Verification Steps

  1. rhoas service-account list should display upto 100 service accounts.

Type of change

jackdelahunt commented 2 years ago

Running rhoas service-account list works as epxected. and so does rhoas service-account list --size=100 as they are pretty much the same thing.

Something that is interesting though is when running rhoas service-account list --size=101 -v I get the following error.

{"fields":{"max":"must be less than or equal to 100"},"error":"invalid_field","error_description":"Request failed field validation"}

Wondering if we can have a custom error message for this as this just returns 400 without verbose mode.

rkpattnaik780 commented 2 years ago

Wondering if we can have a custom error message for this as this just returns 400 without verbose mode.

Nice catch @jackdelahunt :). Unfortunately we dont have custom error message for this, but we can add client level validation to ensure page > 0 and size <= 100

rkpattnaik780 commented 2 years ago

Custom validations have been added @jackdelahunt

./rhoas service-account list --page 0
❌ Invalid page number 0, minimum value is 1. Run the command in verbose mode using the -v flag to see more information

➜  cli git:(svc_acct_pagination) ✗ ./rhoas service-account list --page -1
❌ Invalid page number -1, minimum value is 1. Run the command in verbose mode using the -v flag to see more information

➜  cli git:(svc_acct_pagination) ✗ ./rhoas service-account list --size 101
❌ Invalid size 101, maximum value is 100. Run the command in verbose mode using the -v flag to see more information

➜  cli git:(svc_acct_pagination) ✗ ./rhoas service-account list --size 0  
❌ Invalid size 0, minimum value is 1. Run the command in verbose mode using the -v flag to see more information