# 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.197.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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from sonatype_iq_api_client.models.policy_evaluation_result import PolicyEvaluationResult
from typing import Optional, Set
from typing_extensions import Self

class ApiReportResultsDTO(BaseModel):
    """
    ApiReportResultsDTO
    """ # noqa: E501
    application_id: Optional[StrictStr] = Field(default=None, alias="applicationId")
    commit_hash: Optional[StrictStr] = Field(default=None, alias="commitHash")
    embeddable_report_html_url: Optional[StrictStr] = Field(default=None, alias="embeddableReportHtmlUrl")
    evaluation_date: Optional[datetime] = Field(default=None, alias="evaluationDate")
    is_for_monitoring: Optional[StrictBool] = Field(default=None, alias="isForMonitoring")
    is_reevaluation: Optional[StrictBool] = Field(default=None, alias="isReevaluation")
    latest_report_html_url: Optional[StrictStr] = Field(default=None, alias="latestReportHtmlUrl")
    policy_evaluation_id: Optional[StrictStr] = Field(default=None, alias="policyEvaluationId")
    policy_evaluation_result: Optional[PolicyEvaluationResult] = Field(default=None, alias="policyEvaluationResult")
    report_data_url: Optional[StrictStr] = Field(default=None, alias="reportDataUrl")
    report_html_url: Optional[StrictStr] = Field(default=None, alias="reportHtmlUrl")
    report_pdf_url: Optional[StrictStr] = Field(default=None, alias="reportPdfUrl")
    scan_id: Optional[StrictStr] = Field(default=None, alias="scanId")
    scan_trigger_internal: Optional[StrictBool] = Field(default=None, alias="scanTriggerInternal")
    scan_trigger_type: Optional[StrictStr] = Field(default=None, alias="scanTriggerType")
    scan_trigger_type_display_name: Optional[StrictStr] = Field(default=None, alias="scanTriggerTypeDisplayName")
    scanner_version: Optional[StrictStr] = Field(default=None, alias="scannerVersion")
    stage: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["applicationId", "commitHash", "embeddableReportHtmlUrl", "evaluationDate", "isForMonitoring", "isReevaluation", "latestReportHtmlUrl", "policyEvaluationId", "policyEvaluationResult", "reportDataUrl", "reportHtmlUrl", "reportPdfUrl", "scanId", "scanTriggerInternal", "scanTriggerType", "scanTriggerTypeDisplayName", "scannerVersion", "stage"]

    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 ApiReportResultsDTO 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 policy_evaluation_result
        if self.policy_evaluation_result:
            _dict['policyEvaluationResult'] = self.policy_evaluation_result.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "applicationId": obj.get("applicationId"),
            "commitHash": obj.get("commitHash"),
            "embeddableReportHtmlUrl": obj.get("embeddableReportHtmlUrl"),
            "evaluationDate": obj.get("evaluationDate"),
            "isForMonitoring": obj.get("isForMonitoring"),
            "isReevaluation": obj.get("isReevaluation"),
            "latestReportHtmlUrl": obj.get("latestReportHtmlUrl"),
            "policyEvaluationId": obj.get("policyEvaluationId"),
            "policyEvaluationResult": PolicyEvaluationResult.from_dict(obj["policyEvaluationResult"]) if obj.get("policyEvaluationResult") is not None else None,
            "reportDataUrl": obj.get("reportDataUrl"),
            "reportHtmlUrl": obj.get("reportHtmlUrl"),
            "reportPdfUrl": obj.get("reportPdfUrl"),
            "scanId": obj.get("scanId"),
            "scanTriggerInternal": obj.get("scanTriggerInternal"),
            "scanTriggerType": obj.get("scanTriggerType"),
            "scanTriggerTypeDisplayName": obj.get("scanTriggerTypeDisplayName"),
            "scannerVersion": obj.get("scannerVersion"),
            "stage": obj.get("stage")
        })
        return _obj


