The ``RelatedIndicators`` class provides functionality for adding :class:`stix.common.related.RelatedIndicator` instances to an :class:`Indicator` instance. The ``RelatedIndicators`` class implements methods found on ``collections.MutableSequence`` and as such can be interacted with
| 91 | |
| 92 | |
| 93 | class RelatedIndicators(GenericRelationshipList): |
| 94 | """The ``RelatedIndicators`` class provides functionality for adding |
| 95 | :class:`stix.common.related.RelatedIndicator` instances to an |
| 96 | :class:`Indicator` instance. |
| 97 | |
| 98 | The ``RelatedIndicators`` class implements methods found on |
| 99 | ``collections.MutableSequence`` and as such can be interacted with as a |
| 100 | ``list`` (e.g., ``append()``). |
| 101 | |
| 102 | The ``append()`` method can accept instances of |
| 103 | :class:`stix.common.related.RelatedIndicator` or |
| 104 | :class:`Indicator` as an argument. |
| 105 | |
| 106 | Note: |
| 107 | Calling ``append()`` with an instance of |
| 108 | :class:`stix.coa.CourseOfAction` will wrap that instance in a |
| 109 | :class:`stix.common.related.RelatedIndicator` layer, with ``item`` |
| 110 | set to the :class:`Indicator` instance. |
| 111 | |
| 112 | Examples: |
| 113 | Append an instance of :class:`Indicator` to the |
| 114 | ``Indicator.related_indicators`` property. The instance of |
| 115 | :class:`Indicator` will be wrapped in an instance of |
| 116 | :class:`stix.common.related.RelatedIndicator`: |
| 117 | |
| 118 | >>> related = Indicator() |
| 119 | >>> parent_indicator = Indicator() |
| 120 | >>> parent_indicator.related_indicators.append(related) |
| 121 | >>> print(type(indicator.related_indicators[0])) |
| 122 | <class 'stix.common.related.RelatedIndicator'> |
| 123 | |
| 124 | Iterate over the ``related_indicators`` property of an |
| 125 | :class:`Indicator` instance and print the ids of each underlying |
| 126 | :class:`Indicator`` instance: |
| 127 | |
| 128 | >>> for related in indicator.related_indicators: |
| 129 | >>> print(related.item.id_) |
| 130 | |
| 131 | Args: |
| 132 | related_indicators (list, optional): A list of :class:`Indicator` or |
| 133 | :class:`stix.common.related.RelatedIndicator` instances. |
| 134 | scope (str, optional): The scope of the items. Can be set to |
| 135 | ``"inclusive"`` or ``"exclusive"``. See |
| 136 | :class:`stix.common.related.GenericRelationshipList` documentation |
| 137 | for more information. |
| 138 | |
| 139 | Attributes: |
| 140 | scope (str): The scope of the items. Can be set to ``"inclusive"`` |
| 141 | or ``"exclusive"``. See |
| 142 | :class:`stix.common.related.GenericRelationshipList` documentation |
| 143 | for more information. |
| 144 | |
| 145 | """ |
| 146 | _namespace = "http://docs.oasis-open.org/cti/ns/stix/indicator-1" |
| 147 | _binding = indicator_binding |
| 148 | _binding_class = indicator_binding.RelatedIndicatorsType |
| 149 | |
| 150 | related_indicator = fields.TypedField("Related_Indicator", RelatedIndicator, multiple=True, key_name="related_indicators") |