Skip to content

Commit b91206c

Browse files
committed
Initial import
1 parent c487fcf commit b91206c

File tree

406 files changed

+80194
-0
lines changed

Some content is hidden

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

406 files changed

+80194
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# Distribution / packaging
6+
.Python
7+
env/
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
lib64/
14+
parts/
15+
sdist/
16+
var/
17+
*.egg-info/
18+
.installed.cfg
19+
*.egg
20+
.eggs/
21+
22+
# tempfiles
23+
*.swp
24+
25+
# OS
26+
.DS_Store

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## [v1.0.0]
4+
5+
- Initial release

CONTRIBUTING.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Contributing to gridscale_api_client_python
2+
3+
As an open source project, we encourage and appreciate any kind of contributions
4+
like comments, enhancement requests, bug reports, or code contributions!
5+
6+
## Development workflow
7+
8+
* Development is done on the `develop` branch.
9+
* Releases are cut from the `master` branch.
10+
* For anything larger than single commits, please use feature/bugfix branches.
11+
12+
## Reporting Bugs or Enhancement Requests
13+
14+
Please submit bugs or enhancement requests through the public bug tracker within the
15+
GitHub project.
16+
17+
## Submitting Patches
18+
19+
The gridscale_api_client_python source code is managed using the git distributed source control
20+
management tool <https://www.git-scm.org/>. Please submit patches accordingly.
21+

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 CONTRIBUTORS.MD
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
This the official Python wrapper for gridscale's [API](https://gridscale.io/en//api-documentation/index.html). Allowing you to manage your own infrastructure from your own applications.
2+
3+
# Prerequisites
4+
5+
First, the Python programming language needs to be installed. This can be done by using the [official downloads](https://www.python.org/downloads/) page.
6+
7+
Once done, download and install via [pypi](https://pypi.org)
8+
9+
`pip3 install gs_api_client`
10+
11+
# Introduction
12+
First, you will need your [API credentials](https://my.gridscale.io/Easy/APIs/).
13+
14+
In the [examples.py](examples/examples.py) replace the `AUTH_TOKEN` & `USER_UUID` with your credentials.
15+
16+
# Authentication
17+
18+
These imports and configs need to be setup before other commands can be run. If you do not need synchronous or asynchronous requests, you can leave out `SyncGridscaleApiClient` & `GridscaleApiClient` respectively.
19+
20+
```python
21+
from gs_api_client import Configuration
22+
from gs_api_client import SyncGridscaleApiClient, GridscaleApiClient
23+
24+
# Initiate the configuration
25+
api_config = Configuration()
26+
api_config.api_key['X-Auth-Token'] = "AUTH_TOKEN"
27+
api_config.api_key['X-Auth-UserId'] = "USER_UUID"
28+
29+
# Setup the client
30+
sync_api = SyncGridscaleApiClient(configuration=api_config)
31+
async_api = GridscaleApiClient(configuration=api_config)
32+
```
33+
34+
# Async vs Sync Clients
35+
36+
We provide two clients `SyncGridscaleApiClient` & `GridscaleApiClient`. gridscale's API performs long running operations asynchronously in the background while returning a 202 response code, with the request identifier in the `x-request-id` response header.
37+
38+
The main differences are:
39+
- `GridscaleApiClient` exposes bare gridscale API functionality, while `SyncGridscaleApiClient` adds a convenience layer on top.
40+
- `SyncGridscaleApiClient` determines whether the request is sync or async.
41+
- Makes asynchronous operations behave as if they were synchronous:
42+
- The client will block until the request has finished, successful or not.
43+
- Throws an `AsynchronousApiError` exception, in the case of failure.
44+
- With most `PATCH` and `POST` requests, the synchronous client will return the resulting object instead of an empty body or just the reference.
45+
46+
# Debugging
47+
48+
Adding this line below, will output further information for debugging
49+
50+
```Python
51+
api_config.debug = True
52+
```
53+
54+
# Access response header
55+
56+
Adding `http_info=True` when instantiating the client, return value will be a tuple of response, response code and response headers (dict).
57+
58+
```Python
59+
sync_api = SyncGridscaleApiClient(http_info=True)
60+
async_api = GridscaleApiClient(http_info=True)
61+
```
62+
63+
# Basic request examples
64+
from pprint import pprint
65+
66+
# Get all Servers
67+
pprint(async_api.get_servers())
68+
69+
# Create a Server
70+
pprint(async_api.create_server({'name':'test', 'cores': 1, 'memory': 2}))
71+
72+
# Update a Server
73+
pprint(async_api.update_server('<UUID>', {
74+
'name':'windows production Server',
75+
'cores': 2,
76+
'memory': 4
77+
}))
78+
79+
# Delete a Server
80+
pprint(client.delete_storage('<UUID>'))
81+
82+
# Exhaustive list of all functions
83+
84+
Inside the [examples.py](examples/examples.py) file, you can see some example requests to get your started. All endpoints are fully documented in our [API](https://gridscale.io/en//api-documentation/index.html)
85+
86+
## Requests
87+
88+
- get_request
89+
90+
## Locations
91+
92+
- get_locations
93+
- get_location
94+
- get_location_ips
95+
- get_location_isoimages
96+
- get_location_networks
97+
- get_location_servers
98+
- get_location_snapshots
99+
- get_location_storages
100+
- get_location_templates
101+
102+
## Servers
103+
104+
- get_servers
105+
- get_server
106+
- create_server
107+
- update_server
108+
- delete_server
109+
- get_deleted_servers
110+
- get_server_events
111+
- get_server_metrics
112+
- get_server_power
113+
- update_server_power
114+
- server_power_shutdown
115+
116+
### Server Relations
117+
118+
- get_server_linked_ip
119+
- get_server_linked_ips
120+
- get_server_linked_isoimage
121+
- get_server_linked_isoimages
122+
- get_server_linked_network
123+
- get_server_linked_networks
124+
- get_server_linked_storage
125+
- get_server_linked_storages
126+
- link_ip_to_server',
127+
- link_isoimage_to_server
128+
- link_network_to_server
129+
- link_storage_to_server
130+
- update_server_linked_isoimage
131+
- update_server_linked_network
132+
- update_server_linked_storage
133+
- unlink_ip_from_server
134+
- unlink_isoimage_from_server
135+
- unlink_network_from_server
136+
- unlink_storage_from_server
137+
138+
## Storages
139+
140+
- get_storages
141+
- get_storage
142+
- create_storage
143+
- delete_storage
144+
- get_deleted_storages
145+
- storage_rollback
146+
- update_storage
147+
- get_storage_events
148+
149+
### Snapshots
150+
151+
- get_snapshots
152+
- get_snapshot
153+
- create_snapshot
154+
- delete_snapshot
155+
- get_snapshot_schedule
156+
- get_snapshot_schedules
157+
- update_snapshot
158+
- create_snapshot_schedule
159+
- update_snapshot_schedule
160+
- delete_snapshot_schedule
161+
- snapshot_export_to_s3
162+
- get_deleted_snapshots
163+
164+
### Templates
165+
166+
- get_templates
167+
- get_template
168+
- create_template
169+
- update_template
170+
- delete_template
171+
- get_template_events
172+
- get_deleted_templates
173+
174+
### Marketplace Templates
175+
176+
- get_marketplace_templates
177+
- get_marketplace_template
178+
- create_marketplace_template
179+
- update_marketplace_template
180+
- delete_marketplace_template
181+
- get_marketplace_template_events
182+
183+
## Networks
184+
185+
- get_network
186+
- get_networks
187+
- create_network
188+
- update_network
189+
- delete_network
190+
- get_network_events
191+
- get_deleted_networks
192+
193+
## IPs
194+
195+
- get_ips
196+
- get_ip
197+
- create_ip
198+
- update_ip
199+
- delete_ip
200+
- get_ip_events
201+
- get_deleted_ips
202+
203+
## Load Balancers
204+
205+
- get_loadbalancers
206+
- get_loadbalancer
207+
- create_loadbalancer
208+
- update_loadbalancer
209+
- delete_loadbalancer
210+
- get_loadbalancer_events
211+
212+
## PaaS
213+
214+
- get_paas_services
215+
- get_paas_service
216+
- create_paas_service
217+
- update_paas_service
218+
- delete_paas_service
219+
- get_paas_service_metrics
220+
- get_paas_security_zones
221+
- get_paas_security_zone
222+
- create_paas_security_zone
223+
- update_paas_security_zone
224+
- delete_paas_security_zone
225+
- get_paas_service_templates
226+
- get_deleted_paas_services
227+
228+
## Firewalls
229+
230+
- get_firewalls
231+
- get_firewall
232+
- create_firewall
233+
- update_firewall
234+
- delete_firewall
235+
- get_firewall_events
236+
237+
## Iso Images
238+
239+
- get_isoimages
240+
- get_isoimage
241+
- create_isoimage
242+
- update_isoimage
243+
- delete_isoimage
244+
- get_isoimage_events
245+
- get_deleted_isoimages
246+
247+
## Labels
248+
249+
- get_labels
250+
- create_label
251+
- delete_label
252+
253+
## SSH Keys
254+
255+
- get_ssh_keys
256+
- get_ssh_key
257+
- create_ssh_key
258+
- update_ssh_key
259+
- delete_ssh_key
260+
- get_ssh_key_events
261+
262+
## Events
263+
264+
- event_get_all
265+
266+
## Object Storage
267+
268+
- get_buckets
269+
- get_access_keys
270+
- get_access_key
271+
- create_access_key
272+
- delete_access_key

0 commit comments

Comments
 (0)