{% extends "layout.html" %}
{% block title %}API for Copr{% endblock %}
{% block header %}API for the Copr Build System{% endblock %}
{%block main_menu_api %}active{% endblock %}
{% block breadcrumbs %}
<ol class="breadcrumb">
  <li>
    <a href="{{ url_for('coprs_ns.coprs_show') }}">Home</a>
  </li>
  <li class="active">
    API
  </li>
</ol>
{% endblock %}
{% block body %}
  {% if error %}<p class="error"><strong>Error:</strong> {{ error }}</p>{% endif %}

  <div>
    <h1>Copr API</h1>

    <h2>API Token</h2>
    <p>In order to access the restricted parts of the API, you will need to provide an API token.
    This token is unique, specific to you and <span style="font-weight:bold;">
    should not be shared!</span>.
    </p>

    <p>The API token is valid for {{ config['API_TOKEN_EXPIRATION'] }} days after it has been generated.
    </p>

    {% include 'additional_token_info.html' %}
    {% if g.user %}
    <pre style="font-size:120%">
[copr-cli]
login = {{ g.user.api_login }}
username = {{ g.user.name }}
token = {{ g.user.api_token }}
copr_url = {{ ('https://' + config['PUBLIC_COPR_HOSTNAME'])| fix_url_https_frontend}}
{% if config['ENFORCE_PROTOCOL_FOR_FRONTEND_URL'] == 'http' %}
encrypted = False
{% endif %}
# expiration date: {{ g.user.api_token_expiration }}
</pre>

    <a href="{{ url_for('api_ns.api_new_token') }}">
        <input type="button" value="Generate a new token" />
    </a>
    {% else %}
    <pre style="font-size:120%">
[copr-cli]
login = LOGIN_TO_REVEAL
username = LOGIN_TO_REVEAL
token = LOGIN_TO_REVEAL
copr_url = {{ ('https://' + config['PUBLIC_COPR_HOSTNAME'])| fix_url_https_frontend}}
{% if config['ENFORCE_PROTOCOL_FOR_FRONTEND_URL'] == 'http' %}
encrypted = False
{% endif %}
# expiration date: LOGIN_TO_REVEAL
</pre>
    <p style="font-style:italic">You need to be logged in to see your API token.</p>
    {% endif %}

    <h2>Documentation</h2>

    <ul>
      <li><a href="/api_3/docs">API documentation</a></li>
      <li>
        <a href="https://python-copr.readthedocs.io/en/latest/index.html">
          Python client documentation
        </a>
      </li>
    </ul>

  </div>
{% endblock %}
