def post(self, request): reqData = parseJson(request.body) mandatoryParams(reqData, 'domain') # Filter for current user user = request.user try: domain = core.models.DomainModel.objects.get( domain_name=reqData['domain'], user=user) except core.models.DomainModel.DoesNotExist: return makeError('Invalid domain id: {domain}', reqData) res = core.hostjobs.DomainJobs(domain.host.main_domain, user.username).enableSsl(reqData) return JsonResponse({'completed': False, 'id': taskToId(res)})
def put(self, request): reqData = parseJson(request.body) mandatoryParams(reqData, 'domain', 'publicKey') # Filter for current user user = request.user reqData['user'] = user.username try: domain = core.models.DomainModel.objects.get( domain_name=reqData['domain'], user=user) except ObjectDoesNotExist: return makeError('Invalid domain id: {domain}', reqData) if not domain.host: return makeError('Domain [{domain}] has no host attached.', reqData) res = core.hostjobs.DomainJobs(domain.host.main_domain, user.username).addPublicKey(reqData) return JsonResponse({'completed': False, 'id': taskToId(res)})
def delete(self, request): reqData = parseJson(request.body) params = mandatoryParams(reqData, 'db_user', 'db_name', 'host') try: host = core.models.Host.objects.get(main_domain=params['host']) except core.models.Host.DoesNotExist: return makeError('Host does not exists: {host}', params) params['db_type'] = self.DB_TYPE res = core.hostjobs.DatabaseJobs(host.main_domain, request.user.username).remove(params) return JsonResponse({'completed': False, 'id': taskToId(res)})
def post(self, request): reqData = parseJson(request.body) reqData = mandatoryParams(reqData, 'domain') # Filter for current user user = request.user try: domain = core.models.DomainModel.objects.get( domain_name=reqData['domain']) except ObjectDoesNotExist: return makeError("Domain doesn't exist exists: {domain}", reqData) if not domain.host: return makeError('Domain [{domain}] has no host attached.', reqData) reqData['host'] = domain.host.main_domain reqData['app_type'] = domain.app_type.to_dict(json=True) res = core.hostjobs.DomainJobs(domain.host.main_domain, user.username).create(reqData) return JsonResponse({'completed': False, 'id': taskToId(res)})
def post(self, request): reqData = parseJson(request.body) reqData = mandatoryParams(reqData, 'domain', 'app_type', 'host') # Filter for current user user = request.user try: core.models.DomainModel.objects.get(domain_name=reqData['domain']) return makeError('Domain already exists: {domain}', reqData) except ObjectDoesNotExist: pass try: host = core.models.Host.objects.get(main_domain=reqData['host']) except ObjectDoesNotExist: return makeError('Host does not exists: {host}', reqData) try: app_type = core.models.ContainerRuntime.objects.get( id=reqData['app_type']) except ObjectDoesNotExist: return makeError('app_type does not exists: {host}', reqData) reqData['app_type'] = app_type.to_dict(json=True) res = core.hostjobs.DomainJobs(host.main_domain, user.username).create(reqData) return JsonResponse({'completed': False, 'id': taskToId(res)})