# Copyright (c) 2025, Palo Alto Networks
#
# Licensed under the Polyform Internal Use License 1.0.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at:
#
# https://polyformproject.org/licenses/internal-use/1.0.0
# (or)
# https://github.com/polyformproject/polyform-licenses/blob/76a278c4/PolyForm-Internal-Use-1.0.0.md
#
# As far as the law allows, the software comes as is, without any warranty
# or condition, and the licensor will not be liable to you for any damages
# arising out of these terms or the use or nature of the software, under
# any kind of legal claim.

"""
AISec API service

OpenAPI Specification for the AI Runtime Security API service

The version of the OpenAPI document: 0.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

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

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, StrictBool
from typing_extensions import Self


class ResponseDetected(BaseModel):
    """
    ResponseDetected
    """  # noqa: E501

    url_cats: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any malicious URLs",
    )
    dlp: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any sensitive information",
    )
    db_security: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any database security threats",
    )
    toxic_content: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any harmful content",
    )
    malicious_code: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any malicious code",
    )
    agent: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any Agent related threats",
    )
    ungrounded: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any ungrounded content",
    )
    topic_violation: Optional[StrictBool] = Field(
        default=None,
        description="Indicates whether response contains any content violates topic guardrails",
    )
    __properties: ClassVar[List[str]] = [
        "url_cats",
        "dlp",
        "db_security",
        "toxic_content",
        "malicious_code",
        "agent",
        "ungrounded",
        "topic_violation",
    ]

    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 ResponseDetected 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "url_cats": obj.get("url_cats"),
            "dlp": obj.get("dlp"),
            "db_security": obj.get("db_security"),
            "toxic_content": obj.get("toxic_content"),
            "malicious_code": obj.get("malicious_code"),
            "agent": obj.get("agent"),
            "ungrounded": obj.get("ungrounded"),
            "topic_violation": obj.get("topic_violation"),
        })
        return _obj
