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.0.tar.gz
.
File metadata
- Download URL: pyorchestratorclient-3.2.4.0.tar.gz
- Upload date:
- Size: 18.0 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 | 8a4fdada0ac949bbb5385d076c57ad053b2f225aa44c6126f29ec66140c13e97 |
|
MD5 | 49d7c692ee14e02d2c5589ecc6610e41 |
|
BLAKE2b-256 | fed3bcea3bf1bd3d30cd6eeb79da9d4b107b2e360ce5d04e9649af631676a441 |
File details
Details for the file pyorchestratorclient-3.2.4.0-py3-none-any.whl
.
File metadata
- Download URL: pyorchestratorclient-3.2.4.0-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 | 89405cc0d773e17bbe5e057e87e28e5c173868840866ee75edcf92db47c953fb |
|
MD5 | 1dfa07a403b1fb21615a2813ae7c8f85 |
|
BLAKE2b-256 | 6a23fd4c64bdf88ac89396a27ff64929c47e2b60a9a8ccdce40af1730f23ff48 |