-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbatch.py
More file actions
584 lines (451 loc) · 16.6 KB
/
Copy pathbatch.py
File metadata and controls
584 lines (451 loc) · 16.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# coding: utf-8
"""
mParticle
mParticle Event API
OpenAPI spec version: 1.0.1
Contact: support@mparticle.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from pprint import pformat
from six import iteritems
import re
from .api_response import ApiResponse
from .api_response_errors import ApiResponseErrors
from .app_event import AppEvent
from .application_information import ApplicationInformation
from .application_state_transition_event import ApplicationStateTransitionEvent
from .attribution_info import AttributionInfo
from .breadcrumb_event import BreadcrumbEvent
from .consent_state import ConsentState
from .commerce_event import CommerceEvent
from .crash_report_event import CrashReportEvent
from .device_current_state import DeviceCurrentState
from .device_information import DeviceInformation
from .event_base import EventBase
from .event_data import EventData
from .first_run_event import FirstRunEvent
from .geo_location import GeoLocation
from .media_info import MediaInfo
from .network_performance_event import NetworkPerformanceEvent
from .opt_out_event import OptOutEvent
from .product import Product
from .product_action import ProductAction
from .product_impression import ProductImpression
from .profile_event import ProfileEvent
from .promotion import Promotion
from .promotion_action import PromotionAction
from .push_message_event import PushMessageEvent
from .push_registration_event import PushRegistrationEvent
from .screen_view_event import ScreenViewEvent
from .session_end_event import SessionEndEvent
from .session_start_event import SessionStartEvent
from .shopping_cart import ShoppingCart
from .source_information import SourceInformation
from .user_identities import UserIdentities
from .user_attribute_change_event import UserAttributeChangeEvent
class Batch(object):
def __init__(self, events=None, source_request_id=None, environment=None, ip=None, schema_version=None, device_info=None, application_info=None, user_attributes=None, deleted_user_attributes=None, user_identities=None, api_key=None, mpid=None, mp_deviceid=None, consent_state=None, context=None, integration_attributes=None):
"""
Batch - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition.
"""
self.swagger_types = {
'events': 'list[EventBase]',
'source_request_id': 'str',
'environment': 'str',
'ip': 'str',
'schema_version': 'int',
'device_info': 'DeviceInformation',
'application_info': 'ApplicationInformation',
'user_attributes': 'object',
'deleted_user_attributes': 'list[str]',
'user_identities': 'UserIdentities',
'consent_state': 'ConsentState',
'integration_attributes': 'dict(str, dict(str, str))',
'api_key': 'str',
'mpid': 'int',
'mp_deviceid': 'str',
'context': 'BatchContext'
}
self.attribute_map = {
'events': 'events',
'source_request_id': 'source_request_id',
'environment': 'environment',
'ip': 'ip',
'schema_version': 'schema_version',
'device_info': 'device_info',
'application_info': 'application_info',
'user_attributes': 'user_attributes',
'deleted_user_attributes': 'deleted_user_attributes',
'user_identities': 'user_identities',
'consent_state': 'consent_state',
'integration_attributes': 'integration_attributes',
'api_key': 'api_key',
'mpid': 'mpid',
'mp_deviceid': 'mp_deviceid',
'context': 'context',
}
self._api_key = api_key
self._events = events
self._source_request_id = source_request_id
self._environment = environment
self._ip = ip
self._schema_version = schema_version
self._device_info = device_info
self._application_info = application_info
self._user_attributes = user_attributes
self._consent_state = consent_state
self._integration_attributes = integration_attributes
self._deleted_user_attributes = deleted_user_attributes
self._user_identities = user_identities
self._mpid = mpid
self._mp_deviceid = mp_deviceid
self._allowed_types = {type(AppEvent('empty')): 'custom_event',
type(FirstRunEvent()): 'first_run',
type(SessionStartEvent()): 'session_start',
type(SessionEndEvent()): 'session_end',
type(ApplicationStateTransitionEvent()): 'application_state_transition',
type(ScreenViewEvent()): 'screen_view',
type(PushRegistrationEvent()): 'push_registration',
type(ProfileEvent()): 'profile',
type(OptOutEvent()): 'opt_out',
type(BreadcrumbEvent()): 'breadcrumb',
type(CommerceEvent(ProductAction('purchase'))): 'commerce_event',
type(PushMessageEvent()): 'push_message',
type(NetworkPerformanceEvent()): 'network_performance',
type(CrashReportEvent()): 'commerce_event',
type(UserAttributeChangeEvent()): 'user_attribute_change'}
self._context = context
@property
def events(self):
"""
Gets the events of this Batch.
:return: The events of this Batch.
:rtype: list[EventBase]
"""
return self._events
@events.setter
def events(self, events):
"""
Sets the events of this Batch.
:param events: The events of this Batch.
:type: list[EventBase]
"""
self._events = [self.__convert_to_eventbase(event) for event in events]
def __convert_to_eventbase(self, event):
event_type = type(event)
if (event_type is EventBase):
return event
if event_type not in self._allowed_types:
raise ValueError(
"Invalid event type: " +
str(event_type) + " added to batch, must be one of {0}"
.format(self._allowed_types.keys())
)
event_base = EventBase()
event_base.event_type = self._allowed_types[event_type]
event_base.data = event
return event_base
@property
def source_request_id(self):
"""
Gets the source_request_id of this Batch.
:return: The source_request_id of this Batch.
:rtype: str
"""
return self._source_request_id
@source_request_id.setter
def source_request_id(self, source_request_id):
"""
Sets the source_request_id of this Batch.
:param source_request_id: The source_request_id of this Batch.
:type: str
"""
self._source_request_id = source_request_id
@property
def environment(self):
"""
Gets the environment of this Batch.
:return: The environment of this Batch.
:rtype: str
"""
return self._environment
@environment.setter
def environment(self, environment):
"""
Sets the environment of this Batch.
:param environment: The environment of this Batch.
:type: str
"""
allowed_values = ["production", "development"]
if environment not in allowed_values:
raise ValueError(
"Invalid value for `environment` ({0}), must be one of {1}"
.format(environment, allowed_values)
)
self._environment = environment
@property
def api_key(self):
"""
Gets the api_key of this Batch. This should only be used while uploading
data via Amazon SQS.
:return: The api_key of this Batch.
:rtype: str
"""
return self._api_key
@api_key.setter
def api_key(self, api_key):
"""
Sets the api_key of this Batch. This should only be used while uploading
data via Amazon SQS.
:param ip: The api_key of this Batch.
:type: str
"""
self._api_key = api_key
@property
def ip(self):
"""
Gets the ip address of this Batch.
:return: The ip of this Batch.
:rtype: str
"""
return self._ip
@ip.setter
def ip(self, ip):
"""
Sets the ip address of this Batch.
:param ip: The ip of this Batch.
:type: str
"""
self._ip = ip
@property
def schema_version(self):
"""
Gets the schema_version of this Batch.
:return: The schema_version of this Batch.
:rtype: int
"""
return self._schema_version
@schema_version.setter
def schema_version(self, schema_version):
"""
Sets the schema_version of this Batch.
:param schema_version: The schema_version of this Batch.
:type: int
"""
self._schema_version = schema_version
@property
def device_info(self):
"""
Gets the device_info of this Batch.
:return: The device_info of this Batch.
:rtype: DeviceInformation
"""
return self._device_info
@device_info.setter
def device_info(self, device_info):
"""
Sets the device_info of this Batch.
:param device_info: The device_info of this Batch.
:type: DeviceInformation
"""
self._device_info = device_info
@property
def application_info(self):
"""
Gets the application_info of this Batch.
:return: The application_info of this Batch.
:rtype: ApplicationInformation
"""
return self._application_info
@application_info.setter
def application_info(self, application_info):
"""
Sets the application_info of this Batch.
:param application_info: The application_info of this Batch.
:type: ApplicationInformation
"""
self._application_info = application_info
@property
def user_attributes(self):
"""
Gets the user_attributes of this Batch.
:return: The user_attributes of this Batch.
:rtype: object
"""
return self._user_attributes
@user_attributes.setter
def user_attributes(self, user_attributes):
"""
Sets the user_attributes of this Batch.
User attributes must be a dictionary with strings for keys and either strings or arrays of strings as values,
for example: batch.user_attributes = {"eyes":"brown","favorite_foods":["indian","chinese","italian"]}
:param user_attributes: The user_attributes of this Batch.
:type: object
"""
self._user_attributes = user_attributes
@property
def deleted_user_attributes(self):
"""
Gets the deleted_user_attributes of this Batch.
:return: The deleted_user_attributes of this Batch.
:rtype: list[str]
"""
return self._deleted_user_attributes
@deleted_user_attributes.setter
def deleted_user_attributes(self, deleted_user_attributes):
"""
Sets the deleted_user_attributes of this Batch.
:param deleted_user_attributes: The deleted_user_attributes of this Batch.
:type: list[str]
"""
self._deleted_user_attributes = deleted_user_attributes
@property
def user_identities(self):
"""
Gets the user_identities of this Batch.
:return: The user_identities of this Batch.
:rtype: UserIdentities
"""
return self._user_identities
@user_identities.setter
def user_identities(self, user_identities):
"""
Sets the user_identities of this Batch.
:param user_identities: The user_identities of this Batch.
:type: UserIdentities
"""
self._user_identities = user_identities
@property
def mpid(self):
"""
Gets the mpid of this Batch.
:return: The mpid of this Batch.
:rtype: str
"""
return self._mpid
@mpid.setter
def mpid(self, mpid):
"""
Sets the mpid of this Batch.
:param mpid: The mpid of this Batch.
:type: str
"""
self._mpid = mpid
@property
def mp_deviceid(self):
"""
Gets the mp_deviceid of this Batch.
:return: The mp_deviceid of this Batch.
:rtype: str
"""
return self._mp_deviceid
@mp_deviceid.setter
def mp_deviceid(self, mp_deviceid):
"""
Sets the mp_deviceid of this Batch.
:param mp_deviceid: The mp_deviceid of this Batch.
:type: str
"""
self._mp_deviceid = mp_deviceid
@property
def consent_state(self):
"""
Gets the ConsentState of this Batch
:return: The consent_state of this Batch
:rtype: dict
"""
return self._consent_state
@consent_state.setter
def consent_state(self, consent_state):
"""
Sets the consent_state of this Batch.
:param consent_state: The consent_state of this Batch.
:type: str
"""
self._consent_state = consent_state
@property
def integration_attributes(self):
"""Gets the integration_attributes of this Batch.
:return: The integration_attributes of this Batch.
:rtype: dict(str, dict(str, str))
"""
return self._integration_attributes
@integration_attributes.setter
def integration_attributes(self, integration_attributes):
"""Sets the integration_attributes of this Batch.
:param integration_attributes: The integration_attributes of this Batch.
:type: dict(str, dict(str, str))
"""
self._integration_attributes = integration_attributes
@property
def context(self):
"""
Gets the BatchContext of this Batch
:return: The context of this Batch
:rtype: BatchContext
"""
return self._context
@context.setter
def context(self, context):
"""
Sets the BatchContext of this Batch.
:param context: The context of this Batch.
:type: BatchContext
"""
self._context = context
def to_dict(self):
"""
Returns the model properties as a dict
"""
result = {}
for attr, _ in iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""
Returns the string representation of the model
"""
return pformat(self.to_dict())
def __repr__(self):
"""
For `print` and `pprint`
"""
return self.to_str()
def __eq__(self, other):
"""
Returns true if both objects are equal
"""
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""
Returns true if both objects are not equal
"""
return not self == other