# 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, StrictBool, StrictStr, field_validator
from pydantic import Field
from sailpoint.beta.models.attribute_definition import AttributeDefinition
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class ModelSchema(BaseModel):
    """
    ModelSchema
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="The id of the Schema.")
    name: Optional[StrictStr] = Field(default=None, description="The name of the Schema.")
    native_object_type: Optional[StrictStr] = Field(default=None, description="The name of the object type on the native system that the schema represents.", alias="nativeObjectType")
    identity_attribute: Optional[StrictStr] = Field(default=None, description="The name of the attribute used to calculate the unique identifier for an object in the schema.", alias="identityAttribute")
    display_attribute: Optional[StrictStr] = Field(default=None, description="The name of the attribute used to calculate the display value for an object in the schema.", alias="displayAttribute")
    hierarchy_attribute: Optional[StrictStr] = Field(default=None, description="The name of the attribute whose values represent other objects in a hierarchy. Only relevant to group schemas.", alias="hierarchyAttribute")
    include_permissions: Optional[StrictBool] = Field(default=None, description="Flag indicating whether or not the include permissions with the object data when aggregating the schema.", alias="includePermissions")
    features: Optional[List[StrictStr]] = Field(default=None, description="Optional features that can be supported by a source. Modifying the features array may cause source configuration errors that are unsupportable. It is recommended to not modify this array for SailPoint supported connectors. * AUTHENTICATE: The source supports pass-through authentication. * COMPOSITE: The source supports composite source creation. * DIRECT_PERMISSIONS: The source supports returning DirectPermissions. * DISCOVER_SCHEMA: The source supports discovering schemas for users and groups. * ENABLE The source supports reading if an account is enabled or disabled. * MANAGER_LOOKUP: The source supports looking up managers as they are encountered in a feed. This is the opposite of NO_RANDOM_ACCESS. * NO_RANDOM_ACCESS: The source does not support random access and the getObject() methods should not be called and expected to perform. * PROXY: The source can serve as a proxy for another source. When an source has a proxy, all connector calls made with that source are redirected through the connector for the proxy source. * SEARCH * TEMPLATE * UNLOCK: The source supports reading if an account is locked or unlocked. * UNSTRUCTURED_TARGETS: The source supports returning unstructured Targets. * SHAREPOINT_TARGET: The source supports returning unstructured Target data for SharePoint. It will be typically used by AD, LDAP sources. * PROVISIONING: The source can both read and write accounts. Having this feature implies that the provision() method is implemented. It also means that direct and target permissions can also be provisioned if they can be returned by aggregation. * GROUP_PROVISIONING: The source can both read and write groups. Having this feature implies that the provision() method is implemented. * SYNC_PROVISIONING: The source can provision accounts synchronously. * PASSWORD: The source can provision password changes. Since sources can never read passwords, this is should only be used in conjunction with the PROVISIONING feature. * CURRENT_PASSWORD: Some source types support verification of the current password * ACCOUNT_ONLY_REQUEST: The source supports requesting accounts without entitlements. * ADDITIONAL_ACCOUNT_REQUEST: The source supports requesting additional accounts. * NO_AGGREGATION: A source that does not support aggregation. * GROUPS_HAVE_MEMBERS: The source models group memberships with a member attribute on the group object rather than a groups attribute on the account object. This effects the implementation of delta account aggregation. * NO_PERMISSIONS_PROVISIONING: Indicates that the connector cannot provision direct or target permissions for accounts. When DIRECT_PERMISSIONS and PROVISIONING features are present, it is assumed that the connector can also provision direct permissions. This feature disables that assumption and causes permission request to be converted to work items for accounts. * NO_GROUP_PERMISSIONS_PROVISIONING: Indicates that the connector cannot provision direct or target permissions for groups. When DIRECT_PERMISSIONS and PROVISIONING features are present, it is assumed that the connector can also provision direct permissions. This feature disables that assumption and causes permission request to be converted to work items for groups. * NO_UNSTRUCTURED_TARGETS_PROVISIONING: This string will be replaced by NO_GROUP_PERMISSIONS_PROVISIONING and NO_PERMISSIONS_PROVISIONING. * NO_DIRECT_PERMISSIONS_PROVISIONING: This string will be replaced by NO_GROUP_PERMISSIONS_PROVISIONING and NO_PERMISSIONS_PROVISIONING. * USES_UUID: Connectivity 2.0 flag used to indicate that the connector supports a compound naming structure. * PREFER_UUID: Used in ISC Provisioning AND Aggregation to decide if it should prefer account.uuid to account.nativeIdentity when data is read in through aggregation OR pushed out through provisioning. * ARM_SECURITY_EXTRACT: Indicates the application supports Security extracts for ARM * ARM_UTILIZATION_EXTRACT: Indicates the application supports Utilization extracts for ARM * ARM_CHANGELOG_EXTRACT: Indicates the application supports Change-log extracts for ARM")
    configuration: Optional[Dict[str, Any]] = Field(default=None, description="Holds any extra configuration data that the schema may require.")
    attributes: Optional[List[AttributeDefinition]] = Field(default=None, description="The attribute definitions which form the schema.")
    created: Optional[datetime] = Field(default=None, description="The date the Schema was created.")
    modified: Optional[datetime] = Field(default=None, description="The date the Schema was last modified.")
    __properties: ClassVar[List[str]] = ["id", "name", "nativeObjectType", "identityAttribute", "displayAttribute", "hierarchyAttribute", "includePermissions", "features", "configuration", "attributes", "created", "modified"]

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

        for i in value:
            if i not in ('AUTHENTICATE', 'COMPOSITE', 'DIRECT_PERMISSIONS', 'DISCOVER_SCHEMA', 'ENABLE', 'MANAGER_LOOKUP', 'NO_RANDOM_ACCESS', 'PROXY', 'SEARCH', 'TEMPLATE', 'UNLOCK', 'UNSTRUCTURED_TARGETS', 'SHAREPOINT_TARGET', 'PROVISIONING', 'GROUP_PROVISIONING', 'SYNC_PROVISIONING', 'PASSWORD', 'CURRENT_PASSWORD', 'ACCOUNT_ONLY_REQUEST', 'ADDITIONAL_ACCOUNT_REQUEST', 'NO_AGGREGATION', 'GROUPS_HAVE_MEMBERS', 'NO_PERMISSIONS_PROVISIONING', 'NO_GROUP_PERMISSIONS_PROVISIONING', 'NO_UNSTRUCTURED_TARGETS_PROVISIONING', 'NO_DIRECT_PERMISSIONS_PROVISIONING', 'PREFER_UUID', 'ARM_SECURITY_EXTRACT', 'ARM_UTILIZATION_EXTRACT', 'ARM_CHANGELOG_EXTRACT', 'USES_UUID'):
                raise ValueError("each list item must be one of ('AUTHENTICATE', 'COMPOSITE', 'DIRECT_PERMISSIONS', 'DISCOVER_SCHEMA', 'ENABLE', 'MANAGER_LOOKUP', 'NO_RANDOM_ACCESS', 'PROXY', 'SEARCH', 'TEMPLATE', 'UNLOCK', 'UNSTRUCTURED_TARGETS', 'SHAREPOINT_TARGET', 'PROVISIONING', 'GROUP_PROVISIONING', 'SYNC_PROVISIONING', 'PASSWORD', 'CURRENT_PASSWORD', 'ACCOUNT_ONLY_REQUEST', 'ADDITIONAL_ACCOUNT_REQUEST', 'NO_AGGREGATION', 'GROUPS_HAVE_MEMBERS', 'NO_PERMISSIONS_PROVISIONING', 'NO_GROUP_PERMISSIONS_PROVISIONING', 'NO_UNSTRUCTURED_TARGETS_PROVISIONING', 'NO_DIRECT_PERMISSIONS_PROVISIONING', 'PREFER_UUID', 'ARM_SECURITY_EXTRACT', 'ARM_UTILIZATION_EXTRACT', 'ARM_CHANGELOG_EXTRACT', 'USES_UUID')")
        return value

    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 ModelSchema 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in attributes (list)
        _items = []
        if self.attributes:
            for _item in self.attributes:
                if _item:
                    _items.append(_item.to_dict())
            _dict['attributes'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of ModelSchema 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"),
            "nativeObjectType": obj.get("nativeObjectType"),
            "identityAttribute": obj.get("identityAttribute"),
            "displayAttribute": obj.get("displayAttribute"),
            "hierarchyAttribute": obj.get("hierarchyAttribute"),
            "includePermissions": obj.get("includePermissions"),
            "features": obj.get("features"),
            "configuration": obj.get("configuration"),
            "attributes": [AttributeDefinition.from_dict(_item) for _item in obj.get("attributes")] if obj.get("attributes") is not None else None,
            "created": obj.get("created"),
            "modified": obj.get("modified")
        })
        return _obj


