def remove_permissions()

in ees_microsoft_teams/enterprise_search_wrapper.py [0:0]


    def remove_permissions(self, permission):
        """Removes one or more permissions from an existing set of permissions
        :param permission: dictionary containing permission of particular user
        """
        try:
            if self.version >= ENTERPRISE_V8:
                if permission.get("external_user_properties"):
                    user_name = permission["external_user_properties"][0]["attribute_value"]
                    self.workplace_search_client.delete_external_identity(
                        content_source_id=self.ws_source, external_user_id=user_name
                    )
                else:
                    raise ValueError("Incompatible version")
            else:
                try:
                    user_name = permission["user"]
                    self.workplace_search_client.remove_user_permissions(
                        content_source_id=self.ws_source,
                        user=user_name,
                        body={"permissions": permission["permissions"]},
                    )
                except elastic_transport.exceptions.NotFoundError:
                    raise ValueError("Incompatible version")
            self.logger.info("Successfully removed the permissions from the Workplace Search.")
        except ValueError as error:
            raise ValueError(f"Please compare the Enterprise Search version used while running the installation \
                                to the version of Enterprise Search installed. Error: {error}")
        except Exception as exception:
            self.logger.exception(
                f"Error while removing the permissions from the workplace. Error: {exception}"
            )