# coding: utf-8

"""
    Artifact Keeper API

    Enterprise artifact registry supporting 45+ package formats.

    The version of the OpenAPI document: 1.0.0-rc.3
    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 pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class UpdateLdapConfigRequest(BaseModel):
    """
    UpdateLdapConfigRequest
    """ # noqa: E501
    admin_group_dn: Optional[StrictStr] = None
    bind_dn: Optional[StrictStr] = None
    bind_password: Optional[StrictStr] = None
    display_name_attribute: Optional[StrictStr] = None
    email_attribute: Optional[StrictStr] = None
    group_base_dn: Optional[StrictStr] = None
    group_filter: Optional[StrictStr] = None
    groups_attribute: Optional[StrictStr] = None
    is_enabled: Optional[StrictBool] = None
    name: Optional[StrictStr] = None
    priority: Optional[StrictInt] = None
    server_url: Optional[StrictStr] = None
    use_starttls: Optional[StrictBool] = None
    user_base_dn: Optional[StrictStr] = None
    user_filter: Optional[StrictStr] = None
    username_attribute: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["admin_group_dn", "bind_dn", "bind_password", "display_name_attribute", "email_attribute", "group_base_dn", "group_filter", "groups_attribute", "is_enabled", "name", "priority", "server_url", "use_starttls", "user_base_dn", "user_filter", "username_attribute"]

    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 UpdateLdapConfigRequest 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,
        )
        # set to None if admin_group_dn (nullable) is None
        # and model_fields_set contains the field
        if self.admin_group_dn is None and "admin_group_dn" in self.model_fields_set:
            _dict['admin_group_dn'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "admin_group_dn": obj.get("admin_group_dn"),
            "bind_dn": obj.get("bind_dn"),
            "bind_password": obj.get("bind_password"),
            "display_name_attribute": obj.get("display_name_attribute"),
            "email_attribute": obj.get("email_attribute"),
            "group_base_dn": obj.get("group_base_dn"),
            "group_filter": obj.get("group_filter"),
            "groups_attribute": obj.get("groups_attribute"),
            "is_enabled": obj.get("is_enabled"),
            "name": obj.get("name"),
            "priority": obj.get("priority"),
            "server_url": obj.get("server_url"),
            "use_starttls": obj.get("use_starttls"),
            "user_base_dn": obj.get("user_base_dn"),
            "user_filter": obj.get("user_filter"),
            "username_attribute": obj.get("username_attribute")
        })
        return _obj


