Skip to content

Commit 288ff15

Browse files
author
Kevin McDonald
committed
Change docs to use Client.call instead of hash acessors
1 parent c0ec9f7 commit 288ff15

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

SoftLayer/API.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def create_client_from_env(username=None,
7272
7373
>>> import SoftLayer
7474
>>> client = SoftLayer.create_client_from_env()
75-
>>> resp = client['Account'].getObject()
75+
>>> resp = client.call('Account', 'getObject')
7676
>>> resp['companyName']
7777
'Your Company'
7878
@@ -141,11 +141,11 @@ def authenticate_with_password(self, username, password,
141141
142142
"""
143143
self.auth = None
144-
res = self['User_Customer'].getPortalLoginToken(
145-
username,
146-
password,
147-
security_question_id,
148-
security_question_answer)
144+
res = self.call('User_Customer', 'getPortalLoginToken',
145+
username,
146+
password,
147+
security_question_id,
148+
security_question_answer)
149149
self.auth = slauth.TokenAuthentication(res['userId'], res['hash'])
150150
return res['userId'], res['hash']
151151

@@ -177,7 +177,7 @@ def call(self, service, method, *args, **kwargs):
177177
Usage:
178178
>>> import SoftLayer
179179
>>> client = SoftLayer.create_client_from_env()
180-
>>> client['Account'].getVirtualGuests(mask="id", limit=10)
180+
>>> client.call('Account', 'getVirtualGuests', mask="id", limit=10)
181181
[...]
182182
183183
"""
@@ -344,7 +344,7 @@ def iter_call(self, name, *args, **kwargs):
344344
Usage:
345345
>>> import SoftLayer
346346
>>> client = SoftLayer.create_client_from_env()
347-
>>> gen = client['Account'].getVirtualGuests(iter=True)
347+
>>> gen = client.call('Account', 'getVirtualGuests', iter=True)
348348
>>> for virtual_guest in gen:
349349
... virtual_guest['id']
350350
...

docs/api/client.rst

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

1616
>>> import SoftLayer
1717
>>> client = SoftLayer.create_client_from_env(username="username", api_key="api_key")
18-
>>> resp = client['Account'].getObject()
18+
>>> resp = client.call('Account', 'getObject')
1919
>>> resp['companyName']
2020
'Your Company'
2121

@@ -92,7 +92,7 @@ method on the
9292
service.
9393
::
9494

95-
client['Account'].getObject()
95+
client.call('Account', 'getObject')
9696

9797
For a more complex example we'll retrieve a support ticket with id 123456 along
9898
with the ticket's updates, the user it's assigned to, the servers attached to
@@ -102,7 +102,7 @@ using an `object mask <http://developer.softlayer.com/article/Extended-Object-Ma
102102
Retrieve a ticket using object masks.
103103
::
104104

105-
ticket = client['Ticket'].getObject(
105+
ticket = client.call('Ticket', 'getObject',
106106
id=123456, mask="updates, assignedUser, attachedHardware.datacenter")
107107

108108

@@ -112,19 +112,19 @@ This uses a parameter, which translate to positional arguments in the order
112112
that they appear in the API docs.
113113
::
114114

115-
update = client['Ticket'].addUpdate({'entry' : 'Hello!'}, id=123456)
115+
update = client.call('Ticket', 'addUpdate', {'entry' : 'Hello!'}, id=123456)
116116

117117
Let's get a listing of virtual guests using the domain example.com
118118
::
119119

120-
client['Account'].getVirtualGuests(
120+
client.call('Account', 'getVirtualGuests',
121121
filter={'virtualGuests': {'domain': {'operation': 'example.com'}}})
122122

123123
This call gets tickets created between the beginning of March 1, 2013 and
124124
March 15, 2013.
125125
::
126126

127-
client['Account'].getTickets(
127+
client.call('Account', 'getTickets',
128128
filter={
129129
'tickets': {
130130
'createDate': {
@@ -141,16 +141,16 @@ March 15, 2013.
141141
SoftLayer's XML-RPC API also allows for pagination.
142142
::
143143

144-
client['Account'].getVirtualGuests(limit=10, offset=0) # Page 1
145-
client['Account'].getVirtualGuests(limit=10, offset=10) # Page 2
144+
client.call('Account', 'getVirtualGuests', limit=10, offset=0) # Page 1
145+
client.call('Account', 'getVirtualGuests', limit=10, offset=10) # Page 2
146146

147147
Here's how to create a new Cloud Compute Instance using
148148
`SoftLayer_Virtual_Guest.createObject <http://developer.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject>`_.
149149
Be warned, this call actually creates an hourly virtual server so this will
150150
have billing implications.
151151
::
152152

153-
client['Virtual_Guest'].createObject({
153+
client.call('Virtual_Guest', 'createObject', {
154154
'hostname': 'myhostname',
155155
'domain': 'example.com',
156156
'startCpus': 1,

0 commit comments

Comments
 (0)