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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +770 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.md +741 -0
  5. data/lib/github_api2/api/actions.rb +60 -0
  6. data/lib/github_api2/api/arguments.rb +253 -0
  7. data/lib/github_api2/api/config/property.rb +30 -0
  8. data/lib/github_api2/api/config/property_set.rb +120 -0
  9. data/lib/github_api2/api/config.rb +105 -0
  10. data/lib/github_api2/api/factory.rb +33 -0
  11. data/lib/github_api2/api.rb +398 -0
  12. data/lib/github_api2/authorization.rb +75 -0
  13. data/lib/github_api2/client/activity/events.rb +233 -0
  14. data/lib/github_api2/client/activity/feeds.rb +50 -0
  15. data/lib/github_api2/client/activity/notifications.rb +181 -0
  16. data/lib/github_api2/client/activity/starring.rb +130 -0
  17. data/lib/github_api2/client/activity/watching.rb +176 -0
  18. data/lib/github_api2/client/activity.rb +31 -0
  19. data/lib/github_api2/client/authorizations/app.rb +98 -0
  20. data/lib/github_api2/client/authorizations.rb +142 -0
  21. data/lib/github_api2/client/emojis.rb +19 -0
  22. data/lib/github_api2/client/gists/comments.rb +100 -0
  23. data/lib/github_api2/client/gists.rb +289 -0
  24. data/lib/github_api2/client/git_data/blobs.rb +51 -0
  25. data/lib/github_api2/client/git_data/commits.rb +101 -0
  26. data/lib/github_api2/client/git_data/references.rb +150 -0
  27. data/lib/github_api2/client/git_data/tags.rb +95 -0
  28. data/lib/github_api2/client/git_data/trees.rb +113 -0
  29. data/lib/github_api2/client/git_data.rb +31 -0
  30. data/lib/github_api2/client/gitignore.rb +57 -0
  31. data/lib/github_api2/client/issues/assignees.rb +77 -0
  32. data/lib/github_api2/client/issues/comments.rb +146 -0
  33. data/lib/github_api2/client/issues/events.rb +50 -0
  34. data/lib/github_api2/client/issues/labels.rb +189 -0
  35. data/lib/github_api2/client/issues/milestones.rb +146 -0
  36. data/lib/github_api2/client/issues.rb +248 -0
  37. data/lib/github_api2/client/markdown.rb +62 -0
  38. data/lib/github_api2/client/meta.rb +19 -0
  39. data/lib/github_api2/client/orgs/hooks.rb +182 -0
  40. data/lib/github_api2/client/orgs/members.rb +142 -0
  41. data/lib/github_api2/client/orgs/memberships.rb +131 -0
  42. data/lib/github_api2/client/orgs/projects.rb +57 -0
  43. data/lib/github_api2/client/orgs/teams.rb +407 -0
  44. data/lib/github_api2/client/orgs.rb +127 -0
  45. data/lib/github_api2/client/projects/cards.rb +158 -0
  46. data/lib/github_api2/client/projects/columns.rb +146 -0
  47. data/lib/github_api2/client/projects.rb +83 -0
  48. data/lib/github_api2/client/pull_requests/comments.rb +140 -0
  49. data/lib/github_api2/client/pull_requests/reviews.rb +158 -0
  50. data/lib/github_api2/client/pull_requests.rb +195 -0
  51. data/lib/github_api2/client/repos/branches/protections.rb +75 -0
  52. data/lib/github_api2/client/repos/branches.rb +48 -0
  53. data/lib/github_api2/client/repos/collaborators.rb +84 -0
  54. data/lib/github_api2/client/repos/comments.rb +125 -0
  55. data/lib/github_api2/client/repos/commits.rb +80 -0
  56. data/lib/github_api2/client/repos/contents.rb +263 -0
  57. data/lib/github_api2/client/repos/deployments.rb +138 -0
  58. data/lib/github_api2/client/repos/downloads.rb +62 -0
  59. data/lib/github_api2/client/repos/forks.rb +50 -0
  60. data/lib/github_api2/client/repos/hooks.rb +214 -0
  61. data/lib/github_api2/client/repos/invitations.rb +41 -0
  62. data/lib/github_api2/client/repos/keys.rb +104 -0
  63. data/lib/github_api2/client/repos/merging.rb +47 -0
  64. data/lib/github_api2/client/repos/pages.rb +48 -0
  65. data/lib/github_api2/client/repos/projects.rb +62 -0
  66. data/lib/github_api2/client/repos/pub_sub_hubbub.rb +133 -0
  67. data/lib/github_api2/client/repos/releases/assets.rb +136 -0
  68. data/lib/github_api2/client/repos/releases/tags.rb +24 -0
  69. data/lib/github_api2/client/repos/releases.rb +189 -0
  70. data/lib/github_api2/client/repos/statistics.rb +89 -0
  71. data/lib/github_api2/client/repos/statuses.rb +91 -0
  72. data/lib/github_api2/client/repos.rb +473 -0
  73. data/lib/github_api2/client/say.rb +25 -0
  74. data/lib/github_api2/client/scopes.rb +46 -0
  75. data/lib/github_api2/client/search/legacy.rb +111 -0
  76. data/lib/github_api2/client/search.rb +133 -0
  77. data/lib/github_api2/client/users/emails.rb +65 -0
  78. data/lib/github_api2/client/users/followers.rb +115 -0
  79. data/lib/github_api2/client/users/keys.rb +104 -0
  80. data/lib/github_api2/client/users.rb +117 -0
  81. data/lib/github_api2/client.rb +77 -0
  82. data/lib/github_api2/configuration.rb +70 -0
  83. data/lib/github_api2/connection.rb +82 -0
  84. data/lib/github_api2/constants.rb +61 -0
  85. data/lib/github_api2/core_ext/array.rb +25 -0
  86. data/lib/github_api2/core_ext/hash.rb +91 -0
  87. data/lib/github_api2/deprecation.rb +39 -0
  88. data/lib/github_api2/error/client_error.rb +89 -0
  89. data/lib/github_api2/error/service_error.rb +223 -0
  90. data/lib/github_api2/error.rb +32 -0
  91. data/lib/github_api2/ext/faraday.rb +40 -0
  92. data/lib/github_api2/mash.rb +7 -0
  93. data/lib/github_api2/middleware.rb +37 -0
  94. data/lib/github_api2/mime_type.rb +33 -0
  95. data/lib/github_api2/normalizer.rb +23 -0
  96. data/lib/github_api2/null_encoder.rb +25 -0
  97. data/lib/github_api2/page_iterator.rb +138 -0
  98. data/lib/github_api2/page_links.rb +63 -0
  99. data/lib/github_api2/paged_request.rb +42 -0
  100. data/lib/github_api2/pagination.rb +115 -0
  101. data/lib/github_api2/parameter_filter.rb +35 -0
  102. data/lib/github_api2/params_hash.rb +115 -0
  103. data/lib/github_api2/rate_limit.rb +25 -0
  104. data/lib/github_api2/request/basic_auth.rb +36 -0
  105. data/lib/github_api2/request/jsonize.rb +54 -0
  106. data/lib/github_api2/request/oauth2.rb +45 -0
  107. data/lib/github_api2/request/verbs.rb +63 -0
  108. data/lib/github_api2/request.rb +84 -0
  109. data/lib/github_api2/response/atom_parser.rb +22 -0
  110. data/lib/github_api2/response/follow_redirects.rb +140 -0
  111. data/lib/github_api2/response/header.rb +87 -0
  112. data/lib/github_api2/response/jsonize.rb +28 -0
  113. data/lib/github_api2/response/mashify.rb +24 -0
  114. data/lib/github_api2/response/raise_error.rb +22 -0
  115. data/lib/github_api2/response/xmlize.rb +28 -0
  116. data/lib/github_api2/response.rb +48 -0
  117. data/lib/github_api2/response_wrapper.rb +161 -0
  118. data/lib/github_api2/ssl_certs/cacerts.pem +2183 -0
  119. data/lib/github_api2/utils/url.rb +63 -0
  120. data/lib/github_api2/validations/format.rb +26 -0
  121. data/lib/github_api2/validations/presence.rb +32 -0
  122. data/lib/github_api2/validations/required.rb +21 -0
  123. data/lib/github_api2/validations/token.rb +41 -0
  124. data/lib/github_api2/validations.rb +22 -0
  125. data/lib/github_api2/version.rb +5 -0
  126. data/lib/github_api2.rb +92 -0
  127. metadata +363 -0
@@ -0,0 +1,263 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ # These API methods let you retrieve the contents of files within a repository
7
+ # as Base64 encoded content.
8
+ class Client::Repos::Contents < API
9
+
10
+ REQUIRED_CONTENT_OPTIONS = %w[ path message content ]
11
+
12
+ # Get the README
13
+ #
14
+ # This method returns the preferred README for a repository.
15
+ #
16
+ # @param [Hash] params
17
+ # @option params [String] :ref
18
+ # The name of the commit/branch/tag.
19
+ # Default: the repository’s default branch (usually master)
20
+ #
21
+ # @example
22
+ # github = Github.new
23
+ # github.repos.contents.readme 'user-name', 'repo-name'
24
+ #
25
+ # @example
26
+ # content = Github::Client::Repos::Contents.new user: 'user-name', repo: 'repo-name'
27
+ # content.readme
28
+ #
29
+ # @api public
30
+ def readme(*args)
31
+ arguments(args, required: [:user, :repo])
32
+
33
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/readme", arguments.params)
34
+ end
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
+
53
+ # Get contents
54
+ #
55
+ # This method returns the contents of any file or directory in a repository.
56
+ #
57
+ # @param [Hash] params
58
+ # @option params [String] :path
59
+ # The content path.
60
+ # @option params [String] :ref
61
+ # The name of the commit/branch/tag.
62
+ # Default: the repository’s default branch (usually master)
63
+ #
64
+ # @example
65
+ # github = Github.new
66
+ # github.repos.contents.get 'user-name', 'repo-name', 'path'
67
+ #
68
+ # @example
69
+ # github = Github.new user: 'user-name', repo: 'repo-name'
70
+ # github.repos.contents.get path: 'README.md'
71
+ #
72
+ # @api public
73
+ def get(*args)
74
+ arguments(args, required: [:user, :repo, :path])
75
+
76
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}", arguments.params)
77
+ end
78
+ alias :find :get
79
+
80
+ # Create a file
81
+ #
82
+ # This method creates a new file in a repository
83
+ #
84
+ # @param [Hash] params
85
+ # @option params [String] :path
86
+ # Required string. The content path
87
+ # @option params [String]
88
+ # @option params [String] :message
89
+ # Required string. The commit message.
90
+ # @option params [String] :content
91
+ # Required string. The new file content, which will be Base64 encoded
92
+ # @option params [String] :branch
93
+ # The branch name. If not provided, uses the repository’s
94
+ # default branch (usually master)
95
+ #
96
+ # Optional Parameters
97
+ #
98
+ # The :author section is optional and is filled in with the
99
+ # :committer information if omitted. If the :committer
100
+ # information is omitted, the authenticated user’s information is used.
101
+ #
102
+ # You must provide values for both :name and :email, whether
103
+ # you choose to use :author or :committer. Otherwise, you’ll
104
+ # receive a 500 status code.
105
+ #
106
+ # Both the author and commiter parameters have the same keys:
107
+ #
108
+ # @option params [String] :name
109
+ # The name of the author (or commiter) of the commit
110
+ # @option params [String] :email
111
+ # The email of the author (or commiter) of the commit
112
+ #
113
+ # @example
114
+ # github = Github.new
115
+ # github.repos.contents.create 'user-name', 'repo-name', 'path',
116
+ # path: 'hello.rb',
117
+ # content: "puts 'hello ruby'",
118
+ # message: "my commit message"
119
+ #
120
+ # @api public
121
+ def create(*args)
122
+ arguments(args, required: [:user, :repo, :path]) do
123
+ assert_required REQUIRED_CONTENT_OPTIONS
124
+ end
125
+ params = arguments.params
126
+ params.strict_encode64('content')
127
+
128
+ put_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}", params)
129
+ end
130
+
131
+ # Update a file
132
+ #
133
+ # This method updates a file in a repository
134
+ #
135
+ # @param [Hash] params
136
+ # @option params [String] :path
137
+ # Requried string. The content path
138
+ # @option params [String]
139
+ # @option params [String] :message
140
+ # Requried string. The commit message.
141
+ # @option params [String] :content
142
+ # Requried string. The new file content, which will be Base64 encoded
143
+ # @option params [String] :sha
144
+ # Required string. The blob SHA of the file being replaced.
145
+ # @option params [String] :branch
146
+ # The branch name. If not provided, uses the repository’s
147
+ # default branch (usually master)
148
+ #
149
+ # Optional Parameters
150
+ #
151
+ # The :author section is optional and is filled in with the
152
+ # :committer information if omitted. If the :committer
153
+ # information is omitted, the authenticated user’s information is used.
154
+ #
155
+ # You must provide values for both :name and :email, whether
156
+ # you choose to use :author or :committer. Otherwise, you’ll
157
+ # receive a 500 status code.
158
+ #
159
+ # Both the author and commiter parameters have the same keys:
160
+ #
161
+ # @option params [String] :name
162
+ # The name of the author (or commiter) of the commit
163
+ # @option params [String] :email
164
+ # The email of the author (or commiter) of the commit
165
+ #
166
+ # @example
167
+ # github = Github.new
168
+ # github.repos.contents.update 'user-name', 'repo-name', 'path',
169
+ # path: 'hello.rb',
170
+ # content: "puts 'hello ruby again'",
171
+ # message: "my commit message",
172
+ # sha: "25b0bef9e404bd2e3233de26b7ef8cbd86d0e913"
173
+ #
174
+ # @api public
175
+ def update(*args)
176
+ create(*args)
177
+ end
178
+
179
+ # Delete a file
180
+ #
181
+ # This method deletes a file in a repository
182
+ #
183
+ # @param [Hash] params
184
+ # @option params [String] :path
185
+ # Requried string. The content path
186
+ # @option params [String]
187
+ # @option params [String] :message
188
+ # Requried string. The commit message.
189
+ # @option params [String] :sha
190
+ # Required string. The blob SHA of the file being replaced.
191
+ # @option params [String] :branch
192
+ # The branch name. If not provided, uses the repository’s
193
+ # default branch (usually master)
194
+ #
195
+ # Optional Parameters
196
+ #
197
+ # The :author section is optional and is filled in with the
198
+ # :committer information if omitted. If the :committer
199
+ # information is omitted, the authenticated user’s information is used.
200
+ #
201
+ # You must provide values for both :name and :email, whether
202
+ # you choose to use :author or :committer. Otherwise, you’ll
203
+ # receive a 500 status code.
204
+ #
205
+ # Both the author and commiter parameters have the same keys:
206
+ #
207
+ # @option params [String] :name
208
+ # The name of the author (or commiter) of the commit
209
+ # @option params [String] :email
210
+ # The email of the author (or commiter) of the commit
211
+ #
212
+ # @example
213
+ # github = Github.new
214
+ # github.repos.contents.delete 'user-name', 'repo-name', 'path',
215
+ # path: 'hello.rb',
216
+ # message: "delete hello.rb file",
217
+ # sha: "329688480d39049927147c162b9d2deaf885005f"
218
+ #
219
+ def delete(*args)
220
+ arguments(args, required: [:user, :repo, :path]) do
221
+ assert_required %w[ path message sha ]
222
+ end
223
+
224
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}", arguments.params)
225
+ end
226
+
227
+ # Get archive link
228
+ #
229
+ # This method will return a 302 to a URL to download a tarball or zipball
230
+ # archive for a repository. Please make sure your HTTP framework is configured
231
+ # to follow redirects or you will need to use the Location header to make
232
+ # a second GET request.
233
+ #
234
+ # @note
235
+ # For private repositories, these links are temporary and expire quickly.
236
+ #
237
+ # @param [Hash] params
238
+ # @input params [String] :archive_format
239
+ # Required string. Either tarball or zipball. Default: tarball
240
+ # @input params [String] :ref
241
+ # Optional string. A valid Git reference.
242
+ # Default: the repository’s default branch (usually master)
243
+ #
244
+ # @example
245
+ # github = Github.new
246
+ # github.repos.contents.archive 'user-name', 'repo-name',
247
+ # archive_format: "tarball",
248
+ # ref: "master"
249
+ #
250
+ # @api public
251
+ def archive(*args)
252
+ arguments(args, required: [:user, :repo])
253
+ params = arguments.params
254
+ archive_format = params.delete('archive_format') || 'tarball'
255
+ ref = params.delete('ref') || 'master'
256
+
257
+ disable_redirects do
258
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/#{archive_format}/#{ref}", params)
259
+ response.headers.location
260
+ end
261
+ end
262
+ end # Client::Repos::Contents
263
+ end # Github
@@ -0,0 +1,138 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Repos::Deployments < API
7
+
8
+ VALID_DEPLOYMENTS_OPTIONS = %w[
9
+ ref
10
+ auto_merge
11
+ required_contexts
12
+ payload
13
+ environment
14
+ description
15
+ ]
16
+
17
+ VALID_STATUS_OPTIONS = %w[
18
+ state
19
+ target_url
20
+ description
21
+ ]
22
+
23
+ PREVIEW_MEDIA = 'application/vnd.github.cannonball-preview+json'.freeze # :nodoc:
24
+
25
+ # List deployments on a repository
26
+ #
27
+ # @example
28
+ # github = Github.new
29
+ # github.repos.deployments.list 'user-name', 'repo-name'
30
+ # github.repos.deployments.list 'user-name', 'repo-name' { |deployment| ... }
31
+ #
32
+ # @api public
33
+ def list(*args)
34
+ arguments(args, required: [:user, :repo])
35
+ params = arguments.params
36
+ params['accept'] ||= PREVIEW_MEDIA
37
+
38
+ response = get_request("repos/#{arguments.user}/#{arguments.repo}/deployments", params)
39
+ return response unless block_given?
40
+ response.each { |el| yield el }
41
+ end
42
+ alias :all :list
43
+
44
+ # Create a deployment
45
+ #
46
+ # @param [Hash] params
47
+ # @option params [String] :ref
48
+ # Required string. The ref to deploy. This can be a branch, tag, or sha.
49
+ # @option params [Boolean] :auto_merge
50
+ # Optional boolean. Merge the default branch into the requested.
51
+ # @option params [Array] :required_contexts
52
+ # Optional array of status contexts verified against commit status checks.
53
+ # If this parameter is omitted from the parameters then all unique
54
+ # contexts will be verified before a deployment is created. To bypass
55
+ # checking entirely pass an empty array. Defaults to all unique contexts.
56
+ # @option params [String] :payload
57
+ # Optional JSON payload with extra information about the deployment.
58
+ # Default: ""
59
+ # @option params [String] :payload
60
+ # Optional String. Name for the target deployment environment (e.g.,
61
+ # production, staging, qa). Default: "production"
62
+ # @option params [String] :description
63
+ # Optional string. Optional short description.
64
+ #
65
+ # @example
66
+ # github = Github.new
67
+ # github.repos.deployments.create 'user-name', 'repo-name', ref: '...'
68
+ # github.repos.deployments.create
69
+ # 'user-name',
70
+ # 'repo-name',
71
+ # ref: '...',
72
+ # description: 'New deploy',
73
+ # force: true
74
+ #
75
+ # @api public
76
+ def create(*args)
77
+ arguments(args, required: [:user, :repo]) do
78
+ permit VALID_DEPLOYMENTS_OPTIONS
79
+ assert_required %w[ ref ]
80
+ end
81
+ params = arguments.params
82
+ params['accept'] ||= PREVIEW_MEDIA
83
+
84
+ post_request("repos/#{arguments.user}/#{arguments.repo}/deployments", arguments.params)
85
+ end
86
+
87
+ # List the statuses of a deployment.
88
+ #
89
+ # @param [Hash] params
90
+ # @option params [String] :id
91
+ # Required string. Id of the deployment being queried.
92
+ #
93
+ # @example
94
+ # github = Github.new
95
+ # github.repos.deployments.statuses 'user-name', 'repo-name', DEPLOYMENT_ID
96
+ # github.repos.deployments.statuses 'user-name', 'repo-name', DEPLOYMENT_ID { |status| ... }
97
+ #
98
+ # @api public
99
+ def statuses(*args)
100
+ arguments(args, required: [:user, :repo, :id])
101
+ params = arguments.params
102
+ params['accept'] ||= PREVIEW_MEDIA
103
+
104
+ statuses = get_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params)
105
+ return statuses unless block_given?
106
+ statuses.each { |status| yield status }
107
+ end
108
+
109
+ # Create a deployment status
110
+ #
111
+ # @param [Hash] params
112
+ # @option params [String] :id
113
+ # Required string. Id of the deployment being referenced.
114
+ # @option params [String] :state
115
+ # Required string. State of the deployment. Can be one of:
116
+ # pending, success, error, or failure.
117
+ # @option params [String] :target_url
118
+ # Optional string. The URL associated with the status.
119
+ # @option params [String] :description
120
+ # Optional string. A short description of the status.
121
+ #
122
+ # @example
123
+ # github = Github.new
124
+ # github.repos.deployments.create_status 'user-name', 'repo-name', DEPLOYMENT_ID, state: '...'
125
+ #
126
+ # @api public
127
+ def create_status(*args)
128
+ arguments(args, required: [:user, :repo, :id]) do
129
+ assert_required %w[ state ]
130
+ permit VALID_STATUS_OPTIONS
131
+ end
132
+ params = arguments.params
133
+ params['accept'] ||= PREVIEW_MEDIA
134
+
135
+ post_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params)
136
+ end
137
+ end # Client::Repos::Deployments
138
+ end # Github
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Repos::Downloads < API
7
+
8
+ REQUIRED_PARAMS = %w[ name size ].freeze
9
+
10
+ VALID_DOWNLOAD_PARAM_NAMES = %w[
11
+ name
12
+ size
13
+ description
14
+ content_type
15
+ ].freeze
16
+
17
+ # List downloads for a repository
18
+ #
19
+ # @example
20
+ # github = Github.new
21
+ # github.repos.downloads.list 'user-name', 'repo-name'
22
+ # github.repos.downloads.list 'user-name', 'repo-name' { |downl| ... }
23
+ #
24
+ # @api public
25
+ def list(*args)
26
+ arguments(args, required: [:user, :repo])
27
+
28
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads", arguments.params)
29
+ return response unless block_given?
30
+ response.each { |el| yield el }
31
+ end
32
+ alias :all :list
33
+
34
+ # Get a single download
35
+ #
36
+ # @example
37
+ # github = Github.new
38
+ # github.repos.downloads.get 'user-name', 'repo-name', 'download-id'
39
+ #
40
+ # @api public
41
+ def get(*args)
42
+ arguments(args, required: [:user, :repo, :id])
43
+
44
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
45
+ end
46
+ alias :find :get
47
+
48
+ # Delete download from a repository
49
+ #
50
+ # @example
51
+ # github = Github.new
52
+ # github.repos.downloads.delete 'user-name', 'repo-name', 'download-id'
53
+ #
54
+ # @api public
55
+ def delete(*args)
56
+ arguments(args, required: [:user, :repo, :id])
57
+
58
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
59
+ end
60
+ alias :remove :delete
61
+ end # Repos::Downloads
62
+ end # Github
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Repos::Forks < API
7
+ # List repository forks
8
+ #
9
+ # @param [Hash] params
10
+ # @input params [String] :sort
11
+ # The sort order. Can be either newest, oldest, or stargazers.
12
+ # Default: newest
13
+ #
14
+ # @example
15
+ # github = Github.new
16
+ # github.repos.forks.list('user-name', 'repo-name')
17
+ # github.repos.forks.list('user-name', 'repo-name') { |fork|
18
+ # #...
19
+ # }
20
+ #
21
+ # @api public
22
+ def list(*args)
23
+ arguments(args, required: [:user, :repo])
24
+
25
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/forks", arguments.params)
26
+ return response unless block_given?
27
+ response.each { |el| yield el }
28
+ end
29
+ alias :all :list
30
+
31
+ # Create a fork for the authenticated user
32
+ #
33
+ # @param [Hash] params
34
+ # @input params [String] :organization
35
+ # The organization login. The repository will be forked into
36
+ # this organization.
37
+ #
38
+ # @example
39
+ # github = Github.new
40
+ # github.repos.forks.create 'user-name', 'repo-name',
41
+ # organization: "github"
42
+ #
43
+ # @api public
44
+ def create(*args)
45
+ arguments(args, required: [:user, :repo])
46
+
47
+ post_request("/repos/#{arguments.user}/#{arguments.repo}/forks", arguments.params)
48
+ end
49
+ end # Client::Repos::Forks
50
+ end # Github