diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-20 13:30:14 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-20 13:30:14 +0200 |
commit | 5a4461dfa1862f007b9a1de8d621d5978006009e (patch) | |
tree | 9fda0f918c8c88bf70f92acace52b8edd766f5bb /lib/api/feature_flags.rb | |
parent | 34447c588486e5fc9deb4498b34c9d71117a496e (diff) | |
download | gitlab-ce-feature-flags-backend.tar.gz |
Refactor API interfacefeature-flags-backend
Diffstat (limited to 'lib/api/feature_flags.rb')
-rw-r--r-- | lib/api/feature_flags.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/api/feature_flags.rb b/lib/api/feature_flags.rb new file mode 100644 index 00000000000..dff43544a75 --- /dev/null +++ b/lib/api/feature_flags.rb @@ -0,0 +1,50 @@ +module API + class FeatureFlags < Grape::API + include PaginationParams + + resource :feature_flags do + resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do + params do + requires :id, type: String, desc: 'The ID of a project' + end + route_param :id do + resource :unleash do + before do + authenticate_by_unleash_access_token! + end + + get 'features' do + present project, with: Entities::UnleashFeatures + end + + post 'client/register' do + # not supported yet + status :ok + end + + post 'client/metrics' do + # not supported yet + status :ok + end + end + end + end + + helpers do + def project + @project ||= find_project(params[:id]) + end + + def unleash_instanceid + params[:instanceid] || env[:HTTP_UNLEASH_INSTANCEID] + end + + def authenticate_by_unleash_access_token! + unless Operations::FeatureFlagsAccessToken.find_by(token: unleash_instanceid, project: project) + unauthorized! + end + end + end + end + end +end |