summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorNihad Abbasov <narkoz.2008@gmail.com>2012-11-27 11:43:39 -0800
committerNihad Abbasov <narkoz.2008@gmail.com>2012-11-29 12:11:00 -0800
commit01eab583d0d16b44554a9790fb502f14ea84faf0 (patch)
tree60d50ac821d6251c453e4ae805ed925c34f9d251 /lib/api
parentaaa1c94239df831d10489d686d8883b49d601f43 (diff)
downloadgitlab-ce-01eab583d0d16b44554a9790fb502f14ea84faf0.tar.gz
API: list wall, snippet and issue notes
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb4
-rw-r--r--lib/api/notes.rb38
2 files changed, 41 insertions, 1 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 9e605a607a2..0c44f621b08 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -70,8 +70,10 @@ module Gitlab
end
class Note < Grape::Entity
+ expose :id
+ expose :note, as: :body
expose :author, using: Entities::UserBasic
- expose :note
+ expose :updated_at, :created_at
end
end
end
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
new file mode 100644
index 00000000000..d2857f3d2c7
--- /dev/null
+++ b/lib/api/notes.rb
@@ -0,0 +1,38 @@
+module Gitlab
+ # Notes API
+ class Notes < Grape::API
+ before { authenticate! }
+
+ NOTEABLE_TYPES = [Issue, Snippet]
+
+ resource :projects do
+ # Get a list of project wall notes
+ #
+ # Parameters:
+ # id (required) - The ID or code name of a project
+ # Example Request:
+ # GET /projects/:id/notes
+ get ":id/notes" do
+ @notes = user_project.common_notes
+ present paginate(@notes), with: Entities::Note
+ end
+
+ NOTEABLE_TYPES.each do |noteable_type|
+ noteables_str = noteable_type.to_s.underscore.pluralize
+ noteable_id_str = "#{noteable_type.to_s.underscore}_id"
+
+ # Get a list of project +noteable+ notes
+ #
+ # Parameters:
+ # id (required) - The ID or code name of a project
+ # noteable_id (required) - The ID of an issue or snippet
+ # Example Request:
+ # GET /projects/:id/noteable/:noteable_id/notes
+ get ":id/#{noteables_str}/:#{noteable_id_str}/notes" do
+ @noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"])
+ present paginate(@noteable.notes), with: Entities::Note
+ end
+ end
+ end
+ end
+end