def get(self, project_id): results = list() user = dict() try: data_user = model.read_all("user") except Exception as e: return response(401, message=str(e)) else: for i in data_user: if i['project_id'] == project_id: user = i break try: data_zone = model.read_all("zone") except Exception as e: return response(401, message=str(e)) else: for i in data_zone: if i['user'] == user['key']: user = model.read_by_id("user", i['user']) record = model.record_by_zone(i['key']) data = { "key": i['key'], "value": i['value'], "created_at": i['created_at'], "user": user, "record": record } results.append(data) return response(200, data=results)
def get(self): try: data = model.read_all("ttl") except Exception as e: return response(401, message=str(e)) else: return response(200, data=data)
def record_mx_duplicate(record, types, zone): try: data_record = model.read_all("record") except Exception as e: pass else: result = False for i in data_record: type_data = model.read_by_id("type", types) if zone == i['zone']: if record == i['value'] and type_data['value'] == 'MX': result = True break return result
def get(self): results = list() try: data_zone = model.read_all("zone") except Exception as e: return response(401, message=str(e)) for i in data_zone: user_data = model.read_by_id("user", i['user']) data = { "key": i['key'], "value": i['value'], "created_at": i['created_at'], "user": user_data } results.append(data) return response(200, data=results)
def check_unique(stored, field, value, key=None): results = False try: all_data = model.read_all(stored) except Exception: results = False else: for i in all_data: if i[field] == value: if key is not None: if key == i['key']: results = False else: results = True else: results = True break return results
def get(self): result = list() try: data_serial = model.read_all("serial") except Exception as e: return response(401, message=str(e)) else: for i in data_serial: record = model.read_by_id("record", i["record"]) types = model.read_by_id("type", record['type']) ttl = model.read_by_id("ttl", record['ttl']) zone = model.read_by_id("zone", record['zone']) data = { "key": i['key'], "name": i['name'], "value": i['value'], "record": record, "ttl": ttl, "type": types, "zone": zone } result.append(data) return response(200, data=result)
def get(self): results = list() try: data_content = model.read_all("content") print(data_content) except Exception as e: return response(401, message=str(e)) else: for i in data_content: record = model.read_by_id("record", i['record']) types = model.read_by_id("type", record['type']) ttl = model.read_by_id("ttl", record['ttl']) zone = model.read_by_id("zone", record['zone']) data = { "key": i['key'], "value": i['value'], "created_at": i['created_at'], "record": record, "ttl": ttl, "type": types, "zone": zone } results.append(data) return response(200, data=results)