summaryrefslogtreecommitdiff
path: root/lib/api/resource_access_tokens.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/resource_access_tokens.rb')
-rw-r--r--lib/api/resource_access_tokens.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/api/resource_access_tokens.rb b/lib/api/resource_access_tokens.rb
index e52f8fd9111..2ba109b7092 100644
--- a/lib/api/resource_access_tokens.rb
+++ b/lib/api/resource_access_tokens.rb
@@ -27,6 +27,28 @@ module API
present paginate(tokens), with: Entities::ResourceAccessToken, resource: resource
end
+ desc 'Get an access token for the specified resource by ID' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ end
+ params do
+ requires :id, type: String, desc: "The #{source_type} ID"
+ requires :token_id, type: String, desc: "The ID of the token"
+ end
+ get ":id/access_tokens/:token_id" do
+ resource = find_source(source_type, params[:id])
+
+ next unauthorized! unless current_user.can?(:read_resource_access_tokens, resource)
+
+ token = find_token(resource, params[:token_id])
+
+ if token.nil?
+ next not_found!("Could not find #{source_type} access token with token_id: #{params[:token_id]}")
+ end
+
+ resource.members.load
+ present token, with: Entities::ResourceAccessToken, resource: resource
+ end
+
desc 'Revoke a resource access token' do
detail 'This feature was introduced in GitLab 13.9.'
end