Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ func newAPIKeysListCommand(env *environment) *cobra.Command {
formatMoney(key.MonthlySpend),
formatLimit(key.MonthlyLimit),
formatExpiry(key.ExpiresAt),
formatDate(key.CreatedAt),
formatLabels(key.Labels),
})
}

return writeTable(out, []string{"ID", "NAME", "SPEND", "LIMIT", "EXPIRES", "LABELS"}, rows)
return writeTable(out, []string{"ID", "NAME", "SPEND", "LIMIT", "EXPIRES", "CREATED", "LABELS"}, rows)
},
}
}
Expand Down Expand Up @@ -115,6 +116,7 @@ func newAPIKeysShowCommand(env *environment) *cobra.Command {
{"Spend this month", formatMoney(key.MonthlySpend)},
{"Monthly limit", formatLimit(key.MonthlyLimit)},
{"Expires", formatExpiry(key.ExpiresAt)},
{"Created at", formatTime(key.CreatedAt)},
{"Permissions", formatPermissions(key.Permissions)},
{"Logging", strconv.FormatBool(key.Logging)},
{"Group", formatGroup(key.Group)},
Expand Down
2 changes: 2 additions & 0 deletions internal/client/api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type APIKey struct {
MonthlyLimit decimal.Decimal `json:"monthly_limit"`
MonthlySpend decimal.Decimal `json:"monthly_spend"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
Permissions APIKeyPermissions `json:"permissions"`
Labels map[string]string `json:"labels,omitempty"`
CreatedBy *APIKeyUser `json:"created_by,omitempty"`
Expand All @@ -61,6 +62,7 @@ type APIKeyDetails struct {
MonthlyLimit decimal.Decimal `json:"monthly_limit"`
MonthlySpend decimal.Decimal `json:"monthly_spend"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
Permissions APIKeyPermissions `json:"permissions"`
Group *APIKeyGroup `json:"group,omitempty"`
}
Expand Down
6 changes: 4 additions & 2 deletions internal/client/api_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func mustParseTime(t *testing.T, value string) *time.Time {

func TestClientAPIKeys(t *testing.T) {
reply := `{"keys":[{"id":"key-1","name":"production","monthly_limit":"500","monthly_spend":"12.5",` +
`"expires_at":"2026-12-31T23:59:59Z",` +
`"expires_at":"2026-12-31T23:59:59Z","created_at":"2026-01-15T10:30:00Z",` +
`"permissions":{"manage":"read","completions":"write"},"labels":{"env":"prod"},` +
`"created_by":{"id":"user-1","email":"you@example.com"},"group":{"id":"group-1"}}]}`
client, seen := newTestClient(t, http.StatusOK, reply)
Expand All @@ -79,6 +79,7 @@ func TestClientAPIKeys(t *testing.T) {
MonthlyLimit: decimal.RequireFromString("500"),
MonthlySpend: decimal.RequireFromString("12.5"),
ExpiresAt: mustParseTime(t, "2026-12-31T23:59:59Z"),
CreatedAt: time.Date(2026, time.January, 15, 10, 30, 0, 0, time.UTC),
Permissions: APIKeyPermissions{Manage: APIKeyPermissionRead, Completions: APIKeyPermissionWrite},
Labels: map[string]string{"env": "prod"},
CreatedBy: &APIKeyUser{ID: "user-1", Email: "you@example.com"},
Expand All @@ -88,7 +89,7 @@ func TestClientAPIKeys(t *testing.T) {

func TestClientAPIKey(t *testing.T) {
reply := `{"id":"key-1","name":"production","logging":true,"monthly_limit":"0","monthly_spend":"3",` +
`"expires_at":"2026-12-31T23:59:59Z",` +
`"expires_at":"2026-12-31T23:59:59Z","created_at":"2026-01-15T10:30:00Z",` +
`"permissions":{"manage":"none","completions":"write"},"group":{"id":"group-1"}}`
client, seen := newTestClient(t, http.StatusOK, reply)

Expand All @@ -104,6 +105,7 @@ func TestClientAPIKey(t *testing.T) {
MonthlyLimit: decimal.RequireFromString("0"),
MonthlySpend: decimal.RequireFromString("3"),
ExpiresAt: mustParseTime(t, "2026-12-31T23:59:59Z"),
CreatedAt: time.Date(2026, time.January, 15, 10, 30, 0, 0, time.UTC),
Permissions: APIKeyPermissions{Manage: APIKeyPermissionNone, Completions: APIKeyPermissionWrite},
Group: &APIKeyGroup{ID: "group-1"},
}, key)
Expand Down
Loading