Skip to main content

k2hr3client for python

Project description

https://img.shields.io/badge/license-MIT-blue.svg https://img.shields.io/pypi/pyversions/k2hr3client.svg https://img.shields.io/github/forks/yahoojapan/k2hr3client_python.svg https://img.shields.io/github/stars/yahoojapan/k2hr3client_python.svg https://img.shields.io/github/issues/yahoojapan/k2hr3client_python.svg https://github.com/yahoojapan/k2hr3client_python/workflows/Python%20package/badge.svg https://readthedocs.org/projects/k2hr3client-python/badge/?version=latest https://img.shields.io/pypi/v/k2hr3client

Overview

k2hr3client_python is an official Python WebAPI client for k2hr3.

https://k2hr3.antpick.ax/images/top_k2hr3.png

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)

http://172.24.4.1

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

http://127.0.0.1:18080

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.

Document top page

About K2HR3

About AntPickax

Packages

Here are packages including other components.

k2hr3client(python packages)

License

MIT License. See the LICENSE file.

AntPickax

k2hr3client_python is a project by AntPickax, which is an open source team in LY Corporation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k2hr3client-1.1.2.tar.gz (128.5 kB view details)

Uploaded Source

Built Distribution

k2hr3client-1.1.2-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file k2hr3client-1.1.2.tar.gz.

File metadata

  • Download URL: k2hr3client-1.1.2.tar.gz
  • Upload date:
  • Size: 128.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for k2hr3client-1.1.2.tar.gz
Algorithm Hash digest
SHA256 59eb9c5b0604e6c27557e956bca0d7e9023dcfad737e7d4d13929a74626b7381
MD5 f728f7881baa18266041f47829b2b162
BLAKE2b-256 5d96860cfb285a4ad3bcd006b8b1f562901e7c0e7c4a80a55f6ba16a5e72f3ba

See more details on using hashes here.

File details

Details for the file k2hr3client-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: k2hr3client-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for k2hr3client-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 44cb53cac2719581009270e4371c87b9fe9679cb4afdeaa7dcf7e4394edf1804
MD5 1b7a4a3bf5570eebd3938b1d1d890c39
BLAKE2b-256 fc1b071622125769bafbf45c2e0ca9b73ea9148d5e5ba192fcc3842a2161ab26

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page