cti-python-stix2/stix2/bundle.py

29 lines
829 B
Python
Raw Normal View History

2017-02-10 22:35:02 +01:00
"""STIX 2 Bundle object"""
2017-08-14 15:24:41 +02:00
from collections import OrderedDict
2017-02-10 22:35:02 +01:00
from .base import _STIXBase
from .properties import IDProperty, Property, TypeProperty
2017-02-10 22:35:02 +01:00
class Bundle(_STIXBase):
_type = 'bundle'
2017-08-14 15:24:41 +02:00
_properties = OrderedDict()
_properties = _properties.update([
('type', TypeProperty(_type)),
('id', IDProperty(_type)),
('spec_version', Property(fixed="2.0")),
('objects', Property()),
])
2017-02-10 22:35:02 +01:00
def __init__(self, *args, **kwargs):
# Add any positional arguments to the 'objects' kwarg.
if args:
if isinstance(args[0], list):
kwargs['objects'] = args[0] + list(args[1:]) + kwargs.get('objects', [])
else:
kwargs['objects'] = list(args) + kwargs.get('objects', [])
2017-02-10 22:35:02 +01:00
super(Bundle, self).__init__(**kwargs)