Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Commit b8e87dc

Browse files
committed
Merge pull request #34 from CommandIQ/master
Added RetrieveOptions support for RetreiveRequest in ET_Get. Added support for delete operations to ET_Configure.
2 parents 855ca7d + 251eeff commit b8e87dc

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

FuelSDK/objects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ class ET_ProfileAttribute():
2929
def __init__(self):
3030
self.obj_type = 'PropertyDefinition'
3131
self.update = False
32+
self.delete = False
3233

3334
def post(self):
34-
obj = ET_Configure(self.auth_stub, self.obj_type, self.props, self.update)
35+
obj = ET_Configure(self.auth_stub, self.obj_type, self.props, self.update, self.delete)
3536
if obj is not None:
3637
self.last_request_id = obj.request_id
3738
return obj

FuelSDK/rest.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,16 @@ def __init__(self, auth_stub, obj_type):
119119
##
120120
########
121121
class ET_Configure(ET_Constructor):
122-
def __init__(self, auth_stub, obj_type, props = None, update = False):
122+
def __init__(self, auth_stub, obj_type, props = None, update = False, delete = False):
123123
auth_stub.refresh_token()
124124

125125
ws_configureRequest = auth_stub.soap_client.factory.create('ConfigureRequestMsg')
126-
ws_configureRequest.Action = 'create' if update is False else 'update'
126+
action = 'create'
127+
if delete:
128+
action = 'delete'
129+
elif update:
130+
action = 'update'
131+
ws_configureRequest.Action = action
127132
ws_configureRequest.Configurations = {'Configuration': self.parse_props_into_ws_object(auth_stub, obj_type, props)}
128133

129134
response = auth_stub.soap_client.service.Configure(None, ws_configureRequest)
@@ -138,7 +143,7 @@ def __init__(self, auth_stub, obj_type, props = None, update = False):
138143
##
139144
########
140145
class ET_Get(ET_Constructor):
141-
def __init__(self, auth_stub, obj_type, props = None, search_filter = None):
146+
def __init__(self, auth_stub, obj_type, props = None, search_filter = None, options = None):
142147
auth_stub.refresh_token()
143148

144149
if props is None: #if there are no properties to retrieve for the obj_type then return a Description of obj_type
@@ -187,6 +192,14 @@ def __init__(self, auth_stub, obj_type, props = None, search_filter = None):
187192
ws_simpleFilterPart[prop[0]] = search_filter[prop[0]]
188193
ws_retrieveRequest.Filter = ws_simpleFilterPart
189194

195+
if options is not None:
196+
for key, value in options.iteritems():
197+
if isinstance(value, dict):
198+
for k, v in value.iteritems():
199+
ws_retrieveRequest.Options[key][k] = v
200+
else:
201+
ws_retrieveRequest.Options[key] = value
202+
190203
ws_retrieveRequest.ObjectType = obj_type
191204

192205
response = auth_stub.soap_client.service.Retrieve(ws_retrieveRequest)
@@ -264,6 +277,7 @@ class ET_BaseObject(object):
264277
props = None
265278
extProps = None
266279
search_filter = None
280+
options = None
267281

268282
########
269283
##
@@ -273,9 +287,10 @@ class ET_BaseObject(object):
273287
class ET_GetSupport(ET_BaseObject):
274288
obj_type = 'ET_GetSupport' #should be overwritten by inherited class
275289

276-
def get(self, m_props = None, m_filter = None):
290+
def get(self, m_props = None, m_filter = None, m_options = None):
277291
props = self.props
278292
search_filter = self.search_filter
293+
options = self.options
279294

280295
if m_props is not None and type(m_props) is list:
281296
props = m_props
@@ -285,7 +300,10 @@ def get(self, m_props = None, m_filter = None):
285300
if m_filter is not None and type(m_filter) is dict:
286301
search_filter = m_filter
287302

288-
obj = ET_Get(self.auth_stub, self.obj_type, props, search_filter)
303+
if m_options is not None and type(m_filter) is dict:
304+
options = m_options
305+
306+
obj = ET_Get(self.auth_stub, self.obj_type, props, search_filter, options)
289307
if obj is not None:
290308
self.last_request_id = obj.request_id
291309
return obj

objsamples/sample_dataextension.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
print 'Results Length: ' + str(len(getResponse.results))
2020
#print 'Results: ' + str(getResponse.results)
2121

22+
# Get all of the DataExtensions in an Account belonging to a specific sub account
23+
print '>>> Get all of the DataExtensions in an Account belonging to a specific sub account'
24+
de = ET_Client.ET_DataExtension()
25+
de.auth_stub = stubObj
26+
de.props = ["CustomerKey", "Name"]
27+
de.options = {"Client": {"ID": "1234567"}}
28+
getResponse = de.get()
29+
print 'Retrieve Status: ' + str(getResponse.status)
30+
print 'Code: ' + str(getResponse.code)
31+
print 'Message: ' + str(getResponse.message)
32+
print 'MoreResults: ' + str(getResponse.more_results)
33+
print 'RequestID: ' + str(getResponse.request_id)
34+
print 'Results Length: ' + str(len(getResponse.results))
35+
#print 'Results: ' + str(getResponse.results)
36+
2237
# Specify a name for the data extension that will be used for testing
2338
# Note: Name and CustomerKey will be the same value
2439
# WARNING: Data Extension will be deleted so don't use the name of a
@@ -185,4 +200,4 @@
185200

186201
except Exception as e:
187202
print 'Caught exception: ' + str(e.message)
188-
print e
203+
print e

0 commit comments

Comments
 (0)