diff options
author | Guyzmo <guyzmo+gitlab+pub@m0g.net> | 2016-11-26 16:37:26 +0100 |
---|---|---|
committer | Guyzmo <guyzmo+gitlab+pub@m0g.net> | 2016-12-01 19:07:49 +0100 |
commit | fde754e2676e40dcf2600190983ef54030c5d5a5 (patch) | |
tree | d8d68db59c5625369242c394eb6fa788185a0f17 /lib/api/entities.rb | |
parent | cf1a31a3459786f637971e2dafe4df31f5a28e74 (diff) | |
download | gitlab-ce-fde754e2676e40dcf2600190983ef54030c5d5a5.tar.gz |
API: Endpoint to expose personal snippets as /snippets
Adding the necessary API for the new /snippets Restful resource
added with this commit. Added a new Grape class `Snippets`, as
well as a `PersonalSnippet` entity.
Issue: #20042
Merge-Request: !6373
Signed-off-by: Guyzmo <guyzmo+gitlab+pub@m0g.net>
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r-- | lib/api/entities.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index d5dfb8d00be..dc6d085925d 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -200,6 +200,19 @@ module API end end + class PersonalSnippet < Grape::Entity + expose :id, :title, :file_name + expose :author, using: Entities::UserBasic + expose :updated_at, :created_at + + expose :web_url do |snippet| + Gitlab::UrlBuilder.build(snippet) + end + expose :raw_url do |snippet| + Gitlab::UrlBuilder.build(snippet) + "/raw" + end + end + class ProjectEntity < Grape::Entity expose :id, :iid expose(:project_id) { |entity| entity.project.id } |