Skip to content

Commit bae7b57

Browse files
Merge pull request softlayer#646 from sudorandom/promote-call
Change docs to use Client.call instead of hash accessors
2 parents 23153bc + 288ff15 commit bae7b57

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

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
@@ -151,11 +151,11 @@ def authenticate_with_password(self, username, password,
151151
152152
"""
153153
self.auth = None
154-
res = self['User_Customer'].getPortalLoginToken(
155-
username,
156-
password,
157-
security_question_id,
158-
security_question_answer)
154+
res = self.call('User_Customer', 'getPortalLoginToken',
155+
username,
156+
password,
157+
security_question_id,
158+
security_question_answer)
159159
self.auth = slauth.TokenAuthentication(res['userId'], res['hash'])
160160
return res['userId'], res['hash']
161161

@@ -187,7 +187,7 @@ def call(self, service, method, *args, **kwargs):
187187
Usage:
188188
>>> import SoftLayer
189189
>>> client = SoftLayer.create_client_from_env()
190-
>>> client['Account'].getVirtualGuests(mask="id", limit=10)
190+
>>> client.call('Account', 'getVirtualGuests', mask="id", limit=10)
191191
[...]
192192
193193
"""
@@ -354,7 +354,7 @@ def iter_call(self, name, *args, **kwargs):
354354
Usage:
355355
>>> import SoftLayer
356356
>>> client = SoftLayer.create_client_from_env()
357-
>>> gen = client['Account'].getVirtualGuests(iter=True)
357+
>>> gen = client.call('Account', 'getVirtualGuests', iter=True)
358358
>>> for virtual_guest in gen:
359359
... virtual_guest['id']
360360
...

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)