diff options
author | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-06-29 03:46:01 -0700 |
---|---|---|
committer | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-06-29 03:46:01 -0700 |
commit | 0d67f209fcbabed5831d90561350a8e094c150c4 (patch) | |
tree | 12aadf636dde8f626fd1cfd53f13aaf8cf7a47c8 /lib/api/projects.rb | |
parent | 84a3f8fca4e57422267bdd7e07d4f1b90717fbcc (diff) | |
download | gitlab-ce-0d67f209fcbabed5831d90561350a8e094c150c4.tar.gz |
refactor API and improve docs
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb new file mode 100644 index 00000000000..670d3d97acc --- /dev/null +++ b/lib/api/projects.rb @@ -0,0 +1,50 @@ +module Gitlab + # Projects API + class Projects < Grape::API + before { authenticate! } + + resource :projects do + # Get a projects list for authenticated user + # + # Example Request: + # GET /projects + get do + @projects = current_user.projects + present @projects, :with => Entities::Project + end + + # Get a single project + # + # Parameters: + # id (required) - The code of a project + # Example Request: + # GET /projects/:id + get ":id" do + @project = current_user.projects.find_by_code(params[:id]) + present @project, :with => Entities::Project + end + + # Get a project repository branches + # + # Parameters: + # id (required) - The code of a project + # Example Request: + # GET /projects/:id/repository/branches + get ":id/repository/branches" do + @project = current_user.projects.find_by_code(params[:id]) + present @project.repo.heads.sort_by(&:name), :with => Entities::ProjectRepositoryBranches + end + + # Get a project repository tags + # + # Parameters: + # id (required) - The code of a project + # Example Request: + # GET /projects/:id/repository/tags + get ":id/repository/tags" do + @project = current_user.projects.find_by_code(params[:id]) + present @project.repo.tags.sort_by(&:name).reverse, :with => Entities::ProjectRepositoryTags + end + end + end +end |