github_api 0.15.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +770 -0
- data/README.md +25 -8
- data/lib/github_api.rb +37 -76
- data/lib/github_api/api.rb +46 -19
- data/lib/github_api/api/arguments.rb +6 -1
- data/lib/github_api/api/config.rb +3 -5
- data/lib/github_api/api/config/property_set.rb +1 -0
- data/lib/github_api/authorization.rb +2 -0
- data/lib/github_api/client.rb +5 -0
- data/lib/github_api/client/activity.rb +2 -0
- data/lib/github_api/client/activity/events.rb +2 -0
- data/lib/github_api/client/activity/feeds.rb +2 -0
- data/lib/github_api/client/activity/notifications.rb +2 -0
- data/lib/github_api/client/activity/starring.rb +3 -1
- data/lib/github_api/client/activity/watching.rb +3 -1
- data/lib/github_api/client/authorizations.rb +2 -0
- data/lib/github_api/client/authorizations/app.rb +3 -1
- data/lib/github_api/client/emojis.rb +2 -0
- data/lib/github_api/client/gists.rb +4 -2
- data/lib/github_api/client/gists/comments.rb +3 -1
- data/lib/github_api/client/git_data.rb +2 -0
- data/lib/github_api/client/git_data/blobs.rb +2 -1
- data/lib/github_api/client/git_data/commits.rb +2 -0
- data/lib/github_api/client/git_data/references.rb +6 -2
- data/lib/github_api/client/git_data/tags.rb +2 -0
- data/lib/github_api/client/git_data/trees.rb +2 -0
- data/lib/github_api/client/gitignore.rb +2 -0
- data/lib/github_api/client/issues.rb +2 -0
- data/lib/github_api/client/issues/assignees.rb +35 -0
- data/lib/github_api/client/issues/comments.rb +2 -0
- data/lib/github_api/client/issues/events.rb +2 -0
- data/lib/github_api/client/issues/labels.rb +2 -0
- data/lib/github_api/client/issues/milestones.rb +2 -0
- data/lib/github_api/client/markdown.rb +4 -2
- data/lib/github_api/client/meta.rb +2 -0
- data/lib/github_api/client/orgs.rb +6 -0
- data/lib/github_api/client/orgs/hooks.rb +2 -0
- data/lib/github_api/client/orgs/members.rb +2 -0
- data/lib/github_api/client/orgs/memberships.rb +2 -0
- data/lib/github_api/client/orgs/projects.rb +57 -0
- data/lib/github_api/client/orgs/teams.rb +5 -3
- 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 +2 -0
- data/lib/github_api/client/pull_requests/comments.rb +2 -0
- data/lib/github_api/client/pull_requests/reviews.rb +2 -0
- data/lib/github_api/client/repos.rb +27 -15
- 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 +2 -1
- data/lib/github_api/client/repos/comments.rb +2 -1
- data/lib/github_api/client/repos/commits.rb +2 -0
- data/lib/github_api/client/repos/contents.rb +26 -4
- data/lib/github_api/client/repos/deployments.rb +3 -1
- data/lib/github_api/client/repos/downloads.rb +2 -0
- data/lib/github_api/client/repos/forks.rb +6 -2
- data/lib/github_api/client/repos/hooks.rb +2 -0
- data/lib/github_api/client/repos/invitations.rb +41 -0
- data/lib/github_api/client/repos/keys.rb +2 -0
- data/lib/github_api/client/repos/merging.rb +2 -0
- data/lib/github_api/client/repos/pages.rb +2 -0
- data/lib/github_api/client/repos/projects.rb +62 -0
- data/lib/github_api/client/repos/pub_sub_hubbub.rb +6 -6
- data/lib/github_api/client/repos/releases.rb +2 -0
- data/lib/github_api/client/repos/releases/assets.rb +3 -1
- data/lib/github_api/client/repos/releases/tags.rb +2 -0
- data/lib/github_api/client/repos/statistics.rb +2 -0
- data/lib/github_api/client/repos/statuses.rb +2 -0
- data/lib/github_api/client/say.rb +2 -0
- data/lib/github_api/client/scopes.rb +2 -0
- data/lib/github_api/client/search.rb +3 -0
- data/lib/github_api/client/search/legacy.rb +2 -0
- data/lib/github_api/client/users.rb +2 -0
- data/lib/github_api/client/users/emails.rb +3 -0
- data/lib/github_api/client/users/followers.rb +3 -1
- data/lib/github_api/client/users/keys.rb +2 -0
- data/lib/github_api/configuration.rb +4 -1
- data/lib/github_api/connection.rb +5 -1
- data/lib/github_api/error.rb +1 -4
- data/lib/github_api/error/client_error.rb +4 -2
- data/lib/github_api/error/service_error.rb +9 -2
- data/lib/github_api/ext/faraday.rb +3 -1
- data/lib/github_api/mash.rb +7 -0
- data/lib/github_api/middleware.rb +8 -6
- data/lib/github_api/normalizer.rb +3 -5
- data/lib/github_api/page_iterator.rb +4 -1
- data/lib/github_api/page_links.rb +4 -0
- data/lib/github_api/paged_request.rb +2 -0
- data/lib/github_api/pagination.rb +10 -7
- data/lib/github_api/parameter_filter.rb +4 -1
- data/lib/github_api/params_hash.rb +4 -4
- data/lib/github_api/request.rb +8 -9
- data/lib/github_api/request/basic_auth.rb +1 -1
- data/lib/github_api/request/jsonize.rb +0 -1
- data/lib/github_api/request/oauth2.rb +2 -0
- data/lib/github_api/request/verbs.rb +3 -0
- data/lib/github_api/response/follow_redirects.rb +140 -0
- data/lib/github_api/response/header.rb +6 -1
- data/lib/github_api/response/mashify.rb +2 -3
- data/lib/github_api/response/raise_error.rb +2 -1
- data/lib/github_api/response_wrapper.rb +5 -0
- data/lib/github_api/utils/url.rb +2 -0
- data/lib/github_api/validations.rb +5 -8
- data/lib/github_api/validations/format.rb +2 -0
- data/lib/github_api/validations/presence.rb +3 -1
- data/lib/github_api/validations/required.rb +2 -0
- data/lib/github_api/version.rb +2 -2
- metadata +100 -36
- data/lib/github_api/core_ext/ordered_hash.rb +0 -107
- data/lib/github_api/requestable.rb +0 -67
- data/lib/github_api/resource.rb +0 -13
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
class Client::Repos::Branches < API
|
7
|
+
require_all 'github_api/client/repos/branches', 'protections'
|
8
|
+
|
9
|
+
# Access to Repos::Branches::Protections API
|
10
|
+
namespace :protections
|
11
|
+
|
12
|
+
# List branches
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# github = Github.new
|
16
|
+
# github.repos.branches.list 'user-name', 'repo-name'
|
17
|
+
# github.repos(user: 'user-name', repo: 'repo-name').branches.list
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# repos = Github::Repos.new
|
21
|
+
# repos.branches.list 'user-name', 'repo-name'
|
22
|
+
#
|
23
|
+
# @api public
|
24
|
+
def list(*args)
|
25
|
+
arguments(args, required: [:user, :repo])
|
26
|
+
|
27
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/branches", arguments.params)
|
28
|
+
return response unless block_given?
|
29
|
+
response.each { |el| yield el }
|
30
|
+
end
|
31
|
+
alias :all :list
|
32
|
+
|
33
|
+
# Get branch
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# github = Github.new
|
37
|
+
# github.repos.branches.get 'user-name', 'repo-name', 'branch-name'
|
38
|
+
# github.repos.branches.get user: 'user-name', repo: 'repo-name', branch: 'branch-name'
|
39
|
+
# github.repos(user: 'user-name', repo: 'repo-name', branch: 'branch-name').branches.get
|
40
|
+
# @api public
|
41
|
+
def get(*args)
|
42
|
+
arguments(args, required: [:user, :repo, :branch])
|
43
|
+
|
44
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}", arguments.params)
|
45
|
+
end
|
46
|
+
alias :find :get
|
47
|
+
end # Client::Repos::Branches
|
48
|
+
end # Github
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../../../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
# The Branch Protections API
|
7
|
+
class Client::Repos::Branches::Protections < API
|
8
|
+
VALID_PROTECTION_PARAM_NAMES = %w[
|
9
|
+
required_status_checks
|
10
|
+
required_pull_request_reviews
|
11
|
+
enforce_admins
|
12
|
+
restrictions
|
13
|
+
accept
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
# Get a single branch's protection
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# github = Github.new
|
20
|
+
# github.repos.branches.protections.get 'user', 'repo', 'branch'
|
21
|
+
#
|
22
|
+
# @api public
|
23
|
+
def get(*args)
|
24
|
+
arguments(args, required: [:user, :repo, :branch])
|
25
|
+
|
26
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}/protection", arguments.params)
|
27
|
+
end
|
28
|
+
alias :find :get
|
29
|
+
|
30
|
+
# Edit a branch protection
|
31
|
+
#
|
32
|
+
# Users with push access to the repository can edit a branch protection.
|
33
|
+
#
|
34
|
+
# @param [Hash] params
|
35
|
+
# @input params [String] :required_status_checks
|
36
|
+
# Required.
|
37
|
+
# @input params [String] :enforce_admins
|
38
|
+
# Required.
|
39
|
+
# @input params [String] :restrictions
|
40
|
+
# Required.
|
41
|
+
# @input params [String] :required_pull_request_reviews
|
42
|
+
# Required.
|
43
|
+
# Look to the branch protection API to see how to use these
|
44
|
+
# https://developer.github.com/v3/repos/branches/#update-branch-protection
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# github = Github.new
|
48
|
+
# github.repos.branches.protections.edit 'user', 'repo', 'branch',
|
49
|
+
# required_pull_request_reviews: {dismiss_stale_reviews: false}
|
50
|
+
#
|
51
|
+
# @api public
|
52
|
+
def edit(*args)
|
53
|
+
arguments(args, required: [:user, :repo, :branch]) do
|
54
|
+
permit VALID_PROTECTION_PARAM_NAMES
|
55
|
+
end
|
56
|
+
|
57
|
+
put_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}/protection", arguments.params)
|
58
|
+
end
|
59
|
+
alias :update :edit
|
60
|
+
|
61
|
+
# Delete a branch protection
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# github = Github.new
|
65
|
+
# github.repos.branches.protections.delete 'user', 'repo', 'branch'
|
66
|
+
#
|
67
|
+
# @api public
|
68
|
+
def delete(*args)
|
69
|
+
arguments(args, required: [:user, :repo, :branch])
|
70
|
+
|
71
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}/protection", arguments.params)
|
72
|
+
end
|
73
|
+
alias :remove :delete
|
74
|
+
end # Client::Repos::Branches::Protections
|
75
|
+
end # Github
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client::Repos::Collaborators < API
|
5
7
|
# List collaborators
|
@@ -21,7 +23,6 @@ module Github
|
|
21
23
|
# @api public
|
22
24
|
def list(*args)
|
23
25
|
arguments(args, required: [:user, :repo])
|
24
|
-
params = arguments.params
|
25
26
|
|
26
27
|
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/collaborators", arguments.params)
|
27
28
|
return response unless block_given?
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client::Repos::Comments < API
|
5
7
|
|
@@ -81,7 +83,6 @@ module Github
|
|
81
83
|
# @api public
|
82
84
|
def create(*args)
|
83
85
|
arguments(args, required: [:user, :repo, :sha]) do
|
84
|
-
permit VALID_COMMENT_OPTIONS
|
85
86
|
assert_required REQUIRED_COMMENT_OPTIONS
|
86
87
|
end
|
87
88
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
# These API methods let you retrieve the contents of files within a repository
|
5
7
|
# as Base64 encoded content.
|
@@ -31,6 +33,23 @@ module Github
|
|
31
33
|
get_request("/repos/#{arguments.user}/#{arguments.repo}/readme", arguments.params)
|
32
34
|
end
|
33
35
|
|
36
|
+
# Get the LICENSE
|
37
|
+
#
|
38
|
+
# This method returns the contents of the repository's license file, if one is detected.
|
39
|
+
#
|
40
|
+
# @param [Hash] params
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# github = Github.new
|
44
|
+
# github.repos.contents.license 'user-name', 'repo-name'
|
45
|
+
#
|
46
|
+
# @api public
|
47
|
+
def license(*args)
|
48
|
+
arguments(args, required: [:user, :repo])
|
49
|
+
|
50
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/license", arguments.params)
|
51
|
+
end
|
52
|
+
|
34
53
|
# Get contents
|
35
54
|
#
|
36
55
|
# This method returns the contents of any file or directory in a repository.
|
@@ -64,12 +83,12 @@ module Github
|
|
64
83
|
#
|
65
84
|
# @param [Hash] params
|
66
85
|
# @option params [String] :path
|
67
|
-
#
|
86
|
+
# Required string. The content path
|
68
87
|
# @option params [String]
|
69
88
|
# @option params [String] :message
|
70
|
-
#
|
89
|
+
# Required string. The commit message.
|
71
90
|
# @option params [String] :content
|
72
|
-
#
|
91
|
+
# Required string. The new file content, which will be Base64 encoded
|
73
92
|
# @option params [String] :branch
|
74
93
|
# The branch name. If not provided, uses the repository’s
|
75
94
|
# default branch (usually master)
|
@@ -235,7 +254,10 @@ module Github
|
|
235
254
|
archive_format = params.delete('archive_format') || 'tarball'
|
236
255
|
ref = params.delete('ref') || 'master'
|
237
256
|
|
238
|
-
|
257
|
+
disable_redirects do
|
258
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/#{archive_format}/#{ref}", params)
|
259
|
+
response.headers.location
|
260
|
+
end
|
239
261
|
end
|
240
262
|
end # Client::Repos::Contents
|
241
263
|
end # Github
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client::Repos::Deployments < API
|
5
7
|
|
@@ -22,7 +24,7 @@ module Github
|
|
22
24
|
|
23
25
|
# List deployments on a repository
|
24
26
|
#
|
25
|
-
# @
|
27
|
+
# @example
|
26
28
|
# github = Github.new
|
27
29
|
# github.repos.deployments.list 'user-name', 'repo-name'
|
28
30
|
# github.repos.deployments.list 'user-name', 'repo-name' { |deployment| ... }
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client::Repos::Forks < API
|
5
7
|
# List repository forks
|
@@ -11,8 +13,10 @@ module Github
|
|
11
13
|
#
|
12
14
|
# @example
|
13
15
|
# github = Github.new
|
14
|
-
# github.repos.forks.list
|
15
|
-
# github.repos.forks.list
|
16
|
+
# github.repos.forks.list('user-name', 'repo-name')
|
17
|
+
# github.repos.forks.list('user-name', 'repo-name') { |fork|
|
18
|
+
# #...
|
19
|
+
# }
|
16
20
|
#
|
17
21
|
# @api public
|
18
22
|
def list(*args)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
class Client::Repos::Invitations < API
|
7
|
+
# List repo invitations
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# github = Github.new
|
11
|
+
# github.repos.invitations.list 'user-name', 'repo-name'
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# github.repos.invitations.list 'user-name', 'repo-name' { |cbr| .. }
|
15
|
+
#
|
16
|
+
# @return [Array]
|
17
|
+
#
|
18
|
+
# @api public
|
19
|
+
def list(*args)
|
20
|
+
arguments(args, required: [:user, :repo])
|
21
|
+
|
22
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/invitations", arguments.params)
|
23
|
+
return response unless block_given?
|
24
|
+
response.each { |el| yield el }
|
25
|
+
end
|
26
|
+
alias :all :list
|
27
|
+
|
28
|
+
# Deletes a repo invitation
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# github = Github.new
|
32
|
+
# github.repos.invitations.delete 'user-name', 'repo-name', 'invitation-id'
|
33
|
+
#
|
34
|
+
# @api public
|
35
|
+
def delete(*args)
|
36
|
+
arguments(args, required: [:user, :repo, :id])
|
37
|
+
|
38
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/invitations/#{arguments.id}", arguments.params)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -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
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client::Repos::PubSubHubbub < API
|
5
|
-
|
6
|
-
|
7
|
-
CONTENT_TYPE => 'application/x-www-form-urlencoded'
|
8
|
-
}
|
7
|
+
HEADERS = {
|
8
|
+
CONTENT_TYPE => 'application/x-www-form-urlencoded'
|
9
9
|
}
|
10
10
|
|
11
11
|
# Subscribe to existing topic/event through pubsubhubbub
|
@@ -29,7 +29,7 @@ module Github
|
|
29
29
|
def subscribe(*args)
|
30
30
|
params = arguments(args, required: [:topic, :callback]).params
|
31
31
|
_merge_action!("subscribe", arguments.topic, arguments.callback, params)
|
32
|
-
params['
|
32
|
+
params['headers'] = HEADERS
|
33
33
|
|
34
34
|
post_request("/hub", params)
|
35
35
|
end
|
@@ -56,7 +56,7 @@ module Github
|
|
56
56
|
def unsubscribe(*args)
|
57
57
|
params = arguments(args, required: [:topic, :callback]).params
|
58
58
|
_merge_action!("unsubscribe", arguments.topic, arguments.callback, params)
|
59
|
-
params['
|
59
|
+
params['headers'] = HEADERS
|
60
60
|
|
61
61
|
post_request("/hub", params)
|
62
62
|
end
|