github_api2 1.0.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 +7 -0
- data/CHANGELOG.md +770 -0
- data/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api2/api/actions.rb +60 -0
- data/lib/github_api2/api/arguments.rb +253 -0
- data/lib/github_api2/api/config/property.rb +30 -0
- data/lib/github_api2/api/config/property_set.rb +120 -0
- data/lib/github_api2/api/config.rb +105 -0
- data/lib/github_api2/api/factory.rb +33 -0
- data/lib/github_api2/api.rb +398 -0
- data/lib/github_api2/authorization.rb +75 -0
- data/lib/github_api2/client/activity/events.rb +233 -0
- data/lib/github_api2/client/activity/feeds.rb +50 -0
- data/lib/github_api2/client/activity/notifications.rb +181 -0
- data/lib/github_api2/client/activity/starring.rb +130 -0
- data/lib/github_api2/client/activity/watching.rb +176 -0
- data/lib/github_api2/client/activity.rb +31 -0
- data/lib/github_api2/client/authorizations/app.rb +98 -0
- data/lib/github_api2/client/authorizations.rb +142 -0
- data/lib/github_api2/client/emojis.rb +19 -0
- data/lib/github_api2/client/gists/comments.rb +100 -0
- data/lib/github_api2/client/gists.rb +289 -0
- data/lib/github_api2/client/git_data/blobs.rb +51 -0
- data/lib/github_api2/client/git_data/commits.rb +101 -0
- data/lib/github_api2/client/git_data/references.rb +150 -0
- data/lib/github_api2/client/git_data/tags.rb +95 -0
- data/lib/github_api2/client/git_data/trees.rb +113 -0
- data/lib/github_api2/client/git_data.rb +31 -0
- data/lib/github_api2/client/gitignore.rb +57 -0
- data/lib/github_api2/client/issues/assignees.rb +77 -0
- data/lib/github_api2/client/issues/comments.rb +146 -0
- data/lib/github_api2/client/issues/events.rb +50 -0
- data/lib/github_api2/client/issues/labels.rb +189 -0
- data/lib/github_api2/client/issues/milestones.rb +146 -0
- data/lib/github_api2/client/issues.rb +248 -0
- data/lib/github_api2/client/markdown.rb +62 -0
- data/lib/github_api2/client/meta.rb +19 -0
- data/lib/github_api2/client/orgs/hooks.rb +182 -0
- data/lib/github_api2/client/orgs/members.rb +142 -0
- data/lib/github_api2/client/orgs/memberships.rb +131 -0
- data/lib/github_api2/client/orgs/projects.rb +57 -0
- data/lib/github_api2/client/orgs/teams.rb +407 -0
- data/lib/github_api2/client/orgs.rb +127 -0
- data/lib/github_api2/client/projects/cards.rb +158 -0
- data/lib/github_api2/client/projects/columns.rb +146 -0
- data/lib/github_api2/client/projects.rb +83 -0
- data/lib/github_api2/client/pull_requests/comments.rb +140 -0
- data/lib/github_api2/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api2/client/pull_requests.rb +195 -0
- data/lib/github_api2/client/repos/branches/protections.rb +75 -0
- data/lib/github_api2/client/repos/branches.rb +48 -0
- data/lib/github_api2/client/repos/collaborators.rb +84 -0
- data/lib/github_api2/client/repos/comments.rb +125 -0
- data/lib/github_api2/client/repos/commits.rb +80 -0
- data/lib/github_api2/client/repos/contents.rb +263 -0
- data/lib/github_api2/client/repos/deployments.rb +138 -0
- data/lib/github_api2/client/repos/downloads.rb +62 -0
- data/lib/github_api2/client/repos/forks.rb +50 -0
- data/lib/github_api2/client/repos/hooks.rb +214 -0
- data/lib/github_api2/client/repos/invitations.rb +41 -0
- data/lib/github_api2/client/repos/keys.rb +104 -0
- data/lib/github_api2/client/repos/merging.rb +47 -0
- data/lib/github_api2/client/repos/pages.rb +48 -0
- data/lib/github_api2/client/repos/projects.rb +62 -0
- data/lib/github_api2/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api2/client/repos/releases/assets.rb +136 -0
- data/lib/github_api2/client/repos/releases/tags.rb +24 -0
- data/lib/github_api2/client/repos/releases.rb +189 -0
- data/lib/github_api2/client/repos/statistics.rb +89 -0
- data/lib/github_api2/client/repos/statuses.rb +91 -0
- data/lib/github_api2/client/repos.rb +473 -0
- data/lib/github_api2/client/say.rb +25 -0
- data/lib/github_api2/client/scopes.rb +46 -0
- data/lib/github_api2/client/search/legacy.rb +111 -0
- data/lib/github_api2/client/search.rb +133 -0
- data/lib/github_api2/client/users/emails.rb +65 -0
- data/lib/github_api2/client/users/followers.rb +115 -0
- data/lib/github_api2/client/users/keys.rb +104 -0
- data/lib/github_api2/client/users.rb +117 -0
- data/lib/github_api2/client.rb +77 -0
- data/lib/github_api2/configuration.rb +70 -0
- data/lib/github_api2/connection.rb +82 -0
- data/lib/github_api2/constants.rb +61 -0
- data/lib/github_api2/core_ext/array.rb +25 -0
- data/lib/github_api2/core_ext/hash.rb +91 -0
- data/lib/github_api2/deprecation.rb +39 -0
- data/lib/github_api2/error/client_error.rb +89 -0
- data/lib/github_api2/error/service_error.rb +223 -0
- data/lib/github_api2/error.rb +32 -0
- data/lib/github_api2/ext/faraday.rb +40 -0
- data/lib/github_api2/mash.rb +7 -0
- data/lib/github_api2/middleware.rb +37 -0
- data/lib/github_api2/mime_type.rb +33 -0
- data/lib/github_api2/normalizer.rb +23 -0
- data/lib/github_api2/null_encoder.rb +25 -0
- data/lib/github_api2/page_iterator.rb +138 -0
- data/lib/github_api2/page_links.rb +63 -0
- data/lib/github_api2/paged_request.rb +42 -0
- data/lib/github_api2/pagination.rb +115 -0
- data/lib/github_api2/parameter_filter.rb +35 -0
- data/lib/github_api2/params_hash.rb +115 -0
- data/lib/github_api2/rate_limit.rb +25 -0
- data/lib/github_api2/request/basic_auth.rb +36 -0
- data/lib/github_api2/request/jsonize.rb +54 -0
- data/lib/github_api2/request/oauth2.rb +45 -0
- data/lib/github_api2/request/verbs.rb +63 -0
- data/lib/github_api2/request.rb +84 -0
- data/lib/github_api2/response/atom_parser.rb +22 -0
- data/lib/github_api2/response/follow_redirects.rb +140 -0
- data/lib/github_api2/response/header.rb +87 -0
- data/lib/github_api2/response/jsonize.rb +28 -0
- data/lib/github_api2/response/mashify.rb +24 -0
- data/lib/github_api2/response/raise_error.rb +22 -0
- data/lib/github_api2/response/xmlize.rb +28 -0
- data/lib/github_api2/response.rb +48 -0
- data/lib/github_api2/response_wrapper.rb +161 -0
- data/lib/github_api2/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api2/utils/url.rb +63 -0
- data/lib/github_api2/validations/format.rb +26 -0
- data/lib/github_api2/validations/presence.rb +32 -0
- data/lib/github_api2/validations/required.rb +21 -0
- data/lib/github_api2/validations/token.rb +41 -0
- data/lib/github_api2/validations.rb +22 -0
- data/lib/github_api2/version.rb +5 -0
- data/lib/github_api2.rb +92 -0
- metadata +363 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Issues::Events < API
|
|
7
|
+
# List events for an issue
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# github = Github.new
|
|
11
|
+
# github.issues.events.list 'user-name', 'repo-name',
|
|
12
|
+
# issue_number: 'issue-number'
|
|
13
|
+
#
|
|
14
|
+
# List events for a repository
|
|
15
|
+
#
|
|
16
|
+
# @example
|
|
17
|
+
# github = Github.new
|
|
18
|
+
# github.issues.events.list 'user-name', 'repo-name'
|
|
19
|
+
#
|
|
20
|
+
# @api public
|
|
21
|
+
def list(*args)
|
|
22
|
+
arguments(args, required: [:user, :repo])
|
|
23
|
+
params = arguments.params
|
|
24
|
+
|
|
25
|
+
response = if (issue_number = params.delete('issue_number'))
|
|
26
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{issue_number}/events", params)
|
|
27
|
+
else
|
|
28
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/events", params)
|
|
29
|
+
end
|
|
30
|
+
return response unless block_given?
|
|
31
|
+
response.each { |el| yield el }
|
|
32
|
+
end
|
|
33
|
+
alias :all :list
|
|
34
|
+
|
|
35
|
+
# Get a single event
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# github = Github.new
|
|
39
|
+
# github.issues.events.get 'user-name', 'repo-name', 'event-id'
|
|
40
|
+
#
|
|
41
|
+
# @api public
|
|
42
|
+
def get(*args)
|
|
43
|
+
arguments(args, :required => [:user, :repo, :id])
|
|
44
|
+
params = arguments.params
|
|
45
|
+
|
|
46
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/events/#{arguments.id}", params)
|
|
47
|
+
end
|
|
48
|
+
alias :find :get
|
|
49
|
+
end # Issues::Events
|
|
50
|
+
end # Github
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Issues::Labels < API
|
|
7
|
+
|
|
8
|
+
VALID_LABEL_INPUTS = %w[ name color ].freeze
|
|
9
|
+
|
|
10
|
+
# List all labels for a repository
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
14
|
+
# github.issues.labels.list
|
|
15
|
+
# github.issues.labels.list { |label| ... }
|
|
16
|
+
#
|
|
17
|
+
# Get labels for every issue in a milestone
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# github = Github.new
|
|
21
|
+
# github.issues.labels.list 'user-name', 'repo-name', milestone_id: 'milestone-id'
|
|
22
|
+
#
|
|
23
|
+
# List labels on an issue
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# github = Github.new
|
|
27
|
+
# github.issues.labels.list 'user-name', 'repo-name', issue_id: 'issue-id'
|
|
28
|
+
#
|
|
29
|
+
# @api public
|
|
30
|
+
def list(*args)
|
|
31
|
+
arguments(args, required: [:user, :repo])
|
|
32
|
+
params = arguments.params
|
|
33
|
+
user = arguments.user
|
|
34
|
+
repo = arguments.repo
|
|
35
|
+
|
|
36
|
+
response = if (milestone_id = params.delete('milestone_id'))
|
|
37
|
+
get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
|
|
38
|
+
elsif (issue_id = params.delete('issue_id'))
|
|
39
|
+
get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
40
|
+
else
|
|
41
|
+
get_request("/repos/#{user}/#{repo}/labels", params)
|
|
42
|
+
end
|
|
43
|
+
return response unless block_given?
|
|
44
|
+
response.each { |el| yield el }
|
|
45
|
+
end
|
|
46
|
+
alias :all :list
|
|
47
|
+
|
|
48
|
+
# Get a single label
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# github = Github.new
|
|
52
|
+
# github.issues.labels.find 'user-name', 'repo-name', 'label-name'
|
|
53
|
+
#
|
|
54
|
+
# @example
|
|
55
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
56
|
+
# github.issues.labels.get label_name: 'bug'
|
|
57
|
+
#
|
|
58
|
+
# @api public
|
|
59
|
+
def get(*args)
|
|
60
|
+
arguments(args, required: [:user, :repo, :label_name])
|
|
61
|
+
params = arguments.params
|
|
62
|
+
|
|
63
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", params)
|
|
64
|
+
end
|
|
65
|
+
alias :find :get
|
|
66
|
+
|
|
67
|
+
# Create a label
|
|
68
|
+
#
|
|
69
|
+
# @param [Hash] params
|
|
70
|
+
# @option params [String] :name
|
|
71
|
+
# Required string
|
|
72
|
+
# @option params [String] :color
|
|
73
|
+
# Required string - 6 character hex code, without leading #
|
|
74
|
+
#
|
|
75
|
+
# @example
|
|
76
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
77
|
+
# github.issues.labels.create name: 'API', color: 'FFFFFF'
|
|
78
|
+
#
|
|
79
|
+
# @api public
|
|
80
|
+
def create(*args)
|
|
81
|
+
arguments(args, required: [:user, :repo]) do
|
|
82
|
+
permit VALID_LABEL_INPUTS
|
|
83
|
+
assert_required VALID_LABEL_INPUTS
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/labels", arguments.params)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Update a label
|
|
90
|
+
#
|
|
91
|
+
# @param [Hash] params
|
|
92
|
+
# @option params [String] :name
|
|
93
|
+
# Required string
|
|
94
|
+
# @option params [String] :color
|
|
95
|
+
# Required string - 6 character hex code, without leading #
|
|
96
|
+
#
|
|
97
|
+
# @example
|
|
98
|
+
# github = Github.new
|
|
99
|
+
# github.issues.labels.update 'user-name', 'repo-name', 'label-name',
|
|
100
|
+
# name: 'API', color: "FFFFFF"
|
|
101
|
+
#
|
|
102
|
+
# @api public
|
|
103
|
+
def update(*args)
|
|
104
|
+
arguments(args, required: [:user, :repo, :label_name]) do
|
|
105
|
+
permit VALID_LABEL_INPUTS
|
|
106
|
+
assert_required VALID_LABEL_INPUTS
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", arguments.params)
|
|
110
|
+
end
|
|
111
|
+
alias :edit :update
|
|
112
|
+
|
|
113
|
+
# Delete a label
|
|
114
|
+
#
|
|
115
|
+
# @examples
|
|
116
|
+
# github = Github.new
|
|
117
|
+
# github.issues.labels.delete 'user-name', 'repo-name', 'label-name'
|
|
118
|
+
#
|
|
119
|
+
# @api public
|
|
120
|
+
def delete(*args)
|
|
121
|
+
arguments(args, required: [:user, :repo, :label_name])
|
|
122
|
+
|
|
123
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", arguments.params)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Add labels to an issue
|
|
127
|
+
#
|
|
128
|
+
# @example
|
|
129
|
+
# github = Github.new
|
|
130
|
+
# github.issues.labels.add 'user-name', 'repo-name', 'issue-number',
|
|
131
|
+
# 'label1', 'label2', ...
|
|
132
|
+
#
|
|
133
|
+
# @api public
|
|
134
|
+
def add(*args)
|
|
135
|
+
arguments(args, required: [:user, :repo, :number])
|
|
136
|
+
params = arguments.params
|
|
137
|
+
params['data'] = arguments.remaining unless arguments.remaining.empty?
|
|
138
|
+
|
|
139
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels", params)
|
|
140
|
+
end
|
|
141
|
+
alias :<< :add
|
|
142
|
+
|
|
143
|
+
# Remove a label from an issue
|
|
144
|
+
#
|
|
145
|
+
# @example
|
|
146
|
+
# github = Github.new
|
|
147
|
+
# github.issues.labels.remove 'user-name', 'repo-name', 'issue-number',
|
|
148
|
+
# label_name: 'label-name'
|
|
149
|
+
#
|
|
150
|
+
# Remove all labels from an issue
|
|
151
|
+
#
|
|
152
|
+
# @example
|
|
153
|
+
# github = Github.new
|
|
154
|
+
# github.issues.labels.remove 'user-name', 'repo-name', 'issue-number'
|
|
155
|
+
#
|
|
156
|
+
# @api public
|
|
157
|
+
def remove(*args)
|
|
158
|
+
arguments(args, required: [:user, :repo, :number])
|
|
159
|
+
params = arguments.params
|
|
160
|
+
user = arguments.user
|
|
161
|
+
repo = arguments.repo
|
|
162
|
+
number = arguments.number
|
|
163
|
+
|
|
164
|
+
if (label_name = params.delete('label_name'))
|
|
165
|
+
delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels/#{label_name}", params)
|
|
166
|
+
else
|
|
167
|
+
delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels", params)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Replace all labels for an issue
|
|
172
|
+
#
|
|
173
|
+
# Sending an empty array ([]) will remove all Labels from the Issue.
|
|
174
|
+
#
|
|
175
|
+
# @example
|
|
176
|
+
# github = Github.new
|
|
177
|
+
# github.issues.labels.replace 'user-name', 'repo-name', 'issue-number',
|
|
178
|
+
# 'label1', 'label2', ...
|
|
179
|
+
#
|
|
180
|
+
# @api public
|
|
181
|
+
def replace(*args)
|
|
182
|
+
arguments(args, required: [:user, :repo, :number])
|
|
183
|
+
params = arguments.params
|
|
184
|
+
params['data'] = arguments.remaining unless arguments.remaining.empty?
|
|
185
|
+
|
|
186
|
+
put_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels", params)
|
|
187
|
+
end
|
|
188
|
+
end # Issues::Labels
|
|
189
|
+
end # Github
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Issues::Milestones < API
|
|
7
|
+
|
|
8
|
+
VALID_MILESTONE_OPTIONS = {
|
|
9
|
+
'state' => %w[ open closed all ],
|
|
10
|
+
'sort' => %w[ due_date completeness ],
|
|
11
|
+
'direction' => %w[ desc asc ]
|
|
12
|
+
}.freeze # :nodoc:
|
|
13
|
+
|
|
14
|
+
VALID_MILESTONE_INPUTS = %w[
|
|
15
|
+
title
|
|
16
|
+
state
|
|
17
|
+
description
|
|
18
|
+
due_on
|
|
19
|
+
].freeze # :nodoc:
|
|
20
|
+
|
|
21
|
+
# List milestones for a repository
|
|
22
|
+
#
|
|
23
|
+
# @param [Hash] params
|
|
24
|
+
# @option params [String] :state
|
|
25
|
+
# The state of the milestone. Either open, closed, or all. Default: open
|
|
26
|
+
# @option params [String] :sort
|
|
27
|
+
# What to sort results by. Either due_date or completeness.
|
|
28
|
+
# Default: due_date
|
|
29
|
+
# @option params [String] :direction
|
|
30
|
+
# The directoin of the sort. Either asc or desc. Default: desc
|
|
31
|
+
#
|
|
32
|
+
# @example
|
|
33
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
34
|
+
# github.issues.milestones.list
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# github.issues.milestones.list state: 'open', sort: 'due_date',
|
|
38
|
+
# direction: 'asc'
|
|
39
|
+
#
|
|
40
|
+
# @api public
|
|
41
|
+
def list(*args)
|
|
42
|
+
arguments(args, required: [:user, :repo]) do
|
|
43
|
+
permit VALID_MILESTONE_OPTIONS.keys
|
|
44
|
+
assert_values VALID_MILESTONE_OPTIONS
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/milestones", arguments.params)
|
|
48
|
+
return response unless block_given?
|
|
49
|
+
response.each { |el| yield el }
|
|
50
|
+
end
|
|
51
|
+
alias :all :list
|
|
52
|
+
|
|
53
|
+
# Get a single milestone
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# github = Github.new
|
|
57
|
+
# github.issues.milestones.get 'user-name', 'repo-name', 'milestone-number'
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# github.issues.milestones.get
|
|
61
|
+
# user: 'user-name',
|
|
62
|
+
# repo: 'repo-name',
|
|
63
|
+
# number: 'milestone-number'
|
|
64
|
+
#
|
|
65
|
+
# @api public
|
|
66
|
+
def get(*args)
|
|
67
|
+
arguments(args, required: [:user, :repo, :number])
|
|
68
|
+
|
|
69
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/milestones/#{arguments.number}", arguments.params)
|
|
70
|
+
end
|
|
71
|
+
alias :find :get
|
|
72
|
+
|
|
73
|
+
# Create a milestone
|
|
74
|
+
#
|
|
75
|
+
# @param [Hash] params
|
|
76
|
+
# @option params [String] :title
|
|
77
|
+
# Required string. The title of the milestone
|
|
78
|
+
# @option params [String] :state
|
|
79
|
+
# The state of the milestone. Either open or closed. Default: open.
|
|
80
|
+
# @option params [String] :description
|
|
81
|
+
# A description of the milestone
|
|
82
|
+
# @option params [String] :due_on
|
|
83
|
+
# The milestone due date. This is a timestamp in ISO 8601 format:
|
|
84
|
+
# YYYY-MM-DDTHH:MM:SSZ.
|
|
85
|
+
#
|
|
86
|
+
# @example
|
|
87
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
88
|
+
# github.issues.milestones.create title: 'hello-world',
|
|
89
|
+
# state: "open or closed",
|
|
90
|
+
# description: "String",
|
|
91
|
+
# due_on: "Time"
|
|
92
|
+
#
|
|
93
|
+
# @api public
|
|
94
|
+
def create(*args)
|
|
95
|
+
arguments(args, required: [:user, :repo]) do
|
|
96
|
+
permit VALID_MILESTONE_INPUTS
|
|
97
|
+
assert_required %w[ title ]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/milestones", arguments.params)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Update a milestone
|
|
104
|
+
#
|
|
105
|
+
# @param [Hash] params
|
|
106
|
+
# @option params [String] :title
|
|
107
|
+
# Required string. The title of the milestone
|
|
108
|
+
# @option params [String] :state
|
|
109
|
+
# The state of the milestone. Either open or closed. Default: open.
|
|
110
|
+
# @option params [String] :description
|
|
111
|
+
# A description of the milestone
|
|
112
|
+
# @option params [String] :due_on
|
|
113
|
+
# The milestone due date. This is a timestamp in ISO 8601 format:
|
|
114
|
+
# YYYY-MM-DDTHH:MM:SSZ.
|
|
115
|
+
#
|
|
116
|
+
# @example
|
|
117
|
+
# github = Github.new
|
|
118
|
+
# github.issues.milestones.update 'user-name', 'repo-name', 'number',
|
|
119
|
+
# :title => 'hello-world',
|
|
120
|
+
# :state => "open or closed",
|
|
121
|
+
# :description => "String",
|
|
122
|
+
# :due_on => "Time"
|
|
123
|
+
#
|
|
124
|
+
# @api public
|
|
125
|
+
def update(*args)
|
|
126
|
+
arguments(args, required: [:user, :repo, :number]) do
|
|
127
|
+
permit VALID_MILESTONE_INPUTS
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/milestones/#{arguments.number}", arguments.params)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Delete a milestone
|
|
134
|
+
#
|
|
135
|
+
# @example
|
|
136
|
+
# github = Github.new
|
|
137
|
+
# github.issues.milestones.delete 'user-name', 'repo-name', 'number'
|
|
138
|
+
#
|
|
139
|
+
# @api public
|
|
140
|
+
def delete(*args)
|
|
141
|
+
arguments(args, required: [:user, :repo, :number])
|
|
142
|
+
|
|
143
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/milestones/#{arguments.number}", arguments.params)
|
|
144
|
+
end
|
|
145
|
+
end # Issues::Milestones
|
|
146
|
+
end # Github
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Issues < API
|
|
7
|
+
|
|
8
|
+
require_all 'github_api2/client/issues',
|
|
9
|
+
'assignees',
|
|
10
|
+
'comments',
|
|
11
|
+
'events',
|
|
12
|
+
'labels',
|
|
13
|
+
'milestones'
|
|
14
|
+
|
|
15
|
+
VALID_ISSUE_PARAM_NAMES = %w[
|
|
16
|
+
assignee
|
|
17
|
+
body
|
|
18
|
+
creator
|
|
19
|
+
direction
|
|
20
|
+
filter
|
|
21
|
+
labels
|
|
22
|
+
milestone
|
|
23
|
+
mentioned
|
|
24
|
+
mime_type
|
|
25
|
+
org
|
|
26
|
+
resource
|
|
27
|
+
since
|
|
28
|
+
sort
|
|
29
|
+
state
|
|
30
|
+
title
|
|
31
|
+
].freeze
|
|
32
|
+
|
|
33
|
+
VALID_ISSUE_PARAM_VALUES = {
|
|
34
|
+
'filter' => %w[ assigned created mentioned subscribed all ],
|
|
35
|
+
'state' => %w[ open closed all ],
|
|
36
|
+
'sort' => %w[ created updated comments ],
|
|
37
|
+
'direction' => %w[ desc asc ],
|
|
38
|
+
'since' => %r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# Access to Issues::Assignees API
|
|
42
|
+
namespace :assignees
|
|
43
|
+
|
|
44
|
+
# Access to Issues::Comments API
|
|
45
|
+
namespace :comments
|
|
46
|
+
|
|
47
|
+
# Access to Issues::Events API
|
|
48
|
+
namespace :events
|
|
49
|
+
|
|
50
|
+
# Access to Issues::Comments API
|
|
51
|
+
namespace :labels
|
|
52
|
+
|
|
53
|
+
# Access to Issues::Comments API
|
|
54
|
+
namespace :milestones
|
|
55
|
+
|
|
56
|
+
# List your issues
|
|
57
|
+
#
|
|
58
|
+
# List all issues across all the authenticated user’s visible repositories
|
|
59
|
+
# including owned repositories, member repositories,
|
|
60
|
+
# and organization repositories.
|
|
61
|
+
#
|
|
62
|
+
# @example
|
|
63
|
+
# github = Github.new oauth_token: '...'
|
|
64
|
+
# github.issues.list
|
|
65
|
+
#
|
|
66
|
+
# List all issues across owned and member repositories for the
|
|
67
|
+
# authenticated user.
|
|
68
|
+
#
|
|
69
|
+
# @example
|
|
70
|
+
# github = Github.new oauth_token: '...'
|
|
71
|
+
# github.issues.list :user
|
|
72
|
+
#
|
|
73
|
+
# List all issues for a given organization for the authenticated user.
|
|
74
|
+
#
|
|
75
|
+
# @example
|
|
76
|
+
# github = Github.new oauth_token: '...'
|
|
77
|
+
# github.issues.list org: 'org-name'
|
|
78
|
+
#
|
|
79
|
+
# List issues for a repository
|
|
80
|
+
#
|
|
81
|
+
# @example
|
|
82
|
+
# github = Github.new
|
|
83
|
+
# github.issues.list user: 'user-name', repo: 'repo-name'
|
|
84
|
+
#
|
|
85
|
+
# @param [Hash] params
|
|
86
|
+
# @option params [String] :filter
|
|
87
|
+
# * assigned Issues assigned to you (default)
|
|
88
|
+
# * created Issues created by you
|
|
89
|
+
# * mentioned Issues mentioning you
|
|
90
|
+
# * subscribed Issues you've subscribed to updates for
|
|
91
|
+
# * all All issues the user can see
|
|
92
|
+
# @option params [String] :milestone
|
|
93
|
+
# * Integer Milestone number
|
|
94
|
+
# * none for Issues with no Milestone.
|
|
95
|
+
# * * for Issues with any Milestone
|
|
96
|
+
# @option params [String] :state
|
|
97
|
+
# open, closed, default: open
|
|
98
|
+
# @option params [String] :labels
|
|
99
|
+
# String list of comma separated Label names. Example: bug,ui,@high
|
|
100
|
+
# @option params [String] :assignee
|
|
101
|
+
# * String User login
|
|
102
|
+
# * <tt>none</tt> for Issues with no assigned User.
|
|
103
|
+
# * <tt>*</tt> for Issues with any assigned User.
|
|
104
|
+
# @option params [String] :creator
|
|
105
|
+
# String User login
|
|
106
|
+
# @option params [String] :mentioned
|
|
107
|
+
# String User login
|
|
108
|
+
# @option params [String] :sort
|
|
109
|
+
# created, updated, comments, default: <tt>created</tt>
|
|
110
|
+
# @option params [String] :direction
|
|
111
|
+
# asc, desc, default: desc
|
|
112
|
+
# @option params [String] :since
|
|
113
|
+
# Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
|
|
114
|
+
#
|
|
115
|
+
# @example
|
|
116
|
+
# github = Github.new oauth_token: '...'
|
|
117
|
+
# github.issues.list since: '2011-04-12T12:12:12Z',
|
|
118
|
+
# filter: 'created',
|
|
119
|
+
# state: 'open',
|
|
120
|
+
# labels: "bug,ui,bla",
|
|
121
|
+
# sort: 'comments',
|
|
122
|
+
# direction: 'asc'
|
|
123
|
+
#
|
|
124
|
+
# @api public
|
|
125
|
+
def list(*args)
|
|
126
|
+
params = arguments(args) do
|
|
127
|
+
assert_values VALID_ISSUE_PARAM_VALUES
|
|
128
|
+
end.params
|
|
129
|
+
|
|
130
|
+
response = if (org = params.delete('org'))
|
|
131
|
+
get_request("/orgs/#{org}/issues", params)
|
|
132
|
+
|
|
133
|
+
elsif (user_name = params.delete('user')) &&
|
|
134
|
+
(repo_name = params.delete('repo'))
|
|
135
|
+
|
|
136
|
+
list_repo user_name, repo_name
|
|
137
|
+
elsif args.include? :user
|
|
138
|
+
get_request("/user/issues", params)
|
|
139
|
+
else
|
|
140
|
+
get_request("/issues", params)
|
|
141
|
+
end
|
|
142
|
+
return response unless block_given?
|
|
143
|
+
response.each { |el| yield el }
|
|
144
|
+
end
|
|
145
|
+
alias :all :list
|
|
146
|
+
|
|
147
|
+
# List issues for a repository
|
|
148
|
+
#
|
|
149
|
+
# def list_repo(user_name, repo_name, params)
|
|
150
|
+
def list_repo(user, repo)
|
|
151
|
+
get_request("/repos/#{user}/#{repo}/issues", arguments.params)
|
|
152
|
+
end
|
|
153
|
+
private :list_repo
|
|
154
|
+
|
|
155
|
+
# Get a single issue
|
|
156
|
+
#
|
|
157
|
+
# @example
|
|
158
|
+
# github = Github.new
|
|
159
|
+
# github.issues.get 'user-name', 'repo-name', 'number'
|
|
160
|
+
#
|
|
161
|
+
def get(*args)
|
|
162
|
+
arguments(args, required: [:user, :repo, :number])
|
|
163
|
+
|
|
164
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}", arguments.params)
|
|
165
|
+
end
|
|
166
|
+
alias :find :get
|
|
167
|
+
|
|
168
|
+
# Create an issue
|
|
169
|
+
#
|
|
170
|
+
# @param [Hash] params
|
|
171
|
+
# @option params [String] :title
|
|
172
|
+
# Required string
|
|
173
|
+
# @option params [String] :body
|
|
174
|
+
# Optional string
|
|
175
|
+
# @option params [String] :assignee
|
|
176
|
+
# Optional string - Login for the user that this issue should be
|
|
177
|
+
# assigned to. Only users with push access can set the assignee for
|
|
178
|
+
# new issues. The assignee is silently dropped otherwise.
|
|
179
|
+
# @option params [Number] :milestone
|
|
180
|
+
# Optional number - Milestone to associate this issue with.
|
|
181
|
+
# Only users with push access can set the milestone for new issues.
|
|
182
|
+
# The milestone is silently dropped otherwise.
|
|
183
|
+
# @option params [Array[String]] :labels
|
|
184
|
+
# Optional array of strings - Labels to associate with this issue
|
|
185
|
+
# Only users with push access can set labels for new issues.
|
|
186
|
+
# Labels are silently dropped otherwise.
|
|
187
|
+
#
|
|
188
|
+
# @example
|
|
189
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
190
|
+
# github.issues.create
|
|
191
|
+
# title: "Found a bug",
|
|
192
|
+
# body: "I'm having a problem with this.",
|
|
193
|
+
# assignee: "octocat",
|
|
194
|
+
# milestone: 1,
|
|
195
|
+
# labels: [
|
|
196
|
+
# "Label1",
|
|
197
|
+
# "Label2"
|
|
198
|
+
# ]
|
|
199
|
+
#
|
|
200
|
+
def create(*args)
|
|
201
|
+
arguments(args, required: [:user, :repo]) do
|
|
202
|
+
permit VALID_ISSUE_PARAM_NAMES
|
|
203
|
+
assert_required %w[ title ]
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/issues", arguments.params)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Edit an issue
|
|
210
|
+
#
|
|
211
|
+
# @param [Hash] params
|
|
212
|
+
# @option params [String] :title
|
|
213
|
+
# Optional string
|
|
214
|
+
# @option params [String] :body
|
|
215
|
+
# Optional string
|
|
216
|
+
# @option params [String] :assignee
|
|
217
|
+
# Optional string - Login for the user that this issue should be assigned to.
|
|
218
|
+
# @option params [String] :state
|
|
219
|
+
# Optional string - State of the issue: open or closed
|
|
220
|
+
# @option params [Number] :milestone
|
|
221
|
+
# Optional number - Milestone to associate this issue with
|
|
222
|
+
# @option params [Array[String]] :labels
|
|
223
|
+
# Optional array of strings - Labels to associate with this issue.
|
|
224
|
+
# Pass one or more Labels to replace the set of Labels on this Issue.
|
|
225
|
+
# Send an empty array ([]) to clear all Labels from the Issue.
|
|
226
|
+
#
|
|
227
|
+
# @example
|
|
228
|
+
# github = Github.new
|
|
229
|
+
# github.issues.edit 'user-name', 'repo-name', 'number'
|
|
230
|
+
# title: "Found a bug",
|
|
231
|
+
# body: "I'm having a problem with this.",
|
|
232
|
+
# assignee: "octocat",
|
|
233
|
+
# milestone: 1,
|
|
234
|
+
# labels": [
|
|
235
|
+
# "Label1",
|
|
236
|
+
# "Label2"
|
|
237
|
+
# ]
|
|
238
|
+
#
|
|
239
|
+
# @api public
|
|
240
|
+
def edit(*args)
|
|
241
|
+
arguments(args, required: [:user, :repo, :number]) do
|
|
242
|
+
permit VALID_ISSUE_PARAM_NAMES
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}", arguments.params)
|
|
246
|
+
end
|
|
247
|
+
end # Issues
|
|
248
|
+
end # Github
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Markdown < API
|
|
7
|
+
|
|
8
|
+
# Render an arbitrary Markdown document
|
|
9
|
+
#
|
|
10
|
+
# = Parameters
|
|
11
|
+
# <tt>:text</tt> - Required string - The Markdown text to render
|
|
12
|
+
# <tt>:mode<tt> - Optional string - The rendering mode
|
|
13
|
+
# * <tt>markdown</tt> to render a document as plain Markdown, just
|
|
14
|
+
# like README files are rendered.
|
|
15
|
+
# * <tt>gfm</tt> to render a document as user-content, e.g. like user
|
|
16
|
+
# comments or issues are rendered. In GFM mode, hard line breaks are
|
|
17
|
+
# always taken into account, and issue and user mentions are
|
|
18
|
+
# linked accordingly.
|
|
19
|
+
# <tt>:context<tt> - Optional string - The repository context, only taken
|
|
20
|
+
# into account when rendering as <tt>gfm</tt>
|
|
21
|
+
#
|
|
22
|
+
# = Examples
|
|
23
|
+
# github = Github.new
|
|
24
|
+
# github.markdown.render
|
|
25
|
+
# "text": "Hello world github/linguist#1 **cool**, and #1!",
|
|
26
|
+
# "mode": "gfm",
|
|
27
|
+
# "context": "github/gollum"
|
|
28
|
+
#
|
|
29
|
+
def render(*args)
|
|
30
|
+
arguments(args) do
|
|
31
|
+
assert_required ['text']
|
|
32
|
+
end
|
|
33
|
+
params = arguments.params
|
|
34
|
+
params['raw'] = true
|
|
35
|
+
|
|
36
|
+
post_request("markdown", arguments.params)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Render a Markdown document in raw mode
|
|
40
|
+
#
|
|
41
|
+
# = Input
|
|
42
|
+
# The raw API it not JSON-based. It takes a Markdown document as plaintext
|
|
43
|
+
# <tt>text/plain</tt> or <tt>text/x-markdown</tt> and renders it as plain
|
|
44
|
+
# Markdown without a repository context (just like a README.md file is
|
|
45
|
+
# rendered – this is the simplest way to preview a readme online)
|
|
46
|
+
#
|
|
47
|
+
# = Examples
|
|
48
|
+
# github = Github.new
|
|
49
|
+
# github.markdown.render_raw "Hello github/linguist#1 **cool**, and #1!",
|
|
50
|
+
# "accept": "text/plain",
|
|
51
|
+
#
|
|
52
|
+
def render_raw(*args)
|
|
53
|
+
params = arguments(args).params
|
|
54
|
+
params['data'] = args.shift
|
|
55
|
+
params['raw'] = true
|
|
56
|
+
params['accept'] = params.fetch('accept') { 'text/plain' }
|
|
57
|
+
|
|
58
|
+
post_request("markdown/raw", params)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end # Markdown
|
|
62
|
+
end # Github
|