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.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +770 -0
  3. data/README.md +25 -8
  4. data/lib/github_api.rb +37 -76
  5. data/lib/github_api/api.rb +46 -19
  6. data/lib/github_api/api/arguments.rb +6 -1
  7. data/lib/github_api/api/config.rb +3 -5
  8. data/lib/github_api/api/config/property_set.rb +1 -0
  9. data/lib/github_api/authorization.rb +2 -0
  10. data/lib/github_api/client.rb +5 -0
  11. data/lib/github_api/client/activity.rb +2 -0
  12. data/lib/github_api/client/activity/events.rb +2 -0
  13. data/lib/github_api/client/activity/feeds.rb +2 -0
  14. data/lib/github_api/client/activity/notifications.rb +2 -0
  15. data/lib/github_api/client/activity/starring.rb +3 -1
  16. data/lib/github_api/client/activity/watching.rb +3 -1
  17. data/lib/github_api/client/authorizations.rb +2 -0
  18. data/lib/github_api/client/authorizations/app.rb +3 -1
  19. data/lib/github_api/client/emojis.rb +2 -0
  20. data/lib/github_api/client/gists.rb +4 -2
  21. data/lib/github_api/client/gists/comments.rb +3 -1
  22. data/lib/github_api/client/git_data.rb +2 -0
  23. data/lib/github_api/client/git_data/blobs.rb +2 -1
  24. data/lib/github_api/client/git_data/commits.rb +2 -0
  25. data/lib/github_api/client/git_data/references.rb +6 -2
  26. data/lib/github_api/client/git_data/tags.rb +2 -0
  27. data/lib/github_api/client/git_data/trees.rb +2 -0
  28. data/lib/github_api/client/gitignore.rb +2 -0
  29. data/lib/github_api/client/issues.rb +2 -0
  30. data/lib/github_api/client/issues/assignees.rb +35 -0
  31. data/lib/github_api/client/issues/comments.rb +2 -0
  32. data/lib/github_api/client/issues/events.rb +2 -0
  33. data/lib/github_api/client/issues/labels.rb +2 -0
  34. data/lib/github_api/client/issues/milestones.rb +2 -0
  35. data/lib/github_api/client/markdown.rb +4 -2
  36. data/lib/github_api/client/meta.rb +2 -0
  37. data/lib/github_api/client/orgs.rb +6 -0
  38. data/lib/github_api/client/orgs/hooks.rb +2 -0
  39. data/lib/github_api/client/orgs/members.rb +2 -0
  40. data/lib/github_api/client/orgs/memberships.rb +2 -0
  41. data/lib/github_api/client/orgs/projects.rb +57 -0
  42. data/lib/github_api/client/orgs/teams.rb +5 -3
  43. data/lib/github_api/client/projects.rb +83 -0
  44. data/lib/github_api/client/projects/cards.rb +158 -0
  45. data/lib/github_api/client/projects/columns.rb +146 -0
  46. data/lib/github_api/client/pull_requests.rb +2 -0
  47. data/lib/github_api/client/pull_requests/comments.rb +2 -0
  48. data/lib/github_api/client/pull_requests/reviews.rb +2 -0
  49. data/lib/github_api/client/repos.rb +27 -15
  50. data/lib/github_api/client/repos/branches.rb +48 -0
  51. data/lib/github_api/client/repos/branches/protections.rb +75 -0
  52. data/lib/github_api/client/repos/collaborators.rb +2 -1
  53. data/lib/github_api/client/repos/comments.rb +2 -1
  54. data/lib/github_api/client/repos/commits.rb +2 -0
  55. data/lib/github_api/client/repos/contents.rb +26 -4
  56. data/lib/github_api/client/repos/deployments.rb +3 -1
  57. data/lib/github_api/client/repos/downloads.rb +2 -0
  58. data/lib/github_api/client/repos/forks.rb +6 -2
  59. data/lib/github_api/client/repos/hooks.rb +2 -0
  60. data/lib/github_api/client/repos/invitations.rb +41 -0
  61. data/lib/github_api/client/repos/keys.rb +2 -0
  62. data/lib/github_api/client/repos/merging.rb +2 -0
  63. data/lib/github_api/client/repos/pages.rb +2 -0
  64. data/lib/github_api/client/repos/projects.rb +62 -0
  65. data/lib/github_api/client/repos/pub_sub_hubbub.rb +6 -6
  66. data/lib/github_api/client/repos/releases.rb +2 -0
  67. data/lib/github_api/client/repos/releases/assets.rb +3 -1
  68. data/lib/github_api/client/repos/releases/tags.rb +2 -0
  69. data/lib/github_api/client/repos/statistics.rb +2 -0
  70. data/lib/github_api/client/repos/statuses.rb +2 -0
  71. data/lib/github_api/client/say.rb +2 -0
  72. data/lib/github_api/client/scopes.rb +2 -0
  73. data/lib/github_api/client/search.rb +3 -0
  74. data/lib/github_api/client/search/legacy.rb +2 -0
  75. data/lib/github_api/client/users.rb +2 -0
  76. data/lib/github_api/client/users/emails.rb +3 -0
  77. data/lib/github_api/client/users/followers.rb +3 -1
  78. data/lib/github_api/client/users/keys.rb +2 -0
  79. data/lib/github_api/configuration.rb +4 -1
  80. data/lib/github_api/connection.rb +5 -1
  81. data/lib/github_api/error.rb +1 -4
  82. data/lib/github_api/error/client_error.rb +4 -2
  83. data/lib/github_api/error/service_error.rb +9 -2
  84. data/lib/github_api/ext/faraday.rb +3 -1
  85. data/lib/github_api/mash.rb +7 -0
  86. data/lib/github_api/middleware.rb +8 -6
  87. data/lib/github_api/normalizer.rb +3 -5
  88. data/lib/github_api/page_iterator.rb +4 -1
  89. data/lib/github_api/page_links.rb +4 -0
  90. data/lib/github_api/paged_request.rb +2 -0
  91. data/lib/github_api/pagination.rb +10 -7
  92. data/lib/github_api/parameter_filter.rb +4 -1
  93. data/lib/github_api/params_hash.rb +4 -4
  94. data/lib/github_api/request.rb +8 -9
  95. data/lib/github_api/request/basic_auth.rb +1 -1
  96. data/lib/github_api/request/jsonize.rb +0 -1
  97. data/lib/github_api/request/oauth2.rb +2 -0
  98. data/lib/github_api/request/verbs.rb +3 -0
  99. data/lib/github_api/response/follow_redirects.rb +140 -0
  100. data/lib/github_api/response/header.rb +6 -1
  101. data/lib/github_api/response/mashify.rb +2 -3
  102. data/lib/github_api/response/raise_error.rb +2 -1
  103. data/lib/github_api/response_wrapper.rb +5 -0
  104. data/lib/github_api/utils/url.rb +2 -0
  105. data/lib/github_api/validations.rb +5 -8
  106. data/lib/github_api/validations/format.rb +2 -0
  107. data/lib/github_api/validations/presence.rb +3 -1
  108. data/lib/github_api/validations/required.rb +2 -0
  109. data/lib/github_api/version.rb +2 -2
  110. metadata +100 -36
  111. data/lib/github_api/core_ext/ordered_hash.rb +0 -107
  112. data/lib/github_api/requestable.rb +0 -67
  113. data/lib/github_api/resource.rb +0 -13
@@ -0,0 +1,158 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ require_relative '../../api'
5
+
6
+ module Github
7
+ class Client::Projects::Cards < API
8
+ REQUIRED_MOVE_CARD_PARAMS = %w(position).freeze
9
+
10
+ # List project cards for a column
11
+ #
12
+ # @example
13
+ # github = Github.new
14
+ # github.projects.cards.list :column_id
15
+ #
16
+ # @see https://developer.github.com/v3/projects/cards/#list-project-cards
17
+ #
18
+ # @api public
19
+ def list(*args)
20
+ arguments(args, required: [:column_id])
21
+ params = arguments.params
22
+
23
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
24
+
25
+ response = get_request("/projects/columns/#{arguments.column_id}/cards", params)
26
+
27
+ return response unless block_given?
28
+ response.each { |el| yield el }
29
+ end
30
+ alias all list
31
+
32
+ # Get a project card
33
+ #
34
+ # @example
35
+ # github = Github.new
36
+ # github.projects.cards.get :card_id
37
+ #
38
+ # @see https://developer.github.com/v3/projects/cards/#get-a-project-card
39
+ #
40
+ # @api public
41
+ def get(*args)
42
+ arguments(args, required: [:card_id])
43
+ params = arguments.params
44
+
45
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
46
+
47
+ get_request("/projects/columns/cards/#{arguments.card_id}", params)
48
+ end
49
+ alias find get
50
+
51
+ # Create a project card for a column
52
+ #
53
+ # @param [Hash] params
54
+ # @option params [String] :note
55
+ # The card's note content. Only valid for cards without another type of
56
+ # content, so this must be omitted if content_id and content_type are
57
+ # specified.
58
+ # @option params [Integer] :content_id
59
+ # The id of the Issue to associate with this card.
60
+ # @option params [String] :content_type
61
+ # The type of content to associate with this card. Can only be "Issue" at
62
+ # this time.
63
+ #
64
+ # @example
65
+ # github = Github.new
66
+ # github.projects.cards.create :column_id, note: 'Card Note'
67
+ #
68
+ # @example
69
+ # github = Github.new
70
+ # github.projects.cards.create :column_id, content_id: <content-id>, content_type: 'content-type'
71
+ #
72
+ # @see https://developer.github.com/v3/projects/cards/#create-a-project-card
73
+ #
74
+ # @api public
75
+ def create(*args)
76
+ arguments(args, required: [:column_id])
77
+ params = arguments.params
78
+
79
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
80
+
81
+ post_request("/projects/columns/#{arguments.column_id}/cards", params)
82
+ end
83
+
84
+ # Update a project card
85
+ #
86
+ # @param [Hash] params
87
+ # @option params [String] :note
88
+ # The card's note content. Only valid for cards without another type of
89
+ # content, so this cannot be specified if the card already has a
90
+ # content_id and content_type.
91
+ #
92
+ # @example
93
+ # github = Github.new
94
+ # github.projects.cards.update :card_id, note: 'New card note'
95
+ #
96
+ # @see https://developer.github.com/v3/projects/cards/#update-a-project-card
97
+ #
98
+ # @api public
99
+ def update(*args)
100
+ arguments(args, required: [:card_id])
101
+ params = arguments.params
102
+
103
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
104
+
105
+ patch_request("/projects/columns/cards/#{arguments.card_id}", params)
106
+ end
107
+ alias edit update
108
+
109
+ # Delete a project card
110
+ #
111
+ # @example
112
+ # github = Github.new
113
+ # github.projects.cards.delete :card_id
114
+ #
115
+ # @see https://developer.github.com/v3/projects/cards/#delete-a-project-card
116
+ #
117
+ # @api public
118
+ def delete(*args)
119
+ arguments(args, required: [:card_id])
120
+ params = arguments.params
121
+
122
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
123
+
124
+ delete_request("/projects/columns/cards/#{arguments.card_id}", params)
125
+ end
126
+ alias remove delete
127
+
128
+ # Move a project card
129
+ #
130
+ # @param [Hash] params
131
+ # @option params [String] :position
132
+ # Required. Required. Can be one of 'first', 'last', or
133
+ # 'after:<column-id>', where <column-id> is the id value of a column in
134
+ # the same project.
135
+ #
136
+ # @example
137
+ # github = Github.new
138
+ # github.projects.cards.move :card_id, position: 'bottom'
139
+ #
140
+ # @example
141
+ # github = Github.new
142
+ # github.projects.cards.move :card_id, position: 'after:<card-id>', column_id: <column-id>
143
+ #
144
+ # @see https://developer.github.com/v3/projects/cards/#move-a-project-card
145
+ #
146
+ # @api public
147
+ def move(*args)
148
+ arguments(args, required: [:card_id]) do
149
+ assert_required REQUIRED_MOVE_CARD_PARAMS
150
+ end
151
+ params = arguments.params
152
+
153
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
154
+
155
+ post_request("/projects/columns/cards/#{arguments.card_id}/moves", params)
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ require_relative '../../api'
5
+
6
+ module Github
7
+ class Client::Projects::Columns < API
8
+ REQUIRED_COLUMN_PARAMS = %w(name).freeze
9
+ REQUIRED_MOVE_COLUMN_PARAMS = %w(position).freeze
10
+
11
+ # List a project's columns
12
+ #
13
+ # @example
14
+ # github = Github.new
15
+ # github.projects.columns.list :project_id
16
+ #
17
+ # @see https://developer.github.com/v3/projects/columns/#list-project-columns
18
+ #
19
+ # @api public
20
+ def list(*args)
21
+ arguments(args, required: [:project_id])
22
+ params = arguments.params
23
+
24
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
25
+
26
+ response = get_request("/projects/#{arguments.project_id}/columns", params)
27
+
28
+ return response unless block_given?
29
+ response.each { |el| yield el }
30
+ end
31
+ alias all list
32
+
33
+ # Get a project columns
34
+ #
35
+ # @example
36
+ # github = Github.new
37
+ # github.projects.columns.get :column_id
38
+ #
39
+ # @see https://developer.github.com/v3/projects/columns/#get-a-project-column
40
+ #
41
+ # @api public
42
+ def get(*args)
43
+ arguments(args, required: [:column_id])
44
+ params = arguments.params
45
+
46
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
47
+
48
+ get_request("/projects/columns/#{arguments.column_id}", params)
49
+ end
50
+ alias find get
51
+
52
+ # Create a project column
53
+ #
54
+ # @param [Hash] params
55
+ # @option params [String] :name
56
+ # Required. The name of the column.
57
+ #
58
+ # @example
59
+ # github = Github.new
60
+ # github.projects.columns.create :project_id, name: 'column-name'
61
+ #
62
+ # @see https://developer.github.com/v3/projects/columns/#create-a-project-column
63
+ #
64
+ # @api public
65
+ def create(*args)
66
+ arguments(args, required: [:project_id]) do
67
+ assert_required REQUIRED_COLUMN_PARAMS
68
+ end
69
+ params = arguments.params
70
+
71
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
72
+
73
+ post_request("/projects/#{arguments.project_id}/columns", params)
74
+ end
75
+
76
+ # Update a project column
77
+ #
78
+ # @param [Hash] params
79
+ # @option params [String] :name
80
+ # Required. The name of the column.
81
+ #
82
+ # @example
83
+ # github = Github.new
84
+ # github.repos.projects.update :column_id, name: 'new-column-name'
85
+ #
86
+ # @see https://developer.github.com/v3/projects/columns/#update-a-project-column
87
+ #
88
+ # @api public
89
+ def update(*args)
90
+ arguments(args, required: [:column_id]) do
91
+ assert_required REQUIRED_COLUMN_PARAMS
92
+ end
93
+ params = arguments.params
94
+
95
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
96
+
97
+ patch_request("/projects/columns/#{arguments.column_id}", params)
98
+ end
99
+ alias edit update
100
+
101
+ # Delete a project column
102
+ #
103
+ # @example
104
+ # github = Github.new
105
+ # github.projects.columns.delete :column_id
106
+ #
107
+ # @see https://developer.github.com/v3/projects/columns/#delete-a-project-column
108
+ #
109
+ # @api public
110
+ def delete(*args)
111
+ arguments(args, required: [:column_id])
112
+ params = arguments.params
113
+
114
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
115
+
116
+ delete_request("/projects/columns/#{arguments.column_id}", params)
117
+ end
118
+ alias remove delete
119
+
120
+ # Move a project column
121
+ #
122
+ # @param [Hash] params
123
+ # @option params [String] :position
124
+ # Required. Required. Can be one of 'first', 'last', or
125
+ # 'after:<column-id>', where <column-id> is the id value of a column in
126
+ # the same project.
127
+ #
128
+ # @example
129
+ # github = Github.new
130
+ # github.projects.columns.move :column_id, position: 'first'
131
+ #
132
+ # @see https://developer.github.com/v3/projects/columns/#move-a-project-column
133
+ #
134
+ # @api public
135
+ def move(*args)
136
+ arguments(args, required: [:column_id]) do
137
+ assert_required REQUIRED_MOVE_COLUMN_PARAMS
138
+ end
139
+ params = arguments.params
140
+
141
+ params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
142
+
143
+ post_request("/projects/columns/#{arguments.column_id}/moves", params)
144
+ end
145
+ end
146
+ end
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../api'
4
+
3
5
  module Github
4
6
  class Client::PullRequests < API
5
7
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::PullRequests::Comments < API
5
7
  # List comments on a pull request
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require_relative '../../api'
4
+
3
5
  module Github
4
6
  class Client::PullRequests::Reviews < API
5
7
  PREVIEW_MEDIA = "application/vnd.github.black-cat-preview+json".freeze # :nodoc:
@@ -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',
@@ -12,9 +15,11 @@ module Github
12
15
  'downloads',
13
16
  'forks',
14
17
  'hooks',
18
+ 'invitations',
15
19
  'keys',
16
20
  'merging',
17
21
  'pages',
22
+ 'projects',
18
23
  'pub_sub_hubbub',
19
24
  'releases',
20
25
  'statistics',
@@ -28,6 +33,7 @@ module Github
28
33
  homepage
29
34
  private
30
35
  has_issues
36
+ has_projects
31
37
  has_wiki
32
38
  has_downloads
33
39
  team_id
@@ -62,6 +68,9 @@ module Github
62
68
  # Access to Repos::Hooks API
63
69
  namespace :hooks
64
70
 
71
+ # Access to Repos::Invitations API
72
+ namespace :invitations
73
+
65
74
  # Access to Repos::Keys API
66
75
  namespace :keys
67
76
 
@@ -71,6 +80,9 @@ module Github
71
80
  # Access to Repos::Pages API
72
81
  namespace :pages
73
82
 
83
+ # Access to Repos::Projects API
84
+ namespace :projects
85
+
74
86
  # Access to Repos::PubSubHubbub API
75
87
  namespace :pubsubhubbub, full_name: :pub_sub_hubbub
76
88
 
@@ -83,6 +95,9 @@ module Github
83
95
  # Access to Repos::Statuses API
84
96
  namespace :statuses
85
97
 
98
+ # Access to Repos::Branches API
99
+ namespace :branches
100
+
86
101
  # List repositories for the authenticated user
87
102
  #
88
103
  # @example
@@ -173,7 +188,7 @@ module Github
173
188
  end
174
189
  alias :find_by_id :get_by_id
175
190
 
176
- # Create a new repository for the autheticated user.
191
+ # Create a new repository for the authenticated user.
177
192
  #
178
193
  # @param [Hash] params
179
194
  # @option params [String] :name
@@ -229,7 +244,6 @@ module Github
229
244
  # @example
230
245
  def create(*args)
231
246
  arguments(args) do
232
- permit VALID_REPO_OPTIONS + %w[ org ]
233
247
  assert_required %w[ name ]
234
248
  end
235
249
  params = arguments.params
@@ -275,7 +289,6 @@ module Github
275
289
  arguments(args, required: [:user, :repo]) do
276
290
  permit %w[ anon ]
277
291
  end
278
- params = arguments.params
279
292
 
280
293
  response = get_request("/repos/#{arguments.user}/#{arguments.repo}/contributors", arguments.params)
281
294
  return response unless block_given?
@@ -335,7 +348,6 @@ module Github
335
348
  # @api public
336
349
  def delete(*args)
337
350
  arguments(args, required: [:user, :repo])
338
- params = arguments.params
339
351
 
340
352
  delete_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
341
353
  end
@@ -353,14 +365,14 @@ module Github
353
365
  # repos.branches 'user-name', 'repo-name'
354
366
  #
355
367
  # @api public
356
- def branches(*args)
357
- arguments(args, required: [:user, :repo])
368
+ # def branches(*args)
369
+ # arguments(args, required: [:user, :repo])
358
370
 
359
- response = get_request("/repos/#{arguments.user}/#{arguments.repo}/branches", arguments.params)
360
- return response unless block_given?
361
- response.each { |el| yield el }
362
- end
363
- alias :list_branches :branches
371
+ # response = get_request("/repos/#{arguments.user}/#{arguments.repo}/branches", arguments.params)
372
+ # return response unless block_given?
373
+ # response.each { |el| yield el }
374
+ # end
375
+ # alias :list_branches :branches
364
376
 
365
377
  # Get branch
366
378
  #
@@ -370,11 +382,11 @@ module Github
370
382
  # github.repos.branch user: 'user-name', repo: 'repo-name', branch: 'branch-name'
371
383
  # github.repos(user: 'user-name', repo: 'repo-name', branch: 'branch-name').branch
372
384
  # @api public
373
- def branch(*args)
374
- arguments(args, required: [:user, :repo, :branch])
385
+ # def branch(*args)
386
+ # arguments(args, required: [:user, :repo, :branch])
375
387
 
376
- get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}", arguments.params)
377
- end
388
+ # get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}", arguments.params)
389
+ # end
378
390
 
379
391
  # List contributors
380
392
  #