# coding: utf-8

"""
    Sonatype Lifecycle Public REST API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.196.0-01
    Contact: community@sonatype.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from sonatype_iq_api_client.models.api_component_identifier_dtov2 import ApiComponentIdentifierDTOV2
from typing import Optional, Set
from typing_extensions import Self

class SearchResultItemDTO(BaseModel):
    """
    SearchResultItemDTO
    """ # noqa: E501
    application_category_color: Optional[StrictStr] = Field(default=None, alias="applicationCategoryColor")
    application_category_description: Optional[StrictStr] = Field(default=None, alias="applicationCategoryDescription")
    application_category_id: Optional[StrictStr] = Field(default=None, alias="applicationCategoryId")
    application_category_name: Optional[StrictStr] = Field(default=None, alias="applicationCategoryName")
    application_id: Optional[StrictStr] = Field(default=None, alias="applicationId")
    application_name: Optional[StrictStr] = Field(default=None, alias="applicationName")
    application_public_id: Optional[StrictStr] = Field(default=None, alias="applicationPublicId")
    application_version: Optional[StrictStr] = Field(default=None, alias="applicationVersion")
    component_hash: Optional[StrictStr] = Field(default=None, alias="componentHash")
    component_identifier: Optional[ApiComponentIdentifierDTOV2] = Field(default=None, alias="componentIdentifier")
    component_label_color: Optional[StrictStr] = Field(default=None, alias="componentLabelColor")
    component_label_description: Optional[StrictStr] = Field(default=None, alias="componentLabelDescription")
    component_label_id: Optional[StrictStr] = Field(default=None, alias="componentLabelId")
    component_label_name: Optional[StrictStr] = Field(default=None, alias="componentLabelName")
    component_name: Optional[StrictStr] = Field(default=None, alias="componentName")
    item_type: Optional[StrictStr] = Field(default=None, alias="itemType")
    organization_id: Optional[StrictStr] = Field(default=None, alias="organizationId")
    organization_name: Optional[StrictStr] = Field(default=None, alias="organizationName")
    policy_evaluation_stage: Optional[StrictStr] = Field(default=None, alias="policyEvaluationStage")
    policy_id: Optional[StrictStr] = Field(default=None, alias="policyId")
    policy_name: Optional[StrictStr] = Field(default=None, alias="policyName")
    policy_threat_category: Optional[StrictStr] = Field(default=None, alias="policyThreatCategory")
    policy_threat_level: Optional[StrictInt] = Field(default=None, alias="policyThreatLevel")
    report_id: Optional[StrictStr] = Field(default=None, alias="reportId")
    result_index: Optional[StrictInt] = Field(default=None, alias="resultIndex")
    sbom_specification: Optional[StrictStr] = Field(default=None, alias="sbomSpecification")
    vulnerability_description: Optional[StrictStr] = Field(default=None, alias="vulnerabilityDescription")
    vulnerability_id: Optional[StrictStr] = Field(default=None, alias="vulnerabilityId")
    vulnerability_status: Optional[StrictStr] = Field(default=None, alias="vulnerabilityStatus")
    __properties: ClassVar[List[str]] = ["applicationCategoryColor", "applicationCategoryDescription", "applicationCategoryId", "applicationCategoryName", "applicationId", "applicationName", "applicationPublicId", "applicationVersion", "componentHash", "componentIdentifier", "componentLabelColor", "componentLabelDescription", "componentLabelId", "componentLabelName", "componentName", "itemType", "organizationId", "organizationName", "policyEvaluationStage", "policyId", "policyName", "policyThreatCategory", "policyThreatLevel", "reportId", "resultIndex", "sbomSpecification", "vulnerabilityDescription", "vulnerabilityId", "vulnerabilityStatus"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of SearchResultItemDTO from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of component_identifier
        if self.component_identifier:
            _dict['componentIdentifier'] = self.component_identifier.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SearchResultItemDTO from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "applicationCategoryColor": obj.get("applicationCategoryColor"),
            "applicationCategoryDescription": obj.get("applicationCategoryDescription"),
            "applicationCategoryId": obj.get("applicationCategoryId"),
            "applicationCategoryName": obj.get("applicationCategoryName"),
            "applicationId": obj.get("applicationId"),
            "applicationName": obj.get("applicationName"),
            "applicationPublicId": obj.get("applicationPublicId"),
            "applicationVersion": obj.get("applicationVersion"),
            "componentHash": obj.get("componentHash"),
            "componentIdentifier": ApiComponentIdentifierDTOV2.from_dict(obj["componentIdentifier"]) if obj.get("componentIdentifier") is not None else None,
            "componentLabelColor": obj.get("componentLabelColor"),
            "componentLabelDescription": obj.get("componentLabelDescription"),
            "componentLabelId": obj.get("componentLabelId"),
            "componentLabelName": obj.get("componentLabelName"),
            "componentName": obj.get("componentName"),
            "itemType": obj.get("itemType"),
            "organizationId": obj.get("organizationId"),
            "organizationName": obj.get("organizationName"),
            "policyEvaluationStage": obj.get("policyEvaluationStage"),
            "policyId": obj.get("policyId"),
            "policyName": obj.get("policyName"),
            "policyThreatCategory": obj.get("policyThreatCategory"),
            "policyThreatLevel": obj.get("policyThreatLevel"),
            "reportId": obj.get("reportId"),
            "resultIndex": obj.get("resultIndex"),
            "sbomSpecification": obj.get("sbomSpecification"),
            "vulnerabilityDescription": obj.get("vulnerabilityDescription"),
            "vulnerabilityId": obj.get("vulnerabilityId"),
            "vulnerabilityStatus": obj.get("vulnerabilityStatus")
        })
        return _obj


