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,104 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Repos::Keys < API
|
|
7
|
+
# List deploy keys
|
|
8
|
+
#
|
|
9
|
+
# @see https://developer.github.com/v3/repos/keys/#list
|
|
10
|
+
#
|
|
11
|
+
# @param [String] :user
|
|
12
|
+
# @param [String :repo
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# github = Github.new
|
|
16
|
+
# github.repos.keys.list 'user-name', 'repo-name'
|
|
17
|
+
# github.repos.keys.list 'user-name', 'repo-name' { |key| ... }
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# keys = Github::Repos::Keys.new user: 'user-name', repo: 'repo-name'
|
|
21
|
+
# keys.list
|
|
22
|
+
#
|
|
23
|
+
# @api public
|
|
24
|
+
def list(*args)
|
|
25
|
+
arguments(args, required: [:user, :repo])
|
|
26
|
+
|
|
27
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
|
|
28
|
+
arguments.params)
|
|
29
|
+
return response unless block_given?
|
|
30
|
+
response.each { |el| yield el }
|
|
31
|
+
end
|
|
32
|
+
alias_method :all, :list
|
|
33
|
+
|
|
34
|
+
# Get a key
|
|
35
|
+
#
|
|
36
|
+
# @see https://developer.github.com/v3/repos/keys/#get
|
|
37
|
+
#
|
|
38
|
+
# @param [String] :user
|
|
39
|
+
# @param [String] :repo
|
|
40
|
+
# @param [Integer] :id
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# github = Github.new
|
|
44
|
+
# github.repos.keys.get 'user-name', 'repo-name', 'key-id'
|
|
45
|
+
#
|
|
46
|
+
# @api public
|
|
47
|
+
def get(*args)
|
|
48
|
+
arguments(args, required: [:user, :repo, :id])
|
|
49
|
+
|
|
50
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", arguments.params)
|
|
51
|
+
end
|
|
52
|
+
alias_method :find, :get
|
|
53
|
+
|
|
54
|
+
# Create a key
|
|
55
|
+
#
|
|
56
|
+
# @see https://developer.github.com/v3/repos/keys/#create
|
|
57
|
+
#
|
|
58
|
+
# @param [String] :user
|
|
59
|
+
# @param [String] :repo
|
|
60
|
+
# @param [Hash] params
|
|
61
|
+
# @option params [String] :title
|
|
62
|
+
# Required string.
|
|
63
|
+
# @option params [String] :key
|
|
64
|
+
# Required string.
|
|
65
|
+
# @option params [String] :read_only
|
|
66
|
+
# If true, the key will only be able to read repository contents.
|
|
67
|
+
# Otherwise, the key will be able to read and write.
|
|
68
|
+
#
|
|
69
|
+
# @example
|
|
70
|
+
# github = Github.new
|
|
71
|
+
# github.repos.keys.create 'user-name', 'repo-name',
|
|
72
|
+
# title: "octocat@octomac",
|
|
73
|
+
# key: "ssh-rsa AAA..."
|
|
74
|
+
#
|
|
75
|
+
# @api public
|
|
76
|
+
def create(*args)
|
|
77
|
+
arguments(args, required: [:user, :repo])
|
|
78
|
+
|
|
79
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/keys",
|
|
80
|
+
arguments.params)
|
|
81
|
+
end
|
|
82
|
+
alias_method :add, :create
|
|
83
|
+
|
|
84
|
+
# Delete key
|
|
85
|
+
#
|
|
86
|
+
# @see https://developer.github.com/v3/repos/keys/#delete
|
|
87
|
+
#
|
|
88
|
+
# @param [String] :user
|
|
89
|
+
# @param [String] :repo
|
|
90
|
+
# @param [Integer] :id
|
|
91
|
+
#
|
|
92
|
+
# @example
|
|
93
|
+
# github = Github.new
|
|
94
|
+
# github.repos.keys.delete 'user-name', 'repo-name', 'key-id'
|
|
95
|
+
#
|
|
96
|
+
# @api public
|
|
97
|
+
def delete(*args)
|
|
98
|
+
arguments(args, required: [:user, :repo, :id])
|
|
99
|
+
|
|
100
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", arguments.params)
|
|
101
|
+
end
|
|
102
|
+
alias_method :remove, :delete
|
|
103
|
+
end # Client::Repos::Keys
|
|
104
|
+
end # Github
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
# The Repo Merging API supports merging branches in a repository. This
|
|
7
|
+
# accomplishes essentially the same thing as merging one branch into another
|
|
8
|
+
# in a local repository and then pushing to GitHub.
|
|
9
|
+
class Client::Repos::Merging < API
|
|
10
|
+
|
|
11
|
+
VALID_MERGE_PARAM_NAMES = %w[
|
|
12
|
+
base
|
|
13
|
+
head
|
|
14
|
+
commit_message
|
|
15
|
+
].freeze # :nodoc:
|
|
16
|
+
|
|
17
|
+
REQUIRED_MERGE_PARAMS = %w[ base head ].freeze # :nodoc:
|
|
18
|
+
|
|
19
|
+
# Perform a merge
|
|
20
|
+
#
|
|
21
|
+
# @param [Hash] params
|
|
22
|
+
# @input params [String] :base
|
|
23
|
+
# Required. The name of the base branch that the head will be merged into.
|
|
24
|
+
# @input params [String] :head
|
|
25
|
+
# Required. The head to merge. This can be a branch name or a commit SHA1.
|
|
26
|
+
# @input params [String] :commit_message
|
|
27
|
+
# Commit message to use for the merge commit.
|
|
28
|
+
# If omitted, a default message will be used.
|
|
29
|
+
#
|
|
30
|
+
# @example
|
|
31
|
+
# github = Github.new
|
|
32
|
+
# github.repos.merging.merge 'user', 'repo',
|
|
33
|
+
# base: "master",
|
|
34
|
+
# head: "cool_feature",
|
|
35
|
+
# commit_message: "Shipped cool_feature!"
|
|
36
|
+
#
|
|
37
|
+
# @api public
|
|
38
|
+
def merge(*args)
|
|
39
|
+
arguments(args, required: [:user, :repo]) do
|
|
40
|
+
permit VALID_MERGE_PARAM_NAMES
|
|
41
|
+
assert_required REQUIRED_MERGE_PARAMS
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/merges", arguments.params)
|
|
45
|
+
end
|
|
46
|
+
end # Client::Repos::Merging
|
|
47
|
+
end # Github
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
# The Pages API retrieves information about your GitHub Pages configuration,
|
|
7
|
+
# and the statuses of your builds. Information about the site and the builds
|
|
8
|
+
# can only be accessed by authenticated owners, even though the websites
|
|
9
|
+
# are public.
|
|
10
|
+
class Client::Repos::Pages < API
|
|
11
|
+
|
|
12
|
+
# List Pages builds
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# github = Github.new
|
|
16
|
+
# github.repos.pages.list owner: 'owner-name', repo: 'repo-name'
|
|
17
|
+
#
|
|
18
|
+
# github = Github.new
|
|
19
|
+
# github.repos.pages.list :latest, owner: 'owner-name', repo: 'repo-name'
|
|
20
|
+
# @api public
|
|
21
|
+
def list(*args)
|
|
22
|
+
arguments(args, required: [:owner, :repo])
|
|
23
|
+
|
|
24
|
+
response = if args.map(&:to_s).include?('latest')
|
|
25
|
+
get_request("/repos/#{arguments.owner}/#{arguments.repo}/pages/builds/latest", arguments.params)
|
|
26
|
+
else
|
|
27
|
+
get_request("/repos/#{arguments.owner}/#{arguments.repo}/pages/builds", arguments.params)
|
|
28
|
+
end
|
|
29
|
+
return response unless block_given?
|
|
30
|
+
response.each { |el| yield el }
|
|
31
|
+
end
|
|
32
|
+
alias :all :list
|
|
33
|
+
|
|
34
|
+
# Get information about a Pages site
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# github = Github.new
|
|
38
|
+
# github.repos.pages.get owner: 'owner-name', repo: 'repo-name'
|
|
39
|
+
#
|
|
40
|
+
# @api public
|
|
41
|
+
def get(*args)
|
|
42
|
+
arguments(args, required: [:owner, :repo])
|
|
43
|
+
|
|
44
|
+
get_request("/repos/#{arguments.owner}/#{arguments.repo}/pages", arguments.params)
|
|
45
|
+
end
|
|
46
|
+
alias :find :get
|
|
47
|
+
end # Client::Repos::Pages
|
|
48
|
+
end # Github
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Repos::Projects < API
|
|
7
|
+
PREVIEW_MEDIA = "application/vnd.github.inertia-preview+json".freeze # :nodoc:
|
|
8
|
+
|
|
9
|
+
# List a repo's projects
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# github = Github.new
|
|
13
|
+
# github.repos.projects.list owner: 'owner-name', repo: 'repo-name'
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# github = Github.new
|
|
17
|
+
# github.repos.projects.list state: 'open', owner: 'owner-name', repo: 'repo-name'
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# github.repos.projects.list owner: 'owner-name', repo: 'repo-name' { |cbr| .. }
|
|
21
|
+
#
|
|
22
|
+
# @return [Array]
|
|
23
|
+
#
|
|
24
|
+
# @api public
|
|
25
|
+
def list(*args)
|
|
26
|
+
arguments(args, required: [:owner, :repo])
|
|
27
|
+
params = arguments.params
|
|
28
|
+
|
|
29
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
30
|
+
|
|
31
|
+
response = get_request("/repos/#{arguments.owner}/#{arguments.repo}/projects", params)
|
|
32
|
+
return response unless block_given?
|
|
33
|
+
response.each { |el| yield el }
|
|
34
|
+
end
|
|
35
|
+
alias :all :list
|
|
36
|
+
|
|
37
|
+
# Create a new project for the specified repo
|
|
38
|
+
#
|
|
39
|
+
# @param [Hash] params
|
|
40
|
+
# @option params [String] :name
|
|
41
|
+
# Required string - The name of the project.
|
|
42
|
+
# @option params [String] :body
|
|
43
|
+
# Optional string - The body of the project.
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# github = Github.new
|
|
47
|
+
# github.repos.projects.create 'owner-name', 'repo-name', name: 'project-name'
|
|
48
|
+
# github.repos.projects.create name: 'project-name', body: 'project-body', owner: 'owner-name', repo: 'repo-name'
|
|
49
|
+
#
|
|
50
|
+
# @api public
|
|
51
|
+
def create(*args)
|
|
52
|
+
arguments(args, required: [:owner, :repo]) do
|
|
53
|
+
assert_required %w[ name ]
|
|
54
|
+
end
|
|
55
|
+
params = arguments.params
|
|
56
|
+
|
|
57
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
58
|
+
|
|
59
|
+
post_request("/repos/#{arguments.owner}/#{arguments.repo}/projects", params)
|
|
60
|
+
end
|
|
61
|
+
end # Projects
|
|
62
|
+
end # Github
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Repos::PubSubHubbub < API
|
|
7
|
+
HEADERS = {
|
|
8
|
+
CONTENT_TYPE => 'application/x-www-form-urlencoded'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
# Subscribe to existing topic/event through pubsubhubbub
|
|
12
|
+
#
|
|
13
|
+
# @param [Hash] params
|
|
14
|
+
# @input params [String] :topic
|
|
15
|
+
# Required string. The URI of the GitHub repository to subscribe to.
|
|
16
|
+
# The path must be in the format of /:user/:repo/events/:event.
|
|
17
|
+
# @input params [String] :callback
|
|
18
|
+
# Required string - The URI to receive the updates to the topic.
|
|
19
|
+
#
|
|
20
|
+
# @example
|
|
21
|
+
# github = Github.new oauth_token: 'token'
|
|
22
|
+
# github.repos.pubsubhubbub.subscribe
|
|
23
|
+
# 'https://github.com/:user/:repo/events/push',
|
|
24
|
+
# 'github://Email?address=peter-murach@gmail.com',
|
|
25
|
+
# verify: 'sync',
|
|
26
|
+
# secret: '...'
|
|
27
|
+
#
|
|
28
|
+
# @api public
|
|
29
|
+
def subscribe(*args)
|
|
30
|
+
params = arguments(args, required: [:topic, :callback]).params
|
|
31
|
+
_merge_action!("subscribe", arguments.topic, arguments.callback, params)
|
|
32
|
+
params['headers'] = HEADERS
|
|
33
|
+
|
|
34
|
+
post_request("/hub", params)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Unsubscribe from existing topic/event through pubsubhubbub
|
|
38
|
+
#
|
|
39
|
+
# @param [Hash] params
|
|
40
|
+
# @input params [String] :topic
|
|
41
|
+
# Required string. The URI of the GitHub repository to
|
|
42
|
+
# unsubscribe from. The path must be in the format of
|
|
43
|
+
# /:user/:repo/events/:event.
|
|
44
|
+
# @input params [String] :callback
|
|
45
|
+
# Required string. The URI to unsubscribe the topic from.
|
|
46
|
+
#
|
|
47
|
+
# @example
|
|
48
|
+
# github = Github.new oauth_token: 'token'
|
|
49
|
+
# github.repos.pubsubhubbub.unsubscribe
|
|
50
|
+
# 'https://github.com/:user/:repo/events/push',
|
|
51
|
+
# 'github://Email?address=peter-murach@gmail.com',
|
|
52
|
+
# verify: 'sync',
|
|
53
|
+
# secret: '...'
|
|
54
|
+
#
|
|
55
|
+
# @api public
|
|
56
|
+
def unsubscribe(*args)
|
|
57
|
+
params = arguments(args, required: [:topic, :callback]).params
|
|
58
|
+
_merge_action!("unsubscribe", arguments.topic, arguments.callback, params)
|
|
59
|
+
params['headers'] = HEADERS
|
|
60
|
+
|
|
61
|
+
post_request("/hub", params)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Subscribe repository to service hook through pubsubhubbub
|
|
65
|
+
#
|
|
66
|
+
# @param [Hash] params
|
|
67
|
+
# @input params [String] :event
|
|
68
|
+
# Required hash key for the type of event. The default event is push.
|
|
69
|
+
#
|
|
70
|
+
# @example
|
|
71
|
+
# github = Github.new oauth_token: '...'
|
|
72
|
+
# github.repos.pubsubhubbub.subscribe_service 'user-name', 'repo-name',
|
|
73
|
+
# 'campfire',
|
|
74
|
+
# subdomain: 'github',
|
|
75
|
+
# room: 'Commits',
|
|
76
|
+
# token: 'abc123',
|
|
77
|
+
# event: 'watch'
|
|
78
|
+
#
|
|
79
|
+
# @api public
|
|
80
|
+
def subscribe_service(*args)
|
|
81
|
+
params = arguments(args, required: [:user, :repo, :service]).params
|
|
82
|
+
event = params.delete('event') || 'push'
|
|
83
|
+
topic = "#{site}/#{arguments.user}/#{arguments.repo}/events/#{event}"
|
|
84
|
+
callback = "github://#{arguments.service}?#{params.serialize}"
|
|
85
|
+
|
|
86
|
+
subscribe(topic, callback)
|
|
87
|
+
end
|
|
88
|
+
alias :subscribe_repository :subscribe_service
|
|
89
|
+
alias :subscribe_repo :subscribe_service
|
|
90
|
+
|
|
91
|
+
# Subscribe repository to service hook through pubsubhubbub
|
|
92
|
+
#
|
|
93
|
+
# @param [Hash] params
|
|
94
|
+
# @input params [String] :event
|
|
95
|
+
# Optional hash key for the type of event. The default event is push.
|
|
96
|
+
#
|
|
97
|
+
# @example
|
|
98
|
+
# github = Github.new oauth_token: '...'
|
|
99
|
+
# github.repos.pubsubhubbub.unsubscribe_service 'user-name', 'repo-name',
|
|
100
|
+
# 'campfire'
|
|
101
|
+
#
|
|
102
|
+
# @example
|
|
103
|
+
# github.repos.pubsubhubbub.unsubscribe_service
|
|
104
|
+
# user: 'user-name',
|
|
105
|
+
# repo: 'repo-name',
|
|
106
|
+
# service: 'service-name'
|
|
107
|
+
#
|
|
108
|
+
# @api public
|
|
109
|
+
def unsubscribe_service(*args)
|
|
110
|
+
params = arguments(args, required: [:user, :repo, :service]).params
|
|
111
|
+
event = params.delete('event') || 'push'
|
|
112
|
+
topic = "#{site}/#{arguments.user}/#{arguments.repo}/events/#{event}"
|
|
113
|
+
callback = "github://#{arguments.service}"
|
|
114
|
+
|
|
115
|
+
unsubscribe(topic, callback)
|
|
116
|
+
end
|
|
117
|
+
alias :unsubscribe_repository :unsubscribe_service
|
|
118
|
+
alias :unsubscribe_repo :unsubscribe_service
|
|
119
|
+
|
|
120
|
+
private
|
|
121
|
+
|
|
122
|
+
def _merge_action!(action, topic, callback, params) # :nodoc:
|
|
123
|
+
options = {
|
|
124
|
+
"hub.mode" => action.to_s,
|
|
125
|
+
"hub.topic" => topic.to_s,
|
|
126
|
+
"hub.callback" => callback,
|
|
127
|
+
"hub.verify" => params.delete('verify') || 'sync',
|
|
128
|
+
"hub.secret" => params.delete('secret') || ''
|
|
129
|
+
}
|
|
130
|
+
params.merge! options
|
|
131
|
+
end
|
|
132
|
+
end # Client::Repos::PubSubHubbub
|
|
133
|
+
end # Github
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
# The Releases API
|
|
7
|
+
class Client::Repos::Releases < API
|
|
8
|
+
|
|
9
|
+
require_all 'github_api/client/repos/releases', 'assets', 'tags'
|
|
10
|
+
|
|
11
|
+
# Access to Repos::Releases::Assets API
|
|
12
|
+
namespace :assets
|
|
13
|
+
|
|
14
|
+
# Access to Repos::Releases::Tags API
|
|
15
|
+
namespace :tags
|
|
16
|
+
|
|
17
|
+
# List releases for a repository
|
|
18
|
+
#
|
|
19
|
+
# Users with push access to the repository will receive all releases
|
|
20
|
+
# (i.e., published releases and draft releases). Users with pull access
|
|
21
|
+
# will receive published releases only.
|
|
22
|
+
#
|
|
23
|
+
# @see https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# github = Github.new
|
|
27
|
+
# github.repos.releases.list 'owner', 'repo'
|
|
28
|
+
# github.repos.releases.list 'owner', 'repo' { |release| ... }
|
|
29
|
+
#
|
|
30
|
+
# @api public
|
|
31
|
+
def list(*args)
|
|
32
|
+
arguments(args, required: [:owner, :repo])
|
|
33
|
+
|
|
34
|
+
response = get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases", arguments.params)
|
|
35
|
+
return response unless block_given?
|
|
36
|
+
response.each { |el| yield el }
|
|
37
|
+
end
|
|
38
|
+
alias_method :all, :list
|
|
39
|
+
|
|
40
|
+
# Get a single release
|
|
41
|
+
#
|
|
42
|
+
# @see https://developer.github.com/v3/repos/releases/#get-a-single-release
|
|
43
|
+
#
|
|
44
|
+
# @example
|
|
45
|
+
# github = Github.new
|
|
46
|
+
# github.repos.releases.get 'owner', 'repo', 'id'
|
|
47
|
+
#
|
|
48
|
+
# @api public
|
|
49
|
+
def get(*args)
|
|
50
|
+
arguments(args, required: [:owner, :repo, :id]).params
|
|
51
|
+
|
|
52
|
+
get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}" , arguments.params)
|
|
53
|
+
end
|
|
54
|
+
alias_method :find, :get
|
|
55
|
+
|
|
56
|
+
# Create a release
|
|
57
|
+
#
|
|
58
|
+
# Users with push access to the repository can create a release.
|
|
59
|
+
#
|
|
60
|
+
# @see https://developer.github.com/v3/repos/releases/#create-a-release
|
|
61
|
+
#
|
|
62
|
+
# @param [Hash] params
|
|
63
|
+
# @input params [String] :tag_name
|
|
64
|
+
# Required. The name of the tag.
|
|
65
|
+
# @input params [String] :target_commitish
|
|
66
|
+
# Specifies the commitish value that determines where the Git tag
|
|
67
|
+
# is created from. Can be any branch or commit SHA. Defaults to
|
|
68
|
+
# the repository's default branch (usually 'master').
|
|
69
|
+
# Unused if the Git tag already exists.
|
|
70
|
+
# @input params [String] :name
|
|
71
|
+
# The name of the release.
|
|
72
|
+
# @input params [String] :body
|
|
73
|
+
# Text describing the contents of the tag.
|
|
74
|
+
# @input params [Boolean] :draft
|
|
75
|
+
# true to create a draft (unpublished) release,
|
|
76
|
+
# false to create a published one. Default: false
|
|
77
|
+
# @input params [Boolean] :prerelease
|
|
78
|
+
# true to identify the release as a prerelease.
|
|
79
|
+
# false to identify the release as a full release. Default: false
|
|
80
|
+
#
|
|
81
|
+
# @example
|
|
82
|
+
# github = Github.new
|
|
83
|
+
# github.repos.releases.create 'owner', 'repo',
|
|
84
|
+
# tag_name: "v1.0.0",
|
|
85
|
+
# target_commitish: "master",
|
|
86
|
+
# name: "v1.0.0",
|
|
87
|
+
# body: "Description of the release",
|
|
88
|
+
# draft: false,
|
|
89
|
+
# prerelease: false
|
|
90
|
+
#
|
|
91
|
+
# @api public
|
|
92
|
+
def create(*args)
|
|
93
|
+
arguments(args, required: [:owner, :repo]) do
|
|
94
|
+
assert_required :tag_name
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
post_request("/repos/#{arguments.owner}/#{arguments.repo}/releases",
|
|
98
|
+
arguments.params)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Edit a release
|
|
102
|
+
#
|
|
103
|
+
# Users with push access to the repository can edit a release.
|
|
104
|
+
#
|
|
105
|
+
# @see https://developer.github.com/v3/repos/releases/#edit-a-release
|
|
106
|
+
#
|
|
107
|
+
# @param [String] :owner
|
|
108
|
+
# @param [String] :repo
|
|
109
|
+
# @param [Integer] :id
|
|
110
|
+
# @param [Hash] params
|
|
111
|
+
# @input params [String] :tag_name
|
|
112
|
+
# Required. The name of the tag.
|
|
113
|
+
# @input params [String] :target_commitish
|
|
114
|
+
# Specifies the commitish value that determines where the Git tag
|
|
115
|
+
# is created from. Can be any branch or commit SHA. Defaults to
|
|
116
|
+
# the repository's default branch (usually 'master').
|
|
117
|
+
# Unused if the Git tag already exists.
|
|
118
|
+
# @input params [String] :name
|
|
119
|
+
# The name of the release.
|
|
120
|
+
# @input params [String] :body
|
|
121
|
+
# Text describing the contents of the tag.
|
|
122
|
+
# @input params [Boolean] :draft
|
|
123
|
+
# true to create a draft (unpublished) release,
|
|
124
|
+
# false to create a published one. Default: false
|
|
125
|
+
# @input params [Boolean] :prerelease
|
|
126
|
+
# true to identify the release as a prerelease.
|
|
127
|
+
# false to identify the release as a full release. Default: false
|
|
128
|
+
#
|
|
129
|
+
# @example
|
|
130
|
+
# github = Github.new
|
|
131
|
+
# github.repos.releases.edit 'owner', 'repo', 'id',
|
|
132
|
+
# tag_name: "v1.0.0",
|
|
133
|
+
# target_commitish: "master",
|
|
134
|
+
# name: "v1.0.0",
|
|
135
|
+
# body: "Description of the release",
|
|
136
|
+
# draft: false,
|
|
137
|
+
# prerelease: false
|
|
138
|
+
#
|
|
139
|
+
# @api public
|
|
140
|
+
def edit(*args)
|
|
141
|
+
arguments(args, required: [:owner, :repo, :id])
|
|
142
|
+
|
|
143
|
+
patch_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}", arguments.params)
|
|
144
|
+
end
|
|
145
|
+
alias_method :update, :edit
|
|
146
|
+
|
|
147
|
+
# Delete a release
|
|
148
|
+
#
|
|
149
|
+
# Users with push access to the repository can delete a release.
|
|
150
|
+
#
|
|
151
|
+
# @see https://developer.github.com/v3/repos/releases/#delete-a-release
|
|
152
|
+
#
|
|
153
|
+
# @param [String] :owner
|
|
154
|
+
# @param [String] :repo
|
|
155
|
+
# @param [Integer] :id
|
|
156
|
+
#
|
|
157
|
+
# @example
|
|
158
|
+
# github = Github.new
|
|
159
|
+
# github.repos.releases.delete 'owner', 'repo', 'id'
|
|
160
|
+
#
|
|
161
|
+
# @api public
|
|
162
|
+
def delete(*args)
|
|
163
|
+
arguments(args, required: [:owner, :repo, :id]).params
|
|
164
|
+
|
|
165
|
+
delete_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}", arguments.params)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Get the latest release
|
|
169
|
+
#
|
|
170
|
+
# View the latest published full release for the repository.
|
|
171
|
+
# Draft releases and prereleases are not returned.
|
|
172
|
+
#
|
|
173
|
+
# @see https://developer.github.com/v3/repos/releases/#get-the-latest-release
|
|
174
|
+
#
|
|
175
|
+
# @param [String] :owner
|
|
176
|
+
# @param [String] :repo
|
|
177
|
+
#
|
|
178
|
+
# @example
|
|
179
|
+
# github = Github.new
|
|
180
|
+
# github.repos.releases.latest 'owner', 'repo'
|
|
181
|
+
#
|
|
182
|
+
# @api public
|
|
183
|
+
def latest(*args)
|
|
184
|
+
arguments(args, required: [:owner, :repo]).params
|
|
185
|
+
|
|
186
|
+
get_request("repos/#{arguments.owner}/#{arguments.repo}/releases/latest", arguments.params)
|
|
187
|
+
end
|
|
188
|
+
end # Client::Repos::Statuses
|
|
189
|
+
end # Github
|