Python SDK to query Scaleway's APIs.
The package is available on pip
. To install it in a virtualenv:
$ virtualenv my_virtualenv $ source my_virtualenv/bin/activate $ pip install scaleway-sdk
If you're looking to send a GET
HTTP request against our APIs, like:
you only need to call the following pythonic code:
>>> from scaleway.apis import DummyAPI >>> DummyAPI().query().foo.bar.get()
The magic here lies in scaleway.apis.*API
instances, which all have a query
method returning a slumber.API
object. The latter handling all the excruciating details of the requests.
Even if this SDK is designed to be developer-friendly and aim for self-service discovery, it is still recommended to read the official API documentation.
And because most of the provided helpers takes the form of pre-configured Slumber
objects, a good read of Slumber documention is encouraged as well.
The list of available resources per API can be found [on the Scaleway API repository](https://github.com/scaleway/api.scaleway.com/blob/master/README.md#apis)
>>> from scaleway.apis import AccountAPI >>> api = AccountAPI(auth_token='') # Set your token here! >>> print api.query().organizations.get() {u'organizations': [...]}
>>> from scaleway.apis import AccountAPI >>> api = AccountAPI(auth_token='') # Set your token here! >>> resp = api.query(serialize=False).organizations.get() >>> print type(resp) <Response [200]> >>> print resp.headers {...} # Response HTTP headers. >>> print resp.links {...} # Parsed "Link" HTTP header, for pagination. >>> print resp.json() {u'organizations': [...]}
>>> from scaleway.apis import ComputeAPI >>> api = ComputeAPI(auth_token='') # Set your token here! >>> print api.query().servers.get() {u'servers': [...]} # Or choose your region, as in apis/api_compute.py >>> api = ComputeAPI(region='ams1', auth_token='') # Set your token here! >>> print api.query().servers.get() {u'servers': [...]}
>>> from scaleway.apis import ComputeAPI >>> api = ComputeAPI(auth_token='') # Set your token here! >>> server_id = '' # Set a server ID here! >>> print api.query().servers(server_id).get() {u'server': {...}}
servers:read
for the service compute
for the organization 9a096d36-6bf9-470f-91df-2398aa7361f7
:>>> from scaleway.apis import AccountAPI >>> api = AccountAPI(auth_token='') # Set your token here! >>> print api.has_perm(service='compute', name='servers:read', ... resource='9a096d36-6bf9-470f-91df-2398aa7361f7') False
Assuming you are in a virtualenv:
$ pip install -e . $ python -c 'from scaleway.apis import AccountAPI' # it works!
To submit a patch, you'll need to test your code against python2.7 and python3.4. To run tests:
$ pip install nose coverage pycodestyle pylint $ python setup.py nosetests --with-coverage (...) $ pycodestyle scaleway (...) $ pylint scaleway (...)
Alternatively, to run nosetests on both Python2.7 and Python3.4, you can run tox.
Alternative libraries / clientsWe maintain a list of the current library/client implementations on the api.scaleway.com repository.
This software is licensed under a BSD 2-Clause License.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4