Module: Octokit::Client::Hooks
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/hooks.rb
Overview
Methods for the Hooks API
Instance Method Summary collapse
-
#available_hooks(options = {}) ⇒ Sawyer::Resource
List all Service Hooks supported by GitHub.
-
#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource
Create a hook.
-
#create_org_hook(org, config, options = {}) ⇒ Sawyer::Resource
Create an org hook.
-
#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource
Edit a hook.
-
#edit_org_hook(org, id, config, options = {}) ⇒ Sawyer::Resource
(also: #update_org_hook)
Update an org hook.
-
#hook(repo, id, options = {}) ⇒ Sawyer::Resource
Get single hook.
-
#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>
List repo hooks.
-
#org_hook(org, id, options = {}) ⇒ Sawyer::Resource
Get an org hook.
-
#org_hooks(org, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_org_hooks)
List org hooks.
-
#parse_payload(payload_string) ⇒ Sawyer::Resource
Parse payload string.
-
#ping_org_hook(org, id, options = {}) ⇒ Boolean
Ping org hook.
-
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook.
-
#remove_org_hook(org, id, options = {}) ⇒ Boolean
Remove org hook.
-
#test_hook(repo, id, options = {}) ⇒ Boolean
Test hook.
Instance Method Details
#available_hooks(options = {}) ⇒ Sawyer::Resource
List all Service Hooks supported by GitHub
13 14 15 |
# File 'lib/octokit/client/hooks.rb', line 13 def available_hooks( = {}) get "hooks", end |
#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource
Create a hook
Requires authenticated client.
75 76 77 78 |
# File 'lib/octokit/client/hooks.rb', line 75 def create_hook(repo, name, config, = {}) = {:name => name, :config => config, :events => ["push"], :active => true}.merge() post "#{Repository.path repo}/hooks", end |
#create_org_hook(org, config, options = {}) ⇒ Sawyer::Resource
Create an org hook
Requires client authenticated as admin for the org.
205 206 207 208 |
# File 'lib/octokit/client/hooks.rb', line 205 def create_org_hook(org, config, = {}) = { :name => "web", :config => config }.merge() post "orgs/#{org}/hooks", end |
#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource
Edit a hook
Requires authenticated client.
118 119 120 121 |
# File 'lib/octokit/client/hooks.rb', line 118 def edit_hook(repo, id, name, config, = {}) = {:name => name, :config => config}.merge() patch "#{Repository.path repo}/hooks/#{id}", end |
#edit_org_hook(org, id, config, options = {}) ⇒ Sawyer::Resource Also known as: update_org_hook
Update an org hook
Requires client authenticated as admin for the org.
238 239 240 241 |
# File 'lib/octokit/client/hooks.rb', line 238 def edit_org_hook(org, id, config, = {}) = { :config => config }.merge() patch "orgs/#{org}/hooks/#{id}", end |
#hook(repo, id, options = {}) ⇒ Sawyer::Resource
Get single hook
Requires authenticated client.
40 41 42 |
# File 'lib/octokit/client/hooks.rb', line 40 def hook(repo, id, = {}) get "#{Repository.path repo}/hooks/#{id}", end |
#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>
List repo hooks
Requires authenticated client.
26 27 28 |
# File 'lib/octokit/client/hooks.rb', line 26 def hooks(repo, = {}) paginate "#{Repository.path repo}/hooks", end |
#org_hook(org, id, options = {}) ⇒ Sawyer::Resource
Get an org hook
Requires client authenticated as admin for the org.
175 176 177 |
# File 'lib/octokit/client/hooks.rb', line 175 def org_hook(org, id, = {}) get "orgs/#{org}/hooks/#{id}", end |
#org_hooks(org, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_org_hooks
List org hooks
Requires client authenticated as admin for the org.
160 161 162 |
# File 'lib/octokit/client/hooks.rb', line 160 def org_hooks(org, = {}) paginate "orgs/#{org}/hooks", end |
#parse_payload(payload_string) ⇒ Sawyer::Resource
Parse payload string
277 278 279 280 |
# File 'lib/octokit/client/hooks.rb', line 277 def parse_payload(payload_string) payload_hash = agent.class.decode payload_string Sawyer::Resource.new agent, payload_hash end |
#ping_org_hook(org, id, options = {}) ⇒ Boolean
Ping org hook
Requires client authenticated as admin for the org.
254 255 256 |
# File 'lib/octokit/client/hooks.rb', line 254 def ping_org_hook(org, id, = {}) boolean_from_response :post, "orgs/#{org}/hooks/#{id}/pings", end |
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook
Requires authenticated client.
133 134 135 |
# File 'lib/octokit/client/hooks.rb', line 133 def remove_hook(repo, id, = {}) boolean_from_response :delete, "#{Repository.path repo}/hooks/#{id}", end |
#remove_org_hook(org, id, options = {}) ⇒ Boolean
Remove org hook
Requires client authenticated as admin for the org.
268 269 270 |
# File 'lib/octokit/client/hooks.rb', line 268 def remove_org_hook(org, id, = {}) boolean_from_response :delete, "orgs/#{org}/hooks/#{id}", end |
#test_hook(repo, id, options = {}) ⇒ Boolean
Test hook
Requires authenticated client.
147 148 149 |
# File 'lib/octokit/client/hooks.rb', line 147 def test_hook(repo, id, = {}) boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", end |