cyclonedx.output
================

.. py:module:: cyclonedx.output

.. autoapi-nested-parse::

   Set of classes and methods for outputting our libraries internal Bom model to CycloneDX documents in varying formats
   and according to different versions of the CycloneDX schema standard.



Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/cyclonedx/output/json/index
   /autoapi/cyclonedx/output/xml/index


Classes
-------

.. autoapisummary::

   cyclonedx.output.BaseOutput
   cyclonedx.output.BomRefDiscriminator


Functions
---------

.. autoapisummary::

   cyclonedx.output.make_outputter


Package Contents
----------------

.. py:class:: BaseOutput(bom: cyclonedx.model.bom.Bom, **kwargs: int)

   Bases: :py:obj:`abc.ABC`


   Helper class that provides a standard way to create an ABC using
   inheritance.


   .. py:property:: schema_version
      :type: cyclonedx.schema.SchemaVersion

      :abstractmethod:



   .. py:property:: output_format
      :type: cyclonedx.schema.OutputFormat

      :abstractmethod:



   .. py:property:: generated
      :type: bool



   .. py:method:: get_bom() -> cyclonedx.model.bom.Bom


   .. py:method:: set_bom(bom: cyclonedx.model.bom.Bom) -> None


   .. py:method:: generate(force_regeneration: bool = False) -> None
      :abstractmethod:



   .. py:method:: output_as_string(*, indent: Optional[Union[int, str]] = None, **kwargs: Any) -> str
      :abstractmethod:



   .. py:method:: output_to_file(filename: str, allow_overwrite: bool = False, *, indent: Optional[Union[int, str]] = None, **kwargs: Any) -> None


.. py:function:: make_outputter(bom: cyclonedx.model.bom.Bom, output_format: Literal[cyclonedx.schema.OutputFormat.JSON], schema_version: cyclonedx.schema.SchemaVersion) -> json.Json
                 make_outputter(bom: cyclonedx.model.bom.Bom, output_format: Literal[cyclonedx.schema.OutputFormat.XML], schema_version: cyclonedx.schema.SchemaVersion) -> xml.Xml
                 make_outputter(bom: cyclonedx.model.bom.Bom, output_format: cyclonedx.schema.OutputFormat, schema_version: cyclonedx.schema.SchemaVersion) -> Union[xml.Xml, json.Json]

   Helper method to quickly get the correct output class/formatter.

   Pass in your BOM and optionally an output format and schema version (defaults to XML and latest schema version).


   Raises error when no instance could be made.

   :param bom: Bom
   :param output_format: OutputFormat
   :param schema_version: SchemaVersion
   :return: BaseOutput


.. py:class:: BomRefDiscriminator(bomrefs: collections.abc.Iterable[cyclonedx.model.bom_ref.BomRef], prefix: str = 'BomRef')

   Bases: :py:obj:`cyclonedx.contrib.bom.utils.BomRefDiscriminator`


   Deprecated — Alias of :class:`cyclonedx.contrib.bom.utils.BomRefDiscriminator`.

   .. deprecated:: next
       This re-export location is deprecated.
       Use ``from cyclonedx.contrib.bom.utils import BomRefDiscriminator`` instead.
       The exported symbol itself is NOT deprecated — only this import path.


   .. py:method:: discriminate() -> None

      Enforce uniqueness across all
      :attr:`cyclonedx.model.bom_ref.BomRef.value`s.

      Any BomRef whose ``value`` is ``None`` or duplicates a previously
      encountered value is assigned a newly generated unique identifier.



   .. py:method:: reset() -> None

      Restore all :attr:`cyclonedx.model.bom_ref.BomRef.value`s to
      their original state.



   .. py:method:: from_bom(bom: cyclonedx.model.bom.Bom, prefix: str = 'BomRef') -> BomRefDiscriminator
      :classmethod:


      Create a discriminator for all :class:`cyclonedx.model.bom_ref.BomRefs`
      contained within a Bom.

      This includes BomRefs from
        * :attr:`cyclonedx.model.bom.Bom.components`
        * :attr:`cyclonedx.model.bom.Bom.services`
        * :attr:`cyclonedx.model.bom.Bom.vulnerabilities`



