Skip to content

Commit 8dada70

Browse files
committed
add simple cli entrypoints for api functionality
like: ``` $ ls bin/ block_attack get_app_flavor get_block_attack_descriptions get_flows get_sla get_whitelist_rules command get_app_info get_cluster_relations get_next_best_plan_for_app get_slas validate_app_name get_app_configurations get_available_backups_for_app get_eav_description get_product_info get_whitelist_options hypernode-api-python]$ ./bin/get_sla --help usage: get_sla [-h] sla_code Get a specific SLA. $ ./bin/get_sla sla-standard { "id": 123, "code": "sla-standard", "name": "SLA Standard", "price": 1234, "billing_period": 1, "billing_period_unit": "month" } positional arguments: sla_code The code of the SLA to get optional arguments: -h, --help show this help message and exit ```
1 parent 4aa7ef2 commit 8dada70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1222
-3
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ['3.7', '3.8', '3.9', '3.10']
11+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1212

1313
steps:
1414
- uses: actions/checkout@v3

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,35 @@ pip install -r requirements/development.txt
1818

1919
Each Hypernode has an API token associated with it, you can use that to talk to the API directly. You can find the token in `/etc/hypernode/hypernode_api_token`. For API tokens with special permissions please contact [email protected]. Not all functionality in the API is currently generally available but if you'd like to start automating and have an interesting use-case we'd love to hear from you.
2020

21+
## Using the library from the commandline
22+
23+
In the `bin/` directory you'll find entrypoints to interact with the API directly from the commandline.
24+
25+
See for example:
26+
```bash
27+
$ export PYTHONPATH=.
28+
$ ./bin/get_slas --help
29+
usage: get_slas [-h]
30+
31+
List all available SLAs.
32+
33+
Example:
34+
$ ./bin/get_slas
35+
[
36+
{
37+
"id": 123,
38+
"code": "sla-standard",
39+
"name": "SLA Standard",
40+
"price": 1234,
41+
"billing_period": 1,
42+
"billing_period_unit": "month"
43+
},
44+
...
45+
]
46+
47+
optional arguments:
48+
-h, --help show this help message and exit
49+
```
2150

2251
### Installing the library in your project
2352

bin/block_attack

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

bin/command

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
from hypernode_api_python import commands
5+
6+
7+
if __name__ == '__main__':
8+
command = os.path.basename(__file__)
9+
10+
if hasattr(commands, command):
11+
sys.exit(getattr(commands, command)() or 0)
12+
else:
13+
sys.stderr.write("Command '{}' not found in hypernode_api_python.commands\n".format(command))
14+
sys.exit(1)

bin/get_app_configurations

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

bin/get_app_flavor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

bin/get_app_info

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

bin/get_available_backups_for_app

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

bin/get_block_attack_descriptions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

bin/get_cluster_relations

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

0 commit comments

Comments
 (0)