# coding: utf-8

"""
    Identity Security Cloud Beta API

    Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. These APIs are in beta and are subject to change. 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: 3.1.0-beta
    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_extensions import Annotated
from sailpoint.beta.models.launcher_owner import LauncherOwner
from sailpoint.beta.models.launcher_reference import LauncherReference
from typing import Optional, Set
from typing_extensions import Self

class Launcher(BaseModel):
    """
    Launcher
    """ # noqa: E501
    id: StrictStr = Field(description="ID of the Launcher")
    created: datetime = Field(description="Date the Launcher was created")
    modified: datetime = Field(description="Date the Launcher was last modified")
    owner: LauncherOwner
    name: StrictStr = Field(description="Name of the Launcher, limited to 255 characters")
    description: StrictStr = Field(description="Description of the Launcher, limited to 2000 characters")
    type: StrictStr = Field(description="Launcher type")
    disabled: StrictBool = Field(description="State of the Launcher")
    reference: Optional[LauncherReference] = None
    config: Annotated[str, Field(strict=True)] = Field(description="JSON configuration associated with this Launcher, restricted to a max size of 4KB ")
    __properties: ClassVar[List[str]] = ["id", "created", "modified", "owner", "name", "description", "type", "disabled", "reference", "config"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['INTERACTIVE_PROCESS']):
            raise ValueError("must be one of enum values ('INTERACTIVE_PROCESS')")
        return value

    @field_validator('config')
    def config_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if not re.match(r"^\{\}$", value):
            raise ValueError(r"must validate the regular expression /^\{\}$/")
        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 Launcher 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 owner
        if self.owner:
            _dict['owner'] = self.owner.to_dict()
        # override the default output from pydantic by calling `to_dict()` of reference
        if self.reference:
            _dict['reference'] = self.reference.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Launcher 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"),
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "owner": LauncherOwner.from_dict(obj["owner"]) if obj.get("owner") is not None else None,
            "name": obj.get("name"),
            "description": obj.get("description"),
            "type": obj.get("type"),
            "disabled": obj.get("disabled"),
            "reference": LauncherReference.from_dict(obj["reference"]) if obj.get("reference") is not None else None,
            "config": obj.get("config")
        })
        return _obj


