mainframe.models.schemas ======================== .. py:module:: mainframe.models.schemas Classes ------- .. autoapisummary:: mainframe.models.schemas.ServerMetadata mainframe.models.schemas.Error mainframe.models.schemas.Package mainframe.models.schemas.PackageSpecifier mainframe.models.schemas.ReportPackageBody mainframe.models.schemas.EmailReport mainframe.models.schemas.ObservationKind mainframe.models.schemas.ObservationReport mainframe.models.schemas.PackageScanResult mainframe.models.schemas.PackageScanResultFail mainframe.models.schemas.JobResult mainframe.models.schemas.GetRules mainframe.models.schemas.NoJob mainframe.models.schemas.QueuePackageResponse mainframe.models.schemas.StatsResponse Module Contents --------------- .. py:class:: ServerMetadata(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Server metadata .. py:attribute:: server_commit :type: str .. py:attribute:: rules_commit :type: str .. py:class:: Error(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Error .. py:attribute:: detail :type: str .. py:class:: Package(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Model representing a package queried from the database. .. py:attribute:: scan_id :type: str .. py:attribute:: name :type: str .. py:attribute:: version :type: Optional[str] .. py:attribute:: status :type: Optional[str] .. py:attribute:: score :type: Optional[int] .. py:attribute:: inspector_url :type: Optional[str] .. py:attribute:: rules :type: list[str] :value: [] .. py:attribute:: download_urls :type: list[str] :value: [] .. py:attribute:: queued_at :type: Optional[datetime.datetime] .. py:attribute:: queued_by :type: Optional[str] .. py:attribute:: reported_at :type: Optional[datetime.datetime] .. py:attribute:: reported_by :type: Optional[str] .. py:attribute:: pending_at :type: Optional[datetime.datetime] .. py:attribute:: pending_by :type: Optional[str] .. py:attribute:: finished_at :type: Optional[datetime.datetime] .. py:attribute:: finished_by :type: Optional[str] .. py:attribute:: commit_hash :type: Optional[str] .. py:method:: from_db(scan: mainframe.models.orm.Scan) :classmethod: .. py:method:: serialize_dt(dt: Optional[datetime.datetime], _info) .. py:class:: PackageSpecifier(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Model used to specify a package by name and version name: A str of the name of the package to be scanned version: A str of the package version to scan. .. py:attribute:: model_config .. py:attribute:: name :type: str .. py:attribute:: version :type: str .. py:class:: ReportPackageBody(/, **data: Any) Bases: :py:obj:`PackageSpecifier` Model used to specify a package by name and version name: A str of the name of the package to be scanned version: A str of the package version to scan. .. py:attribute:: recipient :type: Optional[str] .. py:attribute:: inspector_url :type: Optional[str] .. py:attribute:: additional_information :type: Optional[str] .. py:attribute:: use_email :type: bool :value: False .. py:class:: EmailReport(/, **data: Any) Bases: :py:obj:`PackageSpecifier` Model for a report using email .. py:attribute:: rules_matched :type: list[str] .. py:attribute:: recipient :type: Optional[str] :value: None .. py:attribute:: inspector_url :type: Optional[str] .. py:attribute:: additional_information :type: Optional[str] .. py:class:: ObservationKind(*args, **kwds) Bases: :py:obj:`enum.Enum` Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: DependencyConfusion :value: 'is_dependency_confusion' .. py:attribute:: Malware :value: 'is_malware' .. py:attribute:: Spam :value: 'is_spam' .. py:attribute:: Other :value: 'something_else' .. py:class:: ObservationReport(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Model for a report using the PyPI Observation Api .. py:attribute:: kind :type: ObservationKind .. py:attribute:: summary :type: str .. py:attribute:: inspector_url :type: Optional[str] .. py:attribute:: extra :type: dict[str, Any] .. py:class:: PackageScanResult(/, **data: Any) Bases: :py:obj:`PackageSpecifier` Client payload to server containing the results of a package scan .. py:attribute:: commit :type: str .. py:attribute:: score :type: int :value: 0 .. py:attribute:: inspector_url :type: Optional[str] :value: None .. py:attribute:: rules_matched :type: list[str] :value: [] .. py:class:: PackageScanResultFail(/, **data: Any) Bases: :py:obj:`PackageSpecifier` The client's reason as to why scanning a package failed .. py:attribute:: reason :type: str .. py:class:: JobResult(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Package information of a requested job. .. py:attribute:: name :type: str .. py:attribute:: version :type: str .. py:attribute:: distributions :type: list[str] .. py:attribute:: hash :type: str .. py:class:: GetRules(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Usage docs: https://docs.pydantic.dev/2.8/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of classvars defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The signature for instantiating the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The pydantic-core schema used to build the SchemaValidator and SchemaSerializer. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __pydantic_generic_metadata__ Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a `RootModel`. .. attribute:: __pydantic_serializer__ The pydantic-core SchemaSerializer used to dump instances of the model. .. attribute:: __pydantic_validator__ The pydantic-core SchemaValidator used to validate instances of the model. .. attribute:: __pydantic_extra__ An instance attribute with the values of extra fields from validation when `model_config['extra'] == 'allow'`. .. attribute:: __pydantic_fields_set__ An instance attribute with the names of fields explicitly set. .. attribute:: __pydantic_private__ Instance attribute with the values of private attributes set on the model instance. .. py:attribute:: hash :type: str .. py:attribute:: rules :type: dict[str, str] .. py:class:: NoJob(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Returned when no available jobs were found. .. py:attribute:: detail :type: str .. py:class:: QueuePackageResponse(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Returned after queueing a package. Contains the UUID .. py:attribute:: id :type: str .. py:class:: StatsResponse(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Recent system statistics .. py:attribute:: ingested :type: int .. py:attribute:: average_scan_time :type: float .. py:attribute:: failed :type: int