# 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
import warnings

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from sailpoint.beta.models.multi_host_integrations_cluster import MultiHostIntegrationsCluster
from sailpoint.beta.models.multi_host_integrations_connector_attributes import MultiHostIntegrationsConnectorAttributes
from sailpoint.beta.models.multi_host_integrations_management_workgroup import MultiHostIntegrationsManagementWorkgroup
from sailpoint.beta.models.multi_host_integrations_owner import MultiHostIntegrationsOwner
from typing import Optional, Set
from typing_extensions import Self

class MultiHostIntegrations(BaseModel):
    """
    MultiHostIntegrations
    """ # noqa: E501
    id: StrictStr = Field(description="Multi-Host Integration ID.")
    name: StrictStr = Field(description="Multi-Host Integration's human-readable name.")
    description: StrictStr = Field(description="Multi-Host Integration's human-readable description.")
    owner: MultiHostIntegrationsOwner
    cluster: Optional[MultiHostIntegrationsCluster] = None
    type: Optional[StrictStr] = Field(default=None, description="Specifies the type of system being managed e.g. Workday, Multi-Host - Microsoft SQL Server, etc.. If you are creating a delimited file source, you must set the `provisionasCsv` query parameter to `true`. ")
    connector: StrictStr = Field(description="Connector script name.")
    last_source_upload_success_count: Optional[StrictInt] = Field(default=None, description="Last successfully uploaded source count of given Multi-Host Integration.", alias="lastSourceUploadSuccessCount")
    max_sources_per_agg_group: Optional[StrictInt] = Field(default=None, description="Maximum sources that can contain in a aggregation group of Multi-Host Integration.", alias="maxSourcesPerAggGroup")
    connector_class: Optional[StrictStr] = Field(default=None, description="Fully qualified name of the Java class that implements the connector interface.", alias="connectorClass")
    connector_attributes: Optional[MultiHostIntegrationsConnectorAttributes] = Field(default=None, alias="connectorAttributes")
    delete_threshold: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(default=None, description="Number from 0 to 100 that specifies when to skip the delete phase.", alias="deleteThreshold")
    authoritative: Optional[StrictBool] = Field(default=False, description="When this is true, it indicates that the source is referenced by an identity profile.")
    management_workgroup: Optional[MultiHostIntegrationsManagementWorkgroup] = Field(default=None, alias="managementWorkgroup")
    healthy: Optional[StrictBool] = Field(default=False, description="When this is true, it indicates that the source is healthy.")
    status: Optional[StrictStr] = Field(default=None, description="Status identifier that gives specific information about why a source is or isn't healthy. ")
    since: Optional[datetime] = Field(default=None, description="Timestamp that shows when a source health check was last performed.")
    connector_id: Optional[StrictStr] = Field(default=None, description="Connector ID", alias="connectorId")
    connector_name: Optional[StrictStr] = Field(default=None, description="Name of the connector that was chosen during source creation.", alias="connectorName")
    connection_type: Optional[StrictStr] = Field(default=None, description="Type of connection (direct or file).", alias="connectionType")
    connector_implementation_id: Optional[StrictStr] = Field(default=None, description="Connector implementation ID.", alias="connectorImplementationId")
    created: Optional[datetime] = Field(default=None, description="Date-time when the source was created")
    modified: Optional[datetime] = Field(default=None, description="Date-time when the source was last modified.")
    credential_provider_enabled: Optional[StrictBool] = Field(default=False, description="If this is true, it enables a credential provider for the source. If credentialProvider is turned on,  then the source can use credential provider(s) to fetch credentials.", alias="credentialProviderEnabled")
    category: Optional[StrictStr] = Field(default=None, description="Source category (e.g. null, CredentialProvider).")
    __properties: ClassVar[List[str]] = ["id", "name", "description", "owner", "cluster", "type", "connector", "lastSourceUploadSuccessCount", "maxSourcesPerAggGroup", "connectorClass", "connectorAttributes", "deleteThreshold", "authoritative", "managementWorkgroup", "healthy", "status", "since", "connectorId", "connectorName", "connectionType", "connectorImplementationId", "created", "modified", "credentialProviderEnabled", "category"]

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

        if value not in set(['SOURCE_STATE_ERROR_ACCOUNT_FILE_IMPORT', 'SOURCE_STATE_ERROR_CLUSTER', 'SOURCE_STATE_ERROR_SOURCE', 'SOURCE_STATE_ERROR_VA', 'SOURCE_STATE_FAILURE_CLUSTER', 'SOURCE_STATE_FAILURE_SOURCE', 'SOURCE_STATE_HEALTHY', 'SOURCE_STATE_UNCHECKED_CLUSTER', 'SOURCE_STATE_UNCHECKED_CLUSTER_NO_SOURCES', 'SOURCE_STATE_UNCHECKED_SOURCE', 'SOURCE_STATE_UNCHECKED_SOURCE_NO_ACCOUNTS']):
            warnings.warn(f"must be one of enum values ('SOURCE_STATE_ERROR_ACCOUNT_FILE_IMPORT', 'SOURCE_STATE_ERROR_CLUSTER', 'SOURCE_STATE_ERROR_SOURCE', 'SOURCE_STATE_ERROR_VA', 'SOURCE_STATE_FAILURE_CLUSTER', 'SOURCE_STATE_FAILURE_SOURCE', 'SOURCE_STATE_HEALTHY', 'SOURCE_STATE_UNCHECKED_CLUSTER', 'SOURCE_STATE_UNCHECKED_CLUSTER_NO_SOURCES', 'SOURCE_STATE_UNCHECKED_SOURCE', 'SOURCE_STATE_UNCHECKED_SOURCE_NO_ACCOUNTS') unknown value: {value}")
        return value

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

        if value not in set(['direct', 'file']):
            warnings.warn(f"must be one of enum values ('direct', 'file') unknown value: {value}")
        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 MultiHostIntegrations 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.
        """
        excluded_fields: Set[str] = set([
            "id",
        ])

        _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 cluster
        if self.cluster:
            _dict['cluster'] = self.cluster.to_dict()
        # override the default output from pydantic by calling `to_dict()` of connector_attributes
        if self.connector_attributes:
            _dict['connectorAttributes'] = self.connector_attributes.to_dict()
        # override the default output from pydantic by calling `to_dict()` of management_workgroup
        if self.management_workgroup:
            _dict['managementWorkgroup'] = self.management_workgroup.to_dict()
        # set to None if cluster (nullable) is None
        # and model_fields_set contains the field
        if self.cluster is None and "cluster" in self.model_fields_set:
            _dict['cluster'] = None

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of MultiHostIntegrations 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"),
            "description": obj.get("description"),
            "owner": MultiHostIntegrationsOwner.from_dict(obj["owner"]) if obj.get("owner") is not None else None,
            "cluster": MultiHostIntegrationsCluster.from_dict(obj["cluster"]) if obj.get("cluster") is not None else None,
            "type": obj.get("type"),
            "connector": obj.get("connector"),
            "lastSourceUploadSuccessCount": obj.get("lastSourceUploadSuccessCount"),
            "maxSourcesPerAggGroup": obj.get("maxSourcesPerAggGroup"),
            "connectorClass": obj.get("connectorClass"),
            "connectorAttributes": MultiHostIntegrationsConnectorAttributes.from_dict(obj["connectorAttributes"]) if obj.get("connectorAttributes") is not None else None,
            "deleteThreshold": obj.get("deleteThreshold"),
            "authoritative": obj.get("authoritative") if obj.get("authoritative") is not None else False,
            "managementWorkgroup": MultiHostIntegrationsManagementWorkgroup.from_dict(obj["managementWorkgroup"]) if obj.get("managementWorkgroup") is not None else None,
            "healthy": obj.get("healthy") if obj.get("healthy") is not None else False,
            "status": obj.get("status"),
            "since": obj.get("since"),
            "connectorId": obj.get("connectorId"),
            "connectorName": obj.get("connectorName"),
            "connectionType": obj.get("connectionType"),
            "connectorImplementationId": obj.get("connectorImplementationId"),
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "credentialProviderEnabled": obj.get("credentialProviderEnabled") if obj.get("credentialProviderEnabled") is not None else False,
            "category": obj.get("category")
        })
        return _obj


