Files
grafana/pkg/registry/apis/iam/legacy/service_account_tokens_query.sql
Karl Persson 2bfa607ad0 ServiceAccount: Update service account api resource and add service account token (#92972)
* Create own legacy store function to list service accounts and update api model

* Add service account tokens as a sub resource for service accounts
2024-09-05 13:43:54 +02:00

20 lines
538 B
SQL

SELECT
t.id,
t.name,
t.is_revoked,
t.last_used_at,
t.expires,
t.created,
t.updated
FROM {{ .Ident .TokenTable }} as t
INNER JOIN {{ .Ident .UserTable }} as u ON t.service_account_id = u.id
INNER JOIN {{ .Ident .OrgUserTable }} as o ON u.id = o.user_id
WHERE o.org_id = {{ .Arg .Query.OrgID }}
AND u.is_service_account
AND u.uid = {{ .Arg .Query.UID }}
{{ if .Query.Pagination.Continue }}
AND t.id >= {{ .Arg .Query.Pagination.Continue }}
{{ end }}
ORDER BY t.id asc
LIMIT {{ .Arg .Query.Pagination.Limit }}