# coding: utf-8

"""
    The Jira Cloud platform REST API

    Jira Cloud platform REST API documentation

    The version of the OpenAPI document: 1001.0.0-SNAPSHOT-7ce0ee67a52d004425175cea962ad1c1c7200181
    Contact: ecosystem@atlassian.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, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from jira_client.models.json_type_bean import JsonTypeBean
from jira_client.models.scope import Scope
from typing import Optional, Set
from typing_extensions import Self

class FieldDetails(BaseModel):
    """
    Details about a field.
    """ # noqa: E501
    clause_names: Optional[List[StrictStr]] = Field(default=None, description="The names that can be used to reference the field in an advanced search. For more information, see [Advanced searching - fields reference](https://confluence.atlassian.com/x/gwORLQ).", alias="clauseNames")
    custom: Optional[StrictBool] = Field(default=None, description="Whether the field is a custom field.")
    id: Optional[StrictStr] = Field(default=None, description="The ID of the field.")
    key: Optional[StrictStr] = Field(default=None, description="The key of the field.")
    name: Optional[StrictStr] = Field(default=None, description="The name of the field.")
    navigable: Optional[StrictBool] = Field(default=None, description="Whether the field can be used as a column on the issue navigator.")
    orderable: Optional[StrictBool] = Field(default=None, description="Whether the content of the field can be used to order lists.")
    var_schema: Optional[JsonTypeBean] = Field(default=None, description="The data schema for the field.", alias="schema")
    scope: Optional[Scope] = Field(default=None, description="The scope of the field.")
    searchable: Optional[StrictBool] = Field(default=None, description="Whether the content of the field can be searched.")
    __properties: ClassVar[List[str]] = ["clauseNames", "custom", "id", "key", "name", "navigable", "orderable", "schema", "scope", "searchable"]

    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 FieldDetails 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 var_schema
        if self.var_schema:
            _dict['schema'] = self.var_schema.to_dict()
        # override the default output from pydantic by calling `to_dict()` of scope
        if self.scope:
            _dict['scope'] = self.scope.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "clauseNames": obj.get("clauseNames"),
            "custom": obj.get("custom"),
            "id": obj.get("id"),
            "key": obj.get("key"),
            "name": obj.get("name"),
            "navigable": obj.get("navigable"),
            "orderable": obj.get("orderable"),
            "schema": JsonTypeBean.from_dict(obj["schema"]) if obj.get("schema") is not None else None,
            "scope": Scope.from_dict(obj["scope"]) if obj.get("scope") is not None else None,
            "searchable": obj.get("searchable")
        })
        return _obj


