# coding: utf-8

"""
    Automio API

    Documentation of API endpoints of Automio for SDK

    The version of the OpenAPI document: 0.1.2
    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 automio.models.plugin_integration import PluginIntegration
from automio.models.plugin_plugin_interface import PluginPluginInterface
from typing import Optional, Set
from typing_extensions import Self

class Plugin(BaseModel):
    """
    Plugin
    """ # noqa: E501
    id: Optional[StrictInt] = None
    organization: Optional[StrictInt] = None
    plugin_interface: Optional[PluginPluginInterface] = None
    integration: Optional[PluginIntegration] = None
    implemented_capabilities: Optional[List[StrictStr]] = None
    is_enabled: Optional[StrictBool] = None
    is_official: Optional[StrictBool] = None
    is_mine: Optional[StrictBool] = None
    organization_slug: Optional[StrictStr] = None
    capabilities: Optional[List[Annotated[str, Field(strict=True, max_length=70)]]] = None
    is_visible: Optional[StrictBool] = None
    code: Optional[StrictStr] = None
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
    __properties: ClassVar[List[str]] = ["id", "organization", "plugin_interface", "integration", "implemented_capabilities", "is_enabled", "is_official", "is_mine", "organization_slug", "capabilities", "is_visible", "code", "created_at", "updated_at"]

    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 Plugin 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "id",
            "organization",
            "implemented_capabilities",
            "is_enabled",
            "is_official",
            "is_mine",
            "organization_slug",
            "created_at",
            "updated_at",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of plugin_interface
        if self.plugin_interface:
            _dict['plugin_interface'] = self.plugin_interface.to_dict()
        # override the default output from pydantic by calling `to_dict()` of integration
        if self.integration:
            _dict['integration'] = self.integration.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Plugin 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"),
            "organization": obj.get("organization"),
            "plugin_interface": PluginPluginInterface.from_dict(obj["plugin_interface"]) if obj.get("plugin_interface") is not None else None,
            "integration": PluginIntegration.from_dict(obj["integration"]) if obj.get("integration") is not None else None,
            "implemented_capabilities": obj.get("implemented_capabilities"),
            "is_enabled": obj.get("is_enabled"),
            "is_official": obj.get("is_official"),
            "is_mine": obj.get("is_mine"),
            "organization_slug": obj.get("organization_slug"),
            "capabilities": obj.get("capabilities"),
            "is_visible": obj.get("is_visible"),
            "code": obj.get("code"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


