Skip to content

Commit ba41f05

Browse files
authored
Merge pull request #26 from ByteInternet/add-cli-entrypoint
add simple cli entrypoints for api functionality
2 parents 4aa7ef2 + d079678 commit ba41f05

58 files changed

Lines changed: 1805 additions & 4 deletions

Some content is hidden

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

.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: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,36 @@ 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 support@hypernode.com. 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 entry points to interact with the API directly from the commandline.
24+
25+
See for example:
26+
```bash
27+
$ export PYTHONPATH=.
28+
29+
$ ./bin/get_slas --help
30+
usage: get_slas [-h]
31+
32+
List all available SLAs.
33+
34+
Example:
35+
$ ./bin/get_slas
36+
[
37+
{
38+
"id": 123,
39+
"code": "sla-standard",
40+
"name": "SLA Standard",
41+
"price": 1234,
42+
"billing_period": 1,
43+
"billing_period_unit": "month"
44+
},
45+
...
46+
]
47+
48+
optional arguments:
49+
-h, --help show this help message and exit
50+
```
2151

2252
### Installing the library in your project
2353

@@ -56,7 +86,7 @@ client.set_app_setting('yourhypernodeappname', 'php_version', '8.1').json()
5686
{'name': 'yourhypernodeappname', 'type': 'persistent', 'php_version': '8.1', ...}
5787
```
5888

59-
To even performing acts of cloud automation, like scaling to the first next larger plan:
89+
You can even perform acts of cloud automation, like scaling to the first next larger plan:
6090
```python
6191
client.xgrade(
6292
'yourhypernodeappname',

bin/block_attack

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

bin/check_xgrade

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/create_brancher

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

bin/destroy_brancher

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

bin/get_active_branchers

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

bin/get_active_products

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

0 commit comments

Comments
 (0)