# 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 typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictStr
from pydantic import Field
from sailpoint.beta.models.sim_integration_details_all_of_before_provisioning_rule import SimIntegrationDetailsAllOfBeforeProvisioningRule
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class SimIntegrationDetails(BaseModel):
    """
    SimIntegrationDetails
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="System-generated unique ID of the Object")
    name: StrictStr = Field(description="Name of the Object")
    created: Optional[datetime] = Field(default=None, description="Creation date of the Object")
    modified: Optional[datetime] = Field(default=None, description="Last modification date of the Object")
    description: Optional[StrictStr] = Field(default=None, description="The description of the integration")
    type: Optional[StrictStr] = Field(default=None, description="The integration type")
    attributes: Optional[Dict[str, Any]] = Field(default=None, description="The attributes map containing the credentials used to configure the integration.")
    sources: Optional[List[StrictStr]] = Field(default=None, description="The list of sources (managed resources)")
    cluster: Optional[StrictStr] = Field(default=None, description="The cluster/proxy")
    status_map: Optional[Dict[str, Any]] = Field(default=None, description="Custom mapping between the integration result and the provisioning result", alias="statusMap")
    request: Optional[Dict[str, Any]] = Field(default=None, description="Request data to customize desc and body of the created ticket")
    before_provisioning_rule: Optional[SimIntegrationDetailsAllOfBeforeProvisioningRule] = Field(default=None, alias="beforeProvisioningRule")
    __properties: ClassVar[List[str]] = ["id", "name", "created", "modified", "description", "type", "attributes", "sources", "cluster", "statusMap", "request", "beforeProvisioningRule"]

    model_config = {
        "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) -> Self:
        """Create an instance of SimIntegrationDetails 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
                "id",
                "created",
                "modified",
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of before_provisioning_rule
        if self.before_provisioning_rule:
            _dict['beforeProvisioningRule'] = self.before_provisioning_rule.to_dict()
        # set to None if attributes (nullable) is None
        # and model_fields_set contains the field
        if self.attributes is None and "attributes" in self.model_fields_set:
            _dict['attributes'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of SimIntegrationDetails 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"),
            "name": obj.get("name"),
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "description": obj.get("description"),
            "type": obj.get("type"),
            "attributes": obj.get("attributes"),
            "sources": obj.get("sources"),
            "cluster": obj.get("cluster"),
            "statusMap": obj.get("statusMap"),
            "request": obj.get("request"),
            "beforeProvisioningRule": SimIntegrationDetailsAllOfBeforeProvisioningRule.from_dict(obj.get("beforeProvisioningRule")) if obj.get("beforeProvisioningRule") is not None else None
        })
        return _obj


