# coding: utf-8

"""
    Identity Security Cloud V2025 API

    Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.

    The version of the OpenAPI document: v2025
    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
import warnings

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from sailpoint.v2025.models.template_slack_auto_approval_data import TemplateSlackAutoApprovalData
from sailpoint.v2025.models.template_slack_custom_fields import TemplateSlackCustomFields
from typing import Optional, Set
from typing_extensions import Self

class TemplateTeams(BaseModel):
    """
    TemplateTeams
    """ # noqa: E501
    key: Optional[StrictStr] = None
    title: Optional[StrictStr] = None
    text: Optional[StrictStr] = None
    message_json: Optional[StrictStr] = Field(default=None, alias="messageJSON")
    is_subscription: Optional[StrictBool] = Field(default=None, alias="isSubscription")
    approval_id: Optional[StrictStr] = Field(default=None, alias="approvalId")
    request_id: Optional[StrictStr] = Field(default=None, alias="requestId")
    requested_by_id: Optional[StrictStr] = Field(default=None, alias="requestedById")
    notification_type: Optional[StrictStr] = Field(default=None, alias="notificationType")
    auto_approval_data: Optional[TemplateSlackAutoApprovalData] = Field(default=None, alias="autoApprovalData")
    custom_fields: Optional[TemplateSlackCustomFields] = Field(default=None, alias="customFields")
    __properties: ClassVar[List[str]] = ["key", "title", "text", "messageJSON", "isSubscription", "approvalId", "requestId", "requestedById", "notificationType", "autoApprovalData", "customFields"]

    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 TemplateTeams 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 auto_approval_data
        if self.auto_approval_data:
            _dict['autoApprovalData'] = self.auto_approval_data.to_dict()
        # override the default output from pydantic by calling `to_dict()` of custom_fields
        if self.custom_fields:
            _dict['customFields'] = self.custom_fields.to_dict()
        # set to None if key (nullable) is None
        # and model_fields_set contains the field
        if self.key is None and "key" in self.model_fields_set:
            _dict['key'] = None

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "key": obj.get("key"),
            "title": obj.get("title"),
            "text": obj.get("text"),
            "messageJSON": obj.get("messageJSON"),
            "isSubscription": obj.get("isSubscription"),
            "approvalId": obj.get("approvalId"),
            "requestId": obj.get("requestId"),
            "requestedById": obj.get("requestedById"),
            "notificationType": obj.get("notificationType"),
            "autoApprovalData": TemplateSlackAutoApprovalData.from_dict(obj["autoApprovalData"]) if obj.get("autoApprovalData") is not None else None,
            "customFields": TemplateSlackCustomFields.from_dict(obj["customFields"]) if obj.get("customFields") is not None else None
        })
        return _obj


