#
#   © Copyright 2020 Hewlett Packard Enterprise Development LP
#
#   This file was auto-generated by the Python SDK generator; DO NOT EDIT.
#


from ...resource import Resource, Collection


class LdapDomain(Resource):
    """Manages the storage array's membership with LDAP servers.

    # Parameters
    id                     : Identifier for the LDAP Domain.
    domain_name            : Domain name.
    domain_description     : Description of the domain.
    domain_enabled         : Indicates whether the LDAP domain is currently active or not.
    server_uri_list        : A set of up to 3 LDAP URIs.
    bind_user              : Full Distinguished Name of LDAP admin user. If empty, attempt to bind anonymously.
    bind_password          : Password for the Full Distinguished Name of LDAP admin user.  This parameter is mandatory if the bind_user is given.
    base_dn                : The Distinguished Name of the base object from which to start all searches.
    user_search_filter     : Limit the results returned based on specific search criteria.
    user_search_base_list  : A set of upto 10 Relative Distinguished Names, relative to the Base DN, from which to search for User objects.
    group_search_filter    : Limit the results returned based on specific search criteria.
    group_search_base_list : A set of upto 10 Relative Distinguished Names, relative to the Base DN, from which to search for Group objects.
    schema_type            : Enum values are OpenLDAP or AD.
    """
    def test_user(self, user, **kwargs):
        """Tests whether the user exist in the given LDAP Domain.

        # Parameters
        id   : Unique identifier for the LDAP Domain.
        user : Name of the LDAP Domain user.
        """

        return self._collection.test_user(
            self.id,
            user,
            **kwargs
        )
    def test_group(self, group, **kwargs):
        """Tests whether the user group exist in the given LDAP Domain.

        # Parameters
        id    : Unique identifier for the LDAP Domain.
        group : Name of the group.
        """

        return self._collection.test_group(
            self.id,
            group,
            **kwargs
        )
    def report_status(self, **kwargs):
        """Reports the LDAP connectivity status of the given LDAP ID.

        # Parameters
        id : Unique identifier for the LDAP Domain.
        """

        return self._collection.report_status(
            self.id,
            **kwargs
        )


class LdapDomainList(Collection):
    resource = LdapDomain
    resource_type = "ldap_domains"

    def test_user(self, id, user, **kwargs):
        """Tests whether the user exist in the given LDAP Domain.

        # Parameters
        id   : Unique identifier for the LDAP Domain.
        user : Name of the LDAP Domain user.
        """

        return self._client.perform_resource_action(
            self.resource_type,
            id,
            'test_user',
            id=id,
            user=user,
            **kwargs
        )

    def test_group(self, id, group, **kwargs):
        """Tests whether the user group exist in the given LDAP Domain.

        # Parameters
        id    : Unique identifier for the LDAP Domain.
        group : Name of the group.
        """

        return self._client.perform_resource_action(
            self.resource_type,
            id,
            'test_group',
            group=group,
            id=id,
            **kwargs
        )

    def report_status(self, id, **kwargs):
        """Reports the LDAP connectivity status of the given LDAP ID.

        # Parameters
        id : Unique identifier for the LDAP Domain.
        """

        return self._client.perform_resource_action(
            self.resource_type,
            id,
            'report_status',
            id=id,
            **kwargs
        )

    def create(self, **kwargs):
        resp = self._client.create_resource(self.resource_type, **kwargs)
        return self.resource(resp['id'], resp, client=self._client, collection=self)
