# coding: utf-8

"""
    Teambition Open API

    Teambition Open API

    The version of the OpenAPI document: 1.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, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from teambition_oapi_sdk.model.update_task_cusom_field_v3_request_add_values_inner import UpdateTaskCusomFieldV3RequestAddValuesInner
from teambition_oapi_sdk.model.update_task_cusom_field_v3_request_del_values_inner import UpdateTaskCusomFieldV3RequestDelValuesInner
from teambition_oapi_sdk.model.update_task_cusom_field_v3_request_value_inner import UpdateTaskCusomFieldV3RequestValueInner
from typing import Optional, Set
from typing_extensions import Self

class UpdateTaskCusomFieldV3Request(BaseModel):
    """
    修改自定义字段请求
    """ # noqa: E501
    customfield_id: Optional[StrictStr] = Field(default=None, description="自定义字段ID", alias="customfieldId")
    customfield_name: Optional[StrictStr] = Field(default=None, description="自定义字段名称(如果提供自定义字段ID 则忽略)", alias="customfieldName")
    customfield_instance_id: Optional[StrictStr] = Field(default=None, description="自定义字段InstanceId(如果提供自定义字段ID 或者 自定义字段名称 则忽略)", alias="customfieldInstanceId")
    customfield_alias: Optional[StrictStr] = Field(default=None, description="自定义字段别名(如果提供自定义字段ID 则忽略)", alias="customfieldAlias")
    disable_activity: Optional[StrictBool] = Field(default=None, description="是否忽略触发动态", alias="disableActivity")
    value: Optional[List[UpdateTaskCusomFieldV3RequestValueInner]] = Field(default=None, description="字段值集合")
    add_values: Optional[List[UpdateTaskCusomFieldV3RequestAddValuesInner]] = Field(default=None, description="新增的字段值列表", alias="addValues")
    del_values: Optional[List[UpdateTaskCusomFieldV3RequestDelValuesInner]] = Field(default=None, description="移除的字段值列表", alias="delValues")
    __properties: ClassVar[List[str]] = ["customfieldId", "customfieldName", "customfieldInstanceId", "customfieldAlias", "disableActivity", "value", "addValues", "delValues"]

    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 UpdateTaskCusomFieldV3Request 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 each item in value (list)
        _items = []
        if self.value:
            for _item_value in self.value:
                if _item_value:
                    _items.append(_item_value.to_dict())
            _dict['value'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in add_values (list)
        _items = []
        if self.add_values:
            for _item_add_values in self.add_values:
                if _item_add_values:
                    _items.append(_item_add_values.to_dict())
            _dict['addValues'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in del_values (list)
        _items = []
        if self.del_values:
            for _item_del_values in self.del_values:
                if _item_del_values:
                    _items.append(_item_del_values.to_dict())
            _dict['delValues'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "customfieldId": obj.get("customfieldId"),
            "customfieldName": obj.get("customfieldName"),
            "customfieldInstanceId": obj.get("customfieldInstanceId"),
            "customfieldAlias": obj.get("customfieldAlias"),
            "disableActivity": obj.get("disableActivity"),
            "value": [UpdateTaskCusomFieldV3RequestValueInner.from_dict(_item) for _item in obj["value"]] if obj.get("value") is not None else None,
            "addValues": [UpdateTaskCusomFieldV3RequestAddValuesInner.from_dict(_item) for _item in obj["addValues"]] if obj.get("addValues") is not None else None,
            "delValues": [UpdateTaskCusomFieldV3RequestDelValuesInner.from_dict(_item) for _item in obj["delValues"]] if obj.get("delValues") is not None else None
        })
        return _obj


