# coding: utf-8

"""
    FlowHunt

    FlowHunt API

    The version of the OpenAPI document: 2.0.0
    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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from flowhunt.models.document_type import DocumentType
from typing import Optional, Set
from typing_extensions import Self

class DocumentContent(BaseModel):
    """
    DocumentContent
    """ # noqa: E501
    url: Optional[StrictStr] = None
    img_url: Optional[StrictStr] = None
    status_code: Optional[StrictInt] = None
    created_at: Optional[Union[StrictFloat, StrictInt]] = None
    published_at: Optional[Union[StrictFloat, StrictInt]] = None
    title: Optional[StrictStr] = None
    doc_name: Optional[StrictStr] = None
    lang: Optional[StrictStr] = None
    content_type: Optional[StrictStr] = None
    encoding: Optional[StrictStr] = None
    apparent_encoding: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    content: Optional[List[Annotated[List[Any], Field(min_length=2, max_length=2)]]] = None
    metadata: Optional[Dict[str, Any]] = None
    alt_content: Optional[List[StrictStr]] = None
    content_hash: Optional[StrictStr] = None
    author: Optional[StrictStr] = None
    channel_id: Optional[StrictStr] = None
    channel_url: Optional[StrictStr] = None
    channel_title: Optional[StrictStr] = None
    duration: Optional[StrictInt] = None
    keywords: Optional[List[StrictStr]] = None
    doc_type: Optional[DocumentType] = None
    credits: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["url", "img_url", "status_code", "created_at", "published_at", "title", "doc_name", "lang", "content_type", "encoding", "apparent_encoding", "description", "content", "metadata", "alt_content", "content_hash", "author", "channel_id", "channel_url", "channel_title", "duration", "keywords", "doc_type", "credits"]

    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 DocumentContent 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,
        )
        # set to None if url (nullable) is None
        # and model_fields_set contains the field
        if self.url is None and "url" in self.model_fields_set:
            _dict['url'] = None

        # set to None if img_url (nullable) is None
        # and model_fields_set contains the field
        if self.img_url is None and "img_url" in self.model_fields_set:
            _dict['img_url'] = None

        # set to None if status_code (nullable) is None
        # and model_fields_set contains the field
        if self.status_code is None and "status_code" in self.model_fields_set:
            _dict['status_code'] = None

        # set to None if created_at (nullable) is None
        # and model_fields_set contains the field
        if self.created_at is None and "created_at" in self.model_fields_set:
            _dict['created_at'] = None

        # set to None if published_at (nullable) is None
        # and model_fields_set contains the field
        if self.published_at is None and "published_at" in self.model_fields_set:
            _dict['published_at'] = None

        # set to None if title (nullable) is None
        # and model_fields_set contains the field
        if self.title is None and "title" in self.model_fields_set:
            _dict['title'] = None

        # set to None if doc_name (nullable) is None
        # and model_fields_set contains the field
        if self.doc_name is None and "doc_name" in self.model_fields_set:
            _dict['doc_name'] = None

        # set to None if lang (nullable) is None
        # and model_fields_set contains the field
        if self.lang is None and "lang" in self.model_fields_set:
            _dict['lang'] = None

        # set to None if content_type (nullable) is None
        # and model_fields_set contains the field
        if self.content_type is None and "content_type" in self.model_fields_set:
            _dict['content_type'] = None

        # set to None if encoding (nullable) is None
        # and model_fields_set contains the field
        if self.encoding is None and "encoding" in self.model_fields_set:
            _dict['encoding'] = None

        # set to None if apparent_encoding (nullable) is None
        # and model_fields_set contains the field
        if self.apparent_encoding is None and "apparent_encoding" in self.model_fields_set:
            _dict['apparent_encoding'] = None

        # set to None if description (nullable) is None
        # and model_fields_set contains the field
        if self.description is None and "description" in self.model_fields_set:
            _dict['description'] = None

        # set to None if content (nullable) is None
        # and model_fields_set contains the field
        if self.content is None and "content" in self.model_fields_set:
            _dict['content'] = None

        # set to None if metadata (nullable) is None
        # and model_fields_set contains the field
        if self.metadata is None and "metadata" in self.model_fields_set:
            _dict['metadata'] = None

        # set to None if alt_content (nullable) is None
        # and model_fields_set contains the field
        if self.alt_content is None and "alt_content" in self.model_fields_set:
            _dict['alt_content'] = None

        # set to None if content_hash (nullable) is None
        # and model_fields_set contains the field
        if self.content_hash is None and "content_hash" in self.model_fields_set:
            _dict['content_hash'] = None

        # set to None if author (nullable) is None
        # and model_fields_set contains the field
        if self.author is None and "author" in self.model_fields_set:
            _dict['author'] = None

        # set to None if channel_id (nullable) is None
        # and model_fields_set contains the field
        if self.channel_id is None and "channel_id" in self.model_fields_set:
            _dict['channel_id'] = None

        # set to None if channel_url (nullable) is None
        # and model_fields_set contains the field
        if self.channel_url is None and "channel_url" in self.model_fields_set:
            _dict['channel_url'] = None

        # set to None if channel_title (nullable) is None
        # and model_fields_set contains the field
        if self.channel_title is None and "channel_title" in self.model_fields_set:
            _dict['channel_title'] = None

        # set to None if duration (nullable) is None
        # and model_fields_set contains the field
        if self.duration is None and "duration" in self.model_fields_set:
            _dict['duration'] = None

        # set to None if keywords (nullable) is None
        # and model_fields_set contains the field
        if self.keywords is None and "keywords" in self.model_fields_set:
            _dict['keywords'] = None

        # set to None if doc_type (nullable) is None
        # and model_fields_set contains the field
        if self.doc_type is None and "doc_type" in self.model_fields_set:
            _dict['doc_type'] = None

        # set to None if credits (nullable) is None
        # and model_fields_set contains the field
        if self.credits is None and "credits" in self.model_fields_set:
            _dict['credits'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "url": obj.get("url"),
            "img_url": obj.get("img_url"),
            "status_code": obj.get("status_code"),
            "created_at": obj.get("created_at"),
            "published_at": obj.get("published_at"),
            "title": obj.get("title"),
            "doc_name": obj.get("doc_name"),
            "lang": obj.get("lang"),
            "content_type": obj.get("content_type"),
            "encoding": obj.get("encoding"),
            "apparent_encoding": obj.get("apparent_encoding"),
            "description": obj.get("description"),
            "content": obj.get("content"),
            "metadata": obj.get("metadata"),
            "alt_content": obj.get("alt_content"),
            "content_hash": obj.get("content_hash"),
            "author": obj.get("author"),
            "channel_id": obj.get("channel_id"),
            "channel_url": obj.get("channel_url"),
            "channel_title": obj.get("channel_title"),
            "duration": obj.get("duration"),
            "keywords": obj.get("keywords"),
            "doc_type": obj.get("doc_type"),
            "credits": obj.get("credits")
        })
        return _obj


