Skip to content

Commit f9817af

Browse files
docs: add section on how to retrieve user list (#17798)
previews - [admin/users](https://coder.com/docs/@export-coder-users/admin/users) - [reference/cli/users](https://coder.com/docs/@export-coder-users/reference/cli/users) followup to slack thread: > Tim > what's the best way for customers to export a list of Coder users? > > @ericpaulsen > the `/api/v2/users` API route returns all users in the deployment (along with other information - email, status, username, etc.). from <https://coder.com/docs/reference/api/users#get-users> - adds an easy-to-find section to the admin/users doc - updates the cli commands with short descriptions --------- Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Co-authored-by: M Atif Ali <atif@coder.com>
1 parent 170f41a commit f9817af

File tree

10 files changed

+56
-5
lines changed

10 files changed

+56
-5
lines changed

cli/testdata/coder_users_--help.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ USAGE:
1010
SUBCOMMANDS:
1111
activate Update a user's status to 'active'. Active users can fully
1212
interact with the platform
13-
create
13+
create Create a new user.
1414
delete Delete a user by username or user_id.
1515
edit-roles Edit a user's roles by username or id
16-
list
16+
list Prints the list of users.
1717
show Show a single user. Use 'me' to indicate the currently
1818
authenticated user.
1919
suspend Update a user's status to 'suspended'. A suspended user cannot

cli/testdata/coder_users_create_--help.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ coder v0.0.0-devel
33
USAGE:
44
coder users create [flags]
55

6+
Create a new user.
7+
68
OPTIONS:
79
-O, --org string, $CODER_ORGANIZATION
810
Select which organization (uuid or name) to use.

cli/testdata/coder_users_list_--help.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ coder v0.0.0-devel
33
USAGE:
44
coder users list [flags]
55

6+
Prints the list of users.
7+
68
Aliases: ls
79

810
OPTIONS:

cli/usercreate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ func (r *RootCmd) userCreate() *serpent.Command {
2828
)
2929
client := new(codersdk.Client)
3030
cmd := &serpent.Command{
31-
Use: "create",
31+
Use: "create",
32+
Short: "Create a new user.",
3233
Middleware: serpent.Chain(
3334
serpent.RequireNArgs(0),
3435
r.InitClient(client),

cli/userlist.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func (r *RootCmd) userList() *serpent.Command {
2323

2424
cmd := &serpent.Command{
2525
Use: "list",
26+
Short: "Prints the list of users.",
2627
Aliases: []string{"ls"},
2728
Middleware: serpent.Chain(
2829
serpent.RequireNArgs(0),

docs/admin/users/index.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,42 @@ The following filters are supported:
206206
- `created_before` and `created_after` - The time a user was created. Uses the
207207
RFC3339Nano format.
208208
- `login_type` - Represents the login type of the user. Refer to the [LoginType documentation](https://pkg.go.dev/github.com/coder/coder/v2/codersdk#LoginType) for a list of supported values
209+
210+
## Retrieve your list of Coder users
211+
212+
<div class="tabs">
213+
214+
You can use the Coder CLI or API to retrieve your list of users.
215+
216+
### CLI
217+
218+
Use `users list` to export the list of users to a CSV file:
219+
220+
```shell
221+
coder users list > users.csv
222+
```
223+
224+
Visit the [users list](../../reference/cli/users_list.md) documentation for more options.
225+
226+
### API
227+
228+
Use [get users](../../reference/api/users.md#get-users):
229+
230+
```shell
231+
curl -X GET http://coder-server:8080/api/v2/users \
232+
-H 'Accept: application/json' \
233+
-H 'Coder-Session-Token: API_KEY'
234+
```
235+
236+
To export the results to a CSV file, you can use [`jq`](https://jqlang.org/) to process the JSON response:
237+
238+
```shell
239+
curl -X GET http://coder-server:8080/api/v2/users \
240+
-H 'Accept: application/json' \
241+
-H 'Coder-Session-Token: API_KEY' | \
242+
jq -r '.users | (map(keys) | add | unique) as $cols | $cols, (.[] | [.[$cols[]]] | @csv)' > users.csv
243+
```
244+
245+
Visit the [get users](../../reference/api/users.md#get-users) documentation for more options.
246+
247+
</div>

docs/manifest.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,7 @@
16251625
},
16261626
{
16271627
"title": "users create",
1628+
"description": "Create a new user.",
16281629
"path": "reference/cli/users_create.md"
16291630
},
16301631
{
@@ -1639,6 +1640,7 @@
16391640
},
16401641
{
16411642
"title": "users list",
1643+
"description": "Prints the list of users.",
16421644
"path": "reference/cli/users_list.md"
16431645
},
16441646
{

docs/reference/cli/users.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/cli/users_create.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/cli/users_list.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy