cyberpanel icon indicating copy to clipboard operation
cyberpanel copied to clipboard

[FEATURE] listChildDomainsJson

Open Lvl4Sword opened this issue 11 months ago • 2 comments

An ability to listChildDomainsJson through CyberPanel's API much like listWebsitesJson would be great. ChildDomains in websiteFunctions/models.py already gives this information and would be easy enough to get, like how listWebsitesJson works

Lvl4Sword avatar Aug 25 '23 00:08 Lvl4Sword

This is more or less what this will be. Just need to setup a PR:

    def listChildDomainsJson(self):
        try:
            child_domains = ChildDomains.objects.all()
            ipFile = "/etc/cyberpanel/machineIP"
            with open(ipFile, 'r') as f:
                ipData = f.read()
            ipAddress = ipData.split('\n', 1)[0]
            json_data = []
            for items in child_domains:
                dic = {'parent_site': items.master.domain,
                       'domain': items.domain,
                       'path': items.path,
                       'ssl': items.ssl,
                       'php_version': items.phpSelection}
                json_data.append(dic)
            final_json = json.dumps(json_data)
            print(final_json)
        except BaseException as msg:
            logger.writeforCLI(str(msg), "Error", stack()[0][3])
            print(0)

Lvl4Sword avatar Dec 06 '23 23:12 Lvl4Sword

@usmannasir Would it be acceptable if I did args.function = args.function.casefold(), so upper/lowercase doesn't matter when typing a function?

Lvl4Sword avatar Dec 06 '23 23:12 Lvl4Sword