Exemplo n.º 1
0
def get_domains(user_id=None, limit=None, offset=None):
    query =  DomainDatabase.query()
    if user_id is not None:
        if is_positive_numeric(user_id) is not True:
            raise Invalid('User id must be positive integer')
        query = query.filter(DomainDatabase.user_id==user_id)
    query = do_limits(query, limit, offset)
    return query.all()
Exemplo n.º 2
0
def get_domains(user_id=None, limit=None, offset=None):
    query = DomainDatabase.query()
    if user_id is not None:
        if is_positive_numeric(user_id) is not True:
            raise Invalid('User id must be positive integer')
        query = query.filter(DomainDatabase.user_id == user_id)
    query = do_limits(query, limit, offset)
    return query.all()
Exemplo n.º 3
0
def get_ports(user_id=None, limit=None, offset=None):
    query = PortDatabase.query()

    if user_id is not None:
        try:
            Users.get(user_id)
        except DoesNotExist:
            raise
        query = query.filter(PortDatabase.user_id == user_id)

    query = query.filter(PortDatabase.user_id == user_id)
    query = do_limits(query, limit, offset)
    return query.all()
Exemplo n.º 4
0
def get_ports(user_id=None, limit=None, offset=None):
    query = PortDatabase.query()

    if user_id is not None:
        try:
            Users.get(user_id)
        except DoesNotExist:
            raise
        query = query.filter(PortDatabase.user_id == user_id)

    query = query.filter(PortDatabase.user_id == user_id)
    query = do_limits(query, limit, offset)
    return query.all()
Exemplo n.º 5
0
def get_dns_zone(user_id, domain_id, limit=None, offset=None):
    if is_positive_numeric(user_id) is not True:
        raise Invalid("User id must be positive integer")
    elif is_positive_numeric(domain_id) is not True:
        raise Invalid("User id must be positive integer")
    zonequery = DNSZoneDatabase.query()
    zonequery = zonequery.filter(DNSZoneDatabase.domain_id == domain_id)
    zonequery = zonequery.filter(DNSZoneDatabase.domain.has(DomainDatabase.user_id == user_id))
    zonequery = do_limits(zonequery, limit, offset)
    try:
        return zonequery.one()
    except NoResultFound:
        pass
    raise DoesNotExist("DNS entry for domain %s does not exist" % domain_id)
Exemplo n.º 6
0
def get_port_history(user_id=None, limit=None, offset=None):
    PortHistory = PortDatabase.__history_mapper__.class_
    query = PortHistory.query()

    if user_id is not None:
        try:
            Users.get(user_id)
        except DoesNotExist:
            raise
        query = query.filter(PortHistory.user_id == user_id)

    query = query.filter(PortHistory.user_id == user_id)
    query = do_limits(query, limit, offset)
    return query.all()
Exemplo n.º 7
0
def get_port_history(user_id=None, limit=None, offset=None):
    PortHistory = PortDatabase.__history_mapper__.class_
    query = PortHistory.query()

    if user_id is not None:
        try:
            Users.get(user_id)
        except DoesNotExist:
            raise
        query = query.filter(PortHistory.user_id == user_id)

    query = query.filter(PortHistory.user_id == user_id)
    query = do_limits(query, limit, offset)
    return query.all()
Exemplo n.º 8
0
def get_dns_zone(user_id, domain_id, limit=None, offset=None):
    if is_positive_numeric(user_id) is not True:
        raise Invalid('User id must be positive integer')
    elif is_positive_numeric(domain_id) is not True:
        raise Invalid('User id must be positive integer')
    zonequery = DNSZoneDatabase.query()
    zonequery = zonequery.filter(DNSZoneDatabase.domain_id == domain_id)
    zonequery = zonequery.filter(
        DNSZoneDatabase.domain.has(DomainDatabase.user_id == user_id))
    zonequery = do_limits(zonequery, limit, offset)
    try:
        return zonequery.one()
    except NoResultFound:
        pass
    raise DoesNotExist("DNS entry for domain %s does not exist" % domain_id)
Exemplo n.º 9
0
def get_user_repositories(user_id=None, limit=None, offset=None, repo_type=None):
    query = RepositoryDatabase.query()

    if user_id is not None:
        try:
            Users.get(user_id)
        except DoesNotExist:
            raise
        query.filter(RepositoryDatabase.user_id == user_id)

    if repo_type is not None:
        query.filter(RepositoryDatabase.repo_type == repo_type)

    query = do_limits(query, limit, offset)
    return query.all()
Exemplo n.º 10
0
def get_dns_records(user_id, domain_id, offset=None, limit=None):
    zone = get_dns_zone(user_id, domain_id)
    q = DNSRecordDatabase.query().filter(
        DNSRecordDatabase.dns_zone_id == zone.id)
    q = do_limits(q, limit, offset)
    return q.all()
Exemplo n.º 11
0
def get_dns_records(user_id, domain_id, offset=None, limit=None):
    zone = get_dns_zone(user_id, domain_id)
    q = DNSRecordDatabase.query().filter(DNSRecordDatabase.dns_zone_id == zone.id)
    q = do_limits(q, limit, offset)
    return q.all()