diff --git a/FuelSDK/objects.py b/FuelSDK/objects.py index 1a4a912..9de9a01 100644 --- a/FuelSDK/objects.py +++ b/FuelSDK/objects.py @@ -1,21 +1,29 @@ -from FuelSDK.rest import ET_CUDSupport,ET_CUDSupportRest,ET_GetSupport,ET_Get,ET_Patch,ET_Post,ET_Delete,ET_Configure,ET_Describe +from FuelSDK.rest import ET_CUDSupport,ET_CUDSupportRest,ET_GetSupport,ET_Get,ET_Patch,ET_Post,ET_Delete,ET_Configure,ET_Describe,ET_Perform ######## ## ## wrap an Exact Target Content Area ## ######## -class ET_ContentArea(ET_CUDSupport): +class ET_ContentArea(ET_CUDSupport): def __init__(self): super(ET_ContentArea, self).__init__() self.obj_type = 'ContentArea' +class ET_Import(ET_CUDSupport): + def __init__(self): + super(ET_Import, self).__init__() + self.obj_type = 'ImportDefinition' + + def start(self): + return ET_Perform(self.auth_stub, self.obj_type, self.props, 'start') + ######## ## ## wrap an Exact Target DataFolder ## ######## -class ET_Folder(ET_CUDSupport): +class ET_Folder(ET_CUDSupport): def __init__(self): super(ET_Folder, self).__init__() self.obj_type = 'DataFolder' @@ -25,13 +33,13 @@ def __init__(self): ## wrap an Exact Target PropertyDefinition ## ######## -class ET_ProfileAttribute(): +class ET_ProfileAttribute(): def __init__(self): self.obj_type = 'PropertyDefinition' self.update = False self.delete = False - def post(self): + def post(self): obj = ET_Configure(self.auth_stub, self.obj_type, self.props, self.update, self.delete) if obj is not None: self.last_request_id = obj.request_id @@ -48,33 +56,33 @@ def get(self): class ET_BounceEvent(ET_GetSupport): def __init__(self): self.obj_type = 'BounceEvent' - + ######## ## ## wrap an Exact Target Campaign and associated Assets ## -######## +######## class ET_Campaign(ET_CUDSupportRest): def __init__(self): super(ET_Campaign, self).__init__() self.endpoint = 'https://www.exacttargetapis.com/hub/v1/campaigns/{id}' self.urlProps = ["id"] self.urlPropsRequired = [] - + ##the patch rest service is not implemented for campaigns yet. use post instead and remove this when patch is implemented on the back end def patch(self): self.endpoint = 'https://www.exacttargetapis.com/hub/v1/campaigns' #don't put the id on the url when patching via post obj = super(ET_Campaign, self).post() self.endpoint = 'https://www.exacttargetapis.com/hub/v1/campaigns/{id}' #but set it back to the url with id for other operations to continue working return obj - + class ET_Campaign_Asset(ET_CUDSupportRest): def __init__(self): super(ET_Campaign_Asset, self).__init__() self.endpoint = 'https://www.exacttargetapis.com/hub/v1/campaigns/{id}/assets/{assetId}' self.urlProps = ["id", "assetId"] self.urlPropsRequired = ["id"] - + ######## ## ## wrap an Exact Target Click Event @@ -84,7 +92,7 @@ class ET_ClickEvent(ET_GetSupport): def __init__(self): super(ET_ClickEvent, self).__init__() self.obj_type = 'ClickEvent' - + ######## ## ## wrap an Exact Target List and List Subscriber @@ -157,14 +165,14 @@ class ET_Subscriber(ET_CUDSupport): def __init__(self): super(ET_Subscriber, self).__init__() self.obj_type = 'Subscriber' - + class ET_DataExtension(ET_CUDSupport): columns = None - + def __init__(self): super(ET_DataExtension, self).__init__() - self.obj_type = 'DataExtension' - + self.obj_type = 'DataExtension' + def post(self): originalProps = self.props @@ -172,22 +180,22 @@ def post(self): multiDE = [] for currentDE in self.props: currentDE['Fields'] = {} - currentDE['Fields']['Field'] = [] - for key in currentDE['columns']: + currentDE['Fields']['Field'] = [] + for key in currentDE['columns']: currentDE['Fields']['Field'].append(key) del currentDE['columns'] multiDE.append(currentDE.copy()) - + self.props = multiDE else: self.props['Fields'] = {} self.props['Fields']['Field'] = [] - - for key in self.columns: + + for key in self.columns: self.props['Fields']['Field'].append(key) - + obj = super(ET_DataExtension, self).post() - self.props = originalProps + self.props = originalProps return obj def patch(self): @@ -196,21 +204,21 @@ def patch(self): for key in self.columns: self.props['Fields']['Field'].append(key) obj = super(ET_DataExtension, self).patch() - del self.props["Fields"] + del self.props["Fields"] return obj - + class ET_DataExtension_Column(ET_GetSupport): def __init__(self): super(ET_DataExtension_Column, self).__init__() self.obj = 'DataExtensionField' - + def get(self): ''' if props and props.is_a? Array then @props = props end ''' - + if self.props is not None and type(self.props) is dict: self.props = self.props.keys() @@ -219,37 +227,37 @@ def get(self): @filter = filter end ''' - - ''' + + ''' fixCustomerKey = False if filter and filter.is_a? Hash then @filter = filter if @filter.has_key?("Property") && @filter["Property"] == "CustomerKey" then @filter["Property"] = "DataExtension.CustomerKey" - fixCustomerKey = true - end + fixCustomerKey = true + end end ''' - - obj = ET_Get(self.auth_stub, self.obj, self.props, self.search_filter) - self.last_request_id = obj.request_id - - ''' + + obj = ET_Get(self.auth_stub, self.obj, self.props, self.search_filter) + self.last_request_id = obj.request_id + + ''' if fixCustomerKey then @filter["Property"] = "CustomerKey" - end + end ''' - + return obj class ET_DataExtension_Row(ET_CUDSupport): Name = None - CustomerKey = None - - def __init__(self): + CustomerKey = None + + def __init__(self): super(ET_DataExtension_Row, self).__init__() self.obj_type = "DataExtensionObject" - + def get(self): self.getName() ''' @@ -257,7 +265,7 @@ def get(self): @props = props end ''' - + if self.props is not None and type(self.props) is dict: self.props = self.props.keys() @@ -266,49 +274,49 @@ def get(self): @filter = filter end ''' - - obj = ET_Get(self.auth_stub, "DataExtensionObject[{0}]".format(self.Name), self.props, self.search_filter) - self.last_request_id = obj.request_id - + + obj = ET_Get(self.auth_stub, "DataExtensionObject[{0}]".format(self.Name), self.props, self.search_filter) + self.last_request_id = obj.request_id + return obj - + def post(self): self.getCustomerKey() originalProps = self.props - + if type(self.props) is list: currentPropList = [] for rec in self.props: currentFields = [] currentProp = {} - + for key, value in rec.iteritems(): currentFields.append({"Name" : key, "Value" : value}) - + currentProp['CustomerKey'] = self.CustomerKey currentProp['Properties'] = {} currentProp['Properties']['Property'] = currentFields - + currentPropList.append(currentProp) - + currentProp = currentPropList else: currentFields = [] currentProp = {} - + for key, value in self.props.iteritems(): currentFields.append({"Name" : key, "Value" : value}) currentProp['CustomerKey'] = self.CustomerKey currentProp['Properties'] = {} - currentProp['Properties']['Property'] = currentFields + currentProp['Properties']['Property'] = currentFields - obj = ET_Post(self.auth_stub, self.obj_type, currentProp) + obj = ET_Post(self.auth_stub, self.obj_type, currentProp) self.props = originalProps return obj - - def patch(self): + + def patch(self): self.getCustomerKey() if type(self.props) is list: @@ -316,32 +324,32 @@ def patch(self): for rec in self.props: currentFields = [] currentProp = {} - + for key, value in rec.iteritems(): currentFields.append({"Name" : key, "Value" : value}) - + currentProp['CustomerKey'] = self.CustomerKey currentProp['Properties'] = {} currentProp['Properties']['Property'] = currentFields - + currentPropList.append(currentProp) - + currentProp = currentPropList else: currentFields = [] currentProp = {} - + for key, value in self.props.iteritems(): currentFields.append({"Name" : key, "Value" : value}) - + currentProp['CustomerKey'] = self.CustomerKey currentProp['Properties'] = {} currentProp['Properties']['Property'] = currentFields - + obj = ET_Patch(self.auth_stub, self.obj_type, currentProp) return obj - - def delete(self): + + def delete(self): self.getCustomerKey() if type(self.props) is list: @@ -349,58 +357,58 @@ def delete(self): for rec in self.props: currentFields = [] currentProp = {} - + for key, value in rec.iteritems(): currentFields.append({"Name" : key, "Value" : value}) - + currentProp['CustomerKey'] = self.CustomerKey currentProp['Keys'] = {} currentProp['Keys']['Key'] = currentFields - + currentPropList.append(currentProp) - + currentProp = currentPropList else: currentFields = [] currentProp = {} - + for key, value in self.props.iteritems(): currentFields.append({"Name" : key, "Value" : value}) - + currentProp['CustomerKey'] = self.CustomerKey currentProp['Keys'] = {} currentProp['Keys']['Key'] = currentFields - + obj = ET_Delete(self.auth_stub, self.obj_type, currentProp) return obj - + def getCustomerKey(self): if self.CustomerKey is None: - if self.Name is None: - raise Exception('Unable to process DataExtension::Row request due to CustomerKey and Name not being defined on ET_DatExtension::row') + if self.Name is None: + raise Exception('Unable to process DataExtension::Row request due to CustomerKey and Name not being defined on ET_DatExtension::row') else: de = ET_DataExtension() de.auth_stub = self.auth_stub de.props = ["Name","CustomerKey"] de.search_filter = {'Property' : 'CustomerKey','SimpleOperator' : 'equals','Value' : self.Name} getResponse = de.get() - if getResponse.status and len(getResponse.results) == 1 and 'CustomerKey' in getResponse.results[0]: + if getResponse.status and len(getResponse.results) == 1 and 'CustomerKey' in getResponse.results[0]: self.CustomerKey = getResponse.results[0]['CustomerKey'] else: raise Exception('Unable to process DataExtension::Row request due to unable to find DataExtension based on Name') - - + + def getName(self): if self.Name is None: if self.CustomerKey is None: - raise Exception('Unable to process DataExtension::Row request due to CustomerKey and Name not being defined on ET_DatExtension::row') + raise Exception('Unable to process DataExtension::Row request due to CustomerKey and Name not being defined on ET_DatExtension::row') else: de = ET_DataExtension() de.auth_stub = self.auth_stub de.props = ["Name","CustomerKey"] de.search_filter = {'Property' : 'CustomerKey','SimpleOperator' : 'equals','Value' : self.CustomerKey} getResponse = de.get() - if getResponse.status and len(getResponse.results) == 1 and 'Name' in getResponse.results[0]: + if getResponse.status and len(getResponse.results) == 1 and 'Name' in getResponse.results[0]: self.Name = getResponse.results[0]['Name'] else: raise Exception('Unable to process DataExtension::Row request due to unable to find DataExtension based on CustomerKey') diff --git a/FuelSDK/rest.py b/FuelSDK/rest.py index c2f1f82..6c7c6e0 100644 --- a/FuelSDK/rest.py +++ b/FuelSDK/rest.py @@ -2,7 +2,7 @@ import json import copy - + ######## ## ## Parent class used to determine what status we are in depending on web service call results @@ -13,26 +13,26 @@ class ET_Constructor(object): code = None status = False message = None - more_results = False + more_results = False request_id = None - + def __init__(self, response = None, rest = False): - + if response is not None: #if a response was returned from the web service call if rest: # result is from a REST web service call... - self.code = response.status_code + self.code = response.status_code if self.code == 200: self.status = True else: - self.status = False - + self.status = False + try: self.results = response.json() except: self.message = response.json() - + #additional parsing will happen in the child object that called in to here. - + else: #soap call self.code = response[0] #suds puts the code in tuple position 0 body = response[1] #and the result in tuple position 1 @@ -49,20 +49,20 @@ def __init__(self, response = None, rest = False): if body['OverallStatus'] == "MoreDataAvailable": self.more_results = True elif body['OverallStatus'] != "OK": - self.status = False - + self.status = False + body_container_tag = None if 'Results' in body: #most SOAP responses are wrapped in 'Results' body_container_tag = 'Results' elif 'ObjectDefinition' in body: #Describe SOAP response is in 'ObjectDefinition' body_container_tag = 'ObjectDefinition' - + if body_container_tag is not None: - self.results = body[body_container_tag] + self.results = body[body_container_tag] else: self.status = False - + def parse_props_dict_into_ws_object(self, obj_type, ws_object, props_dict): for k, v in props_dict.items(): if k in ws_object: @@ -97,7 +97,7 @@ def parse_props_into_ws_object(self, auth_stub, obj_type, props): ## ######## class ET_Describe(ET_Constructor): - def __init__(self, auth_stub, obj_type): + def __init__(self, auth_stub, obj_type): auth_stub.refresh_token() ws_describeRequest = auth_stub.soap_client.factory.create('ArrayOfObjectDefinitionRequest') @@ -105,7 +105,7 @@ def __init__(self, auth_stub, obj_type): ObjectDefinitionRequest = { 'ObjectType' : obj_type} ws_describeRequest.ObjectDefinitionRequest = [ObjectDefinitionRequest] - response = auth_stub.soap_client.service.Describe(ws_describeRequest) + response = auth_stub.soap_client.service.Describe(ws_describeRequest) if response is not None: self.message = 'Describe: ' + obj_type @@ -116,6 +116,19 @@ def __init__(self, auth_stub, obj_type): ## Used to Configure Objects via web service call ## ######## +class ET_Perform(ET_Constructor): + def __init__(self, auth_stub, obj_type, props, action): + auth_stub.refresh_token() + + performRequest = auth_stub.soap_client.factory.create('PerformRequestMsg') + performRequest.Action = action + performRequest.Definitions = {'Definition': self.parse_props_into_ws_object(auth_stub, obj_type, props) } + + response = auth_stub.soap_client.service.Perform(None, performRequest) + + if response is not None: + super(ET_Perform, self).__init__(response) + class ET_Configure(ET_Constructor): def __init__(self, auth_stub, obj_type, props = None, update = False, delete = False): auth_stub.refresh_token() @@ -129,7 +142,7 @@ def __init__(self, auth_stub, obj_type, props = None, update = False, delete = F ws_configureRequest.Action = action ws_configureRequest.Configurations = {'Configuration': self.parse_props_into_ws_object(auth_stub, obj_type, props)} - response = auth_stub.soap_client.service.Configure(None, ws_configureRequest) + response = auth_stub.soap_client.service.Configure(None, ws_configureRequest) if response is not None: #self.message = 'Describe: ' + obj_type @@ -141,18 +154,18 @@ def __init__(self, auth_stub, obj_type, props = None, update = False, delete = F ## ######## class ET_Get(ET_Constructor): - def __init__(self, auth_stub, obj_type, props = None, search_filter = None, options = None): + def __init__(self, auth_stub, obj_type, props = None, search_filter = None, options = None): auth_stub.refresh_token() - + if props is None: #if there are no properties to retrieve for the obj_type then return a Description of obj_type describe = ET_Describe(auth_stub, obj_type) props = [] for prop in describe.results[0].Properties: if prop.IsRetrievable: - props.append(prop.Name) + props.append(prop.Name) ws_retrieveRequest = auth_stub.soap_client.factory.create('RetrieveRequest') - + if props is not None: if type(props) is dict: # If the properties is a hash, then we just want to use the keys ws_retrieveRequest.Properties = props.keys() @@ -164,14 +177,14 @@ def __init__(self, auth_stub, obj_type, props = None, search_filter = None, opti ws_simpleFilterPartLeft = auth_stub.soap_client.factory.create('SimpleFilterPart') for prop in ws_simpleFilterPartLeft: #print prop[0] - if prop[0] in search_filter['LeftOperand']: - ws_simpleFilterPartLeft[prop[0]] = search_filter['LeftOperand'][prop[0]] - + if prop[0] in search_filter['LeftOperand']: + ws_simpleFilterPartLeft[prop[0]] = search_filter['LeftOperand'][prop[0]] + ws_simpleFilterPartRight = auth_stub.soap_client.factory.create('SimpleFilterPart') for prop in ws_simpleFilterPartRight: if prop[0] in search_filter['RightOperand']: ws_simpleFilterPartRight[prop[0]] = search_filter['RightOperand'][prop[0]] - + ws_complexFilterPart = auth_stub.soap_client.factory.create('ComplexFilterPart') ws_complexFilterPart.LeftOperand = ws_simpleFilterPartLeft ws_complexFilterPart.RightOperand = ws_simpleFilterPartRight @@ -199,8 +212,8 @@ def __init__(self, auth_stub, obj_type, props = None, search_filter = None, opti ws_retrieveRequest.Options[key] = value ws_retrieveRequest.ObjectType = obj_type - - response = auth_stub.soap_client.service.Retrieve(ws_retrieveRequest) + + response = auth_stub.soap_client.service.Retrieve(ws_retrieveRequest) if response is not None: super(ET_Get, self).__init__(response) @@ -225,7 +238,7 @@ def __init__(self, auth_stub, obj_type, props = None): class ET_Patch(ET_Constructor): def __init__(self, auth_stub, obj_type, props = None): auth_stub.refresh_token() - + response = auth_stub.soap_client.service.Update(None, self.parse_props_into_ws_object(auth_stub, obj_type, props)) if(response is not None): @@ -239,7 +252,7 @@ def __init__(self, auth_stub, obj_type, props = None): class ET_Delete(ET_Constructor): def __init__(self, auth_stub, obj_type, props = None): auth_stub.refresh_token() - + response = auth_stub.soap_client.service.Delete(None, self.parse_props_into_ws_object(auth_stub, obj_type, props)) if(response is not None): @@ -256,7 +269,7 @@ def __init__(self, auth_stub, request_id): ws_continueRequest = auth_stub.soap_client.factory.create('RetrieveRequest') ws_continueRequest.ContinueRequest = request_id - response = auth_stub.soap_client.service.Retrieve(ws_continueRequest) + response = auth_stub.soap_client.service.Retrieve(ws_continueRequest) if response is not None: super(ET_Continue, self).__init__(response) @@ -283,14 +296,14 @@ class ET_BaseObject(object): ######## class ET_GetSupport(ET_BaseObject): obj_type = 'ET_GetSupport' #should be overwritten by inherited class - + def get(self, m_props = None, m_filter = None, m_options = None): props = self.props search_filter = self.search_filter options = self.options - + if m_props is not None and type(m_props) is list: - props = m_props + props = m_props elif self.props is not None and type(self.props) is dict: props = self.props.keys() @@ -304,13 +317,13 @@ def get(self, m_props = None, m_filter = None, m_options = None): if obj is not None: self.last_request_id = obj.request_id return obj - + def info(self): obj = ET_Describe(self.auth_stub, self.obj_type) if obj is not None: self.last_request_id = obj.request_id return obj - + def getMoreResults(self): obj = ET_Continue(self.auth_stub, self.last_request_id) if obj is not None: @@ -324,16 +337,16 @@ def getMoreResults(self): ######## class ET_GetRest(ET_Constructor): def __init__(self, auth_stub, endpoint, qs = None): - auth_stub.refresh_token() + auth_stub.refresh_token() fullendpoint = endpoint + '?access_token=' + auth_stub.authToken for qStringValue in qs: fullendpoint += '&'+ qStringValue + '=' + str(qs[qStringValue]) r = requests.get(fullendpoint) - - + + self.more_results = False - + obj = super(ET_GetRest, self).__init__(r, True) return obj @@ -342,16 +355,16 @@ def __init__(self, auth_stub, endpoint, qs = None): ## Restful webservice to Get data ## ######## -class ET_PostRest(ET_Constructor): +class ET_PostRest(ET_Constructor): def __init__(self, auth_stub, endpoint, payload): auth_stub.refresh_token() - + headers = {'content-type' : 'application/json'} r = requests.post(endpoint + '?access_token=' + auth_stub.authToken , data=json.dumps(payload), headers=headers) - + obj = super(ET_PostRest, self).__init__(r, True) return obj - + ######## ## ## Restful webservice to Get data @@ -360,10 +373,10 @@ def __init__(self, auth_stub, endpoint, payload): class ET_PatchRest(ET_Constructor): def __init__(self, auth_stub, endpoint, payload): auth_stub.refresh_token() - + headers = {'content-type' : 'application/json'} r = requests.patch(endpoint + '?access_token=' + auth_stub.authToken , data=json.dumps(payload), headers=headers) - + obj = super(ET_PatchRest, self).__init__(r, True) return obj @@ -375,9 +388,9 @@ def __init__(self, auth_stub, endpoint, payload): class ET_DeleteRest(ET_Constructor): def __init__(self, auth_stub, endpoint): auth_stub.refresh_token() - + r = requests.delete(endpoint + '?access_token=' + auth_stub.authToken) - + obj = super(ET_DeleteRest, self).__init__(r, True) return obj @@ -387,20 +400,20 @@ def __init__(self, auth_stub, endpoint): ## ######## class ET_CUDSupport(ET_GetSupport): - + def __init__(self): super(ET_CUDSupport, self).__init__() - + def post(self): if self.extProps is not None: for k, v in self.extProps.iteritems(): self.props[k.capitalize] = v - + obj = ET_Post(self.auth_stub, self.obj_type, self.props) if obj is not None: self.last_request_id = obj.request_id return obj - + def patch(self): obj = ET_Patch(self.auth_stub, self.obj_type, self.props) if obj is not None: @@ -422,130 +435,130 @@ class ET_GetSupportRest(ET_BaseObject): urlProps = None urlPropsRequired = None lastPageNumber = None - + def __init__(self): super - + def get(self, props = None): if props is not None and type(props) is dict: self.props = props - - completeURL = self.endpoint + + completeURL = self.endpoint additionalQS = {} - + if self.props is not None and type(self.props) is dict: for k, v in self.props.iteritems(): if k in self.urlProps: completeURL = completeURL.replace('{{{0}}}'.format(k), v) else: additionalQS[k] = v - - for value in self.urlPropsRequired: + + for value in self.urlPropsRequired: if self.props is None or value not in self.props: raise "Unable to process request due to missing required prop: #{value}" - - for value in self.urlProps: + + for value in self.urlProps: completeURL = completeURL.replace('/{{{0}}}'.format(value), '') - obj = ET_GetRest(self.auth_stub, completeURL, additionalQS) - + obj = ET_GetRest(self.auth_stub, completeURL, additionalQS) + results = obj.results - if 'page' in obj.results: + if 'page' in obj.results: self.lastPageNumber = obj.results['page'] pageSize = obj.results['pageSize'] - if 'count' in obj.results: + if 'count' in obj.results: count = obj.results['count'] - elif 'totalCount' in obj.results: + elif 'totalCount' in obj.results: count = obj.results['totalCount'] - + if count is not None and count > (self.lastPageNumber * pageSize): obj.more_results = True else: - obj.more_results = False + obj.more_results = False return obj - + def getMoreResults(self): props = None #where should it come from? if props is not None and type(props) is dict: self.props = props - + originalPageValue = "1" - removePageFromProps = False - - if self.props is not None and '$page' in self.props: + removePageFromProps = False + + if self.props is not None and '$page' in self.props: originalPageValue = self.props['page'] else: - removePageFromProps = True - + removePageFromProps = True + if self.props is None: self.props = {} - + self.props['$page'] = self.lastPageNumber + 1 - + obj = self.get() - + if removePageFromProps: del self.props['$page'] else: self.props['$page'] = originalPageValue - + return obj ######## ## ## Create, Update and Delete using a REST call ## -######## +######## class ET_CUDSupportRest(ET_GetSupportRest): endpoint = None urlProps = None urlPropsRequired = None - + def __init__(self): super - + def post(self): - completeURL = self.endpoint - + completeURL = self.endpoint + if self.props is not None and type(self.props) is dict: for k, v in self.props.iteritems(): if k in self.urlProps: completeURL = completeURL.replace('{{{0}}}'.format(k), v) - - for value in self.urlPropsRequired: + + for value in self.urlPropsRequired: if self.props is None or value not in self.props: raise "Unable to process request due to missing required prop: #{value}" - # Clean Optional Parameters from Endpoint URL first - for value in self.urlProps: - completeURL = completeURL.replace('/{{{0}}}'.format(value), '') + # Clean Optional Parameters from Endpoint URL first + for value in self.urlProps: + completeURL = completeURL.replace('/{{{0}}}'.format(value), '') obj = ET_PostRest(self.auth_stub, completeURL, self.props) - return obj - + return obj + def patch(self): completeURL = self.endpoint - # All URL Props are required when doing Patch - for value in self.urlProps: + # All URL Props are required when doing Patch + for value in self.urlProps: if self.props is None or value not in self.props: raise "Unable to process request due to missing required prop: #{value}" - + if self.props is not None and type(self.props) is dict: for k, v in self.props.iteritems(): if k in self.urlProps: completeURL = completeURL.replace('{{{0}}}'.format(k), v) - - obj = ET_PatchRest(self.auth_stub, completeURL, self.props) + + obj = ET_PatchRest(self.auth_stub, completeURL, self.props) return obj - + def delete(self): - completeURL = self.endpoint - # All URL Props are required when doing Patch - for value in self.urlProps: + completeURL = self.endpoint + # All URL Props are required when doing Patch + for value in self.urlProps: if self.props is None or value not in self.props: raise "Unable to process request due to missing required prop: #{value}" - - if self.props is not None and type(self.props) is dict: + + if self.props is not None and type(self.props) is dict: for k, v in self.props.iteritems(): if k in self.urlProps: completeURL = completeURL.replace('{{{0}}}'.format(k), v)