{% extends "layout.html" %} {% block title %}API for Copr{% endblock %} {% block header %}API for the Copr Build System{% endblock %} {% block body %} {% if error %}

Error: {{ error }}

{% endif %}

Copr API

API Token

In order to access the API, you will need to provide an API token. This token is unique, specific to you and should not be shared!.

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

{% if g.user %}

Your information (you can directly paste this into ~/.config/copr):

[copr-cli]
login = {{ g.user.api_login }}
username = {{ g.user.name }}
token = {{ g.user.api_token }}
copr_url = https://copr.fedoraproject.org
# expiration date: {{ g.user.api_token_expiration }}
{% else %}

You need to be logged in to see your API token.

{% endif %}

The API

To make an API call to Copr, make a request to URL corresponding to given call (URLs are listed below). Parameters are denoted by angle brackets. Result is represented as JSON map with "output": "ok" key-value pair on success or "output": "notok" on failure. The rest of the map represents result of the call and is described below for individual calls.

List someone's projects

URL:

/api/coprs/<username>/
or
/api/coprs/?username="<username>"

URL parameters:

Result:

Example call URL

https://copr.fedoraproject.org/api/coprs/jdaniels/

Example results

    {
      "output": "ok",
      "repos": [
        {
          "yum_repos": {
            "fedora-19-i686": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-i686/",
            "fedora-19-x86_64": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-x86_64/"
          },
          "additional_repos": "",
          "instructions": "",
          "name": "log4j",
          "description": "Java logging package"
        }
      ]
    }
    

Detail of project

URL:

/api/coprs/<username>/<projectname>/detail/

URL parameters:

Result:

Example call URL

https://copr.fedoraproject.org/api/coprs/jdaniels/log4j/detail/

Example results

    {
      "output": "ok",
      "repos": [
        {
          "yum_repos": {
            "fedora-19-i686": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-i686/",
            "fedora-19-x86_64": "https://copr-be.cloud.fedoraproject.org/results/jdaniels/log4j/fedora-19-x86_64/"
          },
          "additional_repos": "",
          "instructions": "",
          "name": "log4j",
          "description": "Java logging package",
          "last_modified": 1386695673 
        }
      ]
    }
    

Create new project

Login required

URL:

/api/coprs/<username>/new/

URL parameters:

Parameters sent by POST:

Delete an entire project

Login required

URL:

/api/coprs/<username>/<projectname>/delete/

URL parameters:

Parameters sent by POST:

Builds success summary (project monitor)

URL:

/api/coprs/<username>/<coprname>/monitor/

URL parameters:

Result

Example result

{
  "builds": [
    {
      "id": 9578,
      "src_pkg": "https://fedorapeople.org/~vgologuz/python-copr-client-1.43-1.git.0.f84518d.fc20.src.rpm",
      "pkg_version": "1.43",
      "state": "failed",
      "submitted_on": 1408462225,
      "started_on": 1408462318,
      "ended_on": 1408462701,
      "results": "http://copr-be-dev.cloud.fedoraproject.org/results/vgologuz/copr/",
      "built_packages": [
        "python-copr-client 1.43",
        "python-copr-client-doc 1.43"
      ],
    }
  ],
  "chroots": ["epel-5-x86_64",  "epel-7-x86_64", "fedora-20-x86_64"],
  "packages":  [
    {
      "pkg_name": "python-copr-client",
      "pkg_version": "1.43",
      "results": {
        "epel-5-x86_64": [9578, "failed"],
        "epel-7-x86_64": [9578, "failed"],
        "fedora-20-x86_64": [9578, "skipped"]
      }
    }
  ]
}

    

Add new build

Login required

URL:

/api/coprs/<username>/<projectname>/new_build/

URL parameters:

Parameters sent by POST:

Example results

    {
      "output": "ok",
      "message": "Build was added to log4j.",
      "id": 5
    }
    

Query build status

Login required

URL:

/api/coprs/build_status/<build_id>/

URL parameters:

Result

Example result

    {
      "status": "pending",
      "output": "ok"
    }
    

Query build detail

URL:

/api/coprs/build_detail/<build_id>/
/api/coprs/build/<build_id>/

URL parameters:

Result

Example result

    {
      "status": "pending",
      "project": "myproject",
      "owner": "msuchy",
      "results": "http://copr-be.cloud.fedoraproject.org/results/msuchy/myproject/",
      "built_pkgs": [
        "hello 2.8",
        "hello-gui 2.8",
        "super-lib 5.4"
      ],
      "src_version": "2.8",
      "chroots": {
        "fedora-20-i386": "succeeded",
        "fedora-20-x86_64": "succeeded"
      },
      "submitted_on": 1386695673,
      "started_on": 1386695985,
      "ended_on": 1386696854,
      "src_pkg": "http://asamalik.fedorapeople.org/hello-2.8-1.fc20.src.rpm",
      "submitted_by": "asamalik",
      "output": "ok"
    }
    

Cancel build

Login required

URL:

/api/coprs/cancel_build/<build_id>/

URL parameters:

Result

Example result

    {
      "status": "Build canceled",
      "output": "ok"
    }
    

Copr Modification

Login required

URL:

/api/coprs/<username>/<coprname>/modify/

URL parameters:

Parameters sent by POST:

Result

Example result

    {
      "output": "ok",
      "repos": "foo",
      "description": "bar",
      "instructions": "baz"
    }
    

Chroot Modification

Login required

URL:

/api/coprs/<username>/<coprname>/modify/<chrootname>/

URL parameters:

Parameters sent by POST:

Result

Example result

    {
      "output": "ok",
      "buildroot_pkgs": "scl-utils-build"
    }
    

Chroot details

URL:

/api/coprs/<username>/<coprname>/detail/<chrootname>/

URL parameters:

Result

Example result

    {
      "output": "ok",
      "buildroot_pkgs": "scl-utils-build"
    }
    

Search for project

URL:

/api/coprs/search/<project>/
or
/api/coprs/?search="<project>"

URL parameters:

Result:

Example call URL

https://copr.fedoraproject.org/api/coprs/search/tests/

Example results

    {
      "output": "ok",
      "repos": [
        {
          "username": "ignatenkobrain",
          "coprname": "test",
          "description": "Tests"
        },
          "username": "ignatenkobrain",
          "coprname": "tests",
          "description": ""
        },
        {
          "username": "msuchy",
          "coprname": "tests",
          "description": "Copr testing repository, just for test various builds."
        }
      ]
    }
    
{% endblock %}