# coding: utf-8

"""
    ibl-data-manager

    API for iblai

    The version of the OpenAPI document: 4.202.1-ai-plus
    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, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from uuid import UUID
from typing import Optional, Set
from typing_extensions import Self

class NotificationTemplateList(BaseModel):
    """
    Serializer for listing notification templates with inheritance info
    """ # noqa: E501
    id: UUID = Field(description="Unique identifier for this notification template.")
    type: Optional[StrictStr] = Field(default=None, description="Select the type of notification from the available options.  * `ADMIN_NOTIF_COURSE_ENROLLMENT` - Admin Notif Course Enrollment * `APP_REGISTRATION` - App Registration * `COURSE_INVITATION` - Course Invitation * `COURSE_LICENSE_ASSIGNMENT` - Course License Assignment * `COURSE_LICENSE_GROUP_ASSIGNMENT` - Course License Group Assignment * `CUSTOM_NOTIFICATION` - Custom Notification * `DEFAULT_TEMPLATE` - Default Template * `HUMAN_SUPPORT_NOTIFICATION` - Human Support Notification * `PLATFORM_INVITATION` - Platform Invitation * `POLICY_ASSIGNMENT` - Policy Assignment * `PROACTIVE_LEARNER_NOTIFICATION` - Proactive Learner Notification * `PROGRAM_INVITATION` - Program Invitation * `PROGRAM_LICENSE_ASSIGNMENT` - Program License Assignment * `PROGRAM_LICENSE_GROUP_ASSIGNMENT` - Program License Group Assignment * `REPORT_COMPLETED` - Report Completed * `ROLE_CHANGE` - Role Change * `USER_LICENSE_ASSIGNMENT` - User License Assignment * `USER_LICENSE_GROUP_ASSIGNMENT` - User License Group Assignment * `USER_NOTIF_COURSE_COMPLETION` - User Notif Course Completion * `USER_NOTIF_COURSE_ENROLLMENT` - User Notif Course Enrollment * `USER_NOTIF_CREDENTIALS` - User Notif Credentials * `USER_NOTIF_LEARNER_PROGRESS` - User Notif Learner Progress * `USER_NOTIF_USER_INACTIVITY` - User Notif User Inactivity * `USER_NOTIF_USER_REGISTRATION` - User Notif User Registration")
    name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="A friendly name for the notification template.")
    description: Optional[StrictStr] = Field(default=None, description="Admin-friendly description of what this notification does, when it triggers, and what data it needs")
    is_inherited: StrictBool = Field(description="True if using main platform template (no platform override)")
    source_platform: StrictStr = Field(description="Platform key of the template source (main or tenant)")
    is_enabled: StrictBool = Field(description="True if notification is enabled for this platform")
    can_customize: StrictBool = Field(description="True if platform admin can edit template content")
    is_custom: StrictBool = Field(description="True if this is a custom notification type")
    message_title: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="The title for the notification message.")
    email_subject: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Email subject line (supports Django template syntax)")
    spas: StrictStr = Field(description="SPAs (Single Page Apps) that can use this template")
    allowed_channels: StrictStr = Field(description="Channels this template can be delivered via (email, push, etc.)")
    available_context: StrictStr = Field(description="Context variables available for template rendering")
    __properties: ClassVar[List[str]] = ["id", "type", "name", "description", "is_inherited", "source_platform", "is_enabled", "can_customize", "is_custom", "message_title", "email_subject", "spas", "allowed_channels", "available_context"]

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

        if value not in set(['ADMIN_NOTIF_COURSE_ENROLLMENT', 'APP_REGISTRATION', 'COURSE_INVITATION', 'COURSE_LICENSE_ASSIGNMENT', 'COURSE_LICENSE_GROUP_ASSIGNMENT', 'CUSTOM_NOTIFICATION', 'DEFAULT_TEMPLATE', 'HUMAN_SUPPORT_NOTIFICATION', 'PLATFORM_INVITATION', 'POLICY_ASSIGNMENT', 'PROACTIVE_LEARNER_NOTIFICATION', 'PROGRAM_INVITATION', 'PROGRAM_LICENSE_ASSIGNMENT', 'PROGRAM_LICENSE_GROUP_ASSIGNMENT', 'REPORT_COMPLETED', 'ROLE_CHANGE', 'USER_LICENSE_ASSIGNMENT', 'USER_LICENSE_GROUP_ASSIGNMENT', 'USER_NOTIF_COURSE_COMPLETION', 'USER_NOTIF_COURSE_ENROLLMENT', 'USER_NOTIF_CREDENTIALS', 'USER_NOTIF_LEARNER_PROGRESS', 'USER_NOTIF_USER_INACTIVITY', 'USER_NOTIF_USER_REGISTRATION', '']):
            raise ValueError("must be one of enum values ('ADMIN_NOTIF_COURSE_ENROLLMENT', 'APP_REGISTRATION', 'COURSE_INVITATION', 'COURSE_LICENSE_ASSIGNMENT', 'COURSE_LICENSE_GROUP_ASSIGNMENT', 'CUSTOM_NOTIFICATION', 'DEFAULT_TEMPLATE', 'HUMAN_SUPPORT_NOTIFICATION', 'PLATFORM_INVITATION', 'POLICY_ASSIGNMENT', 'PROACTIVE_LEARNER_NOTIFICATION', 'PROGRAM_INVITATION', 'PROGRAM_LICENSE_ASSIGNMENT', 'PROGRAM_LICENSE_GROUP_ASSIGNMENT', 'REPORT_COMPLETED', 'ROLE_CHANGE', 'USER_LICENSE_ASSIGNMENT', 'USER_LICENSE_GROUP_ASSIGNMENT', 'USER_NOTIF_COURSE_COMPLETION', 'USER_NOTIF_COURSE_ENROLLMENT', 'USER_NOTIF_CREDENTIALS', 'USER_NOTIF_LEARNER_PROGRESS', 'USER_NOTIF_USER_INACTIVITY', 'USER_NOTIF_USER_REGISTRATION', '')")
        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 NotificationTemplateList 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",
            "is_inherited",
            "source_platform",
            "is_enabled",
            "can_customize",
            "is_custom",
            "spas",
            "allowed_channels",
            "available_context",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if type (nullable) is None
        # and model_fields_set contains the field
        if self.type is None and "type" in self.model_fields_set:
            _dict['type'] = 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 message_title (nullable) is None
        # and model_fields_set contains the field
        if self.message_title is None and "message_title" in self.model_fields_set:
            _dict['message_title'] = None

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of NotificationTemplateList 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"),
            "type": obj.get("type"),
            "name": obj.get("name"),
            "description": obj.get("description"),
            "is_inherited": obj.get("is_inherited"),
            "source_platform": obj.get("source_platform"),
            "is_enabled": obj.get("is_enabled"),
            "can_customize": obj.get("can_customize"),
            "is_custom": obj.get("is_custom") if obj.get("is_custom") is not None else False,
            "message_title": obj.get("message_title"),
            "email_subject": obj.get("email_subject"),
            "spas": obj.get("spas"),
            "allowed_channels": obj.get("allowed_channels"),
            "available_context": obj.get("available_context")
        })
        return _obj


