예제 #1
0
def commit(sha=None):
    get_projector(current_app).process_events()
    repos = model.Repository.query \
                .filter(model.Repository.commits.contains([{'sha': sha}])).all()
    if not repos:
        abort(404)
    return jsonify([repo.as_dict() for repo in repos])
예제 #2
0
def replay():
    payload = request.get_json(force=True)
    if 'events' in payload:
        events_to_replay = payload['events']
    else:
        events_to_replay = None
    get_projector(current_app).process_events(only=events_to_replay)

    return "Done!"
예제 #3
0
def pull_request(id=None):
    repo_id = request.args.get('repo')
    external_id = '{}/{}'.format(repo_id, id)
    projector = get_projector(current_app)
    projector.process_events()
    pr = projector.projection_backend.get_one_by_external_id(external_id, model.PullRequest)
    if not pr:
        abort(404)
    return jsonify(pr.as_dict())
예제 #4
0
def pipeline_stage(pipeline_external_id=None, external_id=None):
    """
    swagger_from_file: event_api/blueprints/swagger_docs/pipeline_stage.yaml

    """
    projector = get_projector(current_app)
    projector.process_events()
    stage = projector.projection_backend.get_one_by_filter(model.PipelineStage,
                                                {"pipeline_id": pipeline_external_id,
                                                 "external_id": external_id})
    if not stage:
        abort(404)
    return jsonify(stage.as_dict())
예제 #5
0
def pipeline(external_id=None):
    """
    swagger_from_file: event_api/blueprints/swagger_docs/pipeline.yaml

    """
    projector = get_projector(current_app)
    projector.process_events()
    pipeline = projector.projection_backend.get_one_by_external_id(external_id, model.Pipeline)
    if not pipeline:
        abort(404)

    stages = projector.projection_backend.get_by_filter(model.PipelineStage, {"pipeline_id": pipeline.external_id})
    return jsonify({"pipeline": pipeline.as_dict(),
                    "stages": [stage.as_dict() for stage in stages]})
예제 #6
0
def repository():
    """
    swagger_from_file: event_api/blueprints/swagger_docs/repository.yaml

    """
    repo_id = request.args.get('id')
    projector = get_projector(current_app)
    projector.process_events()
    if repo_id:
        repository = projector.projection_backend.get_one_by_filter(model.Repository,
                                                         {"full_name": repo_id})
        if not repository:
            abort(404)
        return jsonify(repository.as_dict())
    else:
        repositories = projector.projection_backend.get_all(model.Repository)
        return jsonify({"repositories": [repository.as_dict() for repository in repositories]})
예제 #7
0
def all_pipeline_stages():
    projector = get_projector(current_app)
    projector.process_events()
    pipeline_stages = projector.projection_backend.get_all(model.PipelineStage)

    return jsonify({"pipeline_stages": [pipeline_stage.as_dict() for pipeline_stage in pipeline_stages]})
예제 #8
0
def all_pull_requests():
    projector = get_projector(current_app)
    projector.process_events()
    pull_requests = projector.projection_backend.get_all(model.PullRequest)

    return jsonify({"pull_requests": [pull_request.as_dict() for pull_request in pull_requests]})