Overview
k2hr3client_python is an official Python WebAPI client for k2hr3.
Install
Let’s install k2hr3client_python using pip:
pip install k2hr3client
Usage
Let’s try to get a token and create a resource.:
>>> from k2hr3client.token import K2hr3Token
>>> iaas_user = "demo"
>>> iaas_project = "demo"
>>> iaas_token_url = "http://172.24.4.1/identity/v3/auth/tokens"
>>> iaas_token = K2hr3Token.get_openstack_token(
... iaas_token_url, iaas_user, "password", iaas_project
... )
>>> mytoken = K2hr3Token(iaas_project, iaas_token)
>>>
>>> from k2hr3client.http import K2hr3Http
>>> k2hr3_token_url = "http://127.0.0.1:18080"
>>> myhttp = K2hr3Http(k2hr3_token_url)
>>> myhttp.POST(mytoken.create())
>>> mytoken.token # k2hr3 token
>>>
>>> from k2hr3client.resource import K2hr3Resource
>>> k2hr3_resource_name = "test_resource"
>>> myresource = K2hr3Resource(mytoken.token)
>>> myhttp.POST(
... myresource.create_conf_resource(
... name=k2hr3_resource_name,
... data_type="string",
... data="testresourcedata",
... keys={
... "cluster-name": "test-cluster",
... "chmpx-server-port": "8020",
... "chmpx-server-ctrlport": "8021",
... "chmpx-slave-ctrlport": "8031"},
... alias=[])
... )
>>> myresource.resp.body # {"result":true...
Settings
To customize the settings of this library, place the configuration file in one of the following locations.:
$PWD/k2hr3client.ini $HOME/.k2hr3client.ini /etc/antpickax/k2hr3client.ini
To use the settings in your program, see the following example.:
>>> from k2hr3client import CONFIG >>> print(CONFIG['DEFAULT']['iaas_user']) demo
Here are the default settings.
section |
key name |
description |
default value |
|---|---|---|---|
DEFAULT |
debug |
Enable debug log if True |
False |
DEFAULT |
iaas_url |
IaaS API URL(OpenStack) |
|
DEFAULT |
iaas_project |
IaaS project name |
demo |
DEFAULT |
iaas_user |
IaaS user name |
demo |
DEFAULT |
iaas_password |
IaaS password of the user |
password |
DEFAULT |
log_file |
log file name |
sys.stderr |
DEFAULT |
log_dir |
log directory name |
logs |
DEFAULT |
log_level |
log level(error,warn,info,debug,notset) |
info |
k2hr3 |
api_url |
k2hr3 API URL |
|
k2hr3 |
api_version |
k2hr3 api version |
v1 |
http |
timeout_seconds |
timeout to establish tcp connections |
30 |
http |
retry_interval_seconds |
interval to reconnect with HTTP server |
60 |
http |
max_retries |
maximum count to reconnect with HTTP server |
3 |
http |
allow_self_signed_cert |
Allow to use self-signed certification in HTTPS |
False |
Development
Clone this repository and go into the directory, then run the following command:
$ make init $ pipenv shell $ make lint test docs build
Documents
Here are documents including other components.
Packages
Here are packages including other components.
License
MIT License. See the LICENSE file.
AntPickax
k2hr3client_python is a project by AntPickax, which is an open source team in LY Corporation.
Metadata
Release files for k2hr3client 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| k2hr3client-1.1.3.tar.gz | 128.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| k2hr3client-1.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 173.0 kB
Release files / k2hr3client-1.1.3.tar.gz
| Download URL | k2hr3client-1.1.3.tar.gz |
|---|---|
| Size | 128.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a13702ceff66690ee6fe23e89a1abe9bc720f15dbaa1fece8798b8912124a96
|
|
BLAKE2b-256 checksum How to use checksums |
2e2140594375d3c4986d63a95727e931e32a616bbe76c7f74b84e7837339f934
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2025.
Transparency logRelease files / k2hr3client-1.1.3-py3-none-any.whl
| Download URL | k2hr3client-1.1.3-py3-none-any.whl |
|---|---|
| Size | 44.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb610edab79205ab52dc770ede384af504e8ee52b233128cb1635465ac4b3e57
|
|
BLAKE2b-256 checksum How to use checksums |
87e979ff090b2a6835b770df9018e02d708f6d034902df6132e4b41f4a7906db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2025.
Transparency log