1# Copyright (c) 2017, The MITRE Corporation. All rights reserved. 2# See LICENSE.txt for complete terms. 3 4from mixbox import fields 5 6import stix 7from stix.common import StructuredTextList, Confidence 8import stix.bindings.course_of_action as coa_binding 9 10 11class Objective(stix.Entity): 12 _binding = coa_binding 13 _binding_class = coa_binding.ObjectiveType 14 _namespace = "http://stix.mitre.org/CourseOfAction-1" 15 16 applicability_confidence = fields.TypedField("Applicability_Confidence", type_=Confidence) 17 descriptions = fields.TypedField("Description", type_=StructuredTextList) 18 short_descriptions = fields.TypedField("Short_Description", type_=StructuredTextList) 19 20 def __init__(self, description=None, short_description=None): 21 super(Objective, self).__init__() 22 23 self.description = StructuredTextList(description) 24 self.short_description = StructuredTextList(short_description) 25 26 @property 27 def description(self): 28 """A single description about the contents or purpose of this object. 29 30 Default Value: ``None`` 31 32 Note: 33 If this object has more than one description set, this will return 34 the description with the lowest ordinality value. 35 36 Returns: 37 An instance of 38 :class:`.StructuredText` 39 40 """ 41 return next(iter(self.descriptions), None) 42 43 @description.setter 44 def description(self, value): 45 self.descriptions = value 46 47 def add_description(self, description): 48 """Adds a description to the ``descriptions`` collection. 49 50 This is the same as calling "foo.descriptions.add(bar)". 51 52 """ 53 self.descriptions.add(description) 54 55 @property 56 def short_description(self): 57 """A single short description about the contents or purpose of this 58 object. 59 60 Default Value: ``None`` 61 62 Note: 63 If this object has more than one short description set, this will 64 return the description with the lowest ordinality value. 65 66 Returns: 67 An instance of :class:`.StructuredText` 68 69 """ 70 return next(iter(self.short_descriptions), None) 71 72 @short_description.setter 73 def short_description(self, value): 74 self.short_descriptions = value 75 76 def add_short_description(self, description): 77 """Adds a description to the ``short_descriptions`` collection. 78 79 This is the same as calling "foo.short_descriptions.add(bar)". 80 81 """ 82 self.short_descriptions.add(description) 83