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

class CreateProjectFromTemplateV3Request(BaseModel):
    """
    从模板创建项目请求
    """ # noqa: E501
    name: Optional[StrictStr] = Field(default=None, description="项目名称")
    template_id: Optional[StrictStr] = Field(default=None, description="模板ID", alias="templateId")
    template_name: Optional[StrictStr] = Field(default=None, description="模板名称（取通过模版名匹配到的第一个模版，templateId、templateName至少传一个，与templateId同时传入时优先用templateId）", alias="templateName")
    is_template: Optional[StrictBool] = Field(default=None, description="是否为模板项目，默认为 false", alias="isTemplate")
    visibility: Optional[StrictStr] = Field(default=None, description="项目可见性")
    program_id: Optional[StrictStr] = Field(default=None, description="项目所属项目集ID", alias="programId")
    program_name: Optional[StrictStr] = Field(default=None, description="项目所属项目集名称（取通过项目集名匹配到的第一个项目集，与programId同时传入时优先用programId）", alias="programName")
    description: Optional[StrictStr] = Field(default=None, description="项目描述")
    start_date: Optional[datetime] = Field(default=None, description="项目开始时间", alias="startDate")
    end_date: Optional[datetime] = Field(default=None, description="项目结束时间", alias="endDate")
    __properties: ClassVar[List[str]] = ["name", "templateId", "templateName", "isTemplate", "visibility", "programId", "programName", "description", "startDate", "endDate"]

    @field_validator('visibility')
    def visibility_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['project', 'organization']):
            raise ValueError("must be one of enum values ('project', 'organization')")
        return value

    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 CreateProjectFromTemplateV3Request 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 CreateProjectFromTemplateV3Request from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "templateId": obj.get("templateId"),
            "templateName": obj.get("templateName"),
            "isTemplate": obj.get("isTemplate"),
            "visibility": obj.get("visibility"),
            "programId": obj.get("programId"),
            "programName": obj.get("programName"),
            "description": obj.get("description"),
            "startDate": obj.get("startDate"),
            "endDate": obj.get("endDate")
        })
        return _obj


