Skip to content

Commit 1affb4f

Browse files
committed
Updates documentation
1 parent 89a7f51 commit 1affb4f

2 files changed

Lines changed: 12 additions & 145 deletions

File tree

SoftLayer/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
__author__ = 'SoftLayer Technologies, Inc.'
2929
__license__ = 'MIT'
3030
__copyright__ = 'Copyright 2014 SoftLayer Technologies, Inc.'
31-
__all__ = ['Client', 'BasicAuthentication', 'SoftLayerError',
32-
'SoftLayerAPIError', 'API_PUBLIC_ENDPOINT', 'API_PRIVATE_ENDPOINT']
31+
__all__ = ['BaseClient', 'create_client_from_env', 'Client',
32+
'BasicAuthentication', 'SoftLayerError', 'SoftLayerAPIError',
33+
'API_PUBLIC_ENDPOINT', 'API_PRIVATE_ENDPOINT']

docs/api/client.rst

Lines changed: 9 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ that will help to use the SoftLayer API.
1414
::
1515

1616
>>> import SoftLayer
17-
>>> client = SoftLayer.Client(username="username", api_key="api_key")
17+
>>> client = SoftLayer.create_client_from_env(username="username", api_key="api_key")
1818
>>> resp = client['Account'].getObject()
1919
>>> resp['companyName']
2020
'Your Company'
@@ -30,7 +30,7 @@ Creating a client instance by passing in the username/api_key:
3030
::
3131

3232
import SoftLayer
33-
client = SoftLayer.Client(username='YOUR_USERNAME', api_key='YOUR_API_KEY')
33+
client = SoftLayer.create_client_from_env(username='YOUR_USERNAME', api_key='YOUR_API_KEY')
3434

3535
Creating a client instance with environmental variables set:
3636
::
@@ -39,17 +39,17 @@ Creating a client instance with environmental variables set:
3939
$ export SL_API_KEY=YOUR_API_KEY
4040
$ python
4141
>>> import SoftLayer
42-
>>> client = SoftLayer.Client()
42+
>>> client = SoftLayer.create_client_from_env()
4343

4444
Below is an example of creating a client instance with more options. This will
4545
create a client with the private API endpoint (only accessible from the
4646
SoftLayer private network) and a timeout of 4 minutes.
4747
::
4848

49-
client = SoftLayer.Client(username='YOUR_USERNAME',
50-
api_key='YOUR_API_KEY'
51-
endpoint_url=SoftLayer.API_PRIVATE_ENDPOINT,
52-
timeout=240)
49+
client = SoftLayer.create_client_from_env(username='YOUR_USERNAME',
50+
api_key='YOUR_API_KEY'
51+
endpoint_url=SoftLayer.API_PRIVATE_ENDPOINT,
52+
timeout=240)
5353

5454
Managers
5555
--------
@@ -163,140 +163,6 @@ have billing implications.
163163

164164
API Reference
165165
-------------
166-
.. autoclass:: SoftLayer.Client
167-
:members:
168-
:undoc-members:
169166

170-
.. automethod:: SoftLayer.Client.__getitem__
171-
172-
.. autoclass:: SoftLayer.API.Service
173-
:members:
174-
:undoc-members:
175-
176-
.. automethod:: SoftLayer.API.Service.__call__
177-
178-
179-
.. automodule:: SoftLayer.exceptions
180-
:members:
181-
:undoc-members:
182-
183-
184-
Backwards Compatibility
185-
-----------------------
186-
As of version 3.0 of the API bindings, the old API methods and parameters no
187-
longer work. Below are examples of converting old API calls to the new ones.
188-
189-
**Get the IP address for an account**
190-
::
191-
192-
# Old
193-
import SoftLayer.API
194-
client = SoftLayer.API.Client('SoftLayer_Account', None, 'username', 'api_key')
195-
client.set_object_mask({'ipAddresses' : None})
196-
client.set_result_limit(10, offset=10)
197-
client.getObject()
198-
199-
# New
200-
import SoftLayer
201-
client = SoftLayer.Client(username='username', api_key='api_key')
202-
client['Account'].getObject(mask="ipAddresses", limit=10, offset=0)
203-
204-
**Importing the module**
205-
::
206-
207-
# Old
208-
import SoftLayer.API
209-
210-
# New
211-
import SoftLayer
212-
213-
**Creating a client instance**
214-
::
215-
216-
# Old
217-
client = SoftLayer.API.Client('SoftLayer_Account', None, 'username', 'api_key')
218-
219-
# New
220-
client = SoftLayer.Client(username='username', api_key='api_key')
221-
service = client['Account']
222-
223-
**Making an API call**
224-
::
225-
226-
# Old
227-
client = SoftLayer.API.Client('SoftLayer_Account', None, 'username', 'api_key')
228-
client.getObject()
229-
230-
# New
231-
client = SoftLayer.Client(username='username', api_key='api_key')
232-
client['Account'].getObject()
233-
234-
# Optionally
235-
service = client['Account']
236-
service.getObject()
237-
238-
**Setting Object Mask**
239-
::
240-
241-
# Old
242-
client.set_object_mask({'ipAddresses' : None})
243-
244-
# New
245-
client['Account'].getObject(mask="ipAddresses")
246-
247-
**Using Init Parameter**
248-
::
249-
250-
# Old
251-
client.set_init_parameter(1234)
252-
253-
# New
254-
client['Account'].getObject(id=1234)
255-
256-
**Setting Result Limit and Offset**
257-
::
258-
259-
# Old
260-
client.set_result_limit(10, offset=10)
261-
262-
# New
263-
client['Account'].getObject(limit=10, offset=10)
264-
265-
**Adding Additional Headers**
266-
::
267-
268-
# Old
269-
# These headers are persisted accross API calls
270-
client.add_header('header', 'value')
271-
272-
# New
273-
# These headers are NOT persisted accross API calls
274-
client['Account'].getObject(headers={'header': 'value'})
275-
276-
**Removing Additional Headers**
277-
::
278-
279-
# Old
280-
client.remove_header('header')
281-
282-
# New
283-
client['Account'].getObject()
284-
285-
**Adding Additional HTTP Headers**
286-
::
287-
288-
# Old
289-
client.add_raw_header('header', 'value')
290-
291-
# New
292-
client['Account'].getObject(raw_headers={'header': 'value'})
293-
294-
**Changing Authentication Credentials**
295-
::
296-
297-
# Old
298-
client.set_authentication('username', 'api_key')
299-
300-
# New
301-
client.username = 'username'
302-
client.api_key = 'api_key'
167+
.. automodule:: SoftLayer
168+
:members:

0 commit comments

Comments
 (0)