Skip to content

Commit 4be0789

Browse files
authored
Adds verify as a API call argument (softlayer#741)
Fixes softlayer#726
1 parent ba1410e commit 4be0789

2 files changed

Lines changed: 28 additions & 45 deletions

File tree

SoftLayer/API.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'raw_headers',
3535
'limit',
3636
'offset',
37+
'verify',
3738
))
3839

3940

@@ -174,15 +175,22 @@ def __getitem__(self, name):
174175
return Service(self, name)
175176

176177
def call(self, service, method, *args, **kwargs):
177-
"""Make a SoftLayer API call
178+
"""Make a SoftLayer API call.
178179
179-
:param service: the name of the SoftLayer API service
180180
:param method: the method to call on the service
181-
:param \\*args: same optional arguments that ``Service.call`` takes
182-
:param \\*\\*kwargs: same optional keyword arguments that
183-
``Service.call`` takes
184-
185-
:param service: the name of the SoftLayer API service
181+
:param \\*args: (optional) arguments for the remote call
182+
:param id: (optional) id for the resource
183+
:param mask: (optional) object mask
184+
:param dict filter: (optional) filter dict
185+
:param dict headers: (optional) optional XML-RPC headers
186+
:param boolean compress: (optional) Enable/Disable HTTP compression
187+
:param dict raw_headers: (optional) HTTP transport headers
188+
:param int limit: (optional) return at most this many results
189+
:param int offset: (optional) offset results by this many
190+
:param boolean iter: (optional) if True, returns a generator with the
191+
results
192+
:param bool verify: verify SSL cert
193+
:param cert: client certificate path
186194
187195
Usage:
188196
>>> import SoftLayer
@@ -222,6 +230,7 @@ def call(self, service, method, *args, **kwargs):
222230
request.filter = kwargs.get('filter')
223231
request.limit = kwargs.get('limit')
224232
request.offset = kwargs.get('offset')
233+
request.verify = kwargs.get('verify')
225234

226235
if self.auth:
227236
extra_headers = self.auth.get_headers()
@@ -314,22 +323,15 @@ def __init__(self, client, name):
314323
self.name = name
315324

316325
def call(self, name, *args, **kwargs):
317-
"""Make a SoftLayer API call.
326+
"""Make a SoftLayer API call
318327
328+
:param service: the name of the SoftLayer API service
319329
:param method: the method to call on the service
320-
:param \\*args: (optional) arguments for the remote call
321-
:param id: (optional) id for the resource
322-
:param mask: (optional) object mask
323-
:param dict filter: (optional) filter dict
324-
:param dict headers: (optional) optional XML-RPC headers
325-
:param boolean compress: (optional) Enable/Disable HTTP compression
326-
:param dict raw_headers: (optional) HTTP transport headers
327-
:param int limit: (optional) return at most this many results
328-
:param int offset: (optional) offset results by this many
329-
:param boolean iter: (optional) if True, returns a generator with the
330-
results
331-
:param bool verify: verify SSL cert
332-
:param cert: client certificate path
330+
:param \\*args: same optional arguments that ``BaseClient.call`` takes
331+
:param \\*\\*kwargs: same optional keyword arguments that
332+
``BaseClient.call`` takes
333+
334+
:param service: the name of the SoftLayer API service
333335
334336
Usage:
335337
>>> import SoftLayer

tests/api_tests.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,15 @@ def test_simple_call(self):
8080
offset=None,
8181
)
8282

83-
def test_complex(self):
83+
def test_verify(self):
84+
client = SoftLayer.BaseClient(transport=self.mocks)
8485
mock = self.set_mock('SoftLayer_SERVICE', 'METHOD')
8586
mock.return_value = {"test": "result"}
86-
_filter = {'TYPE': {'attribute': {'operation': '^= prefix'}}}
87-
88-
resp = self.client['SERVICE'].METHOD(
89-
1234,
90-
id=5678,
91-
mask={'object': {'attribute': ''}},
92-
headers={'header': 'value'},
93-
raw_headers={'RAW': 'HEADER'},
94-
filter=_filter,
95-
limit=9,
96-
offset=10)
87+
88+
resp = client.call('SERVICE', 'METHOD', verify=False)
9789

9890
self.assertEqual(resp, {"test": "result"})
99-
self.assert_called_with('SoftLayer_SERVICE', 'METHOD',
100-
mask={'object': {'attribute': ''}},
101-
filter=_filter,
102-
identifier=5678,
103-
args=(1234,),
104-
limit=9,
105-
offset=10,
106-
)
107-
calls = self.calls('SoftLayer_SERVICE', 'METHOD')
108-
self.assertEqual(len(calls), 1)
109-
self.assertIn('header', calls[0].headers)
110-
self.assertEqual(calls[0].headers['header'], 'value')
91+
self.assert_called_with('SoftLayer_SERVICE', 'METHOD', verify=False)
11192

11293
@mock.patch('SoftLayer.API.BaseClient.iter_call')
11394
def test_iterate(self, _iter_call):

0 commit comments

Comments
 (0)