usmannasir / cyberpanel

Cyber Panel - The hosting control panel for OpenLiteSpeed
GNU General Public License v3.0
1.53k stars 592 forks source link

[FEATURE] listChildDomainsJson #1120

Open Lvl4Sword opened 1 year ago

Lvl4Sword commented 1 year ago

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 commented 10 months ago

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 commented 10 months ago

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