lingfennan-github_api 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api.rb +93 -0
- data/lib/github_api/api.rb +398 -0
- data/lib/github_api/api/actions.rb +60 -0
- data/lib/github_api/api/arguments.rb +253 -0
- data/lib/github_api/api/config.rb +105 -0
- data/lib/github_api/api/config/property.rb +30 -0
- data/lib/github_api/api/config/property_set.rb +120 -0
- data/lib/github_api/api/factory.rb +33 -0
- data/lib/github_api/authorization.rb +75 -0
- data/lib/github_api/client.rb +77 -0
- data/lib/github_api/client/activity.rb +31 -0
- data/lib/github_api/client/activity/events.rb +233 -0
- data/lib/github_api/client/activity/feeds.rb +50 -0
- data/lib/github_api/client/activity/notifications.rb +181 -0
- data/lib/github_api/client/activity/starring.rb +130 -0
- data/lib/github_api/client/activity/watching.rb +176 -0
- data/lib/github_api/client/authorizations.rb +142 -0
- data/lib/github_api/client/authorizations/app.rb +98 -0
- data/lib/github_api/client/emojis.rb +19 -0
- data/lib/github_api/client/gists.rb +289 -0
- data/lib/github_api/client/gists/comments.rb +100 -0
- data/lib/github_api/client/git_data.rb +31 -0
- data/lib/github_api/client/git_data/blobs.rb +51 -0
- data/lib/github_api/client/git_data/commits.rb +101 -0
- data/lib/github_api/client/git_data/references.rb +150 -0
- data/lib/github_api/client/git_data/tags.rb +95 -0
- data/lib/github_api/client/git_data/trees.rb +113 -0
- data/lib/github_api/client/gitignore.rb +57 -0
- data/lib/github_api/client/issues.rb +248 -0
- data/lib/github_api/client/issues/assignees.rb +77 -0
- data/lib/github_api/client/issues/comments.rb +146 -0
- data/lib/github_api/client/issues/events.rb +50 -0
- data/lib/github_api/client/issues/labels.rb +189 -0
- data/lib/github_api/client/issues/milestones.rb +146 -0
- data/lib/github_api/client/markdown.rb +62 -0
- data/lib/github_api/client/meta.rb +19 -0
- data/lib/github_api/client/orgs.rb +127 -0
- data/lib/github_api/client/orgs/hooks.rb +182 -0
- data/lib/github_api/client/orgs/members.rb +142 -0
- data/lib/github_api/client/orgs/memberships.rb +131 -0
- data/lib/github_api/client/orgs/projects.rb +57 -0
- data/lib/github_api/client/orgs/teams.rb +407 -0
- data/lib/github_api/client/projects.rb +83 -0
- data/lib/github_api/client/projects/cards.rb +158 -0
- data/lib/github_api/client/projects/columns.rb +146 -0
- data/lib/github_api/client/pull_requests.rb +195 -0
- data/lib/github_api/client/pull_requests/comments.rb +140 -0
- data/lib/github_api/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api/client/repos.rb +468 -0
- data/lib/github_api/client/repos/branches.rb +48 -0
- data/lib/github_api/client/repos/branches/protections.rb +75 -0
- data/lib/github_api/client/repos/collaborators.rb +84 -0
- data/lib/github_api/client/repos/comments.rb +125 -0
- data/lib/github_api/client/repos/commits.rb +80 -0
- data/lib/github_api/client/repos/contents.rb +246 -0
- data/lib/github_api/client/repos/deployments.rb +138 -0
- data/lib/github_api/client/repos/downloads.rb +62 -0
- data/lib/github_api/client/repos/forks.rb +48 -0
- data/lib/github_api/client/repos/hooks.rb +214 -0
- data/lib/github_api/client/repos/keys.rb +104 -0
- data/lib/github_api/client/repos/merging.rb +47 -0
- data/lib/github_api/client/repos/pages.rb +48 -0
- data/lib/github_api/client/repos/projects.rb +62 -0
- data/lib/github_api/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api/client/repos/releases.rb +189 -0
- data/lib/github_api/client/repos/releases/assets.rb +136 -0
- data/lib/github_api/client/repos/releases/tags.rb +24 -0
- data/lib/github_api/client/repos/statistics.rb +89 -0
- data/lib/github_api/client/repos/statuses.rb +91 -0
- data/lib/github_api/client/say.rb +25 -0
- data/lib/github_api/client/scopes.rb +46 -0
- data/lib/github_api/client/search.rb +133 -0
- data/lib/github_api/client/search/legacy.rb +111 -0
- data/lib/github_api/client/users.rb +117 -0
- data/lib/github_api/client/users/emails.rb +65 -0
- data/lib/github_api/client/users/followers.rb +115 -0
- data/lib/github_api/client/users/keys.rb +104 -0
- data/lib/github_api/configuration.rb +70 -0
- data/lib/github_api/connection.rb +82 -0
- data/lib/github_api/constants.rb +61 -0
- data/lib/github_api/core_ext/array.rb +25 -0
- data/lib/github_api/core_ext/hash.rb +91 -0
- data/lib/github_api/core_ext/ordered_hash.rb +107 -0
- data/lib/github_api/deprecation.rb +39 -0
- data/lib/github_api/error.rb +32 -0
- data/lib/github_api/error/client_error.rb +89 -0
- data/lib/github_api/error/service_error.rb +223 -0
- data/lib/github_api/ext/faraday.rb +38 -0
- data/lib/github_api/mash.rb +7 -0
- data/lib/github_api/middleware.rb +37 -0
- data/lib/github_api/mime_type.rb +33 -0
- data/lib/github_api/normalizer.rb +23 -0
- data/lib/github_api/null_encoder.rb +25 -0
- data/lib/github_api/page_iterator.rb +138 -0
- data/lib/github_api/page_links.rb +63 -0
- data/lib/github_api/paged_request.rb +42 -0
- data/lib/github_api/pagination.rb +115 -0
- data/lib/github_api/parameter_filter.rb +35 -0
- data/lib/github_api/params_hash.rb +115 -0
- data/lib/github_api/rate_limit.rb +25 -0
- data/lib/github_api/request.rb +85 -0
- data/lib/github_api/request/basic_auth.rb +36 -0
- data/lib/github_api/request/jsonize.rb +54 -0
- data/lib/github_api/request/oauth2.rb +44 -0
- data/lib/github_api/request/verbs.rb +63 -0
- data/lib/github_api/response.rb +48 -0
- data/lib/github_api/response/atom_parser.rb +22 -0
- data/lib/github_api/response/follow_redirects.rb +140 -0
- data/lib/github_api/response/header.rb +87 -0
- data/lib/github_api/response/jsonize.rb +28 -0
- data/lib/github_api/response/mashify.rb +24 -0
- data/lib/github_api/response/raise_error.rb +22 -0
- data/lib/github_api/response/xmlize.rb +27 -0
- data/lib/github_api/response_wrapper.rb +161 -0
- data/lib/github_api/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api/utils/url.rb +63 -0
- data/lib/github_api/validations.rb +22 -0
- data/lib/github_api/validations/format.rb +26 -0
- data/lib/github_api/validations/presence.rb +32 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +5 -0
- metadata +338 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Repos::Deployments < API
|
|
7
|
+
|
|
8
|
+
VALID_DEPLOYMENTS_OPTIONS = %w[
|
|
9
|
+
ref
|
|
10
|
+
auto_merge
|
|
11
|
+
required_contexts
|
|
12
|
+
payload
|
|
13
|
+
environment
|
|
14
|
+
description
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
VALID_STATUS_OPTIONS = %w[
|
|
18
|
+
state
|
|
19
|
+
target_url
|
|
20
|
+
description
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
PREVIEW_MEDIA = 'application/vnd.github.cannonball-preview+json'.freeze # :nodoc:
|
|
24
|
+
|
|
25
|
+
# List deployments on a repository
|
|
26
|
+
#
|
|
27
|
+
# @xample
|
|
28
|
+
# github = Github.new
|
|
29
|
+
# github.repos.deployments.list 'user-name', 'repo-name'
|
|
30
|
+
# github.repos.deployments.list 'user-name', 'repo-name' { |deployment| ... }
|
|
31
|
+
#
|
|
32
|
+
# @api public
|
|
33
|
+
def list(*args)
|
|
34
|
+
arguments(args, required: [:user, :repo])
|
|
35
|
+
params = arguments.params
|
|
36
|
+
params['accept'] ||= PREVIEW_MEDIA
|
|
37
|
+
|
|
38
|
+
response = get_request("repos/#{arguments.user}/#{arguments.repo}/deployments", params)
|
|
39
|
+
return response unless block_given?
|
|
40
|
+
response.each { |el| yield el }
|
|
41
|
+
end
|
|
42
|
+
alias :all :list
|
|
43
|
+
|
|
44
|
+
# Create a deployment
|
|
45
|
+
#
|
|
46
|
+
# @param [Hash] params
|
|
47
|
+
# @option params [String] :ref
|
|
48
|
+
# Required string. The ref to deploy. This can be a branch, tag, or sha.
|
|
49
|
+
# @option params [Boolean] :auto_merge
|
|
50
|
+
# Optional boolean. Merge the default branch into the requested.
|
|
51
|
+
# @option params [Array] :required_contexts
|
|
52
|
+
# Optional array of status contexts verified against commit status checks.
|
|
53
|
+
# If this parameter is omitted from the parameters then all unique
|
|
54
|
+
# contexts will be verified before a deployment is created. To bypass
|
|
55
|
+
# checking entirely pass an empty array. Defaults to all unique contexts.
|
|
56
|
+
# @option params [String] :payload
|
|
57
|
+
# Optional JSON payload with extra information about the deployment.
|
|
58
|
+
# Default: ""
|
|
59
|
+
# @option params [String] :payload
|
|
60
|
+
# Optional String. Name for the target deployment environment (e.g.,
|
|
61
|
+
# production, staging, qa). Default: "production"
|
|
62
|
+
# @option params [String] :description
|
|
63
|
+
# Optional string. Optional short description.
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# github = Github.new
|
|
67
|
+
# github.repos.deployments.create 'user-name', 'repo-name', ref: '...'
|
|
68
|
+
# github.repos.deployments.create
|
|
69
|
+
# 'user-name',
|
|
70
|
+
# 'repo-name',
|
|
71
|
+
# ref: '...',
|
|
72
|
+
# description: 'New deploy',
|
|
73
|
+
# force: true
|
|
74
|
+
#
|
|
75
|
+
# @api public
|
|
76
|
+
def create(*args)
|
|
77
|
+
arguments(args, required: [:user, :repo]) do
|
|
78
|
+
permit VALID_DEPLOYMENTS_OPTIONS
|
|
79
|
+
assert_required %w[ ref ]
|
|
80
|
+
end
|
|
81
|
+
params = arguments.params
|
|
82
|
+
params['accept'] ||= PREVIEW_MEDIA
|
|
83
|
+
|
|
84
|
+
post_request("repos/#{arguments.user}/#{arguments.repo}/deployments", arguments.params)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# List the statuses of a deployment.
|
|
88
|
+
#
|
|
89
|
+
# @param [Hash] params
|
|
90
|
+
# @option params [String] :id
|
|
91
|
+
# Required string. Id of the deployment being queried.
|
|
92
|
+
#
|
|
93
|
+
# @example
|
|
94
|
+
# github = Github.new
|
|
95
|
+
# github.repos.deployments.statuses 'user-name', 'repo-name', DEPLOYMENT_ID
|
|
96
|
+
# github.repos.deployments.statuses 'user-name', 'repo-name', DEPLOYMENT_ID { |status| ... }
|
|
97
|
+
#
|
|
98
|
+
# @api public
|
|
99
|
+
def statuses(*args)
|
|
100
|
+
arguments(args, required: [:user, :repo, :id])
|
|
101
|
+
params = arguments.params
|
|
102
|
+
params['accept'] ||= PREVIEW_MEDIA
|
|
103
|
+
|
|
104
|
+
statuses = get_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params)
|
|
105
|
+
return statuses unless block_given?
|
|
106
|
+
statuses.each { |status| yield status }
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Create a deployment status
|
|
110
|
+
#
|
|
111
|
+
# @param [Hash] params
|
|
112
|
+
# @option params [String] :id
|
|
113
|
+
# Required string. Id of the deployment being referenced.
|
|
114
|
+
# @option params [String] :state
|
|
115
|
+
# Required string. State of the deployment. Can be one of:
|
|
116
|
+
# pending, success, error, or failure.
|
|
117
|
+
# @option params [String] :target_url
|
|
118
|
+
# Optional string. The URL associated with the status.
|
|
119
|
+
# @option params [String] :description
|
|
120
|
+
# Optional string. A short description of the status.
|
|
121
|
+
#
|
|
122
|
+
# @example
|
|
123
|
+
# github = Github.new
|
|
124
|
+
# github.repos.deployments.create_status 'user-name', 'repo-name', DEPLOYMENT_ID, state: '...'
|
|
125
|
+
#
|
|
126
|
+
# @api public
|
|
127
|
+
def create_status(*args)
|
|
128
|
+
arguments(args, required: [:user, :repo, :id]) do
|
|
129
|
+
assert_required %w[ state ]
|
|
130
|
+
permit VALID_STATUS_OPTIONS
|
|
131
|
+
end
|
|
132
|
+
params = arguments.params
|
|
133
|
+
params['accept'] ||= PREVIEW_MEDIA
|
|
134
|
+
|
|
135
|
+
post_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params)
|
|
136
|
+
end
|
|
137
|
+
end # Client::Repos::Deployments
|
|
138
|
+
end # Github
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Repos::Downloads < API
|
|
7
|
+
|
|
8
|
+
REQUIRED_PARAMS = %w[ name size ].freeze
|
|
9
|
+
|
|
10
|
+
VALID_DOWNLOAD_PARAM_NAMES = %w[
|
|
11
|
+
name
|
|
12
|
+
size
|
|
13
|
+
description
|
|
14
|
+
content_type
|
|
15
|
+
].freeze
|
|
16
|
+
|
|
17
|
+
# List downloads for a repository
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# github = Github.new
|
|
21
|
+
# github.repos.downloads.list 'user-name', 'repo-name'
|
|
22
|
+
# github.repos.downloads.list 'user-name', 'repo-name' { |downl| ... }
|
|
23
|
+
#
|
|
24
|
+
# @api public
|
|
25
|
+
def list(*args)
|
|
26
|
+
arguments(args, required: [:user, :repo])
|
|
27
|
+
|
|
28
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads", arguments.params)
|
|
29
|
+
return response unless block_given?
|
|
30
|
+
response.each { |el| yield el }
|
|
31
|
+
end
|
|
32
|
+
alias :all :list
|
|
33
|
+
|
|
34
|
+
# Get a single download
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# github = Github.new
|
|
38
|
+
# github.repos.downloads.get 'user-name', 'repo-name', 'download-id'
|
|
39
|
+
#
|
|
40
|
+
# @api public
|
|
41
|
+
def get(*args)
|
|
42
|
+
arguments(args, required: [:user, :repo, :id])
|
|
43
|
+
|
|
44
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
|
|
45
|
+
end
|
|
46
|
+
alias :find :get
|
|
47
|
+
|
|
48
|
+
# Delete download from a repository
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# github = Github.new
|
|
52
|
+
# github.repos.downloads.delete 'user-name', 'repo-name', 'download-id'
|
|
53
|
+
#
|
|
54
|
+
# @api public
|
|
55
|
+
def delete(*args)
|
|
56
|
+
arguments(args, required: [:user, :repo, :id])
|
|
57
|
+
|
|
58
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
|
|
59
|
+
end
|
|
60
|
+
alias :remove :delete
|
|
61
|
+
end # Repos::Downloads
|
|
62
|
+
end # Github
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Repos::Forks < API
|
|
7
|
+
# List repository forks
|
|
8
|
+
#
|
|
9
|
+
# @param [Hash] params
|
|
10
|
+
# @input params [String] :sort
|
|
11
|
+
# The sort order. Can be either newest, oldest, or stargazers.
|
|
12
|
+
# Default: newest
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# github = Github.new
|
|
16
|
+
# github.repos.forks.list 'user-name', 'repo-name'
|
|
17
|
+
# github.repos.forks.list 'user-name', 'repo-name' { |fork| ... }
|
|
18
|
+
#
|
|
19
|
+
# @api public
|
|
20
|
+
def list(*args)
|
|
21
|
+
arguments(args, required: [:user, :repo])
|
|
22
|
+
|
|
23
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/forks", arguments.params)
|
|
24
|
+
return response unless block_given?
|
|
25
|
+
response.each { |el| yield el }
|
|
26
|
+
end
|
|
27
|
+
alias :all :list
|
|
28
|
+
|
|
29
|
+
# Create a fork for the authenticated user
|
|
30
|
+
#
|
|
31
|
+
# @param [Hash] params
|
|
32
|
+
# @input params [String] :organization
|
|
33
|
+
# The organization login. The repository will be forked into
|
|
34
|
+
# this organization.
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# github = Github.new
|
|
38
|
+
# github.repos.forks.create 'user-name', 'repo-name',
|
|
39
|
+
# organization: "github"
|
|
40
|
+
#
|
|
41
|
+
# @api public
|
|
42
|
+
def create(*args)
|
|
43
|
+
arguments(args, required: [:user, :repo])
|
|
44
|
+
|
|
45
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/forks", arguments.params)
|
|
46
|
+
end
|
|
47
|
+
end # Client::Repos::Forks
|
|
48
|
+
end # Github
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
# The Repository Hooks API manages the post-receive web and
|
|
7
|
+
# service hooks for a repository.
|
|
8
|
+
class Client::Repos::Hooks < API
|
|
9
|
+
|
|
10
|
+
VALID_HOOK_PARAM_NAMES = %w[
|
|
11
|
+
name
|
|
12
|
+
config
|
|
13
|
+
active
|
|
14
|
+
events
|
|
15
|
+
add_events
|
|
16
|
+
remove_events
|
|
17
|
+
].freeze # :nodoc:
|
|
18
|
+
|
|
19
|
+
# Active hooks can be configured to trigger for one or more events.
|
|
20
|
+
# The default event is push. The available events are:
|
|
21
|
+
VALID_HOOK_PARAM_VALUES = {
|
|
22
|
+
'events' => %w[
|
|
23
|
+
push
|
|
24
|
+
issues
|
|
25
|
+
issue_comment
|
|
26
|
+
commit_comment
|
|
27
|
+
pull_request
|
|
28
|
+
gollum
|
|
29
|
+
watch
|
|
30
|
+
download
|
|
31
|
+
fork
|
|
32
|
+
fork_apply
|
|
33
|
+
member
|
|
34
|
+
public
|
|
35
|
+
]
|
|
36
|
+
}.freeze # :nodoc:
|
|
37
|
+
|
|
38
|
+
REQUIRED_PARAMS = %w[ name config ].freeze # :nodoc:
|
|
39
|
+
|
|
40
|
+
# List repository hooks
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# github = Github.new
|
|
44
|
+
# github.repos.hooks.list 'user-name', 'repo-name'
|
|
45
|
+
# github.repos.hooks.list 'user-name', 'repo-name' { |hook| ... }
|
|
46
|
+
#
|
|
47
|
+
# @api public
|
|
48
|
+
def list(*args)
|
|
49
|
+
arguments(args, required: [:user, :repo])
|
|
50
|
+
|
|
51
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/hooks", arguments.params)
|
|
52
|
+
return response unless block_given?
|
|
53
|
+
response.each { |el| yield el }
|
|
54
|
+
end
|
|
55
|
+
alias :all :list
|
|
56
|
+
|
|
57
|
+
# Get a single hook
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# github = Github.new
|
|
61
|
+
# github.repos.hooks.get 'user-name', 'repo-name', 'hook-id'
|
|
62
|
+
#
|
|
63
|
+
# @api public
|
|
64
|
+
def get(*args)
|
|
65
|
+
arguments(args, required: [:user, :repo, :id])
|
|
66
|
+
|
|
67
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/hooks/#{arguments.id}", arguments.params)
|
|
68
|
+
end
|
|
69
|
+
alias :find :get
|
|
70
|
+
|
|
71
|
+
# Create a hook
|
|
72
|
+
#
|
|
73
|
+
# @param [Hash] params
|
|
74
|
+
# @input params [String] :name
|
|
75
|
+
# Required. The name of the service that is being called.
|
|
76
|
+
# @input params [Hash] :config
|
|
77
|
+
# Required. Key/value pairs to provide settings for this hook.
|
|
78
|
+
# These settings vary between the services and are defined in
|
|
79
|
+
# the github-services repository. Booleans are stored internally
|
|
80
|
+
# as “1” for true, and “0” for false. Any JSON true/false values
|
|
81
|
+
# will be converted automatically.
|
|
82
|
+
# @input params [Array] :events
|
|
83
|
+
# Determines what events the hook is triggered for. Default: ["push"]
|
|
84
|
+
# @input params [Boolean] :active
|
|
85
|
+
# Determines whether the hook is actually triggered on pushes.
|
|
86
|
+
#
|
|
87
|
+
# To create a webhook, the following fields are required by the config:
|
|
88
|
+
#
|
|
89
|
+
# @input config [String] :url
|
|
90
|
+
# A required string defining the URL to which the payloads
|
|
91
|
+
# will be delivered.
|
|
92
|
+
# @input config [String] :content_type
|
|
93
|
+
# An optional string defining the media type used to serialize
|
|
94
|
+
# the payloads. Supported values include json and form.
|
|
95
|
+
# The default is form.
|
|
96
|
+
# @input config [String] :secret
|
|
97
|
+
# An optional string that’s passed with the HTTP requests as
|
|
98
|
+
# an X-Hub-Signature header. The value of this header is
|
|
99
|
+
# computed as the HMAC hex digest of the body,
|
|
100
|
+
# using the secret as the key.
|
|
101
|
+
# @input config [String] :insecure_ssl
|
|
102
|
+
# An optional string that determines whether the SSL certificate
|
|
103
|
+
# of the host for url will be verified when delivering payloads.
|
|
104
|
+
# Supported values include "0" (verification is performed) and
|
|
105
|
+
# "1" (verification is not performed). The default is "0".
|
|
106
|
+
#
|
|
107
|
+
# @example
|
|
108
|
+
# github = Github.new
|
|
109
|
+
# github.repos.hooks.create 'user-name', 'repo-name',
|
|
110
|
+
# name: "web",
|
|
111
|
+
# active: true,
|
|
112
|
+
# config: {
|
|
113
|
+
# url: "http://something.com/webhook"
|
|
114
|
+
# }
|
|
115
|
+
# }
|
|
116
|
+
#
|
|
117
|
+
# @api public
|
|
118
|
+
def create(*args)
|
|
119
|
+
arguments(args, required: [:user, :repo]) do
|
|
120
|
+
permit VALID_HOOK_PARAM_NAMES, recursive: false
|
|
121
|
+
assert_required REQUIRED_PARAMS
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/hooks", arguments.params)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Edit a hook
|
|
128
|
+
#
|
|
129
|
+
# @param [Hash] params
|
|
130
|
+
# @input params [Hash] :config
|
|
131
|
+
# Required. Key/value pairs to provide settings for this hook.
|
|
132
|
+
# These settings vary between the services and are defined in
|
|
133
|
+
# the github-services repository. Booleans are stored internally
|
|
134
|
+
# as “1” for true, and “0” for false. Any JSON true/false values
|
|
135
|
+
# will be converted automatically.
|
|
136
|
+
# @input params [Array] :events
|
|
137
|
+
# Determines what events the hook is triggered for. Default: ["push"]
|
|
138
|
+
# @input params [Array] :add_events
|
|
139
|
+
# Determines a list of events to be added to the list of events
|
|
140
|
+
# that the Hook triggers for.
|
|
141
|
+
# @input params [Array] :remove_events
|
|
142
|
+
# Determines a list of events to be removed from the list of
|
|
143
|
+
# events that the Hook triggers for.
|
|
144
|
+
# @input params [Boolean] :active
|
|
145
|
+
# Determines whether the hook is actually triggered on pushes.
|
|
146
|
+
#
|
|
147
|
+
# @example
|
|
148
|
+
# github = Github.new
|
|
149
|
+
# github.repos.hooks.edit 'user-name', 'repo-name', 'hook-id',
|
|
150
|
+
# "name" => "campfire",
|
|
151
|
+
# "active" => true,
|
|
152
|
+
# "config" => {
|
|
153
|
+
# "subdomain" => "github",
|
|
154
|
+
# "room" => "Commits",
|
|
155
|
+
# "token" => "abc123"
|
|
156
|
+
# }
|
|
157
|
+
#
|
|
158
|
+
# @api public
|
|
159
|
+
def edit(*args)
|
|
160
|
+
arguments(args, required: [:user, :repo, :id]) do
|
|
161
|
+
permit VALID_HOOK_PARAM_NAMES, recursive: false
|
|
162
|
+
assert_required REQUIRED_PARAMS
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/hooks/#{arguments.id}", arguments.params)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Test a hook
|
|
169
|
+
#
|
|
170
|
+
# This will trigger the hook with the latest push to the current
|
|
171
|
+
# repository if the hook is subscribed to push events. If the hook
|
|
172
|
+
# is not subscribed to push events, the server will respond with 204
|
|
173
|
+
# but no test POST will be generated.
|
|
174
|
+
#
|
|
175
|
+
# @example
|
|
176
|
+
# github = Github.new
|
|
177
|
+
# github.repos.hooks.test 'user-name', 'repo-name', 'hook-id'
|
|
178
|
+
#
|
|
179
|
+
# @api public
|
|
180
|
+
def test(*args)
|
|
181
|
+
arguments(args, required: [:user, :repo, :id])
|
|
182
|
+
|
|
183
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/hooks/#{arguments.id}/tests", arguments.params)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Ping a hook
|
|
187
|
+
#
|
|
188
|
+
# This will trigger a ping event to be sent to the hook.
|
|
189
|
+
#
|
|
190
|
+
# @example
|
|
191
|
+
# github = Github.new
|
|
192
|
+
# github.repos.hooks.ping 'user-name', 'repo-name', 'hook-id'
|
|
193
|
+
#
|
|
194
|
+
# @api public
|
|
195
|
+
def ping(*args)
|
|
196
|
+
arguments(args, required: [:user, :repo, :id])
|
|
197
|
+
|
|
198
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/hooks/#{arguments.id}/pings", arguments.params)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Delete a hook
|
|
202
|
+
#
|
|
203
|
+
# @example
|
|
204
|
+
# github = Github.new
|
|
205
|
+
# github.repos.hooks.delete 'user-name', 'repo-name', 'hook-id'
|
|
206
|
+
#
|
|
207
|
+
# @api public
|
|
208
|
+
def delete(*args)
|
|
209
|
+
arguments(args, required: [:user, :repo, :id])
|
|
210
|
+
|
|
211
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/hooks/#{arguments.id}", arguments.params)
|
|
212
|
+
end
|
|
213
|
+
end # Client::Repos::Hooks
|
|
214
|
+
end # Github
|