Toggle diagnostics per server

In the old API i used to use this snippet provided by @mjlbach for diagnostics toggling

virtual_text = {}

virtual_text.show = true

virtual_text.toggle = function()
    virtual_text.show = not virtual_text.show
    vim.lsp.diagnostic.display(
        vim.lsp.diagnostic.get(0, 1),
        0,
        1,
        {virtual_text = virtual_text.show}
    )
end

vim.api.nvim_set_keymap(
    'n',
    '<Leader>lv',
    '<Cmd>lua virtual_text.toggle()<CR>',
    {silent=true, noremap=true}
)

But with the new API i just cant seem to figure out how to do the same, per server
I am having trouble understanding the namespace and how to do the above per server.
Does anyone have a working snippet that they can share?

Thanks in advance

Found certain functions in this plugin that helped me