fix(token): preserve JSON field names in list output

Summary

Fixes a regression introduced in !2839 (merged) (d9ec79fd) where the JSON output structure was inadvertently changed.

Problem

The previous fix for #8155 (closed) switched the JSON output from using the raw API response (apiTokens) to our internal Token struct (outputTokens). While this fixed the --active flag filtering issue, it also changed the JSON field names:

Before !2839 (merged) (and before this MR):

{
  "id": "123",
  "name": "token",
  "active": true,
  "access_level": 10,
  "created_at": "2024-07-05T10:02:37Z"
}

After !2839 (merged) (regression):

{
  "ID": "123",
  "Name": "token",
  "Active": "true",
  "AccessLevel": "10",
  "CreatedAt": "2024-07-05T10:02:37Z"
}

This is a breaking change for anyone parsing the JSON output.

Solution

Added JSON struct tags to the Token struct to match the original API field names:

  • id (lowercase)
  • name (lowercase)
  • active (lowercase)
  • access_level (snake_case)
  • etc.

This ensures the JSON output structure remains consistent with the API while still applying the --active flag filter correctly.

Testing

  • Updated test assertions to verify lowercase field names
  • All tests pass
  • JSON output now matches the original API structure

Merge request reports

Loading