def _w(cls, draft): def drop_if_empty(val): return val if val else None target = wrapped_func(cls, draft) target.categories = cleanstrings(draft.get('categories')) for key, value in draft.get('time').iteritems(): DBIncidentPatch.append_config_timezone(value) target.time = StixTime() StixTime.from_dict(draft.get('time'), target.time) target.external_ids = [] for ex_id in draft.get('external_ids', []): target.external_ids.append(ExternalID(ex_id['id'], ex_id['source'])) target.coordinators = [EdgeInformationSource.from_draft(drop_if_empty(coordinator)) for coordinator in draft.get('coordinators', [])] return target
def update_with(self, update_obj, update_timestamp=True): super(DBIncidentPatch, self).update_with(update_obj, update_timestamp) self.categories = None IncidentCategories.from_dict(update_obj.categories.to_dict(), self.categories) if update_obj.time: self.time = StixTime.from_dict(update_obj.time.to_dict()) self.coordinators = update_obj.coordinators self.intended_effects = IntendedEffects() self.discovery_methods = DiscoveryMethods() IntendedEffects.from_dict(update_obj.intended_effects.to_dict(), self.intended_effects) DiscoveryMethods.from_dict(update_obj.discovery_methods.to_dict(), self.discovery_methods) self.external_ids = [] for ex_id in update_obj.external_ids: self.external_ids.append(ExternalID(ex_id.value, ex_id.source))