summaryrefslogtreecommitdiff
path: root/lib/api/project_snippets.rb
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-03-01 16:16:29 +0100
committerToon Claes <toon@gitlab.com>2017-03-02 09:33:24 +0100
commitb2c2dfe545526a1857e9605761f6d256ef73e190 (patch)
treeba3ec9ea7ce38a4c2ca09b6d92a3d67bb492daf1 /lib/api/project_snippets.rb
parentfc287191451bb6aac80d759ab521b5834d27df43 (diff)
downloadgitlab-ce-b2c2dfe545526a1857e9605761f6d256ef73e190.tar.gz
Expose Project's & ProjectSnippet's VisibilityLevel as String
Instead of exposing the VisibilityLevel as Integer, expose it as String `visibility` for Project and ProjectSnippet. Filter queries also accept the `visibility` as String instead of `visibility_level` as Integer. Also remove the `public` boolean.
Diffstat (limited to 'lib/api/project_snippets.rb')
-rw-r--r--lib/api/project_snippets.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb
index 2a1cce73f3f..31919a6270d 100644
--- a/lib/api/project_snippets.rb
+++ b/lib/api/project_snippets.rb
@@ -50,15 +50,13 @@ module API
requires :title, type: String, desc: 'The title of the snippet'
requires :file_name, type: String, desc: 'The file name of the snippet'
requires :code, type: String, desc: 'The content of the snippet'
- requires :visibility_level, type: Integer,
- values: [Gitlab::VisibilityLevel::PRIVATE,
- Gitlab::VisibilityLevel::INTERNAL,
- Gitlab::VisibilityLevel::PUBLIC],
- desc: 'The visibility level of the snippet'
+ requires :visibility, type: String,
+ values: Gitlab::VisibilityLevel.string_values,
+ desc: 'The visibility of the snippet'
end
post ":id/snippets" do
authorize! :create_project_snippet, user_project
- snippet_params = declared_params.merge(request: request, api: true)
+ snippet_params = map_visibility_level(declared_params).merge(request: request, api: true)
snippet_params[:content] = snippet_params.delete(:code)
snippet = CreateSnippetService.new(user_project, current_user, snippet_params).execute
@@ -80,11 +78,9 @@ module API
optional :title, type: String, desc: 'The title of the snippet'
optional :file_name, type: String, desc: 'The file name of the snippet'
optional :code, type: String, desc: 'The content of the snippet'
- optional :visibility_level, type: Integer,
- values: [Gitlab::VisibilityLevel::PRIVATE,
- Gitlab::VisibilityLevel::INTERNAL,
- Gitlab::VisibilityLevel::PUBLIC],
- desc: 'The visibility level of the snippet'
+ optional :visibility, type: String,
+ values: Gitlab::VisibilityLevel.string_values,
+ desc: 'The visibility of the snippet'
at_least_one_of :title, :file_name, :code, :visibility_level
end
put ":id/snippets/:snippet_id" do
@@ -93,7 +89,7 @@ module API
authorize! :update_project_snippet, snippet
- snippet_params = declared_params(include_missing: false)
+ snippet_params = map_visibility_level(declared_params(include_missing: false))
.merge(request: request, api: true)
snippet_params[:content] = snippet_params.delete(:code) if snippet_params[:code].present?