1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-02 13:24:20 +01:00
fab-manager/app/controllers/api/openlab_projects_controller.rb

21 lines
616 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# API Controller for resources of type Openlab::Projects
# Openlab::Projects are Projects shared between different instances
class API::OpenlabProjectsController < API::ApiController
before_action :init_openlab
def index
2022-02-25 15:22:14 +01:00
render json: @projects.search(params[:q], page: params[:page], per_page: params[:per_page]).response.body
rescue StandardError
render json: { errors: ['service unavailable'] }
end
private
def init_openlab
client = Openlab::Client.new(app_secret: Setting.get('openlab_app_secret'))
2022-02-25 15:22:14 +01:00
@projects = Openlab::Projects.new(client)
end
end