Skip to content

Commit 9a4d01d

Browse files
committed
move various methods to the open source client
This commit moves these methods to the open source hypernode-api-python client: ``` get_app_info_or_404 get_next_best_plan_for_app_or_404 validate_app_name get_slas get_available_backups_for_app get_app_eav_description set_app_settings get_app_configurations get_product_info_with_price get_whitelist_options get_whitelist_rules get_current_product_for_app check_payment_information_for_app get_active_products check_xgrade xgrade order_hypernode ``` There is some code in here that's slightly incongruent, but that's an artifact of where this came from. I added docstrings with usage examples and refactored out some of the django specific exceptions (Http404) and replaced those with RuntimeError so that the client doesn't make any assumptions about being ran in a Django application.
1 parent bdb74a0 commit 9a4d01d

21 files changed

+1294
-12
lines changed

README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,44 @@ pip install -e git+https://github.com/byteinternet/hypernode-api-python.git@mast
2727
```
2828
Of course you might want to put that in a `requirements.txt` file in your project instead of installing it manually.
2929

30+
### Performing API calls
31+
3032
Then to use the API client you can test out an example request in your Python repl:
31-
```bash
32-
[1]: from hypernode_api_python.client import HypernodeAPIPython
33+
```python
34+
from hypernode_api_python.client import HypernodeAPIPython
3335

34-
In [2]: client = HypernodeAPIPython(token='yoursecrettoken')
36+
client = HypernodeAPIPython(token='yoursecrettoken')
3537

36-
In [3]: response = client.get_app_flavor('yourhypernodeappname')
38+
response = client.get_app_flavor('yourhypernodeappname')
39+
40+
response.json()
41+
{'name': '2CPU/8GB/60GB (Falcon S 202202)', 'redis_size': '1024'}
42+
```
3743

38-
In [4]: response.json()
39-
Out[4]: {'name': '2CPU/8GB/60GB (Falcon S 202202)', 'redis_size': '1024'}
44+
Using the Hypernode-API you can automate all kinds of cool things like configuring settings:
45+
```python
46+
client.set_app_setting('yourhypernodeappname', 'php_version', '8.1').json()
47+
{'name': 'yourhypernodeappname', 'type': 'persistent', 'php_version': '8.1', ...}
48+
```
4049

50+
To even performing acts of cloud automation, like scaling to the first next larger plan:
51+
```python
52+
client.xgrade(
53+
'yourhypernodeappname',
54+
data={
55+
'product': client.get_next_best_plan_for_app_or_404(
56+
'yourhypernodeappname'
57+
).json()['code']
58+
}
59+
)
4160
```
4261

62+
4363
## Development
4464

45-
To run the unit tests you can us `tox`:
46-
```
47-
tox
65+
To run the unit tests you can use `tox`:
66+
```bash
67+
tox -r
4868
```
4969

5070
## Related projects

0 commit comments

Comments
 (0)