from defence360agent.rpc_tools import lookup
from defence360agent.utils import Scope
from im360.model import whitelisted_domains


class WhitelistedDomainsEndpoints(lookup.RootEndpoints):
    SCOPE = Scope.IM360

    @lookup.bind("whitelist", "domain", "add")
    async def whitelist_domain_add(self, domain):
        await whitelisted_domains.add_domain(domain)

    @lookup.bind("whitelist", "domain", "delete")
    async def whitelist_domain_delete(self, domain):
        await whitelisted_domains.del_domain(domain)

    @lookup.bind("whitelist", "domain", "list")
    async def whitelist_domain_list(self):
        return whitelisted_domains.get_list()

    @lookup.bind("whitelist", "domain", "reset-to")
    async def whitelist_domain_reset(self, domains):
        await whitelisted_domains.reset_domains(domains)
