{% extends "config/base.html" %} {% import "site_shell/_macros.html" as ui %} {% block title %}API Tokens - Pychestrate Configuration{% endblock %} {% block content %} {% set form = form_data or {} %} {% include "config/tokens/_minted.html" %} {{ ui.error_summary(errors, error_labels) }}

Service accounts

{% if can_create_service_accounts %}

Create a service account

{{ ui.field_error(errors, "login_name") }}

2-63 lower-case letters, digits, '.', '_' or '—'.

{{ ui.field_error(errors, "display_name") }}
{% endif %}
{% for account in service_accounts %} {% set uid = account.user_id | string %} {% set mine = issue_for == uid %} {% set chosen_days = ((form.get('expires_in_days') if mine else '') or default_lifetime_days) | string %} {% else %} {{ ui.empty_state("No service accounts yet", hint="Create one for each CI system or script that calls the API.", colspan=6) }} {% endfor %}
Service accounts
Login name Display name Status Active tokens Created Actions
{{ account.login_name }} {{ account.display_name }} {{ ui.status_badge(account.status) }} {{ account.active_token_count }} {{ account.created_at | format_datetime }} {% if can_manage_tokens and account.status == 'ACTIVE' %}
{{ ui.icon("add") }} Issue token
{{ ui.field_error(errors, "sa-token-name-" ~ uid) }} {{ ui.field_error(errors, "sa-token-expires-" ~ uid) }} {{ ui.field_error(errors, "sa-token-scope-" ~ uid) }}
{% else %} — {% endif %}

All tokens

{% for token in tokens %} {% else %} {{ ui.empty_state("No API tokens have been issued", colspan=8) }} {% endfor %}
Every API token
Account Name Token Access Status Last used Expires Actions
{{ token.login_name }} {% if token.is_service_account %}service account{% endif %} {{ token.name }} {{ token.token_hint }}… {{ token.scope }} {{ ui.status_badge(token.status) }} {% if token.last_used_at %}{{ token.last_used_at | format_datetime }}{% else %}never{% endif %} {{ token.expires_at | format_datetime }} {% if can_manage_tokens and token.status == 'active' %}
{% else %} — {% endif %}

{% set token_count = tokens | length %}{% set account_count = service_accounts | length %}Total: {{ token_count }} token{{ '' if token_count == 1 else 's' }}, {{ account_count }} service account{{ '' if account_count == 1 else 's' }}

{% endblock %}