| |
@@ -1,11 +1,41 @@
|
| |
Client initialization
|
| |
=====================
|
| |
|
| |
- Before an API client can be used, it needs to be initialized with a configuration. There are several ways to do it.
|
| |
- The most standard option is reading the ``~/.config/copr`` file and providing it to the ``Client`` class. Please read
|
| |
- https://copr.fedorainfracloud.org/api/ for more information about API token.
|
| |
+ Before an API client can be used, it needs to be initialized with a
|
| |
+ configuration. There are several ways to do it. The most standard option is
|
| |
+ reading the ``~/.config/copr`` file and providing it to the ``Client`` class.
|
| |
|
| |
- ::
|
| |
+ Such a configuration file typically has::
|
| |
+
|
| |
+ [copr-cli]
|
| |
+ copr_url = https://copr.fedorainfracloud.org
|
| |
+ username = coprusername
|
| |
+ login = secretlogin
|
| |
+ token = secrettoken
|
| |
+ # expiration date: 2023-01-17
|
| |
+
|
| |
+ To get your configuration file for the Fedora Copr instance, go to
|
| |
+ https://copr.fedorainfracloud.org/api/
|
| |
+
|
| |
+ The only mandatory field though is ``copr_url``::
|
| |
+
|
| |
+ [copr-cli]
|
| |
+ copr_url = https://copr.fedorainfracloud.org
|
| |
+
|
| |
+ With such a simplified configuration, you can still do the read-only API
|
| |
+ queries that do not require user-authentication (listing projects, builds,
|
| |
+ etc.).
|
| |
+
|
| |
+ Alternatively, the Copr server you work with might support GSSAPI
|
| |
+ authentication (Fedora Copr does). To let the Client use your ``kinit``
|
| |
+ tokens, you need to enable GSSAPI authentication first::
|
| |
+
|
| |
+ [copr-cli]
|
| |
+ copr_url = https://copr.fedorainfracloud.org
|
| |
+ gssapi = true
|
| |
+
|
| |
+ Having the config file prepared, you can finally use it for creating a
|
| |
+ ``Client`` instance. Just like::
|
| |
|
| |
from copr.v3 import Client
|
| |
from pprint import pprint
|
| |
@@ -17,7 +47,7 @@
|
| |
{'copr_url': u'https://copr.fedorainfracloud.org',
|
| |
'login': u'secretlogin',
|
| |
'token': u'secrettoken',
|
| |
- 'username': u'frostyx'}
|
| |
+ 'username': u'coprusername'}
|
| |
|
| |
A different config file can be easily used by passing its path to ``create_from_config_file`` method.
|
| |
|
| |
@@ -34,7 +64,7 @@
|
| |
config = {'copr_url': u'https://copr.fedorainfracloud.org',
|
| |
'login': u'secretlogin',
|
| |
'token': u'secrettoken',
|
| |
- 'username': u'frostyx'}
|
| |
+ 'username': u'coprusername'}
|
| |
|
| |
client = Client(config)
|
| |
assert client.config == config
|
| |
@@ -53,7 +83,7 @@
|
| |
config = {'copr_url': u'https://copr.fedorainfracloud.org',
|
| |
'login': u'secretlogin',
|
| |
'token': u'secrettoken',
|
| |
- 'username': u'frostyx'}
|
| |
+ 'username': u'coprusername'}
|
| |
|
| |
build_proxy = BuildProxy(config)
|
| |
|
| |
Mention that copr_url= is the only mandatory field in the configuration,
and that there's the gssapi= token. Use a placeholder copr_url and
username in the examples.