github_api 0.17.0 → 0.18.1
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 +4 -4
- data/lib/github_api.rb +38 -76
- data/lib/github_api/api.rb +35 -18
- data/lib/github_api/api/arguments.rb +5 -0
- data/lib/github_api/api/config.rb +2 -4
- 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 +2 -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 +2 -0
- data/lib/github_api/client/activity/watching.rb +2 -0
- 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 +2 -0
- data/lib/github_api/client/gists/comments.rb +2 -0
- 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 +2 -0
- 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 +3 -1
- data/lib/github_api/client/meta.rb +2 -0
- data/lib/github_api/client/orgs.rb +2 -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 +2 -0
- data/lib/github_api/client/orgs/teams.rb +2 -0
- data/lib/github_api/client/projects.rb +2 -0
- data/lib/github_api/client/projects/cards.rb +3 -1
- data/lib/github_api/client/projects/columns.rb +2 -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 +17 -13
- 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 -0
- data/lib/github_api/client/repos/commits.rb +2 -0
- data/lib/github_api/client/repos/contents.rb +2 -0
- data/lib/github_api/client/repos/deployments.rb +2 -0
- data/lib/github_api/client/repos/downloads.rb +2 -0
- data/lib/github_api/client/repos/forks.rb +2 -0
- data/lib/github_api/client/repos/hooks.rb +2 -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 +4 -2
- data/lib/github_api/client/repos/pub_sub_hubbub.rb +2 -0
- 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 +2 -0
- data/lib/github_api/client/users/keys.rb +2 -0
- data/lib/github_api/configuration.rb +2 -1
- data/lib/github_api/connection.rb +4 -0
- data/lib/github_api/error.rb +1 -4
- data/lib/github_api/error/client_error.rb +2 -0
- data/lib/github_api/error/service_error.rb +2 -0
- data/lib/github_api/ext/faraday.rb +1 -1
- data/lib/github_api/middleware.rb +7 -7
- 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 +4 -1
- data/lib/github_api/parameter_filter.rb +4 -1
- data/lib/github_api/params_hash.rb +3 -0
- data/lib/github_api/request.rb +5 -5
- 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/header.rb +2 -0
- 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 +2 -0
- data/lib/github_api/validations/required.rb +2 -0
- data/lib/github_api/version.rb +1 -1
- metadata +9 -34
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client::Issues::Assignees < API
|
5
7
|
# Lists all the available assignees (owner + collaborators)
|
@@ -38,5 +40,38 @@ module Github
|
|
38
40
|
rescue Github::Error::NotFound
|
39
41
|
false
|
40
42
|
end
|
43
|
+
|
44
|
+
# Add assignees to an issue
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# github = Github.new
|
48
|
+
# github.issues.assignees.add 'user', 'repo', 'issue-number',
|
49
|
+
# 'hubot', 'other_assignee', ...
|
50
|
+
#
|
51
|
+
# @api public
|
52
|
+
def add(*args)
|
53
|
+
arguments(args, required: [:user, :repo, :number])
|
54
|
+
params = arguments.params
|
55
|
+
params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty?
|
56
|
+
|
57
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params)
|
58
|
+
end
|
59
|
+
alias :<< :add
|
60
|
+
|
61
|
+
# Remove a assignees from an issue
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# github = Github.new
|
65
|
+
# github.issues.assignees.remove 'user', 'repo', 'issue-number',
|
66
|
+
# 'hubot', 'other_assignee'
|
67
|
+
#
|
68
|
+
# @api public
|
69
|
+
def remove(*args)
|
70
|
+
arguments(args, required: [:user, :repo, :number])
|
71
|
+
params = arguments.params
|
72
|
+
params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty?
|
73
|
+
|
74
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params)
|
75
|
+
end
|
41
76
|
end # Issues::Assignees
|
42
77
|
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::Markdown < API
|
5
7
|
|
@@ -49,7 +51,7 @@ module Github
|
|
49
51
|
#
|
50
52
|
def render_raw(*args)
|
51
53
|
params = arguments(args).params
|
52
|
-
|
54
|
+
params['data'] = args.shift
|
53
55
|
params['raw'] = true
|
54
56
|
params['accept'] = params.fetch('accept') { 'text/plain' }
|
55
57
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
+
require_relative '../../api'
|
5
|
+
|
4
6
|
module Github
|
5
7
|
class Client::Projects::Cards < API
|
6
8
|
REQUIRED_MOVE_CARD_PARAMS = %w(position).freeze
|
@@ -65,7 +67,7 @@ module Github
|
|
65
67
|
#
|
66
68
|
# @example
|
67
69
|
# github = Github.new
|
68
|
-
# github.projects.cards.create :column_id,
|
70
|
+
# github.projects.cards.create :column_id, content_id: <content-id>, content_type: 'content-type'
|
69
71
|
#
|
70
72
|
# @see https://developer.github.com/v3/projects/cards/#create-a-project-card
|
71
73
|
#
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require_relative '../api'
|
4
|
+
|
3
5
|
module Github
|
4
6
|
class Client::Repos < API
|
5
7
|
# Load all the modules after initializing Repos to avoid superclass mismatch
|
6
8
|
require_all 'github_api/client/repos',
|
9
|
+
'branches',
|
7
10
|
'collaborators',
|
8
11
|
'comments',
|
9
12
|
'commits',
|
@@ -87,6 +90,9 @@ module Github
|
|
87
90
|
# Access to Repos::Statuses API
|
88
91
|
namespace :statuses
|
89
92
|
|
93
|
+
# Access to Repos::Branches API
|
94
|
+
namespace :branches
|
95
|
+
|
90
96
|
# List repositories for the authenticated user
|
91
97
|
#
|
92
98
|
# @example
|
@@ -278,7 +284,6 @@ module Github
|
|
278
284
|
arguments(args, required: [:user, :repo]) do
|
279
285
|
permit %w[ anon ]
|
280
286
|
end
|
281
|
-
params = arguments.params
|
282
287
|
|
283
288
|
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/contributors", arguments.params)
|
284
289
|
return response unless block_given?
|
@@ -338,7 +343,6 @@ module Github
|
|
338
343
|
# @api public
|
339
344
|
def delete(*args)
|
340
345
|
arguments(args, required: [:user, :repo])
|
341
|
-
params = arguments.params
|
342
346
|
|
343
347
|
delete_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
|
344
348
|
end
|
@@ -356,14 +360,14 @@ module Github
|
|
356
360
|
# repos.branches 'user-name', 'repo-name'
|
357
361
|
#
|
358
362
|
# @api public
|
359
|
-
def branches(*args)
|
360
|
-
|
363
|
+
# def branches(*args)
|
364
|
+
# arguments(args, required: [:user, :repo])
|
361
365
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
end
|
366
|
-
alias :list_branches :branches
|
366
|
+
# response = get_request("/repos/#{arguments.user}/#{arguments.repo}/branches", arguments.params)
|
367
|
+
# return response unless block_given?
|
368
|
+
# response.each { |el| yield el }
|
369
|
+
# end
|
370
|
+
# alias :list_branches :branches
|
367
371
|
|
368
372
|
# Get branch
|
369
373
|
#
|
@@ -373,11 +377,11 @@ module Github
|
|
373
377
|
# github.repos.branch user: 'user-name', repo: 'repo-name', branch: 'branch-name'
|
374
378
|
# github.repos(user: 'user-name', repo: 'repo-name', branch: 'branch-name').branch
|
375
379
|
# @api public
|
376
|
-
def branch(*args)
|
377
|
-
|
380
|
+
# def branch(*args)
|
381
|
+
# arguments(args, required: [:user, :repo, :branch])
|
378
382
|
|
379
|
-
|
380
|
-
end
|
383
|
+
# get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}", arguments.params)
|
384
|
+
# end
|
381
385
|
|
382
386
|
# List contributors
|
383
387
|
#
|
@@ -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 t 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?
|