From Fedora Project Wiki
(JSON web api)
 
(client library and command-line client)
Line 37: Line 37:
* delete - Delete an existing package from a Copr.
* delete - Delete an existing package from a Copr.


== client library ==
All of the Copr API methods described above are available via a python client library. Users of the client library can access the functions like this:
from copr.client.lib import CoprClient
client = CoprClient(username='fedorian', password='mysecret')
client.copr_list()
client.copr_create(copr_name, copr_description, release, dependency_list)
...


== client library ==
The methods have different names in the client library. The following is a list of all the available methods (name in API/name in client lib):
 
Coprs:
* get_all - copr_list
* get_one - copr_info
* post - copr_create
* put - copr_edit
* delete - copr_delete
* add_releases - copr_add_releases
* remove_releases - copr_remove_releases
* add_dependencies - copr_add_dependencies
* remove_dependencies - copr_remove_dependencies
* grant - copr_grant
* revoke - copr_revoke
 
Packages:
* get_all - pkg_list
* get_one - pkg_info
* post - pkg_create
* delete - pkg_delete


== command-line client ==
== command-line client ==
The command line client can be used by invoking the bin.py file (which will probably be installed by the package in /usr/bin/copr). Following is the list of available commands available via the ''--help'' argument:
<pre>
$ python client/bin.py --help
usage: bin.py [-h] [-v] [-u USERNAME] [-p] [--url URL]
              {remove-copr-deps,list-pkgs,list-coprs,info-copr,add-copr-deps,create-pkg,edit-copr,delete-copr,create-copr,grant-copr,revoke-copr,add-copr-releases,remove-copr-releases,delete-pkg,info-pkg}
              ...
Command line tool for interacting with Fedora Copr
positional arguments:
  {remove-copr-deps,list-pkgs,list-coprs,info-copr,add-copr-deps,create-pkg,edit-copr,delete-copr,create-copr,grant-copr,revoke-copr,add-copr-releases,remove-copr-releases,delete-pkg,info-pkg}
    list-coprs          list all the available Coprs
    info-copr          get information about a specific Copr
    create-copr        create a new Copr
    edit-copr          edit an existing copr
    delete-copr        delete an existing copr
    add-copr-deps      add dependencies to a copr
    remove-copr-deps    remove dependencies from a copr
    add-copr-releases  add releases to a copr
    remove-copr-releases
                        remove releases from a copr
    grant-copr          grant permission on a copr
    revoke-copr        revoke permission on a copr
    list-pkgs          list all the packages in a copr
    info-pkg            get information on a package
    create-pkg          create a new package by uploading a srpm
    delete-pkg          delete a package
optional arguments:
  -h, --help            show this help message and exit
  -v, --version
  --url URL            provide an alternate url for the Copr service
authentication:
  -u USERNAME, --username USERNAME
  -p, --password
</pre>


== func module ==
== func module ==

Revision as of 21:51, 27 September 2010

JSON web API

This is a JSON web API implemented as TurboGears2 app. There is no web interface at this point. The API is supposed to be used with the help of the client library or the future web interface.

The available methods are grouped into copr-related and package-related methods.

Coprs

/coprs/*

A copr is a group of package repositories belonging to a user. A REST interface is provided, with the following methods:

  • get_all - Return all the Copr objects.
  • get_one - Return the Copr specified by 'copr_name'.
  • post - Create a new Copr from the given arguments.
  • put - Edit an existing Copr.
  • delete - Delete the Copr specified by 'copr_name'.

There are other additional methods available for managing: copr dependencies (Coprs can depend on other Coprs for BuildRequires dependencies), copr releases and for managing permissions:

  • add_dependencies - Add one or more Copr objects as dependencies for a Copr.
  • remove_dependencies - Remove the list of specified dependencies for a Copr.
  • add_releases - Add one or more releases to an existing Copr
  • remove_releases - Remove one or more releases from an existing Copr.
  • grant - Grant a user some permission on a Copr.
  • revoke - Revoke a given user's permission on a Copr.

Packages

/coprs/my_copr/packages/*

A package is roughly equivalent to a SRPM - it is independent of any release or architecture. All of the methods are relative to a copr, receive that copr as the first argument and the package also belongs to a specific copr. The available methods are:

  • get_all - Return all the packages in a copr.
  • get_one - Return information about a package.
  • post - Create a new package.
  • delete - Delete an existing package from a Copr.

client library

All of the Copr API methods described above are available via a python client library. Users of the client library can access the functions like this:

from copr.client.lib import CoprClient
client = CoprClient(username='fedorian', password='mysecret')
client.copr_list()
client.copr_create(copr_name, copr_description, release, dependency_list)
...

The methods have different names in the client library. The following is a list of all the available methods (name in API/name in client lib):

Coprs:

  • get_all - copr_list
  • get_one - copr_info
  • post - copr_create
  • put - copr_edit
  • delete - copr_delete
  • add_releases - copr_add_releases
  • remove_releases - copr_remove_releases
  • add_dependencies - copr_add_dependencies
  • remove_dependencies - copr_remove_dependencies
  • grant - copr_grant
  • revoke - copr_revoke

Packages:

  • get_all - pkg_list
  • get_one - pkg_info
  • post - pkg_create
  • delete - pkg_delete

command-line client

The command line client can be used by invoking the bin.py file (which will probably be installed by the package in /usr/bin/copr). Following is the list of available commands available via the --help argument:

 $ python client/bin.py --help
 usage: bin.py [-h] [-v] [-u USERNAME] [-p] [--url URL]

               {remove-copr-deps,list-pkgs,list-coprs,info-copr,add-copr-deps,create-pkg,edit-copr,delete-copr,create-copr,grant-copr,revoke-copr,add-copr-releases,remove-copr-releases,delete-pkg,info-pkg}
               ...

 Command line tool for interacting with Fedora Copr

 positional arguments:
   {remove-copr-deps,list-pkgs,list-coprs,info-copr,add-copr-deps,create-pkg,edit-copr,delete-copr,create-copr,grant-copr,revoke-copr,add-copr-releases,remove-copr-releases,delete-pkg,info-pkg}
     list-coprs          list all the available Coprs
     info-copr           get information about a specific Copr
     create-copr         create a new Copr
     edit-copr           edit an existing copr
     delete-copr         delete an existing copr
     add-copr-deps       add dependencies to a copr
     remove-copr-deps    remove dependencies from a copr
     add-copr-releases   add releases to a copr
     remove-copr-releases
                         remove releases from a copr
     grant-copr          grant permission on a copr
     revoke-copr         revoke permission on a copr
     list-pkgs           list all the packages in a copr
     info-pkg            get information on a package
     create-pkg          create a new package by uploading a srpm
     delete-pkg          delete a package

 optional arguments:
   -h, --help            show this help message and exit
   -v, --version
   --url URL             provide an alternate url for the Copr service

 authentication:
   -u USERNAME, --username USERNAME
   -p, --password

func module