|
2 | 2 | Usage |
3 | 3 | ===== |
4 | 4 |
|
5 | | -To use iland-sdk in a project:: |
6 | | - |
7 | | - import iland |
8 | | - |
9 | | -The API is exposed via the ``iland.Api`` class. |
10 | | - |
11 | | -To create an instance of the ``iland.Api``:: |
12 | | - |
13 | | - >>> import iland |
14 | | - >>> api = iland.Api(client_id=CLIENT_ID, |
15 | | - client_secret=CLIENT_SECRET, |
16 | | - username=USERNAME, |
17 | | - password=PASSWORD) |
18 | | - |
19 | | -You can then perform GET, PUT, POST and DELETE requests against the iland |
20 | | -cloud:: |
21 | | - |
22 | | - >>> user = api.get('/user/' + USERNAME) |
23 | | - >>> user.get('name')) |
24 | | - USERNAME |
25 | | - |
26 | | - >>> user_alert_emails = {'emails': ['test@iland.com', 'test2@iland.com'], |
27 | | - 'username': USERNAME} |
28 | | - >>> api.post('/user/' + USERNAME + '/alert-emails', user_alert_emails) |
29 | | - |
30 | | -To use a proxy you can define a ``python-requests`` style proxies_ dictionary |
31 | | -and set the ``_proxies`` attribute on the api object:: |
32 | | - |
33 | | - >>> api = iland.Api(client_id=CLIENT_ID, |
34 | | - client_secret=CLIENT_SECRET, |
35 | | - username=USERNAME, |
36 | | - password=PASSWORD) |
37 | | - >>> api._proxies = {'https': 'https://10.10.1.10:3128'} |
38 | | - >>> user = api.get('/user/' + USERNAME) |
39 | | - |
40 | | -The ``get``, ``post``, ``put``, and ``delete`` methods can accept an optional |
41 | | -``_timeout`` parameter that is passed to ``requests``:: |
42 | | - |
43 | | - >>> user = api.get('/user/' + USERNAME, timeout=5.0) |
44 | | - |
45 | | -.. _proxies: http://docs.python-requests.org/en/master/user/advanced/#proxies |
46 | | -.. _timeout: http://docs.python-requests.org/en/master/user/quickstart/#timeouts |
| 5 | +To get started using iland's Python SDK check out our `Wiki <https://github.com/ilanddev/python-sdk/wiki>`_. |
0 commit comments