From 76690017e28c2e42e58130fe64d7feb92d085b01 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Tue, 18 Oct 2016 20:07:56 +0200 Subject: Expose more data on the SystemHooks API Now exposed: - push_events - tag_push_events - enable_ssl_verification - token Fixes gitlab-org/gitlab-ce#23307 --- lib/api/entities.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index feaa0c213bf..c6c7747d022 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -43,14 +43,13 @@ module API end class Hook < Grape::Entity - expose :id, :url, :created_at + expose :id, :url, :created_at, :push_events, :tag_push_events + expose :enable_ssl_verification, :token end class ProjectHook < Hook - expose :project_id, :push_events - expose :issues_events, :merge_requests_events, :tag_push_events + expose :project_id, :issues_events, :merge_requests_events expose :note_events, :build_events, :pipeline_events, :wiki_page_events - expose :enable_ssl_verification end class BasicProjectDetails < Grape::Entity -- cgit v1.2.3 From a4827ee2b9a5dd51356a4e11455c0075fe6cea69 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Tue, 18 Oct 2016 20:10:08 +0200 Subject: Be able to POST subscriptions for system hooks --- lib/api/system_hooks.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/api') diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index 794e34874f4..ca95c044ecc 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -19,10 +19,14 @@ module API success Entities::Hook end params do - requires :url, type: String, desc: 'The URL for the system hook' + requires :url, type: String, desc: "The URL to send the request to" + optional :token, type: String, desc: 'The token used to validate payloads' + optional :push_events, type: Boolean, desc: "Trigger hook on push events" + optional :tag_push_events, type: Boolean, desc: "Trigger hook on tag push events" + optional :enable_ssl_verification, type: Boolean, desc: "Do SSL verification when triggering the hook" end post do - hook = SystemHook.new declared(params).to_h + hook = SystemHook.new declared(params, include_missing: false).to_h if hook.save present hook, with: Entities::Hook -- cgit v1.2.3 From 57fd233a557158dbaa1a227f7c549fbe6a45e799 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 19 Oct 2016 14:08:30 +0000 Subject: Update docs and unexpose token --- lib/api/entities.rb | 2 +- lib/api/system_hooks.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c6c7747d022..47a5874ae75 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -44,7 +44,7 @@ module API class Hook < Grape::Entity expose :id, :url, :created_at, :push_events, :tag_push_events - expose :enable_ssl_verification, :token + expose :enable_ssl_verification end class ProjectHook < Hook diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index ca95c044ecc..32f731c5652 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -12,6 +12,7 @@ module API end get do hooks = SystemHook.all + present hooks, with: Entities::Hook end -- cgit v1.2.3