def create_iobject(self,<EOL>identifier_ns_uri=None,<EOL>uid=None,<EOL>timestamp=None,<EOL>create_timestamp=None,<EOL>iobject_data=None,<EOL>config_hooks=None,<EOL>namespace_dict=None,<EOL>markings=None,<EOL>import_older_ts=True,<EOL>iobject_family_name=DINGOS_IOBJECT_FAMILY_NAME,<EOL>iobject_family_revision_name=DINGOS_REVISION_NAME,<EOL>iobject_type_name=DINGOS_PLACEHOLDER_TYPE_NAME,<EOL>iobject_type_namespace_uri=DINGOS_NAMESPACE_URI,<EOL>iobject_type_revision_name="<STR_LIT>",<EOL>):
<EOL>if not uid:<EOL><INDENT>raise StandardError("<STR_LIT>")<EOL><DEDENT>if not identifier_ns_uri:<EOL><INDENT>raise StandardError("<STR_LIT>")<EOL><DEDENT>if not iobject_data:<EOL><INDENT>iobject_data = DingoObjDict()<EOL><DEDENT>if not config_hooks:<EOL><INDENT>config_hooks = {}<EOL><DEDENT>latest_existing_iobject = None<EOL>latest_existing_timestamp = None<EOL>existing_iobject = None<EOL>exists = False<EOL>overwrite = False<EOL>latest_existing_iobject = self.get_latest_revision_of_iobject_by_uid(identifier_ns_uri, uid)<EOL>if latest_existing_iobject:<EOL><INDENT>latest_existing_timestamp = latest_existing_iobject.timestamp<EOL>if ((not timestamp) and<EOL>iobject_type_name==DINGOS_PLACEHOLDER_TYPE_NAME and<EOL>iobject_type_namespace_uri==DINGOS_NAMESPACE_URI):<EOL><INDENT>return (latest_existing_iobject, EXIST_ID_AND_EXACT_TIMESTAMP)<EOL><DEDENT><DEDENT>if not timestamp:<EOL><INDENT>timestamp = create_timestamp<EOL><DEDENT>existing_iobjects = self._DCM['<STR_LIT>'].objects.filter(identifier__uid=uid).filter(<EOL>identifier__namespace__uri=identifier_ns_uri).filter(timestamp=timestamp)<EOL>if existing_iobjects:<EOL><INDENT>existing_iobject = existing_iobjects[<NUM_LIT:0>]<EOL><DEDENT>if existing_iobject:<EOL><INDENT>if existing_iobject.iobject_type.name == DINGOS_PLACEHOLDER_TYPE_NAMEand existing_iobject.iobject_family.name == DINGOS_IOBJECT_FAMILY_NAME:<EOL><INDENT>overwrite = existing_iobject<EOL>exists = EXIST_PLACEHOLDER<EOL><DEDENT>else:<EOL><INDENT>exists = EXIST_ID_AND_EXACT_TIMESTAMP<EOL><DEDENT><DEDENT>elif latest_existing_iobject:<EOL><INDENT>if timestamp < latest_existing_timestamp:<EOL><INDENT>exists = EXIST_ID_AND_NEWER_TIMESTAMP<EOL><DEDENT>else:<EOL><INDENT>exists = EXIST_ID_AND_OLDER_TIMESTAMP<EOL><DEDENT><DEDENT>logger.debug("<STR_LIT>" % (identifier_ns_uri, uid, exists))<EOL>if exists==EXIST_ID_AND_EXACT_TIMESTAMP:<EOL><INDENT>if markings:<EOL><INDENT>for marking in markings:<EOL><INDENT>Marking2X.objects.create(marked=existing_iobject,<EOL>marking=marking)<EOL><DEDENT><DEDENT>return (existing_iobject, exists)<EOL><DEDENT>elif  (not import_older_ts and exists == EXIST_ID_AND_NEWER_TIMESTAMP):<EOL><INDENT>return (latest_existing_iobject, exists)<EOL><DEDENT>else:<EOL><INDENT>logger.info("<STR_LIT>" % (iobject_type_name,<EOL>identifier_ns_uri,<EOL>uid,<EOL>'<STR_LIT>'.format(timestamp, timestamp.microsecond // <NUM_LIT:1000>)))<EOL>iobject, created = get_or_create_iobject(uid,<EOL>identifier_ns_uri,<EOL>iobject_type_name,<EOL>iobject_type_namespace_uri,<EOL>iobject_type_revision_name,<EOL>iobject_family_name,<EOL>iobject_family_revision_name,<EOL>identifier_namespace_name=None,<EOL>timestamp=timestamp,<EOL>create_timestamp=create_timestamp,<EOL>overwrite=overwrite,<EOL>dingos_class_map=self._DCM,<EOL>)<EOL>if created or overwrite:<EOL><INDENT>iobject.from_dict(iobject_data, config_hooks=config_hooks, namespace_dict=namespace_dict)<EOL><DEDENT>if not exists or exists == EXIST_ID_AND_OLDER_TIMESTAMP or exists == EXIST_PLACEHOLDER:<EOL><INDENT>iobject.identifier.latest = iobject<EOL>iobject.identifier.save()<EOL><DEDENT>if markings:<EOL><INDENT>for marking in markings:<EOL><INDENT>Marking2X.objects.create(marked=iobject,<EOL>marking=marking)<EOL><DEDENT><DEDENT>return (iobject, exists)<EOL><DEDENT>
Create an information object:

- the unique identifier of the information object is specified
  by identifier_ns_uri and uid

- the timestamp specifies the revision of the information object

- iobject data must contain the DingoObjDict with the contents
  of the information object that is to be created

- config_hooks specifies hooking functions for customizing the
  way the DingoObjDict is transformed into facts -- please
  look at the sample import modules for STIX and OpenIOC to
  get an idea of how this is used

- A list of markings can be provided. Essentially, a marking is simply
  another information object, to which the created information object
  will receive a link. This can be used, e.g., to keep track of provenance
  information (e.g., which import step led to the creation of that information object.

- Existing defaults for object family and type can be changed via function parameters.
  If nothing is changed, then a DINGO PLACEHOLDER object is created. This special
  object is used by the importer to create objects for forward references found
  during the import.

Call the function as

(iobject(s),exists) = create_iobject(...)

The 'exists' flag contains information about whether there were already existing
revisions.