Esempio n. 1
0
def get_recent_entity_changes(db: Session, entity_id: int, params: Params = DEFAULT_PARAMS) \
        -> Page[ChangeRequest]:
    q = db.query(ChangeRequest)\
        .filter(ChangeRequest.object_id == entity_id,
                ChangeRequest.object_type == EditableObjectType.ENTITY)\
        .order_by(ChangeRequest.created_at.desc())
    return paginate(q, params)
Esempio n. 2
0
def read_tickets(db: Session = Depends(deps.get_db),
                 request: ReadTicketsGetParams = Depends()) -> Any:
    """
    Retrieve tickets.
    """
    service = TicketService(db).get_paginate_query(request=request)
    result = handle_result(service)
    return paginate(result)
Esempio n. 3
0
def read_claims(
    db: Session = Depends(deps.get_db),
    request: ReadClaimsGetParams = Depends()
) -> t.Any:
    """
    Retrieve claims.
    """
    service = ClaimService(db).get_paginate_query(request=request)
    result = handle_result(service)
    return paginate(result)
Esempio n. 4
0
File: crud.py Progetto: SUSE/aimaas
def get_pending_change_requests(db: Session, params: Params = DEFAULT_PARAMS,
                                obj_type: Optional[EditableObjectType] = None) \
        -> Page[ChangeRequest]:
    q = db.query(ChangeRequest) \
        .filter(ChangeRequest.status == ChangeStatus.PENDING) \
        .order_by(ChangeRequest.created_at.desc())

    if obj_type:
        q = q.filter(ChangeRequest.object_type == obj_type)

    return paginate(q, params)
Esempio n. 5
0
def get_recent_schema_changes(db: Session, schema_id: int, params: Params = DEFAULT_PARAMS) \
        -> Page[ChangeRequest]:
    pending_entity_creations = db.query(ChangeRequest)\
        .filter(ChangeRequest.status == ChangeStatus.PENDING,
                ChangeRequest.change_type == ChangeType.CREATE,
                ChangeRequest.object_type == EditableObjectType.ENTITY)\
        .join(Change)\
        .filter(Change.field_name == 'schema_id')\
        .join(ChangeValueInt, Change.value_id == ChangeValueInt.id)\
        .filter(ChangeValueInt.new_value == schema_id)\
        .distinct()
    schema_history = db.query(ChangeRequest)\
        .filter(ChangeRequest.object_id == schema_id,
                ChangeRequest.object_type == EditableObjectType.SCHEMA)
    q = pending_entity_creations.union(schema_history)\
        .order_by(ChangeRequest.created_at.desc(), ChangeRequest.status == ChangeStatus.PENDING)
    return paginate(q, params)
Esempio n. 6
0
async def get_discoveries(
        conn_id: int,
        plan_id,
        plan_instance_id: int,
        rule_id: Optional[int] = None,
        db: Session = Depends(get_db),
        params: Params = Depends(),
):
    disvcoveries = (db.query(models.Discovery).outerjoin(
        models.Rule).outerjoin(models.PlanInstance).outerjoin(
            models.Plan).outerjoin(models.Connection).filter(
                models.Connection.id == conn_id,
                models.Plan.id == plan_id,
                models.PlanInstance.id == plan_instance_id,
                models.Rule.id == rule_id if rule_id else True,
            ))
    return paginate(disvcoveries, params)
Esempio n. 7
0
def read_users(db: Session = Depends(get_db)) -> Any:
    # return crud.get_users(db)
    return paginate(crud.get_users(db))
Esempio n. 8
0
 def route(db: Session = Depends(get_db)):
     return paginate(db.query(User))
Esempio n. 9
0
 def route(params: LimitOffsetPaginationParams = Depends(), db: Session = Depends(get_db)):
     return paginate(db.query(User), params)
def get_users(db: Session = Depends(get_db)) -> Any:
    return paginate(db.query(User))