# coding: utf-8

"""
    全部  API 文档

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1
    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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class App(BaseModel):
    """
    应用
    """ # noqa: E501
    id: Optional[StrictInt] = Field(default=None, description="唯一标识符")
    user_id: Optional[StrictInt] = Field(default=None, description="用户 ID", alias="userID")
    project_id: Optional[StrictInt] = Field(default=None, description="项目 ID", alias="projectID")
    website: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=255)]] = Field(default=None, description="网站默认域名")
    name: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=255)]] = Field(default=None, description="名称")
    logo: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=255)]] = Field(default=None, description="Logo")
    description: Optional[StrictStr] = Field(default=None, description="描述")
    tags: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=255)]] = Field(default=None, description="标签")
    app_key: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=50)]] = Field(default=None, description="应用公钥", alias="appKey")
    app_secret: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=50)]] = Field(default=None, description="应用私密密钥", alias="appSecret")
    client_secret: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=50)]] = Field(default=None, description="客户端密钥", alias="clientSecret")
    ssh_publickey: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=50)]] = Field(default=None, description="SSH公钥", alias="sshPublickey")
    share: Optional[StrictBool] = Field(default=None, description="是否共享")
    create_date: Optional[datetime] = Field(default=None, description="创建时间", alias="createDate")
    last_update: Optional[datetime] = Field(default=None, description="最后更新时间", alias="lastUpdate")
    show: Optional[StrictBool] = Field(default=None, description="是否显示")
    show_index: Optional[StrictInt] = Field(default=None, description="显示索引", alias="showIndex")
    __properties: ClassVar[List[str]] = ["id", "userID", "projectID", "website", "name", "logo", "description", "tags", "appKey", "appSecret", "clientSecret", "sshPublickey", "share", "createDate", "lastUpdate", "show", "showIndex"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "userID": obj.get("userID"),
            "projectID": obj.get("projectID"),
            "website": obj.get("website"),
            "name": obj.get("name"),
            "logo": obj.get("logo"),
            "description": obj.get("description"),
            "tags": obj.get("tags"),
            "appKey": obj.get("appKey"),
            "appSecret": obj.get("appSecret"),
            "clientSecret": obj.get("clientSecret"),
            "sshPublickey": obj.get("sshPublickey"),
            "share": obj.get("share"),
            "createDate": obj.get("createDate"),
            "lastUpdate": obj.get("lastUpdate"),
            "show": obj.get("show"),
            "showIndex": obj.get("showIndex")
        })
        return _obj


