github_api 0.15.0 → 0.19.0
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 +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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
class Client::Authorizations::App < Client::Authorizations
|
|
5
7
|
# Get-or-create an authorization for a specific app
|
|
@@ -47,7 +49,7 @@ module Github
|
|
|
47
49
|
if arguments.client_id
|
|
48
50
|
begin
|
|
49
51
|
get_request("/applications/#{arguments.client_id}/tokens/#{arguments.access_token}", params)
|
|
50
|
-
rescue Github::Error::NotFound
|
|
52
|
+
rescue Github::Error::NotFound
|
|
51
53
|
nil
|
|
52
54
|
end
|
|
53
55
|
else
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
class Client::Gists < API
|
|
5
7
|
|
|
@@ -141,7 +143,7 @@ module Github
|
|
|
141
143
|
# Optional string
|
|
142
144
|
# @option [Hash] :files
|
|
143
145
|
# Optional hash - Files that make up this gist.
|
|
144
|
-
# The key of which should be a optional string filename and
|
|
146
|
+
# The key of which should be a optional string filename and
|
|
145
147
|
# the value another optional hash with parameters:
|
|
146
148
|
# @option [String] :content
|
|
147
149
|
# Updated string - Update file contents.
|
|
@@ -211,7 +213,7 @@ module Github
|
|
|
211
213
|
#
|
|
212
214
|
# @see https://developer.github.com/v3/gists/#unstar-a-gist
|
|
213
215
|
#
|
|
214
|
-
# @
|
|
216
|
+
# @example
|
|
215
217
|
# github = Github.new
|
|
216
218
|
# github.gists.unstar 'gist-id'
|
|
217
219
|
#
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
class Client::Gists::Comments < API
|
|
5
7
|
# List comments on a gist
|
|
@@ -83,7 +85,7 @@ module Github
|
|
|
83
85
|
#
|
|
84
86
|
# @see https://developer.github.com/v3/gists/comments/#delete-a-comment
|
|
85
87
|
#
|
|
86
|
-
# @
|
|
88
|
+
# @example
|
|
87
89
|
# github = Github.new
|
|
88
90
|
# github.gists.comments.delete 'gist-id', 'comment-id'
|
|
89
91
|
#
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../../api'
|
|
4
4
|
|
|
5
|
+
module Github
|
|
5
6
|
# Since blobs can be any arbitrary binary data, the input and responses for
|
|
6
7
|
# the blob api takes an encoding parameter that can be either utf-8 or base64.
|
|
7
8
|
# If your data cannot be losslessly sent as a UTF-8 string, you can base64 encode it.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
class Client::GitData::References < API
|
|
5
7
|
|
|
@@ -33,8 +35,8 @@ module Github
|
|
|
33
35
|
repo = arguments.repo
|
|
34
36
|
|
|
35
37
|
response = if (ref = params.delete('ref'))
|
|
36
|
-
validate_reference ref
|
|
37
|
-
get_request("/repos/#{user}/#{repo}/git
|
|
38
|
+
formatted_ref = validate_reference ref
|
|
39
|
+
get_request("/repos/#{user}/#{repo}/git/#{formatted_ref}", params)
|
|
38
40
|
else
|
|
39
41
|
get_request("/repos/#{user}/#{repo}/git/refs", params)
|
|
40
42
|
end
|
|
@@ -141,6 +143,8 @@ module Github
|
|
|
141
143
|
unless VALID_REF_PARAM_VALUES['ref'] =~ refs
|
|
142
144
|
raise ArgumentError, "Provided 'reference' is invalid"
|
|
143
145
|
end
|
|
146
|
+
|
|
147
|
+
refs
|
|
144
148
|
end
|
|
145
149
|
end # GitData::References
|
|
146
150
|
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::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,9 +1,11 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
class Client::Markdown < API
|
|
5
7
|
|
|
6
|
-
# Render an
|
|
8
|
+
# Render an arbitrary Markdown document
|
|
7
9
|
#
|
|
8
10
|
# = Parameters
|
|
9
11
|
# <tt>:text</tt> - Required string - The Markdown text to render
|
|
@@ -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,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
# Organizations API
|
|
5
7
|
class Client::Orgs < API
|
|
@@ -8,6 +10,7 @@ module Github
|
|
|
8
10
|
'hooks',
|
|
9
11
|
'members',
|
|
10
12
|
'memberships',
|
|
13
|
+
'projects',
|
|
11
14
|
'teams'
|
|
12
15
|
|
|
13
16
|
# Access to Client::Orgs::Hooks API
|
|
@@ -19,6 +22,9 @@ module Github
|
|
|
19
22
|
# Access to Client::Orgs::Memberships API
|
|
20
23
|
namespace :memberships
|
|
21
24
|
|
|
25
|
+
# Access to Client::Orgs::Projects API
|
|
26
|
+
namespace :projects
|
|
27
|
+
|
|
22
28
|
# Access to Client::Orgs::Teams API
|
|
23
29
|
namespace :teams
|
|
24
30
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Orgs::Projects < API
|
|
7
|
+
PREVIEW_MEDIA = "application/vnd.github.inertia-preview+json".freeze # :nodoc:
|
|
8
|
+
|
|
9
|
+
# List your organization projects
|
|
10
|
+
#
|
|
11
|
+
# @see List your organization projects
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# github = Github.new 'org-name'
|
|
15
|
+
# github.orgs.projects.list 'org-name' { |project| ... }
|
|
16
|
+
#
|
|
17
|
+
# @example
|
|
18
|
+
# github = Github.new
|
|
19
|
+
# github.orgs.projects.list 'org-name', state: 'closed'
|
|
20
|
+
#
|
|
21
|
+
# @api public
|
|
22
|
+
def list(*args)
|
|
23
|
+
arguments(args, required: [:org_name])
|
|
24
|
+
params = arguments.params
|
|
25
|
+
|
|
26
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
27
|
+
|
|
28
|
+
response = get_request("/orgs/#{arguments.org_name}/projects", params)
|
|
29
|
+
return response unless block_given?
|
|
30
|
+
response.each { |el| yield el }
|
|
31
|
+
end
|
|
32
|
+
alias_method :all, :list
|
|
33
|
+
|
|
34
|
+
# Create a new project for the specified repo
|
|
35
|
+
#
|
|
36
|
+
# @param [Hash] params
|
|
37
|
+
# @option params [String] :name
|
|
38
|
+
# Required string - The name of the project.
|
|
39
|
+
# @option params [String] :body
|
|
40
|
+
# Optional string - The body of the project.
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# github = Github.new
|
|
44
|
+
# github.repos.create 'owner-name', 'repo-name', name: 'project-name'
|
|
45
|
+
# github.repos.create name: 'project-name', body: 'project-body', owner: 'owner-name', repo: 'repo-name'
|
|
46
|
+
def create(*args)
|
|
47
|
+
arguments(args, required: [:org_name]) do
|
|
48
|
+
assert_required %w[ name ]
|
|
49
|
+
end
|
|
50
|
+
params = arguments.params
|
|
51
|
+
|
|
52
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
53
|
+
|
|
54
|
+
post_request("/orgs/#{arguments.org_name}/projects", params)
|
|
55
|
+
end
|
|
56
|
+
end # Projects
|
|
57
|
+
end # Github
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
3
5
|
module Github
|
|
4
6
|
# All actions against teams require at a minimum an authenticated user
|
|
5
7
|
# who is a member of the owner's team in the :org being managed.
|
|
@@ -77,7 +79,7 @@ module Github
|
|
|
77
79
|
# * pull - team members can pull, but not push or
|
|
78
80
|
# administor this repositories.
|
|
79
81
|
# * push - team members can pull and push,
|
|
80
|
-
# but not
|
|
82
|
+
# but not administer this repositores.
|
|
81
83
|
# * admin - team members can pull, push and
|
|
82
84
|
# administor these repositories.
|
|
83
85
|
# Default: pull
|
|
@@ -123,9 +125,9 @@ module Github
|
|
|
123
125
|
# * pull - team members can pull, but not push or
|
|
124
126
|
# administor this repositories.
|
|
125
127
|
# * push - team members can pull and push,
|
|
126
|
-
# but not
|
|
128
|
+
# but not administer this repositores.
|
|
127
129
|
# * admin - team members can pull, push and
|
|
128
|
-
#
|
|
130
|
+
# administer these repositories.
|
|
129
131
|
# Default: pull
|
|
130
132
|
#
|
|
131
133
|
# @example
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative '../api'
|
|
5
|
+
|
|
6
|
+
module Github
|
|
7
|
+
# Projects API
|
|
8
|
+
class Client::Projects < API
|
|
9
|
+
PREVIEW_MEDIA = "application/vnd.github.inertia-preview+json" # :nodoc:
|
|
10
|
+
|
|
11
|
+
require_all 'github_api/client/projects',
|
|
12
|
+
'columns',
|
|
13
|
+
'cards'
|
|
14
|
+
|
|
15
|
+
# Access to Projects::Columns API
|
|
16
|
+
namespace :columns
|
|
17
|
+
|
|
18
|
+
# Access to Projects::Cards API
|
|
19
|
+
namespace :cards
|
|
20
|
+
|
|
21
|
+
# Get properties for a single project
|
|
22
|
+
#
|
|
23
|
+
# @see https://developer.github.com/v3/projects/#get-a-project
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# github = Github.new
|
|
27
|
+
# github.projects.get 1002604
|
|
28
|
+
#
|
|
29
|
+
# @api public
|
|
30
|
+
def get(*args)
|
|
31
|
+
arguments(args, required: [:id])
|
|
32
|
+
params = arguments.params
|
|
33
|
+
|
|
34
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
35
|
+
|
|
36
|
+
get_request("/projects/#{arguments.id}", params)
|
|
37
|
+
end
|
|
38
|
+
alias find get
|
|
39
|
+
|
|
40
|
+
# Edit a project
|
|
41
|
+
#
|
|
42
|
+
# @param [Hash] params
|
|
43
|
+
# @option params [String] :name
|
|
44
|
+
# Optional string
|
|
45
|
+
# @option params [String] :body
|
|
46
|
+
# Optional string
|
|
47
|
+
# @option params [String] :state
|
|
48
|
+
# Optional string
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# github = Github.new
|
|
52
|
+
# github.projects.edit 1002604,
|
|
53
|
+
# name: "Outcomes Tracker",
|
|
54
|
+
# body: "The board to track work for the Outcomes application."
|
|
55
|
+
#
|
|
56
|
+
# @api public
|
|
57
|
+
def edit(*args)
|
|
58
|
+
arguments(args, required: [:id])
|
|
59
|
+
params = arguments.params
|
|
60
|
+
|
|
61
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
62
|
+
|
|
63
|
+
patch_request("/projects/#{arguments.id}", params)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Delete a project
|
|
67
|
+
#
|
|
68
|
+
# @example
|
|
69
|
+
# github = Github.new
|
|
70
|
+
# github.projects.delete 1002604
|
|
71
|
+
#
|
|
72
|
+
# @api public
|
|
73
|
+
def delete(*args)
|
|
74
|
+
arguments(args, required: [:id])
|
|
75
|
+
params = arguments.params
|
|
76
|
+
|
|
77
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
78
|
+
|
|
79
|
+
delete_request("/projects/#{arguments.id}", arguments.params)
|
|
80
|
+
end
|
|
81
|
+
alias remove delete
|
|
82
|
+
end # Projects
|
|
83
|
+
end # Github
|