A simple Orchestrator API client
Project description
python-orchestrator-client
A simple Python Orchestrator (https://github.com/github/orchestrator) client.
It ensures that the commands to be sent to Orchestrator API are valid, and that the number of arguments matches what the
API expects. This is achieved via the definition of all endpoints and their arguments. The configuration is under
pyorchestratorclient/endpoints.py
and has been generated from Orchestrator's
source code using
scripts/orchestrator_api_conf.sh
. You can generate your own to ensure its contents match what your Orchestrator
version supports, if required.
Usage:
In [1]: from pyorchestratorclient import OrchestratorClient
In [2]: o = OrchestratorClient('http://localhost:3000') # Orchestrator URL
In [3]: o.clusters()
Out[3]: ['deceive:20516']
In [4]: o.relocate('deceive', '20518', 'deceive', '20516') # Call with methods
Out[4]:
{'Code': 'OK',
'Details': {'AllowTLS': False,
'AncestryUUID': '00020516-1111-1111-1111-111111111111,00020518-3333-3333-3333-333333333333',
'BinlogRowImage': 'FULL',
'Binlog_format': 'ROW',
'ClusterName': 'deceive:20516',
...
'Version': '8.0.15',
'VersionComment': 'MySQL Community Server - GPL'},
'Message': 'Instance deceive:20518 relocated below deceive:20516'}
In [5]: o.check_global_recoveries() # Notice that dashes in HTTP API are translated to underscores for the python client
Out[5]: {'Code': 'OK', 'Details': 'enabled', 'Message': 'Global recoveries enabled'}
In [6]: o.clusters("ssfd") # Validation of expected number of arguments
---------------------------------------------------------------------------
OrchestratorClientError Traceback (most recent call last)
<ipython-input-7-0494111cc886> in <module>
----> 1 o.clusters("ssfd")
~/git/python-orchestrator-client/pyorchestratorclient/__init__.py in _method_mapper(*args, **kwargs)
151 def __getattr__(self, item):
152 def _method_mapper(*args, **kwargs):
--> 153 return self.run(item.replace("_", "-"), *args, *kwargs)
154
155 if item.replace("_", "-") in self.commands.keys():
~/git/python-orchestrator-client/pyorchestratorclient/__init__.py in run(self, cmd, *args)
110 sample = ", ".join(usage).strip().strip(",")
111 usages.append(f"[{sample}]")
--> 112 raise OrchestratorClientError(
113 f"Specified number of arguments for command {cmd} ({len(args)})"
114 f" does not match expected number of arguments for it "
OrchestratorClientError: Specified number of arguments for command clusters (1) does not match expected number of arguments for it ([0]). Check that your call is correct.
In [7]: o.something() # Validation of supported methods
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-10-3a11b5057530> in <module>
----> 1 o.something()
~/git/python-orchestrator-client/pyorchestratorclient/__init__.py in __getattr__(self, item)
155 if item.replace("_", "-") in self.commands.keys():
156 return _method_mapper
--> 157 raise AttributeError(f"No such attribute or method: {item}")
158
159
AttributeError: No such attribute or method: something
In [11]:
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 pyorchestratorclient-3.2.4.1.tar.gz
.
File metadata
- Download URL: pyorchestratorclient-3.2.4.1.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67f476d9ac0ef595417ac5af9befdeb9ee29b03de5e10b905054acb6b63530ed |
|
MD5 | e8376f573b7b959acbb2bd1161b71f0c |
|
BLAKE2b-256 | 9d3b967cc50eb0602549909840cbb7f7b5059cefa3bf6dd271c76a930680a301 |
File details
Details for the file pyorchestratorclient-3.2.4.1-py3-none-any.whl
.
File metadata
- Download URL: pyorchestratorclient-3.2.4.1-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84e4297daf0eeac7d971177a02eedac515e0dcc40618a9876dbff3b99565a9ec |
|
MD5 | 147399a429aa48a514857e2999dd2488 |
|
BLAKE2b-256 | 023b83fc7a3005f06b71d704b7adbcf6e5f3daa39e6b87f86ef01dc848263317 |