Python client library for openQA API
Project description
openqa_client
This is a client for the openQA API, based on requests. It requires Python 3.6 or later.
Usage
Here's a simple example of reading the status of a job:
from openqa_client.client import OpenQA_Client
client = OpenQA_Client(server='openqa.opensuse.org')
print(client.openqa_request('GET', 'jobs/1'))
Here's an example of triggering jobs for an ISO:
# This is a Fedora server.
client = OpenQA_Client(server='openqa.happyassassin.net')
params = {}
params['ISO'] = '22_Beta_TC2_server_x86_64_boot.iso'
params['DISTRI'] = 'fedora'
params['VERSION'] = '22'
params['FLAVOR'] = 'server_boot'
params['ARCH'] = 'x86_64'
params['BUILD'] = '22_Beta_TC2'
print(cl.openqa_request('POST', 'isos', params))
All methods other than GET
require authentication. This client uses
the same configuration file format as the reference (perl) client in
openQA itself. Configuration will be read from /etc/openqa/client.conf
or ~/.config/openqa/client.conf
. A configuration file looks like this:
[openqa.happyassassin.net]
key = APIKEY
secret = APISECRET
You can get the API key and secret from the web UI after logging in. Your configuration file may include credentials for multiple servers; each section contains the credentials for the server named in the section title.
If you create an OpenQA_Client
instance without passing the server
argument, it will use the first server listed in the configuration file
if there is one, otherwise it will use 'localhost'. Note: this is a
difference in behaviour from the perl client, which always uses 'localhost'
unless a server name is passed.
TLS/SSL connections are the default (except for localhost). You can
pass the argument scheme
to OpenQA_Client
to force the use of
unencrypted HTTP, e.g.
OpenQA_Client(server='openqa.happyassassin.net', scheme='http')
.
The API always returns JSON responses; this client's request functions parse the response before returning it.
If you need for some reason to make a request which does not fall into
the openqa_request()
method's expected pattern, you can construct a
requests.Request
and pass it to do_request()
, which will attach the
required headers, execute the request, and return the parsed JSON response.
The const
module provides several constants that are shadowed from the
upstream openQA code, including job states, results, and the 'scenario
keys'.
Licensing
This software is available under the GPL, version 2 or any later version. A copy is included as COPYING.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file openqa_client-4.0.0.tar.gz
.
File metadata
- Download URL: openqa_client-4.0.0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.2rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 421c798de61e63eeed0372196f613e8028f3396fc57578d7bfeb80c267726eaa |
|
MD5 | ff7fefa706e935438515ca2019cd2430 |
|
BLAKE2b-256 | b61d9a2150555702f154c9c3bdb4fb15e9aac4020c2e6eb80acb36b43b4c6f55 |
File details
Details for the file openqa_client-4.0.0-py3-none-any.whl
.
File metadata
- Download URL: openqa_client-4.0.0-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.2rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bc368bdf2e3042d0bc2133931debdecd05ae2ea7ad0f28d11fede874550b353 |
|
MD5 | 0f57dce51adbb9dfd52bc6221e9e1c08 |
|
BLAKE2b-256 | 521c0e0c954081a6e9791ea9fa86b03ecfdb07e080197854e993b3888416cd4c |