@@ -77,17 +77,21 @@ class Identity(BaseResource):
7777 'trafficTypeId' : 'string' ,
7878 'environmentId' : 'string' ,
7979 'values' : 'object' ,
80+ 'organizationId' : 'string' ,
81+ 'timestamp' : 'string' ,
8082 }
8183
8284 def __init__ (self , client , key , traffic_type_id , environment_id ,
83- values = None ):
85+ values = None , organization_id = None , timestamp = None ):
8486 '''
8587 '''
8688 BaseResource .__init__ (self , client , key )
8789 self ._traffic_type_id = traffic_type_id
8890 self ._key = key
8991 self ._environment_id = environment_id
9092 self ._values = values
93+ self ._organization_id = organization_id
94+ self ._timestamp = timestamp
9195
9296 @property
9397 def key (self ):
@@ -105,14 +109,23 @@ def environment_id(self):
105109 def values (self ):
106110 return self ._values
107111
112+ @property
113+ def organization_id (self ):
114+ return self ._organization_id
115+
116+ @property
117+ def timestamp (self ):
118+ return self ._timestamp
119+
108120 @classmethod
109121 def _build_single_from_collection_response (cls , client , response ):
110122 '''
111123 '''
112124 raise MethodNotApplicable ()
113125
114126 @classmethod
115- def create (cls , client , key , traffic_type_id , environment_id , values ):
127+ def create (cls , client , key , traffic_type_id , environment_id , values ,
128+ organization_id = None ):
116129 '''
117130 '''
118131 try :
@@ -122,6 +135,7 @@ def create(cls, client, key, traffic_type_id, environment_id, values):
122135 'key' : key ,
123136 'trafficTypeId' : traffic_type_id ,
124137 'environmentId' : environment_id ,
138+ 'organization_id' : organization_id ,
125139 'values' : values
126140 },
127141 key = key ,
@@ -140,11 +154,14 @@ def create(cls, client, key, traffic_type_id, environment_id, values):
140154 response ['key' ],
141155 response ['trafficTypeId' ],
142156 response ['environmentId' ],
143- response ['values' ]
157+ response ['values' ],
158+ response ['organizationId' ],
159+ response ['timestamp' ]
144160 )
145161
146162 @classmethod
147- def create_many (cls , client , traffic_type_id , environment_id , identities ):
163+ def create_many (cls , client , traffic_type_id , environment_id , identities ,
164+ organization_id = None ):
148165 '''
149166 entities: { key: { attr_id: value, ...} }
150167 '''
@@ -157,20 +174,42 @@ def create_many(cls, client, traffic_type_id, environment_id, identities):
157174 'key' : key ,
158175 'trafficTypeId' : traffic_type_id ,
159176 'environmentId' : environment_id ,
177+ 'organizationId' : organization_id ,
160178 'values' : identities [key ]
161179 }
162180 for key in identities .keys ()
163181 ],
164182 trafficTypeId = traffic_type_id ,
165183 environmentId = environment_id
166184 )
167- return [
185+
186+ successful = [
168187 Identity (
169188 client , i ['key' ], i ['trafficTypeId' ],
170- i ['environmentId' ], i ['values' ]
189+ i ['environmentId' ], i ['values' ], i ['organizationId' ],
190+ i ['timestamp' ]
171191 ) for i in response ['objects' ]
172192 ]
173193
194+ failed = [
195+ {
196+ 'object' : Identity (
197+ client ,
198+ i ['object' ]['key' ],
199+ i ['object' ]['trafficTypeId' ],
200+ i ['object' ]['environmentId' ],
201+ i ['object' ]['values' ],
202+ i ['object' ]['organizationId' ],
203+ i ['object' ]['timestamp' ]
204+ ),
205+ 'status' : i ['status' ],
206+ 'message' : i ['message' ]
207+ }
208+ for i in response ['failed' ]
209+ ]
210+
211+ return successful , failed
212+
174213 except HTTPResponseError as e :
175214 LOGGER .error ('Call to Identify API failed. Identities not created.' )
176215 raise e
@@ -179,7 +218,8 @@ def create_many(cls, client, traffic_type_id, environment_id, identities):
179218 raise UnknownIdentifyClientError ()
180219
181220 @classmethod
182- def update (cls , client , key , traffic_type_id , environment_id , values ):
221+ def update (cls , client , key , traffic_type_id , environment_id , values ,
222+ organization_id ):
183223 '''
184224 '''
185225 try :
@@ -189,6 +229,7 @@ def update(cls, client, key, traffic_type_id, environment_id, values):
189229 'key' : key ,
190230 'trafficTypeId' : traffic_type_id ,
191231 'environmentId' : environment_id ,
232+ 'organizationId' : organization_id ,
192233 'values' : values
193234 },
194235 key = key ,
@@ -207,11 +248,13 @@ def update(cls, client, key, traffic_type_id, environment_id, values):
207248 response ['key' ],
208249 response ['trafficTypeId' ],
209250 response ['environmentId' ],
210- response ['values' ]
251+ response ['values' ],
252+ response ['timestamp' ]
211253 )
212254
213255 @classmethod
214- def patch (cls , client , key , traffic_type_id , environment_id , values ):
256+ def patch (cls , client , key , traffic_type_id , environment_id , values ,
257+ organization_id ):
215258 '''
216259 '''
217260 try :
@@ -221,6 +264,7 @@ def patch(cls, client, key, traffic_type_id, environment_id, values):
221264 'key' : key ,
222265 'trafficTypeId' : traffic_type_id ,
223266 'environmentId' : environment_id ,
267+ 'organizationId' : organization_id ,
224268 'values' : values
225269 },
226270 key = key ,
@@ -239,7 +283,9 @@ def patch(cls, client, key, traffic_type_id, environment_id, values):
239283 response ['key' ],
240284 response ['trafficTypeId' ],
241285 response ['environmentId' ],
242- response ['values' ]
286+ response ['values' ],
287+ response ['organization_id' ],
288+ response ['timestamp' ]
243289 )
244290
245291 @classmethod
0 commit comments