summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/api.rb1
-rw-r--r--lib/api/entities.rb8
-rw-r--r--lib/api/gitignores.rb29
3 files changed, 38 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 360fb41a721..6cd909f6115 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -58,5 +58,6 @@ module API
mount ::API::Runners
mount ::API::Licenses
mount ::API::Subscriptions
+ mount ::API::Gitignores
end
end
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 8298e3ad34c..31491cf31dd 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -457,5 +457,13 @@ module API
expose(:limitations) { |license| license.meta['limitations'] }
expose :content
end
+
+ class GitignoresList < Grape::Entity
+ expose :name
+ end
+
+ class Gitignore < Grape::Entity
+ expose :name, :content
+ end
end
end
diff --git a/lib/api/gitignores.rb b/lib/api/gitignores.rb
new file mode 100644
index 00000000000..1af9ba6b316
--- /dev/null
+++ b/lib/api/gitignores.rb
@@ -0,0 +1,29 @@
+module API
+ class Gitignores < Grape::API
+
+ # Get the list of the available gitignore templates
+ #
+ # Example Request:
+ # GET /gitignores
+ get 'gitignores' do
+ present Gitlab::Gitignore.all, with: Entities::GitignoresList
+ end
+
+ # Get the text for a specific gitignore
+ #
+ # Parameters:
+ # key (required) - The key of a license
+ #
+ # Example Request:
+ # GET /gitignores/elixir
+ #
+ get 'gitignores/:key' do
+ required_attributes! [:key]
+
+ gitignore = Gitlab::Gitignore.find(params[:key])
+ not_found!('.gitignore') unless gitignore
+
+ present gitignore, with: Entities::Gitignore
+ end
+ end
+end