@@ -77,17 +77,19 @@ class Identity(BaseResource):
7777 'trafficTypeId' : 'string' ,
7878 'environmentId' : 'string' ,
7979 'values' : 'object' ,
80+ 'organizationId' : 'string' ,
8081 }
8182
8283 def __init__ (self , client , key , traffic_type_id , environment_id ,
83- values = None ):
84+ values = None , organization_id = None ):
8485 '''
8586 '''
8687 BaseResource .__init__ (self , client , key )
8788 self ._traffic_type_id = traffic_type_id
8889 self ._key = key
8990 self ._environment_id = environment_id
9091 self ._values = values
92+ self ._organization_id = organization_id
9193
9294 @property
9395 def key (self ):
@@ -105,14 +107,25 @@ def environment_id(self):
105107 def values (self ):
106108 return self ._values
107109
110+ def organization_id (self ):
111+ return self ._organization_id
112+
108113 @classmethod
109- def _build_single_from_collection_response (cls , client , response ):
114+ def from_dict (cls , client , response ):
110115 '''
111116 '''
112- raise MethodNotApplicable ()
117+ return Identity (
118+ client ,
119+ response .get ('key' ),
120+ response .get ('trafficTypeId' ),
121+ response .get ('environmentId' ),
122+ response .get ('values' ),
123+ response .get ('organizationId' )
124+ )
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,7 +135,8 @@ def create(cls, client, key, traffic_type_id, environment_id, values):
122135 'key' : key ,
123136 'trafficTypeId' : traffic_type_id ,
124137 'environmentId' : environment_id ,
125- 'values' : values
138+ 'values' : values ,
139+ 'organizationId' : organization_id
126140 },
127141 key = key ,
128142 trafficTypeId = traffic_type_id ,
@@ -135,16 +149,11 @@ def create(cls, client, key, traffic_type_id, environment_id, values):
135149 LOGGER .debug (e )
136150 raise UnknownIdentifyClientError ()
137151
138- return Identity (
139- client ,
140- response ['key' ],
141- response ['trafficTypeId' ],
142- response ['environmentId' ],
143- response ['values' ],
144- )
152+ return Identity .from_dict (client , response )
145153
146154 @classmethod
147- def create_many (cls , client , traffic_type_id , environment_id , identities ):
155+ def create_many (cls , client , traffic_type_id , environment_id , identities ,
156+ organization_id = None ):
148157 '''
149158 entities: { key: { attr_id: value, ...} }
150159 '''
@@ -157,7 +166,8 @@ def create_many(cls, client, traffic_type_id, environment_id, identities):
157166 'key' : key ,
158167 'trafficTypeId' : traffic_type_id ,
159168 'environmentId' : environment_id ,
160- 'values' : identities [key ]
169+ 'values' : identities [key ],
170+ 'organizationId' : organization_id ,
161171 }
162172 for key in identities .keys ()
163173 ],
@@ -166,23 +176,14 @@ def create_many(cls, client, traffic_type_id, environment_id, identities):
166176 )
167177
168178 successful = [
169- Identity (
170- client , i ['key' ], i ['trafficTypeId' ],
171- i ['environmentId' ], i ['values' ]
172- ) for i in response ['objects' ]
179+ Identity .from_dict (client , i ) for i in response ['objects' ]
173180 ]
174181
175182 failed = [
176183 {
177- 'object' : Identity (
178- client ,
179- i ['object' ]['key' ],
180- i ['object' ]['trafficTypeId' ],
181- i ['object' ]['environmentId' ],
182- i ['object' ]['values' ],
183- ),
184+ 'object' : Identity .from_dict (client , i ['object' ]),
184185 'status' : i ['status' ],
185- 'message' : i ['message' ]
186+ 'message' : i ['message' ],
186187 }
187188 for i in response ['failed' ]
188189 ]
@@ -197,7 +198,8 @@ def create_many(cls, client, traffic_type_id, environment_id, identities):
197198 raise UnknownIdentifyClientError ()
198199
199200 @classmethod
200- def update (cls , client , key , traffic_type_id , environment_id , values ):
201+ def update (cls , client , key , traffic_type_id , environment_id , values ,
202+ organization_id = None ):
201203 '''
202204 '''
203205 try :
@@ -207,7 +209,8 @@ def update(cls, client, key, traffic_type_id, environment_id, values):
207209 'key' : key ,
208210 'trafficTypeId' : traffic_type_id ,
209211 'environmentId' : environment_id ,
210- 'values' : values
212+ 'values' : values ,
213+ 'organizationId' : organization_id ,
211214 },
212215 key = key ,
213216 trafficTypeId = traffic_type_id ,
@@ -220,16 +223,11 @@ def update(cls, client, key, traffic_type_id, environment_id, values):
220223 LOGGER .debug (e )
221224 raise UnknownIdentifyClientError ()
222225
223- return Identity (
224- client ,
225- response ['key' ],
226- response ['trafficTypeId' ],
227- response ['environmentId' ],
228- response ['values' ],
229- )
226+ return Identity .from_dict (client , response )
230227
231228 @classmethod
232- def patch (cls , client , key , traffic_type_id , environment_id , values ):
229+ def patch (cls , client , key , traffic_type_id , environment_id , values ,
230+ organization_id = None ):
233231 '''
234232 '''
235233 try :
@@ -239,7 +237,8 @@ def patch(cls, client, key, traffic_type_id, environment_id, values):
239237 'key' : key ,
240238 'trafficTypeId' : traffic_type_id ,
241239 'environmentId' : environment_id ,
242- 'values' : values
240+ 'values' : values ,
241+ 'organizationId' : organization_id ,
243242 },
244243 key = key ,
245244 trafficTypeId = traffic_type_id ,
@@ -252,13 +251,7 @@ def patch(cls, client, key, traffic_type_id, environment_id, values):
252251 LOGGER .debug (e )
253252 raise UnknownIdentifyClientError ()
254253
255- return Identity (
256- client ,
257- response ['key' ],
258- response ['trafficTypeId' ],
259- response ['environmentId' ],
260- response ['values' ],
261- )
254+ return Identity .from_dict (client , response )
262255
263256 @classmethod
264257 def delete_all_attributes (cls , client , traffic_type_id , environment_id ,
@@ -284,7 +277,7 @@ def update_this(self, values):
284277 '''
285278 return Identity .update (
286279 self ._client , self .key , self .traffic_type_id , self .environment_id ,
287- values
280+ values , self . _organization_id
288281 )
289282
290283 def patch_this (self , values ):
0 commit comments