diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /lib/api/deploy_tokens.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'lib/api/deploy_tokens.rb')
-rw-r--r-- | lib/api/deploy_tokens.rb | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/api/deploy_tokens.rb b/lib/api/deploy_tokens.rb index 30ec4e52b2a..e9beeb18d62 100644 --- a/lib/api/deploy_tokens.rb +++ b/lib/api/deploy_tokens.rb @@ -18,6 +18,10 @@ module API result_hash[:read_repository] = scopes.include?('read_repository') result_hash end + + params :filter_params do + optional :active, type: Boolean, desc: 'Limit by active status' + end end desc 'Return all deploy tokens' do @@ -26,11 +30,18 @@ module API end params do use :pagination + use :filter_params end get 'deploy_tokens' do authenticated_as_admin! - present paginate(DeployToken.all), with: Entities::DeployToken + deploy_tokens = ::DeployTokens::TokensFinder.new( + current_user, + :all, + declared_params + ).execute + + present paginate(deploy_tokens), with: Entities::DeployToken end params do @@ -39,6 +50,7 @@ module API resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do params do use :pagination + use :filter_params end desc 'List deploy tokens for a project' do detail 'This feature was introduced in GitLab 12.9' @@ -47,7 +59,13 @@ module API get ':id/deploy_tokens' do authorize!(:read_deploy_token, user_project) - present paginate(user_project.deploy_tokens), with: Entities::DeployToken + deploy_tokens = ::DeployTokens::TokensFinder.new( + current_user, + user_project, + declared_params + ).execute + + present paginate(deploy_tokens), with: Entities::DeployToken end params do @@ -98,6 +116,7 @@ module API resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do params do use :pagination + use :filter_params end desc 'List deploy tokens for a group' do detail 'This feature was introduced in GitLab 12.9' @@ -106,7 +125,13 @@ module API get ':id/deploy_tokens' do authorize!(:read_deploy_token, user_group) - present paginate(user_group.deploy_tokens), with: Entities::DeployToken + deploy_tokens = ::DeployTokens::TokensFinder.new( + current_user, + user_group, + declared_params + ).execute + + present paginate(deploy_tokens), with: Entities::DeployToken end params do |