예제 #1
0
 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)
예제 #2
0
파일: ttl.py 프로젝트: sofyan48/domba-api
 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)
예제 #3
0
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
예제 #4
0
파일: zone.py 프로젝트: sofyan48/domba-api
    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)
예제 #5
0
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
예제 #6
0
 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)
예제 #7
0
 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)