Compare commits

...

296 Commits

Author SHA1 Message Date
Liam Newman
cda7607e1c [maven-release-plugin] prepare release github-api-1.107 2020-02-22 20:18:57 -08:00
Liam Newman
0c3c490d58 Merge pull request #707 from rdvdijk/add-rocket-eyes-reactions
Add support for rocket and eyes reactions.
2020-02-22 19:33:08 -08:00
Liam Newman
99da6fb66f Merge pull request #710 from avano/checks
CheckRun - Add ability to get the head sha + Implement GH Status Event
2020-02-22 19:17:06 -08:00
Liam Newman
fa2601386c Add tests for new reactions 2020-02-22 19:16:33 -08:00
Liam Newman
122833b0e3 Merge branch 'master' into checks 2020-02-22 18:48:50 -08:00
Liam Newman
8618dbf0d5 Merge pull request #709 from bitwiseman/issue/708
Fix for NullPointer in issue search results
2020-02-22 18:42:09 -08:00
Liam Newman
a0baf33459 Fix for NullPointer in issue search results
User reported #708 which made me realize that search tests were basically all disabled.
This terms on two basic search tests and also makes it so GHIssue can continue to work without
a GHRepository set on it.

Fixes #708
2020-02-22 17:01:12 -08:00
Andrej Vano
0ee66ea928 [Status] Add GHEventPayload.Status class 2020-02-22 18:14:03 +01:00
Andrej Vano
f68d4aaf5b [CheckRun] Add ability to access HEAD SHA 2020-02-22 18:10:27 +01:00
Liam Newman
888abc9e2a Removed extraneous author javadocs 2020-02-21 15:58:39 -08:00
Liam Newman
c8115b1c10 Remove shading 2020-02-21 15:58:39 -08:00
Liam Newman
137d4f591f Update maven-build.yml 2020-02-21 15:44:31 -08:00
Liam Newman
337d49770d Update maven-build.yml 2020-02-21 15:42:28 -08:00
Liam Newman
614c5578b0 Fix code coverage and GHRepositoryTraffic test 2020-02-21 15:35:45 -08:00
Liam Newman
d456e60800 Check code coverage on ubuntu 2020-02-21 13:17:31 -08:00
Liam Newman
064206fb9a Merge pull request #706 from bitwiseman/task/guard
Add basic rate limit checker
2020-02-21 13:06:51 -08:00
Liam Newman
a68fe3b39d More javadoc because words are hard 2020-02-21 12:04:25 -08:00
Liam Newman
1904c82941 PR feedback 2020-02-21 10:52:28 -08:00
Roel van Dijk
6fc9dd4b30 Add support for rocket and eyes reactions. 2020-02-21 10:59:17 +01:00
Liam Newman
158a31e924 Added javadocs and other cleanup
Whenever I submit a PR and then start looking at it as a reviewer, I immediately find a bunch of things that need changing.
2020-02-20 18:53:13 -08:00
Liam Newman
b70b924db4 Inital implmentation of RateLimitChecker
This is a stripped down rate limit checking implmentation that handles the infrastructure
of deciding how to get rate limit information and leaves it to other implementers to
decided what kind of checks they want to do and how long they want to wait.

The implmentation supports checkers that sleep less than the full time until the
rate limit is expected to reset, allowing for polling and notifying clients of why their query
is not returning.

A basic checker which sleeps until the rate limit is expected to reset is included as working example..
2020-02-20 16:03:46 -08:00
Liam Newman
9018d72e97 Merge pull request #697 from bitwiseman/tast/response-info
Refactor `Requester` into multiple smaller classes
2020-02-20 15:59:11 -08:00
Liam Newman
5c395138ed Merge pull request #705 from github-api/dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-5.6.1.202002131546-r
Bump org.eclipse.jgit from 5.6.0.201912101111-r to 5.6.1.202002131546-r
2020-02-19 16:01:40 -08:00
Liam Newman
af157adc1b Merge pull request #704 from github-api/dependabot/maven/com.squareup.okhttp3-okhttp-4.4.0
Bump okhttp from 4.3.1 to 4.4.0
2020-02-19 16:01:21 -08:00
Liam Newman
1db4fca9db Comment tweaks 2020-02-18 09:02:52 -08:00
dependabot-preview[bot]
013f475859 Bump org.eclipse.jgit from 5.6.0.201912101111-r to 5.6.1.202002131546-r
Bumps org.eclipse.jgit from 5.6.0.201912101111-r to 5.6.1.202002131546-r.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-18 06:36:30 +00:00
dependabot-preview[bot]
b5bc38fa52 Bump okhttp from 4.3.1 to 4.4.0
Bumps [okhttp](https://github.com/square/okhttp) from 4.3.1 to 4.4.0.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-4.3.1...parent-4.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-18 06:36:08 +00:00
Liam Newman
bd0e0cdfa4 Revert synchronization in iterators
These were not synchronized before we should leave them fix this in a future change
2020-02-17 20:08:52 -08:00
Liam Newman
dade4c4cc4 Bump spotbugs to 4.0.0 2020-02-17 13:11:00 -08:00
Liam Newman
acc5a89dff Class clean up
We don't need two layers of PageIterator just to get the final response.
Also made iterators thread-safe.
And added more detailed comments.
2020-02-17 12:55:44 -08:00
Liam Newman
b7af635a9a Address PR feedback 2020-02-16 21:33:19 -08:00
Liam Newman
dc33e28452 Create GitHubHttpUrlConnectionClient to encapsulate interactions with HttpUrlConnection 2020-02-13 08:37:07 -08:00
Liam Newman
9da4781759 Update src/main/java/org/kohsuke/github/GitHub.java 2020-02-12 23:59:15 -08:00
Liam Newman
0c6959cb4a Merge remote-tracking branch 'github-api/master' into tast/response-info 2020-02-12 23:52:45 -08:00
Liam Newman
ff3136df70 Move a few static helpers to GitHubClient 2020-02-12 23:48:33 -08:00
Liam Newman
326c627221 Merge pull request #698 from github-api/dependabot/maven/org.apache.maven.plugins-maven-shade-plugin-3.2.2
Bump maven-shade-plugin from 3.2.1 to 3.2.2
2020-02-12 23:33:14 -08:00
dependabot-preview[bot]
075f382a8f Bump maven-shade-plugin from 3.2.1 to 3.2.2
Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.1 to 3.2.2.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.2.1...maven-shade-plugin-3.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-13 07:29:11 +00:00
Liam Newman
dabb8fe49e Merge pull request #675 from jimmysombrero/collaborator-permissions
Added ability to specify permissions for collaborators
2020-02-12 23:28:00 -08:00
Liam Newman
90489e4392 JavaDocs and refactoring 2020-02-12 22:42:12 -08:00
Liam Newman
ad45a74f87 Further clean up of refactored classes 2020-02-12 22:42:12 -08:00
Liam Newman
60c045a713 Delete mocking test that is just too brittle to live 2020-02-12 22:42:12 -08:00
Liam Newman
f6c75e1f99 More refactoring 2020-02-12 22:42:12 -08:00
Liam Newman
dd9245f6f2 Progress commit on moving to Client/Request/Response refactor 2020-02-12 22:42:12 -08:00
Liam Newman
7310a70743 Disable two tests due to spurious mocking failures 2020-02-12 22:42:12 -08:00
Liam Newman
82276837ac Created Client/Request/Response classes 2020-02-12 22:42:12 -08:00
Liam Newman
bd68252b44 Test cleanup 2020-02-12 22:42:12 -08:00
Liam Newman
6b1258e33a Major rewrite of Requester 2020-02-12 22:42:12 -08:00
Liam Newman
0400032923 Merge branch 'master' into collaborator-permissions 2020-02-12 22:32:50 -08:00
Liam Newman
d9563322f1 Merge pull request #695 from github-api/dependabot/maven/org.kohsuke.stapler-stapler-1.259
Bump stapler from 1.258 to 1.259
2020-02-12 22:32:31 -08:00
Liam Newman
ab965969dd Merge branch 'master' into collaborator-permissions 2020-02-12 22:31:03 -08:00
Liam Newman
2f32e034d8 Merge pull request #694 from bitwiseman/task/fetch
Streamline fetch and retry process
2020-02-12 22:29:22 -08:00
dependabot-preview[bot]
1cf7931f43 Bump stapler from 1.258 to 1.259
Bumps [stapler](https://github.com/stapler/stapler) from 1.258 to 1.259.
- [Release notes](https://github.com/stapler/stapler/releases)
- [Changelog](https://github.com/stapler/stapler/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stapler/stapler/compare/stapler-parent-1.258...stapler-parent-1.259)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-11 06:30:12 +00:00
James Vaughn
edc697dd73 fixed javadoc isues 2020-02-07 21:27:00 -06:00
James Vaughn
54a059ff68 updated signatures for addCollaborators methods
updated javadoc comments for addCollaborators methods
combined both modifyCollaborators methods into one method
updated addColloaborators test to match new method signature
2020-02-07 21:13:23 -06:00
Liam Newman
289282e235 Move OTP detection earlier
Like other errors we've been waiting until later to catch, this one is detectable so
whe should do that before the downstream exception needs to be thrown.
2020-02-06 16:59:49 -08:00
Liam Newman
825c36c15e Tweaks for clarity 2020-02-06 14:11:16 -08:00
Liam Newman
1234c2e99e Add tests for rate limit 2020-02-06 13:33:29 -08:00
Liam Newman
b8fae1308d Streamline fetch and retry process 2020-02-06 08:01:17 -08:00
James Vaughn
dddcf624e6 finished suggested formatting changes 2020-02-05 21:30:52 -06:00
James Vaughn
b33fe9f7fe Merge branch 'collaborator-permissions' of https://github.com/jimmysombrero/github-api into collaborator-permissions 2020-02-04 21:10:39 -06:00
James Vaughn
5a799400a9 fixed minor formatting issues 2020-02-04 21:10:29 -06:00
Liam Newman
76919a819f Merge branch 'master' into collaborator-permissions 2020-02-03 12:46:17 -08:00
Liam Newman
9c30f846b2 Merge pull request #692 from github-api/dependabot/maven/com.github.tomakehurst-wiremock-jre8-standalone-2.26.0
Bump wiremock-jre8-standalone from 2.25.1 to 2.26.0
2020-02-03 12:45:46 -08:00
Liam Newman
9230f51988 Implement new methods on Options 2020-02-03 12:41:33 -08:00
dependabot-preview[bot]
712035dc9a Bump wiremock-jre8-standalone from 2.25.1 to 2.26.0
Bumps [wiremock-jre8-standalone](https://github.com/tomakehurst/wiremock) from 2.25.1 to 2.26.0.
- [Release notes](https://github.com/tomakehurst/wiremock/releases)
- [Commits](https://github.com/tomakehurst/wiremock/compare/2.25.1...2.26.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-03 12:34:01 -08:00
Liam Newman
32e5c5b4ad Merge pull request #693 from alexanderrtaylor/replaceAsserts
Replacing asserts with standard
2020-02-03 12:29:59 -08:00
Alex Taylor
134a6fab7e Merge branch 'master' into replaceAsserts 2020-02-03 14:47:11 -05:00
Alex Taylor
82e27cb962 Replacing asserts with standard
Beginning work to replace Asserts with assertThat to keep consistency
2020-02-03 11:43:16 -05:00
James Vaughn
8bcad7b3f9 Merge branch 'collaborator-permissions' of https://github.com/jimmysombrero/github-api into collaborator-permissions 2020-02-02 22:03:08 -06:00
James Vaughn
d767575f76 Added test for addCollaborators
Mark old addCollaborators methods depricated
2020-02-02 22:02:56 -06:00
jimmysombrero
7214c7d393 Merge branch 'master' into collaborator-permissions 2020-02-01 22:40:54 -06:00
James Vaughn
205e5ab03d Merge branch 'collaborator-permissions' of https://github.com/jimmysombrero/github-api into collaborator-permissions 2020-02-01 22:39:28 -06:00
James Vaughn
6576beae76 Added missing methods to keep the API from breaking
added tests for addCollaborators()
2020-02-01 22:39:14 -06:00
Liam Newman
001f8f1f50 Update PULL_REQUEST_TEMPLATE.md 2020-01-31 13:18:17 -08:00
Liam Newman
3b694a87ef Fix formatting 2020-01-31 13:17:16 -08:00
spierce
84dd06d769 [#690]Implement the ability to read total_private_repos for GHPerson 2020-01-31 13:44:43 -06:00
Liam Newman
c5cb16abfb Merge branch 'master' into collaborator-permissions 2020-01-31 08:32:35 -08:00
Liam Newman
79fb34324d Merge pull request #684 from alexanderrtaylor/assertThatIssues
Authentication and assertThat issues
2020-01-30 11:10:38 -08:00
Alex Taylor
303aef3548 Merge branch 'assertThatIssues' of https://github.com/alexanderrtaylor/github-api into assertThatIssues 2020-01-30 11:22:39 -05:00
Alex Taylor
fd278f8c32 Update AbstractGitHubWireMockTest.java
added return for Javadoc
2020-01-30 11:22:37 -05:00
Liam Newman
53041a4117 Merge branch 'master' into assertThatIssues 2020-01-29 18:32:47 -08:00
Liam Newman
9b3fe3b13a Merge pull request #687 from bitwiseman/task/windows-ci
Shorten file names for Windows
2020-01-29 18:06:48 -08:00
Liam Newman
5c6c5081e9 Improve naming of jobs 2020-01-29 18:00:30 -08:00
Liam Newman
e087ea0ac7 Split build jobs for clarity 2020-01-29 17:36:31 -08:00
Liam Newman
71c44dc805 Move CI to cache .m2 directory 2020-01-29 17:18:19 -08:00
Liam Newman
c5c8596664 Reduce output from connection retry 2020-01-29 17:04:24 -08:00
Liam Newman
92a86f4d1c No formatting checks on Windows CI build 2020-01-29 16:01:37 -08:00
Alex Taylor
8098b68b8e formatting changes
sorry forgot to run the formatting automation before committing the last
2020-01-29 16:56:49 -05:00
Alex Taylor
7356001723 Merge remote-tracking branch 'upstream/master' into assertThatIssues 2020-01-29 16:56:15 -05:00
Alex Taylor
aba60587ab Corrected massive change
Added back the extends Assert to the wiremock test base class so that I am not making a massive change and potentially  breaking inflight work people are doing
2020-01-29 16:49:33 -05:00
Liam Newman
936a6a04fb Reduce some code coverage bars on windows 2020-01-29 13:38:08 -08:00
Liam Newman
9675126298 Turn off some tests for windows 2020-01-29 13:30:01 -08:00
Liam Newman
6a5886ea1c Disable import sorting 2020-01-29 11:38:32 -08:00
Liam Newman
648c6a5a8f Shorten file names for Windows 2020-01-29 09:24:50 -08:00
Liam Newman
14b7bf4753 Add windows to CI matrix 2020-01-28 20:52:49 -08:00
jimmysombrero
0e310fa96a Merge branch 'master' into collaborator-permissions 2020-01-28 15:21:25 -06:00
Liam Newman
0f6c282c80 [maven-release-plugin] prepare for next development iteration 2020-01-27 19:07:15 -08:00
Liam Newman
ed3cd0c9c8 [maven-release-plugin] prepare release github-api-1.106 2020-01-27 19:07:07 -08:00
Liam Newman
398f029f6d Merge pull request #685 from bitwiseman/task/commons-io-2.4
Downgrade to commons-io 2.4
2020-01-27 19:04:24 -08:00
Liam Newman
ad9c2b917b Disable rate limit hanging test 2020-01-27 18:56:41 -08:00
Liam Newman
d0d65182c0 Downgrade to commons-io 2.4 for Jenkins compatibility 2020-01-27 18:43:56 -08:00
Alex Taylor
4c3a0d329b added Authentication Check
Added additional authentication checks on gitHubBeforeAfter so that cleanup is done with a user logged in
2020-01-27 15:24:28 -05:00
Alex Taylor
7c495c2177 Fixes after merge
Fixed some failing tests after merge
2020-01-27 14:45:02 -05:00
Alex Taylor
2f86a9e534 Merge remote-tracking branch 'upstream/master' into assertThatIssues 2020-01-27 14:37:46 -05:00
Alex Taylor
12c3a0b1fa Authentication and assertThat issues
Fixed some problems with tests trying to authenticate when you are not actually signed in. This hit rate API limiting which caused tests to hang/fail

Also fixed assertThat getting deprecated from junit
2020-01-27 14:29:46 -05:00
Liam Newman
14f3660f55 [maven-release-plugin] prepare for next development iteration 2020-01-27 00:03:48 -08:00
Liam Newman
5a8b032d74 [maven-release-plugin] prepare release github-api-1.105 2020-01-27 00:03:39 -08:00
Liam Newman
57c4613b1f Merge pull request #683 from timja/add-full-create-team-parameters
Add support for all create team parameters
2020-01-27 00:00:44 -08:00
Tim Jacomb
e008021a42 Merge branch 'add-full-create-team-parameters' of github.com:timja/github-api into add-full-create-team-parameters 2020-01-27 07:52:15 +00:00
Tim Jacomb
7e600c43ed Var-args instead of list 2020-01-27 07:52:08 +00:00
Tim Jacomb
963478e206 Merge branch 'master' into add-full-create-team-parameters 2020-01-27 07:46:14 +00:00
Tim Jacomb
0f32783488 Revert updatePrivacy 2020-01-27 07:40:16 +00:00
Liam Newman
756d470715 [maven-release-plugin] prepare for next development iteration 2020-01-26 23:33:20 -08:00
Liam Newman
2c47b7535b [maven-release-plugin] prepare release github-api-1.104 2020-01-26 23:33:11 -08:00
Tim Jacomb
4cc90b4929 Fix test 2020-01-27 07:31:19 +00:00
Tim Jacomb
32754ffcf5 Cleanup based on review 2020-01-27 07:24:01 +00:00
Tim Jacomb
64aae75680 Allow updating privacy status 2020-01-26 11:02:01 +00:00
Tim Jacomb
69d2160a0d Add support for all create team parameters 2020-01-25 20:07:56 +00:00
Liam Newman
99e326539e Merge pull request #680 from bitwiseman/issue/ssl
Handle SSLHandshakeException with connection retry
2020-01-24 21:47:20 -08:00
Liam Newman
1dde975cfe Handle SSLHandshakeException with connection retry 2020-01-24 21:24:55 -08:00
jimmysombrero
58c069ec5c Merge branch 'master' into collaborator-permissions 2020-01-24 18:26:54 -06:00
James Vaughn
7916600a7b updating local branch 2020-01-24 18:24:53 -06:00
James Vaughn
3e4f160c5d ran mvn clean install then the build commmand and build was successful 2020-01-24 18:23:59 -06:00
Liam Newman
aeb5e5f681 Merge pull request #674 from v1v/master
Retry when SocketException with some sleep
2020-01-24 14:43:29 -08:00
Liam Newman
1c2e491845 Minor improvement to statistics
Reading raw streams just to map them is not needed.
Using arrays instead of lists works fine.
2020-01-24 14:07:19 -08:00
Liam Newman
eb4000f26b Streamline retry code path 2020-01-24 12:32:04 -08:00
Liam Newman
74dd887c79 Merge branch 'master' into master 2020-01-23 22:22:42 -08:00
Liam Newman
764599a7d9 Move socket handling and add test 2020-01-23 20:54:13 -08:00
Liam Newman
ad683fee89 Merge branch 'master' into collaborator-permissions 2020-01-23 17:51:59 -08:00
Liam Newman
85a53fc68f Merge pull request #676 from alexanderrtaylor/issues-349
Issues 349
2020-01-23 17:49:39 -08:00
James Vaughn
3bf8baee85 format fixed and validation passed 2020-01-23 18:32:37 -06:00
Vaughn
8792213594 tried formatting the file once again. 2020-01-23 15:16:36 -06:00
Victor Martinez
d9ebc9455c UTs for the Timeout and Retry 2020-01-23 21:09:14 +00:00
Vaughn
9ab8bdfe4a formatted file 2020-01-23 14:45:24 -06:00
Victor Martinez
418ea9a19e As suggested in the code review, handle exceptions and setup the connection 2020-01-23 20:39:58 +00:00
Victor Martinez
20f04febf2 As suggested in the code review, make a configurable sleep 2020-01-23 20:36:00 +00:00
Alex Taylor
a65783201e updated the test files
Updated the test files and did a temp repo
2020-01-23 15:31:50 -05:00
Victor Martinez
a5f04d44a4 Fix javadoc warning 2020-01-23 20:29:55 +00:00
Victor Martinez
cbe1022f20 Support more generic Socket Exceptions
For instance: connection reset by peer
2020-01-23 20:28:57 +00:00
Vaughn
90301ae9ee Added ability to specify permissions for collaborators 2020-01-23 13:37:35 -06:00
Victor Martinez
4f38ab3640 Cosmetic change 2020-01-23 14:01:29 +00:00
Victor Martinez
fca179abab Retry if SocketException
See https://github.com/github-api/github-api/pull/373
2020-01-23 13:33:12 +00:00
Liam Newman
e426237c35 [maven-release-plugin] prepare for next development iteration 2020-01-22 11:57:10 -08:00
Liam Newman
3dae361d7b [maven-release-plugin] prepare release github-api-1.103 2020-01-22 11:56:59 -08:00
Liam Newman
967831388e Relocate shaded dependecies and generate separate shaded artifact 2020-01-22 09:59:10 -08:00
Liam Newman
f9794f20d4 Use Https 2020-01-21 17:22:58 -08:00
Liam Newman
f98efd6af0 Update site.xml 2020-01-21 16:56:44 -08:00
Liam Newman
69bf0641f8 Update site.xml
Closes #671
2020-01-21 16:55:46 -08:00
Liam Newman
5791843d16 [maven-release-plugin] prepare for next development iteration 2020-01-21 15:40:09 -08:00
Liam Newman
58d0a20074 [maven-release-plugin] prepare release github-api-1.102 2020-01-21 15:40:00 -08:00
Liam Newman
5884c7b3ba Re-enable jacoco during ci 2020-01-21 14:44:47 -08:00
Liam Newman
dd1da268a2 Additional checks and clean up to GHRateLimit and tests 2020-01-21 13:30:08 -08:00
Alex Taylor
473f3954c7 Update GHRepositoryTest.java
Added some parent tests as well
2020-01-21 15:56:07 -05:00
Alex Taylor
5aad5406a2 [WIP]Adding GHRepo tests 2020-01-21 14:35:29 -05:00
Liam Newman
98b606287d Add more validation to rate limit
Downstream tests are doing some strange Json.  Give better output when they do something invalid.
2020-01-18 23:33:44 -08:00
Liam Newman
9792fc0daa Fix missing version 2020-01-18 19:20:21 -08:00
Liam Newman
a9bb9302bc Move cached 404 retry to main code path 2020-01-18 18:53:31 -08:00
Liam Newman
30c70bc8d4 Merge pull request #651 from martinvanzijl/issue_500_create_tag_method
Add createTag() method to GHRepository
2020-01-18 14:02:39 -08:00
Liam Newman
0df48c37ac Merge branch 'master' into issue_500_create_tag_method 2020-01-17 22:43:07 -08:00
Liam Newman
ec31e94e7a Merge pull request #665 from bitwiseman/task/cache-error-test
Workaround for `If-Modified-Since` HTTP request header causing cache corruption
2020-01-17 22:42:09 -08:00
Liam Newman
ea631d0e88 Merge pull request #633 from bitwiseman/task/shade
Add shading of dependencies
2020-01-17 22:41:29 -08:00
Liam Newman
66a180346e Improve commenting of workaround 2020-01-17 17:52:50 -08:00
Liam Newman
63ee878789 Merge remote-tracking branch 'github-api/master' into task/cache-error-test 2020-01-17 17:27:12 -08:00
Liam Newman
3479e4f2fd Clean up and formatting 2020-01-17 17:05:45 -08:00
Liam Newman
54f4152f89 Template data files to make okhttp2 test runnable in CI
OkHttp2 doesn't invalidate caches sometimes when it probably should
2020-01-17 17:00:40 -08:00
Liam Newman
06334bf272 Template data files to make okhttp3 test runnable in CI 2020-01-17 16:58:54 -08:00
Liam Newman
839f096f39 Add caching error test for OkHttp 2020-01-17 15:57:14 -08:00
Liam Newman
f3b2fdc4fc Update test and resources using new workaround 2020-01-17 15:53:55 -08:00
Liam Newman
16d34f3268 Workaround for #669 - retry with cache overridden
This is much more reasonable way to address this issue.
When the Requester detects a 404 response with an ETag (only happpens when the server's 304
is bogus and would cause cache corruption), try the query again with new request header
that forces the server to not return 304 and return new data instead.

Ths solution is transparent to users of this library and autmatically fixes a situation that
was causing cache corruption. If GitHub ever fixes the issue and begins providing accurate
ETags to their 404 responses, this will result in two calls being made for each 404 response.
While that would be unfortunate, it would still be better than the current situation.
2020-01-17 15:53:55 -08:00
Liam Newman
61e8dd09d6 Revert "Workaround for #669 - remove If-Modified-Since header"
This reverts commit 90d7fea7aa.
2020-01-17 14:46:31 -08:00
Liam Newman
90d7fea7aa Workaround for #669 - remove If-Modified-Since header
This is a first cut at working round #669.  It is hacky as hell and I hate it.
2020-01-17 14:46:10 -08:00
Liam Newman
b9c8bf07ea Restore correct exception throwing for getArray 2020-01-15 19:42:42 -08:00
Liam Newman
a3ba07d45f Inline toIterable 2020-01-15 19:33:22 -08:00
Liam Newman
5a6a29cbb5 Add array and iterator tests 2020-01-15 19:31:30 -08:00
Liam Newman
72aedbb76c JENKINS-54126 - Repro of github caching error 2020-01-14 00:29:43 -08:00
Liam Newman
e7e3be6ea7 Merge pull request #662 from sullis/github-actions-checkout-v2
GitHub Actions checkout v2
2020-01-13 11:29:25 -08:00
Liam Newman
62e1b9eb01 Merge pull request #663 from sullis/jackson-2.10.2
jackson 2.10.2
2020-01-13 11:22:29 -08:00
Sean C. Sullivan
3fff92dc35 jackson 2.10.2 2020-01-12 16:09:57 -08:00
Sean C. Sullivan
352d77719e GitHub Actions checkout v2 2020-01-12 15:23:13 -08:00
Martin van Zijl
ff397dfa4d Correction per "mvn install site". 2020-01-11 13:03:41 +13:00
Martin van Zijl
34d64c0dff Added comment to JavaDoc as advised per GitHub Maven test. 2020-01-11 12:53:54 +13:00
Martin van Zijl
b5fdc2f956 Merge branch 'master' of https://github.com/kohsuke/github-api into issue_500_create_tag_method 2020-01-11 12:46:08 +13:00
Martin van Zijl
38602965db Merge branch 'issue_500_create_tag_method' of https://github.com/martinvanzijl/github-api into issue_500_create_tag_method 2020-01-11 12:31:28 +13:00
Martin van Zijl
df1ea62883 Removed wiremock files for old test case. 2020-01-11 12:24:12 +13:00
Martin van Zijl
afaff52888 Removed test from GHRepositoryTest and added to GHTagTest. 2020-01-11 12:23:41 +13:00
Liam Newman
5b7829c288 Merge branch 'master' into task/shade 2020-01-10 11:14:18 -08:00
Liam Newman
2462eb2c79 Merge pull request #652 from github-api/dependabot/maven/com.squareup.okio-okio-2.4.3
Bump okio from 2.4.2 to 2.4.3
2020-01-10 11:13:59 -08:00
Liam Newman
edc26b0a55 Fix site 2020-01-10 10:11:31 -08:00
Liam Newman
cc94e8b0ca Merge branch 'master' into dependabot/maven/com.squareup.okio-okio-2.4.3 2020-01-10 09:24:04 -08:00
Liam Newman
80f3a6e507 Merge pull request #659 from github-api/dependabot/maven/com.squareup.okhttp3-okhttp-4.3.1
Bump okhttp from 4.2.2 to 4.3.1
2020-01-10 09:23:03 -08:00
Liam Newman
5709be7ff7 Merge branch 'master' into issue_500_create_tag_method 2020-01-10 09:19:05 -08:00
Liam Newman
46fce8cf4b Merge branch 'master' into dependabot/maven/com.squareup.okio-okio-2.4.3 2020-01-10 09:18:51 -08:00
Liam Newman
e84049367e Merge branch 'master' into dependabot/maven/com.squareup.okhttp3-okhttp-4.3.1 2020-01-10 09:18:05 -08:00
Liam Newman
f213ead595 Move shade to ci and release profiles 2020-01-09 11:36:24 -08:00
Liam Newman
ba540b0725 Remove parent pom 2020-01-09 08:27:06 -08:00
Liam Newman
eb55691c89 Add shading of dependencies
Fixes #630
2020-01-09 08:26:49 -08:00
Liam Newman
dd508e7dea Rerecord GHTreeBuilder for test org 2020-01-08 19:44:23 -08:00
dependabot-preview[bot]
66357866c5 Bump okio from 2.4.2 to 2.4.3
Bumps [okio](https://github.com/square/okio) from 2.4.2 to 2.4.3.
- [Release notes](https://github.com/square/okio/releases)
- [Changelog](https://github.com/square/okio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okio/compare/parent-2.4.2...parent-2.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-09 03:22:54 +00:00
dependabot-preview[bot]
6e3728b458 Bump okhttp from 4.2.2 to 4.3.1
Bumps [okhttp](https://github.com/square/okhttp) from 4.2.2 to 4.3.1.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-4.2.2...parent-4.3.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-09 03:22:54 +00:00
Liam Newman
31d4eef4b1 Merge pull request #642 from asthinasthi/create-tree-null-sha-field
Post only non-null values in request body for createTree
2020-01-08 19:21:43 -08:00
Liam Newman
f58f32a7a8 Merge branch 'master' into create-tree-null-sha-field 2020-01-08 17:36:36 -08:00
Liam Newman
28d8fb686a Merge pull request #653 from github-api/dependabot/maven/org.apache.maven.plugins-maven-source-plugin-3.2.1
Bump maven-source-plugin from 3.2.0 to 3.2.1
2020-01-07 11:26:07 -08:00
dependabot-preview[bot]
4c7fc2ef47 Bump maven-source-plugin from 3.2.0 to 3.2.1
Bumps [maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.2.0 to 3.2.1.
- [Release notes](https://github.com/apache/maven-source-plugin/releases)
- [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.2.0...maven-source-plugin-3.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-07 00:00:39 +00:00
Liam Newman
a3f99978c2 Merge pull request #657 from github-api/dependabot/maven/junit-junit-4.13
Bump junit from 4.12 to 4.13
2020-01-06 15:59:26 -08:00
Liam Newman
136b55d310 Merge pull request #650 from bitwiseman/issue/mime-base64-638
Do not MIME encode Base64 content for sending
2020-01-06 09:23:44 -08:00
dependabot-preview[bot]
617e90259b Bump junit from 4.12 to 4.13
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/master/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-02 06:36:48 +00:00
Martin van Zijl
959eb46162 Deleted unit test cleanup method.
This method failed in the automated GitHub build online with a null
pointer exception.

I tried to make it a @Before/@After method, but that fails on
my local PC.
2020-01-02 13:21:27 +13:00
Martin van Zijl
998bda9de7 Add createTag() method.
Fixes #500.
2019-12-23 05:43:48 +13:00
Liam Newman
37a2018fe3 Do not MIME encode Base64 content for sending
Fixes #638
2019-12-20 19:48:17 -08:00
Liam Newman
2c80e07c9d Merge branch 'master' into create-tree-null-sha-field 2019-12-19 19:11:09 -08:00
Liam Newman
a115f34766 Merge pull request #637 from PauloMigAlmeida/marketplace_endpoints_patch2
[Patch 2/2] :: Add support to Marketplace endpoints
2019-12-19 19:10:00 -08:00
Liam Newman
cd66c1e7c3 Add Accept header 2019-12-19 18:59:50 -08:00
Liam Newman
4f9975dc6d Merge remote-tracking branch 'github-api/master' into marketplace_endpoints_patch2 2019-12-19 18:44:48 -08:00
Liam Newman
9da487d962 Merge pull request #635 from PauloMigAlmeida/marketplace_endpoints
[Patch 1/2] :: Add support to Marketplace endpoints
2019-12-19 18:26:16 -08:00
Liam Newman
c7123b016b Update for Accept header 2019-12-19 18:21:09 -08:00
PauloMigAlmeida
efb13ddaf0 Fix errors caught during the build
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
3539b73c08 Implement changes requested for patch 1
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
2c084ef4d5 improve docs related to credentials requirements for some methods
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
754e66f4dd Additional tests for list accounts with a few parameters combinations
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
41b698f0a8 Add tests for listing GitHub marketplace accounts
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
de78da4fa6 Implement listing all GitHub Marketplace accounts given a plan
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
3d241d6fa1 formatting improvements
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:14 -08:00
PauloMigAlmeida
1d983a0090 Implement list marketplace plans
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-19 18:06:13 -08:00
Liam Newman
78fb860305 Merge pull request #648 from bitwiseman/task/accept-header
Enforce 'Accept' request header values
2019-12-19 18:04:55 -08:00
Liam Newman
c699a84f42 Enforce 'Accept' request header values
The 'Accept' header on requests can change what data is returned, so we need to
only match requests with the correct value.
2019-12-19 17:56:32 -08:00
PauloMigAlmeida
d8a178d93d Implement changes requested for patch 2
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 13:27:40 +13:00
PauloMigAlmeida
ada4243548 Merge branch 'marketplace_endpoints' of https://github.com/PauloMigAlmeida/github-api into marketplace_endpoints_patch2
 Conflicts:
	src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
	src/main/java/org/kohsuke/github/GHMarketplaceListAccountBuilder.java
	src/test/java/org/kohsuke/github/GHMarketplacePlanTest.java
2019-12-20 13:14:12 +13:00
PauloMigAlmeida
fa2e3aad6c Fix errors caught during the build
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 12:58:11 +13:00
PauloMigAlmeida
0cf457a46f Merge branch 'master' of https://github.com/kohsuke/github-api into marketplace_endpoints 2019-12-20 12:46:48 +13:00
PauloMigAlmeida
bb7b98d448 Merge remote-tracking branch 'origin/marketplace_endpoints' into marketplace_endpoints 2019-12-20 12:38:16 +13:00
PauloMigAlmeida
e8d90848f2 Implement changes requested for patch 1
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 12:37:59 +13:00
Liam Newman
7c791451ba Merge pull request #647 from halkeye/patch-1
Labels with description are not preview anymore
2019-12-19 13:57:07 -08:00
Liam Newman
16d8c2b221 Remove Symmetra preview 2019-12-19 13:50:18 -08:00
Gavin Mogan
dceecbef0a Labels with description are not preview anymore
https://developer.github.com/v3/issues/labels/#create-a-label
2019-12-19 13:50:07 -08:00
Liam Newman
3cbddf1de9 Merge pull request #646 from PauloMigAlmeida/issue_628
Implement App createToken with empty body
2019-12-19 13:47:22 -08:00
PauloMigAlmeida
650340fcb3 Fix example on the docs
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 01:47:39 +13:00
PauloMigAlmeida
ce5b893224 Add example on the docs
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 01:44:09 +13:00
PauloMigAlmeida
7869afa4ff Implement test for createToken method with no json property
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 01:09:34 +13:00
Paulo Miguel Almeida
9085606082 Fix GHObjectTest test broken on PR #644
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 00:08:23 +13:00
Paulo Miguel Almeida
1e3f646814 Refactor GHAppCreateTokenBuilder;
Add docs;

Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-20 00:05:31 +13:00
PauloMigAlmeida
933f0cb4b8 Merge branch 'master' of https://github.com/github-api/github-api into issue_628
 Conflicts:
	src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
2019-12-19 22:59:44 +13:00
PauloMigAlmeida
7497761fcc Implement create token variation 2019-12-19 19:42:22 +13:00
Liam Newman
12b3d4ec7a Merge branch 'master' into marketplace_endpoints 2019-12-17 17:27:10 -08:00
Liam Newman
8fd5ed57c4 Merge pull request #644 from martinvanzijl/issue_126_add_type_and_site_admin_fields
Add type and site_admin fields to GHPerson
2019-12-17 17:23:54 -08:00
Liam Newman
7bc301bc70 Merge pull request #634 from bitwiseman/task/minimum-coverage
Task/minimum coverage
2019-12-17 17:23:30 -08:00
Liam Newman
30321d3a0e Update coverage excludes and bars 2019-12-17 17:16:23 -08:00
Liam Newman
511a0ae503 Exclude deprecated classes 2019-12-17 17:16:22 -08:00
Liam Newman
1057636666 Add wiremock data 2019-12-17 17:16:22 -08:00
Liam Newman
564b1d2a98 Enable event tests 2019-12-17 17:16:22 -08:00
Liam Newman
20cd0e2de2 Turn Traffic tests back on 2019-12-17 17:16:22 -08:00
Liam Newman
6bc617c488 Merge pull request #623 from bitwiseman/task/iterator
Move array population to single iterator code path
2019-12-17 15:01:12 -08:00
Liam Newman
049db83423 Merge remote-tracking branch 'github-api/master' into task/iterator 2019-12-17 14:35:37 -08:00
Liam Newman
52dd90e85d Additional tweaks to reduce the number of code paths 2019-12-17 14:15:38 -08:00
Liam Newman
305267d07f Rename methods for better clarity 2019-12-17 12:41:23 -08:00
Liam Newman
20369aa1b5 Merge pull request #622 from alexanderrtaylor/GHEventAddition
[JENKINS-57430] Added some new GH Event Types
2019-12-17 11:32:45 -08:00
Liam Newman
40f05e4dbb Clean up request method calls 2019-12-17 10:02:55 -08:00
Liam Newman
a23d19f208 Merge pull request #645 from github-api/dependabot/maven/org.mockito-mockito-core-3.2.4
Bump mockito-core from 3.2.0 to 3.2.4
2019-12-17 09:06:48 -08:00
dependabot-preview[bot]
cb1d1e8ed7 Bump mockito-core from 3.2.0 to 3.2.4
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.2.0 to 3.2.4.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.2.0...v3.2.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-17 06:37:39 +00:00
Alex Taylor
4f67f32719 Update src/main/java/org/kohsuke/github/GHCheckRun.java 2019-12-16 14:53:38 -05:00
Alex Taylor
a80b5b6abc Fixed the findbugs errors 2019-12-14 15:38:34 -05:00
Liam Newman
0be3d88872 Merge pull request #643 from github-api/dependabot/maven/com.squareup.okio-okio-2.4.2
Bump okio from 2.4.1 to 2.4.2
2019-12-13 19:42:09 +00:00
Liam Newman
48bb996350 Merge pull request #640 from github-api/dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-5.6.0.201912101111-r
Bump org.eclipse.jgit from 5.5.1.201910021850-r to 5.6.0.201912101111-r
2019-12-13 19:41:52 +00:00
Martin van Zijl
ee2dde4cd1 Add type and site_admin fields to GHPerson.
Helps with #126.
2019-12-14 07:24:23 +13:00
dependabot-preview[bot]
c10a31c933 Bump okio from 2.4.1 to 2.4.2
Bumps [okio](https://github.com/square/okio) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/square/okio/releases)
- [Changelog](https://github.com/square/okio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okio/compare/2.4.1...parent-2.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-12 06:33:01 +00:00
Anirudh Mathad
d6a846f58d Post only non-null values in request body for createTree 2019-12-11 15:25:24 -08:00
dependabot-preview[bot]
945873231d Bump org.eclipse.jgit from 5.5.1.201910021850-r to 5.6.0.201912101111-r
Bumps org.eclipse.jgit from 5.5.1.201910021850-r to 5.6.0.201912101111-r.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-11 06:36:08 +00:00
PauloMigAlmeida
5dc494978e Implement tests
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-10 13:21:52 +13:00
PauloMigAlmeida
c870ec10c0 Implement /user/marketplace_purchases endpoint
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-10 13:21:06 +13:00
PauloMigAlmeida
2085b8fd14 Split GHMarketplaceAccount.java into 2 pieces for re-utilisation purposes
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-10 13:19:19 +13:00
PauloMigAlmeida
e065b6435c improve docs related to credentials requirements for some methods
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 20:59:03 +13:00
PauloMigAlmeida
da5331ceb0 Additional tests for list accounts with a few parameters combinations
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 20:07:32 +13:00
PauloMigAlmeida
8f81982de4 Add tests for listing GitHub marketplace accounts
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 19:36:13 +13:00
PauloMigAlmeida
499b46ecf3 Implement listing all GitHub Marketplace accounts given a plan
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-09 15:53:46 +13:00
PauloMigAlmeida
a7d232e15f formatting improvements
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-08 20:26:37 +13:00
PauloMigAlmeida
8fdb394ec5 Implement list marketplace plans
Signed-off-by: PauloMigAlmeida <paulo.miguel.almeida.rodenas@gmail.com>
2019-12-08 20:13:54 +13:00
PauloMigAlmeida
7a1da64bf2 Merge branch 'master' of https://github.com/kohsuke/github-api 2019-12-08 15:42:54 +13:00
PauloMigAlmeida
95ae155fc0 Merge branch 'master' of https://github.com/PauloMigAlmeida/github-api 2019-12-08 15:42:34 +13:00
Liam Newman
d1507f2666 Merge pull request #631 from bitwiseman/task/base64
Remove dependency on apache commons-codec
2019-12-04 10:56:08 +00:00
Liam Newman
7e4f98d328 Remove dependency on apache commons-codec 2019-12-03 11:39:05 +00:00
Liam Newman
f9a956905e Merge pull request #629 from sullis/mockito-3.2.0
mockito 3.2.0
2019-11-30 13:20:54 -08:00
Sean C. Sullivan
e7d95f9da6 mockito 3.2.0 2019-11-29 13:33:54 -05:00
Alex Taylor
bc8f0aa223 Update GHEventPayload.java
updated to meet standards
2019-11-27 15:18:43 -05:00
Liam Newman
6f2ae94e12 Changelog for v1.101 2019-11-27 10:47:25 -08:00
Alex Taylor
8f787e9976 Added the Check Run event
Added the check run event and the objects used there along with a valid test
2019-11-27 13:30:45 -05:00
Liam Newman
321d8240a2 [maven-release-plugin] prepare for next development iteration 2019-11-27 10:27:31 -08:00
Liam Newman
d667b2f822 [maven-release-plugin] prepare release github-api-1.101 2019-11-27 10:27:24 -08:00
Liam Newman
d7f511363d Merge pull request #627 from alecharp/fix-cache-control-packagename
Fixed CacheControl package name
2019-11-27 10:14:12 -08:00
Adrien Lecharpentier
39e7c5c3de Fixed CacheControl package name
With okhttp 3, the package name changed. In the okhttp3.OkHttpConnector,
the incorrect class is loaded, creating a ClassNotFoundException at
runtime when okhttp3 only is loaded.
2019-11-27 18:30:06 +01:00
Liam Newman
60acd5c864 Update CHANGELOG.md 2019-11-26 19:08:00 -08:00
Liam Newman
b92cf6fd35 [maven-release-plugin] prepare for next development iteration 2019-11-26 17:53:42 -08:00
Liam Newman
0f9482864c Move url to separate method 2019-11-26 15:26:46 -08:00
Liam Newman
60700d59fe Force URI encoding for api paths starting with slash 2019-11-26 15:14:36 -08:00
Liam Newman
3296cef02d Change requester to GET by default 2019-11-25 18:15:21 -08:00
Liam Newman
1b55b5fa3c Move array population to single iterator code path
This remove a second code path throught pagination.
2019-11-25 18:15:21 -08:00
Alex Taylor
b2701f5ba4 [JENKINS-57430] Added some new GH Event Types
Added some new GH Event types so that it does not throw errors
2019-11-22 14:26:35 -05:00
PauloMigAlmeida
5d9a4b42a6 Merge branch 'master' of https://github.com/kohsuke/github-api 2019-11-14 15:56:42 +13:00
2111 changed files with 114821 additions and 5049 deletions

View File

@@ -7,4 +7,4 @@ We love getting PRs, but we hate asking people for the same basic changes every
- [ ] Push your changes to a branch other than `master`. Create your PR from that branch.
- [ ] Add JavaDocs and other comments
- [ ] Write tests that run and pass in CI. See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to capture snapshot data.
- [ ] Run `mvn install site` locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.
- [ ] Run `mvn -D enable-ci clean install site` locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.

View File

@@ -1,22 +1,72 @@
name: Java CI Build and Test
name: CI
on: [push, pull_request]
jobs:
build:
name: build-only (Java ${{ matrix.java }})
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '1.8.0', '11.0.x', '13.0.x' ]
java: [ 11 ]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Cached .m2
uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven Install (skipTests)
run: mvn -B install -DskipTests -D enable-ci --file pom.xml
site:
name: site (Java ${{ matrix.java }})
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven Site
run: mvn -B site -D enable-ci --file pom.xml
test:
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ ubuntu, windows ]
java: [ 8, 11, 13 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Maven Download all dependencies
run: mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
- name: Maven Build
run: mvn -B install site -P ci --file pom.xml
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven Install without Code Coverage
if: matrix.os == 'windows'
run: mvn -B install --file pom.xml
- name: Maven Install with Code Coverage
if: matrix.os != 'windows'
run: mvn -B install -D enable-ci --file pom.xml

4
.gitignore vendored
View File

@@ -7,3 +7,7 @@ target
.project
.settings/
.DS_Store
dependency-reduced-pom.xml
.factorypath
.vscode/settings.json

View File

@@ -1,29 +1,37 @@
# Changelog
## [github-api-1.100](https://github.com/github-api/github-api/tree/github-api-1.100) (2019-11-27)
## [github-api-1.101](https://github.com/github-api/github-api/tree/github-api-1.101) (2019-11-27)
[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.100...github-api-1.101)
### Fixes
- Fixed `ClassNotFoundException` when creating `okhttp3.OkHttpConnector` with `Cache` @alecharp [\#627](https://github.com/github-api/github-api/issues/627)
## [github-api-1.100](https://github.com/github-api/github-api/tree/github-api-1.100) (2019-11-26)
[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.99...github-api-1.100)
### Features and Fixes
- Add method to set repository topics @martinvanzijl (#594)
- Adjust GHRateLimit to system time instead of depending on synchronization @bitwiseman (#595)
- Add Functionality of OTP to support user 2fa @madhephaestus (#603)
- Implement Meta endpoint @PauloMigAlmeida (#611)
- fix and unit tests for issue #504 @siordache (#620)
- Fixed GHContent to allow spaces in path @bitwiseman (#625)
- Add method to set repository topics @martinvanzijl [\#594](https://github.com/github-api/github-api/issues/594)
- Adjust GHRateLimit to system time instead of depending on synchronization @bitwiseman [#595](https://github.com/github-api/github-api/issues/595)
- Add Functionality of OTP to support user 2fa @madhephaestus [\#603](https://github.com/github-api/github-api/issues/603)
- Implement Meta endpoint @PauloMigAlmeida [\#611](https://github.com/github-api/github-api/issues/611)
- fix and unit tests for issue #504 @siordache [\#620](https://github.com/github-api/github-api/issues/620)
- Fixed GHContent to allow spaces in path @bitwiseman [\#625](https://github.com/github-api/github-api/issues/625)
### Internals
- Clean up Requester interface a bit @bitwiseman (#614)
- Javadoc fail on warning during CI build @bitwiseman (#613)
- Code style fixes @bitwiseman (#609)
- Re-enable Lifecycle test @bitwiseman (#621)
- Removed permission field in createTeam. It is deprecated in the API @asthinasthi (#619)
- Cleanup imports @bitwiseman (#616)
- Branch missing @alexanderrtaylor (#615)
- jackson 2.10.1 @sullis (#604)
- Bump okhttp from 3.14.2 to 4.2.2 @dependabot-preview (#593)
- Bump okhttp3 from 3.14.2 to 4.2.2 @dependabot-preview [\#593](https://github.com/github-api/github-api/issues/593)
- jackson 2.10.1 @sullis [\#604](https://github.com/github-api/github-api/issues/604)
- Code style fixes @bitwiseman [\#609](https://github.com/github-api/github-api/issues/609)
- Javadoc fail on warning during CI build @bitwiseman [\#613](https://github.com/github-api/github-api/issues/613)
- Clean up Requester interface a bit @bitwiseman [\#614](https://github.com/github-api/github-api/issues/614)
- Branch missing @alexanderrtaylor [\#615](https://github.com/github-api/github-api/issues/615)
- Cleanup imports @bitwiseman [\#616](https://github.com/github-api/github-api/issues/616)
- Removed permission field in createTeam. It is deprecated in the API @asthinasthi [\#619](https://github.com/github-api/github-api/issues/619)
- Re-enable Lifecycle test @bitwiseman [\#621](https://github.com/github-api/github-api/issues/621)
## [github-api-1.99](https://github.com/github-api/github-api/tree/github-api-1.99) (2019-11-04)

372
pom.xml
View File

@@ -1,14 +1,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kohsuke</groupId>
<artifactId>pom</artifactId>
<version>21</version>
<relativePath />
</parent>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.100</version>
<version>1.107</version>
<name>GitHub API for Java</name>
<url>https://github-api.kohsuke.org/</url>
<description>GitHub API for Java</description>
@@ -17,10 +11,20 @@
<connection>scm:git:git@github.com/github-api/${project.artifactId}.git</connection>
<developerConnection>scm:git:ssh://git@github.com/github-api/${project.artifactId}.git</developerConnection>
<url>https://${project.artifactId}.kohsuke.org/</url>
<tag>github-api-1.100</tag>
<tag>github-api-1.107</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<site>
<id>github-pages</id>
<url>gitsite:git@github.com/github-api/${project.artifactId}.git</url>
@@ -30,17 +34,16 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotbugs-maven-plugin.version>3.1.12.2</spotbugs-maven-plugin.version>
<spotbugs.version>3.1.12</spotbugs.version>
<spotbugs.version>4.0.0</spotbugs.version>
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
<hamcrest.version>2.2</hamcrest.version>
<okhttp3.version>4.2.2</okhttp3.version>
<okio.version>2.4.1</okio.version>
<okhttp3.version>4.4.0</okhttp3.version>
<okio.version>2.4.3</okio.version>
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
<jacoco.coverage.target.class>.80</jacoco.coverage.target.class>
<jacoco.coverage.target.method>0.20</jacoco.coverage.target.method>
<jacoco.coverage.target.line>0.50</jacoco.coverage.target.line>
<jacoco.coverage.target.other>0.50</jacoco.coverage.target.other>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<jacoco.coverage.target.bundle.method>0.556</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
</properties>
@@ -57,6 +60,14 @@
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.11.2</version>
</extension>
<!-- Doing site publishing manually for now -->
<!--
<extension>
<groupId>org.kohsuke</groupId>
<artifactId>wagon-gitsite</artifactId>
<version>0.3.5</version>
</extension>
-->
</extensions>
<testResources>
<testResource>
@@ -68,11 +79,136 @@
</testResources>
<pluginManagement>
<plugins>
<!-- adds jacoco coverage -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.bundle.method}</minimum>
</limit>
</limits>
</rule>
<rule>
<!--We end up with chatty logs, but it shows us which particular classes -->
<!--are lacking in coverage. If this is too much, just remove the -->
<!--<element>CLASS</element> tag below. -->
<element>CLASS</element>
<limits>
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.class.method}</minimum>
</limit>
</limits>
<excludes>
<!-- Code implemented externally -->
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.**</exclude>
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
<!-- Sample only -->
<exclude>org.kohsuke.github.example.*</exclude>
<!-- No methods -->
<exclude>org.kohsuke.github.DeleteToken</exclude>
<exclude>org.kohsuke.github.Previews</exclude>
<!-- Deprecated -->
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
<exclude>org.kohsuke.github.GHPerson.1</exclude>
<exclude>org.kohsuke.github.GHPerson.1.1</exclude>
<!-- These fail coverage on windows because tests are disabled -->
<exclude>org.kohsuke.github.GHAsset</exclude>
<exclude>org.kohsuke.github.GHReleaseBuilder</exclude>
<exclude>org.kohsuke.github.GHRelease</exclude>
<!-- TODO: These still need test coverage -->
<exclude>org.kohsuke.github.GitHubClient.GHApiInfo</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
<exclude>org.kohsuke.github.GHCommentAuthorAssociation</exclude>
<exclude>org.kohsuke.github.GHCommitBuilder.UserInfo</exclude>
<exclude>org.kohsuke.github.GHCommitState</exclude>
<exclude>org.kohsuke.github.GHCompare.Commit</exclude>
<exclude>org.kohsuke.github.GHCompare.InnerCommit</exclude>
<exclude>org.kohsuke.github.GHCompare.Status</exclude>
<exclude>org.kohsuke.github.GHCompare.Tree</exclude>
<exclude>org.kohsuke.github.GHCompare.User</exclude>
<exclude>org.kohsuke.github.GHCompare</exclude>
<exclude>org.kohsuke.github.GHDeployKey</exclude>
<exclude>org.kohsuke.github.GHDeploymentStatusBuilder</exclude>
<exclude>org.kohsuke.github.GHDirection</exclude>
<exclude>org.kohsuke.github.GHEmail</exclude>
<exclude>org.kohsuke.github.GHEventPayload.Ping</exclude>
<exclude>org.kohsuke.github.GHEventPayload.Release</exclude>
<exclude>org.kohsuke.github.GHException</exclude>
<exclude>org.kohsuke.github.GHHook</exclude>
<exclude>org.kohsuke.github.GHHooks.OrgContext</exclude>
<exclude>org.kohsuke.github.GHInvitation</exclude>
<exclude>org.kohsuke.github.GHMilestoneState</exclude>
<exclude>org.kohsuke.github.GHOrgHook</exclude>
<exclude>org.kohsuke.github.GHProject.ProjectStateFilter</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Authorship</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Commit</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.CommitPointer</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Tree</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail</exclude>
<exclude>org.kohsuke.github.GHPullRequestFileDetail</exclude>
<exclude>org.kohsuke.github.GHPullRequestQueryBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHReleaseUpdater</exclude>
<exclude>org.kohsuke.github.GHRepository.ForkSort</exclude>
<exclude>org.kohsuke.github.GHRequestedAction</exclude>
<exclude>org.kohsuke.github.GHStargazer</exclude>
<exclude>org.kohsuke.github.GHTagObject</exclude>
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
<exclude>org.kohsuke.github.GitHubBuilder.1</exclude>
</excludes>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -81,6 +217,18 @@
<configuration>
<source>8</source>
<failOnWarnings>true</failOnWarnings>
<doclint>all</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
@@ -102,6 +250,10 @@
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
@@ -225,17 +377,6 @@
</dependency>
</dependencies>
</plugin>
<!-- Do not use gmaven plugin -->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<goals>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@@ -245,11 +386,6 @@
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
@@ -272,18 +408,18 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.1</version>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.infradna.tool</groupId>
@@ -291,6 +427,27 @@
<version>1.18</version>
<optional>true</optional>
</dependency>
<!-- for stapler-jetty -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<!-- for stapler-jetty -->
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.5</version>
<scope>test</scope>
</dependency>
<!-- for stapler-jetty -->
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId>
<version>1.259</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-jetty</artifactId>
@@ -300,7 +457,7 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.5.1.201910021850-r</version>
<version>5.6.1.202002131546-r</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -338,19 +495,19 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.1.0</version>
<version>3.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>${spotbugs.version}</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.25.1</version>
<version>2.26.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -374,119 +531,50 @@
</pluginRepositories>
<profiles>
<profile>
<id>ci</id>
<id>ci-non-windows</id>
<activation>
<property>
<name>enable-ci</name>
</property>
<os>
<family>!windows</family>
</os>
</activation>
<properties>
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
</properties>
<build>
</build>
</profile>
<profile>
<id>jacoco</id>
<id>ci-all</id>
<activation>
<property>
<name>enable-jacoco</name>
<name>enable-ci</name>
</property>
</activation>
<properties>
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>install</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<!--We end up with chatty logs, but it shows us which particular classes -->
<!--are lacking in coverage. If this is too much, just remove the -->
<!--<element>CLASS</element> tag below. -->
<element>CLASS</element>
<limits>
<!-- These limits can be overridden, in the form of `0.50` for -->
<!-- 50%, as necessary. Using a property just puts it in one spot. -->
<!--
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.lines}</minimum>
</limit>
-->
<!--
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.other}</minimum>
</limit>
-->
<!--
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.other}</minimum>
</limit>
-->
<!--
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.other}</minimum>
</limit>
-->
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.coverage.target.method}</minimum>
</limit>
<!-- <limit>-->
<!-- <counter>CLASS</counter>-->
<!-- <value>COVEREDRATIO</value>-->
<!-- <minimum>${jacoco.coverage.target.class}</minimum>-->
<!-- </limit>-->
</limits>
<excludes>
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.**</exclude>
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
<!--<exclude>io.jenkins.plugins.todeclarative.converter.api.*</exclude>-->
</excludes>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<properties>
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
@@ -506,7 +594,26 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@@ -540,4 +647,13 @@
<archive>https://groups.google.com/forum/#!forum/github-api</archive>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>Kohsuke Kawaguchi</name>
<id>kohsuke</id>
<email>kk@kohsuke.org</email>
</developer>
</developers>
</project>

View File

@@ -7,7 +7,6 @@ import java.net.HttpURLConnection;
/**
* Pluggable strategy to determine what to do when the API abuse limit is hit.
*
* @author Kohsuke Kawaguchi
* @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler)
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">documentation</a>
* @see RateLimitHandler
@@ -29,6 +28,9 @@ public abstract class AbuseLimitHandler {
* @throws IOException
* on failure
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">API documentation from GitHub</a>
* @see <a href=
* "https://developer.github.com/v3/guides/best-practices-for-integrators/#dealing-with-abuse-rate-limits">Dealing
* with abuse rate limits</a>
*/
public abstract void onError(IOException e, HttpURLConnection uc) throws IOException;

View File

@@ -26,8 +26,7 @@ package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* @author Kohsuke Kawaguchi
*/
*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD",
justification = "Being constructed by JSON deserialization")
class DeleteToken {

View File

@@ -4,8 +4,6 @@ import java.util.Locale;
/**
* This was added during preview API period but it has changed since then.
*
* @author Kohsuke Kawaguchi
*/
@Deprecated
public enum EnforcementLevel {

View File

@@ -10,7 +10,6 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
/**
* A Github App.
*
* @author Paulo Miguel Almeida
* @see GitHub#getApp() GitHub#getApp()
*/
public class GHApp extends GHObject {
@@ -140,7 +139,7 @@ public class GHApp extends GHObject {
}
public URL getHtmlUrl() {
return GitHub.parseURL(htmlUrl);
return GitHubClient.parseURL(htmlUrl);
}
/**
@@ -178,9 +177,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public PagedIterable<GHAppInstallation> listInstallations() {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.asPagedIterable("/app/installations", GHAppInstallation[].class, item -> item.wrapUp(root));
.withUrlPath("/app/installations")
.toIterable(GHAppInstallation[].class, item -> item.wrapUp(root));
}
/**
@@ -198,9 +198,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationById(long id) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/app/installations/%d", id), GHAppInstallation.class)
.withUrlPath(String.format("/app/installations/%d", id))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}
@@ -220,9 +221,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class)
.withUrlPath(String.format("/orgs/%s/installation", name))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}
@@ -244,9 +246,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class)
.withUrlPath(String.format("/repos/%s/%s/installation", ownerName, repositoryName))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}
@@ -265,9 +268,10 @@ public class GHApp extends GHObject {
@Preview
@Deprecated
public GHAppInstallation getInstallationByUser(String name) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(MACHINE_MAN)
.to(String.format("/users/%s/installation", name), GHAppInstallation.class)
.withUrlPath(String.format("/users/%s/installation", name))
.fetch(GHAppInstallation.class)
.wrapUp(root);
}

View File

@@ -10,8 +10,8 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
/**
* Creates a access token for a GitHub App Installation
*
* @author Paulo Miguel Almeida
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
*/
public class GHAppCreateTokenBuilder {
private final GitHub root;
@@ -20,11 +20,17 @@ public class GHAppCreateTokenBuilder {
@Preview
@Deprecated
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = new Requester(root);
withPermissions(builder, permissions);
this.builder = root.createRequest();
}
@Preview
@Deprecated
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
this(root, apiUrlTail);
permissions(permissions);
}
/**
@@ -43,6 +49,25 @@ public class GHAppCreateTokenBuilder {
return this;
}
/**
* Set the permissions granted to the access token. The permissions object includes the permission names and their
* access type.
*
* @param permissions
* Map containing the permission names and types.
* @return a GHAppCreateTokenBuilder
*/
@Preview
@Deprecated
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
Map<String, String> retMap = new HashMap<>();
for (Map.Entry<String, GHPermissionType> entry : permissions.entrySet()) {
retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));
}
builder.with("permissions", retMap);
return this;
}
/**
* Creates an app token with all the parameters.
* <p>
@@ -57,16 +82,9 @@ public class GHAppCreateTokenBuilder {
public GHAppInstallationToken create() throws IOException {
return builder.method("POST")
.withPreview(MACHINE_MAN)
.to(apiUrlTail, GHAppInstallationToken.class)
.withUrlPath(apiUrlTail)
.fetch(GHAppInstallationToken.class)
.wrapUp(root);
}
private static Requester withPermissions(Requester builder, Map<String, GHPermissionType> value) {
Map<String, String> retMap = new HashMap<String, String>();
for (Map.Entry<String, GHPermissionType> entry : value.entrySet()) {
retMap.put(entry.getKey(), Requester.transformEnum(entry.getValue()));
}
return builder.with("permissions", retMap);
}
}

View File

@@ -12,7 +12,6 @@ import static org.kohsuke.github.Previews.GAMBIT;
/**
* A Github App Installation.
*
* @author Paulo Miguel Almeida
* @see GHApp#listInstallations() GHApp#listInstallations()
* @see GHApp#getInstallationById(long) GHApp#getInstallationById(long)
* @see GHApp#getInstallationByOrganization(String) GHApp#getInstallationByOrganization(String)
@@ -42,7 +41,7 @@ public class GHAppInstallation extends GHObject {
private String htmlUrl;
public URL getHtmlUrl() {
return GitHub.parseURL(htmlUrl);
return GitHubClient.parseURL(htmlUrl);
}
/**
@@ -271,7 +270,11 @@ public class GHAppInstallation extends GHObject {
@Preview
@Deprecated
public void deleteInstallation() throws IOException {
root.retrieve().method("DELETE").withPreview(GAMBIT).to(String.format("/app/installations/%d", id));
root.createRequest()
.method("DELETE")
.withPreview(GAMBIT)
.withUrlPath(String.format("/app/installations/%d", id))
.send();
}
/**
@@ -283,11 +286,27 @@ public class GHAppInstallation extends GHObject {
*
* @param permissions
* map of permissions for the created token
* @return a GHAppCreateTokenBuilder on error
* @return a GHAppCreateTokenBuilder instance
* @deprecated Use {@link GHAppInstallation#createToken()} instead.
*/
@Preview
@Deprecated
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", id), permissions);
}
/**
* Starts a builder that creates a new App Installation Token.
*
* <p>
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
* finally create an access token.
*
* @return a GHAppCreateTokenBuilder instance
*/
@Preview
@Deprecated
public GHAppCreateTokenBuilder createToken() {
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", id));
}
}

View File

@@ -11,7 +11,6 @@ import java.util.Map;
/**
* A Github App Installation Token.
*
* @author Paulo Miguel Almeida
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
*/
public class GHAppInstallationToken {
@@ -127,7 +126,7 @@ public class GHAppInstallationToken {
*/
@WithBridgeMethods(value = String.class, adapterMethod = "expiresAtStr")
public Date getExpiresAt() throws IOException {
return GitHub.parseDate(expires_at);
return GitHubClient.parseDate(expires_at);
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getExpiresAt")

View File

@@ -135,7 +135,7 @@ public class GHAsset extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
/**
@@ -145,7 +145,7 @@ public class GHAsset extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to(getApiRoute());
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
private String getApiRoute() {

View File

@@ -9,7 +9,6 @@ import java.util.List;
/**
* Generated OAuth token
*
* @author janinko
* @see GitHub#createToken(Collection, String, String) GitHub#createToken(Collection, String, String)
* @see <a href="http://developer.github.com/v3/oauth/#create-a-new-authorization">API documentation</a>
*/
@@ -96,7 +95,7 @@ public class GHAuthorization extends GHObject {
* @return the app url
*/
public URL getAppUrl() {
return GitHub.parseURL(app.url);
return GitHubClient.parseURL(app.url);
}
/**
@@ -115,7 +114,7 @@ public class GHAuthorization extends GHObject {
*/
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed")
public URL getApiURL() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -141,7 +140,7 @@ public class GHAuthorization extends GHObject {
* @return the note url
*/
public URL getNoteUrl() {
return GitHub.parseURL(note_url);
return GitHubClient.parseURL(note_url);
}
/**

View File

@@ -1,16 +1,13 @@
package org.kohsuke.github;
import org.apache.commons.codec.binary.Base64InputStream;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.Base64;
/**
* The type GHBlob.
*
* @author Kanstantsin Shautsou
* @author Kohsuke Kawaguchi
* @see GHTreeEntry#asBlob() GHTreeEntry#asBlob()
* @see GHRepository#getBlob(String) GHRepository#getBlob(String)
@@ -26,7 +23,7 @@ public class GHBlob {
* @return API URL of this blob.
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -73,8 +70,9 @@ public class GHBlob {
public InputStream read() {
if (encoding.equals("base64")) {
try {
return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false);
} catch (UnsupportedEncodingException e) {
Base64.Decoder decoder = Base64.getMimeDecoder();
return new ByteArrayInputStream(decoder.decode(content));
} catch (IllegalArgumentException e) {
throw new AssertionError(e); // US-ASCII is mandatory
}
}

View File

@@ -1,8 +1,7 @@
package org.kohsuke.github;
import org.apache.commons.codec.binary.Base64;
import java.io.IOException;
import java.util.Base64;
/**
* Builder pattern for creating a new blob. Based on https://developer.github.com/v3/git/blobs/#create-a-blob
@@ -13,7 +12,7 @@ public class GHBlobBuilder {
GHBlobBuilder(GHRepository repo) {
this.repo = repo;
req = new Requester(repo.root);
req = repo.root.createRequest();
}
/**
@@ -37,7 +36,7 @@ public class GHBlobBuilder {
* @return a GHBlobBuilder
*/
public GHBlobBuilder binaryContent(byte[] content) {
String base64Content = Base64.encodeBase64String(content);
String base64Content = Base64.getEncoder().encodeToString(content);
req.with("content", base64Content);
req.with("encoding", "base64");
return this;
@@ -55,6 +54,6 @@ public class GHBlobBuilder {
* if the blob cannot be created.
*/
public GHBlob create() throws IOException {
return req.method("POST").to(getApiTail(), GHBlob.class);
return req.method("POST").withUrlPath(getApiTail()).fetch(GHBlob.class);
}
}

View File

@@ -9,12 +9,8 @@ import java.net.URL;
import java.util.Collection;
import java.util.Objects;
import static org.kohsuke.github.Previews.*;
/**
* A branch in a repository.
*
* @author Yusuke Kokubo
*/
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
@@ -92,7 +88,7 @@ public class GHBranch {
@Preview
@Deprecated
public URL getProtectionUrl() {
return GitHub.parseURL(protection_url);
return GitHubClient.parseURL(protection_url);
}
/**
@@ -103,7 +99,7 @@ public class GHBranch {
* the io exception
*/
public GHBranchProtection getProtection() throws IOException {
return root.retrieve().to(protection_url, GHBranchProtection.class).wrap(this);
return root.createRequest().withUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
}
/**
@@ -122,7 +118,7 @@ public class GHBranch {
* if disabling protection fails
*/
public void disableProtection() throws IOException {
new Requester(root).method("DELETE").to(protection_url);
root.createRequest().method("DELETE").withUrlPath(protection_url).send();
}
/**

View File

@@ -44,7 +44,7 @@ public class GHBranchProtection {
@Preview
@Deprecated
public void enabledSignedCommits() throws IOException {
requester().method("POST").to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class);
requester().method("POST").withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class);
}
/**
@@ -56,7 +56,7 @@ public class GHBranchProtection {
@Preview
@Deprecated
public void disableSignedCommits() throws IOException {
requester().method("DELETE").to(url + REQUIRE_SIGNATURES_URI);
requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
}
/**
@@ -87,7 +87,7 @@ public class GHBranchProtection {
@Preview
@Deprecated
public boolean getRequiredSignatures() throws IOException {
return requester().method("GET").to(url + REQUIRE_SIGNATURES_URI, RequiredSignatures.class).enabled;
return requester().withUrlPath(url + REQUIRE_SIGNATURES_URI).fetch(RequiredSignatures.class).enabled;
}
/**
@@ -123,7 +123,7 @@ public class GHBranchProtection {
}
private Requester requester() {
return new Requester(root).withPreview(ZZZAX);
return root.createRequest().withPreview(ZZZAX);
}
/**

View File

@@ -93,7 +93,8 @@ public class GHBranchProtectionBuilder {
.withNullable("required_pull_request_reviews", prReviews)
.withNullable("restrictions", restrictions)
.withNullable("enforce_admins", enforceAdmins)
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class)
.withUrlPath(branch.getProtectionUrl().toString())
.fetch(GHBranchProtection.class)
.wrap(branch);
}
@@ -352,7 +353,7 @@ public class GHBranchProtectionBuilder {
}
private Requester requester() {
return new Requester(branch.getRoot()).withPreview(LUKE_CAGE);
return branch.getRoot().createRequest().withPreview(LUKE_CAGE);
}
private static class Restrictions {

View File

@@ -0,0 +1,82 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
/**
* Represents a check run.
*
* @see <a href="https://developer.github.com/v3/checks/runs/">documentation</a>
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHCheckRun extends GHObject {
GHRepository owner;
GitHub root;
private String status;
private String conclusion;
private String name;
private String headSha;
private GHPullRequest[] pullRequests;
GHCheckRun wrap(GHRepository owner) {
this.owner = owner;
this.root = owner.root;
return this;
}
GHCheckRun wrap(GitHub root) {
this.root = root;
if (owner != null) {
owner.wrap(root);
}
return this;
}
GHPullRequest[] wrap() {
return pullRequests;
}
public String getStatus() {
return status;
}
public String getConclusion() {
return conclusion;
}
public String getName() {
return name;
}
/**
* Gets the HEAD SHA.
*
* @return sha for the HEAD commit
*/
public String getHeadSha() {
return headSha;
}
GHPullRequest[] getPullRequests() throws IOException {
if (pullRequests != null && pullRequests.length != 0) {
for (GHPullRequest singlePull : pullRequests) {
singlePull.refresh();
}
}
return pullRequests;
}
/**
* @deprecated This object has no HTML URL.
*/
@Override
public URL getHtmlUrl() {
return null;
}
}

View File

@@ -2,8 +2,6 @@ package org.kohsuke.github;
/**
* How is an user associated with a repository?
*
* @author Kohsuke Kawaguchi
*/
public enum GHCommentAuthorAssociation {
/**

View File

@@ -14,7 +14,6 @@ import java.util.List;
/**
* A commit in a repository.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getCommit(String) GHRepository#getCommit(String)
* @see GHCommitComment#getCommit() GHCommitComment#getCommit()
*/
@@ -61,7 +60,7 @@ public class GHCommit {
* @return the authored date
*/
public Date getAuthoredDate() {
return GitHub.parseDate(author.date);
return GitHubClient.parseDate(author.date);
}
/**
@@ -80,7 +79,7 @@ public class GHCommit {
* @return the commit date
*/
public Date getCommitDate() {
return GitHub.parseDate(committer.date);
return GitHubClient.parseDate(committer.date);
}
/**
@@ -201,7 +200,7 @@ public class GHCommit {
* resolves to the actual content of the file.
*/
public URL getRawUrl() {
return GitHub.parseURL(raw_url);
return GitHubClient.parseURL(raw_url);
}
/**
@@ -212,7 +211,7 @@ public class GHCommit {
* that resolves to the HTML page that describes this file.
*/
public URL getBlobUrl() {
return GitHub.parseURL(blob_url);
return GitHubClient.parseURL(blob_url);
}
/**
@@ -326,7 +325,7 @@ public class GHCommit {
* "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000"
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -441,11 +440,10 @@ public class GHCommit {
* @return {@link PagedIterable} with all the commit comments in this repository.
*/
public PagedIterable<GHCommitComment> listComments() {
return owner.root.retrieve()
.asPagedIterable(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
GHCommitComment[].class,
item -> item.wrap(owner));
return owner.root.createRequest()
.withUrlPath(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
.toIterable(GHCommitComment[].class, item -> item.wrap(owner));
}
/**
@@ -466,12 +464,15 @@ public class GHCommit {
* if comment is not created
*/
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
GHCommitComment r = new Requester(owner.root).with("body", body)
GHCommitComment r = owner.root.createRequest()
.method("POST")
.with("body", body)
.with("path", path)
.with("line", line)
.with("position", position)
.to(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
GHCommitComment.class);
.withUrlPath(
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
.fetch(GHCommitComment.class);
return r.wrap(owner);
}
@@ -518,7 +519,7 @@ public class GHCommit {
*/
void populate() throws IOException {
if (files == null && stats == null)
owner.root.retrieve().to(owner.getApiTailUrl("commits/" + sha), this);
owner.root.createRequest().withUrlPath(owner.getApiTailUrl("commits/" + sha)).fetchInto(this);
}
GHCommit wrapUp(GHRepository owner) {

View File

@@ -34,7 +34,7 @@ public class GHCommitBuilder {
GHCommitBuilder(GHRepository repo) {
this.repo = repo;
req = new Requester(repo.root);
req = repo.root.createRequest().method("POST");
}
/**
@@ -118,6 +118,6 @@ public class GHCommitBuilder {
*/
public GHCommit create() throws IOException {
req.with("parents", parents);
return req.method("POST").to(getApiTail(), GHCommit.class).wrapUp(repo);
return req.method("POST").withUrlPath(getApiTail()).fetch(GHCommit.class).wrapUp(repo);
}
}

View File

@@ -10,7 +10,6 @@ import static org.kohsuke.github.Previews.*;
/**
* A comment attached to a commit (or a specific line in a specific file of a commit.)
*
* @author Kohsuke Kawaguchi
* @see GHRepository#listCommitComments() GHRepository#listCommitComments()
* @see GHCommit#listComments() GHCommit#listComments()
* @see GHCommit#createComment(String, String, Integer, Integer) GHCommit#createComment(String, String, Integer,
@@ -41,7 +40,7 @@ public class GHCommitComment extends GHObject implements Reactable {
* show this commit comment in a browser.
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -113,25 +112,33 @@ public class GHCommitComment extends GHObject implements Reactable {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getApiTail(), GHCommitComment.class);
owner.root.createRequest()
.method("PATCH")
.with("body", body)
.withUrlPath(getApiTail())
.fetch(GHCommitComment.class);
this.body = body;
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiTail() + "/reactions", GHReaction.class)
.withUrlPath(getApiTail() + "/reactions")
.fetch(GHReaction.class)
.wrap(owner.root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return owner.root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiTail() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiTail() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
}
/**
@@ -141,7 +148,7 @@ public class GHCommitComment extends GHObject implements Reactable {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiTail());
owner.root.createRequest().method("DELETE").withUrlPath(getApiTail()).send();
}
private String getApiTail() {

View File

@@ -27,8 +27,6 @@ import java.io.IOException;
/**
* Identifies a commit in {@link GHPullRequest}.
*
* @author Kohsuke Kawaguchi
*/
public class GHCommitPointer {
private String ref, sha, label;

View File

@@ -15,7 +15,6 @@ import java.util.Date;
* }
* </pre>
*
* @author Kohsuke Kawaguchi
* @see GHRepository#queryCommits() GHRepository#queryCommits()
*/
public class GHCommitQueryBuilder {
@@ -24,7 +23,7 @@ public class GHCommitQueryBuilder {
GHCommitQueryBuilder(GHRepository repo) {
this.repo = repo;
this.req = repo.root.retrieve(); // requester to build up
this.req = repo.root.createRequest(); // requester to build up
}
/**
@@ -83,7 +82,7 @@ public class GHCommitQueryBuilder {
* @return the gh commit query builder
*/
public GHCommitQueryBuilder since(Date dt) {
req.with("since", GitHub.printDate(dt));
req.with("since", GitHubClient.printDate(dt));
return this;
}
@@ -106,7 +105,7 @@ public class GHCommitQueryBuilder {
* @return the gh commit query builder
*/
public GHCommitQueryBuilder until(Date dt) {
req.with("until", GitHub.printDate(dt));
req.with("until", GitHubClient.printDate(dt));
return this;
}
@@ -127,6 +126,6 @@ public class GHCommitQueryBuilder {
* @return the paged iterable
*/
public PagedIterable<GHCommit> list() {
return req.asPagedIterable(repo.getApiTailUrl("commits"), GHCommit[].class, item -> item.wrapUp(repo));
return req.withUrlPath(repo.getApiTailUrl("commits")).toIterable(GHCommit[].class, item -> item.wrapUp(repo));
}
}

View File

@@ -7,7 +7,6 @@ import java.io.IOException;
/**
* Search commits.
*
* @author Marc de Verdelhan
* @see GitHub#searchCommits() GitHub#searchCommits()
*/
@Preview
@@ -259,7 +258,7 @@ public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
if (StringUtils.isBlank(commitUrl)) {
return null;
}
int indexOfUsername = (GitHub.GITHUB_URL + "/repos/").length();
int indexOfUsername = (GitHubClient.GITHUB_URL + "/repos/").length();
String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);
return tokens[0] + '/' + tokens[1];
}

View File

@@ -3,7 +3,6 @@ package org.kohsuke.github;
/**
* Represents the state of commit
*
* @author Kohsuke Kawaguchi
* @see GHCommitStatus
*/
public enum GHCommitState {

View File

@@ -6,7 +6,6 @@ import java.net.URL;
/**
* Represents a status of a commit.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getLastCommitStatus(String) GHRepository#getLastCommitStatus(String)
* @see GHCommit#getLastStatus() GHCommit#getLastStatus()
* @see GHRepository#createCommitStatus(String, GHCommitState, String, String) GHRepository#createCommitStatus(String,

View File

@@ -7,8 +7,6 @@ import java.net.URL;
/**
* The model user for comparing 2 commits in the GitHub API.
*
* @author Michael Clarke
*/
public class GHCompare {
@@ -27,7 +25,7 @@ public class GHCompare {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -36,7 +34,7 @@ public class GHCompare {
* @return the html url
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -45,7 +43,7 @@ public class GHCompare {
* @return the permalink url
*/
public URL getPermalinkUrl() {
return GitHub.parseURL(permalink_url);
return GitHubClient.parseURL(permalink_url);
}
/**
@@ -54,7 +52,7 @@ public class GHCompare {
* @return the diff url
*/
public URL getDiffUrl() {
return GitHub.parseURL(diff_url);
return GitHubClient.parseURL(diff_url);
}
/**
@@ -63,7 +61,7 @@ public class GHCompare {
* @return the patch url
*/
public URL getPatchUrl() {
return GitHub.parseURL(patch_url);
return GitHubClient.parseURL(patch_url);
}
/**

View File

@@ -1,18 +1,16 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Base64InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
/**
* A Content of a repository.
*
* @author Alexandre COLLIGNON
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
*/
@SuppressWarnings({ "UnusedDeclaration" })
@@ -114,7 +112,7 @@ public class GHContent implements Refreshable {
*/
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public String getContent() throws IOException {
return new String(Base64.decodeBase64(getEncodedContent()));
return new String(Base64.getMimeDecoder().decode(getEncodedContent()));
}
/**
@@ -175,8 +173,9 @@ public class GHContent implements Refreshable {
refresh(content);
if (encoding.equals("base64")) {
try {
return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false);
} catch (UnsupportedEncodingException e) {
Base64.Decoder decoder = Base64.getMimeDecoder();
return new ByteArrayInputStream(decoder.decode(content.getBytes(StandardCharsets.US_ASCII)));
} catch (IllegalArgumentException e) {
throw new AssertionError(e); // US-ASCII is mandatory
}
}
@@ -223,7 +222,7 @@ public class GHContent implements Refreshable {
* the io exception
*/
protected synchronized void populate() throws IOException {
root.retrieve().to(url, this);
root.createRequest().withUrlPath(url).fetchInto(this);
}
/**
@@ -237,7 +236,7 @@ public class GHContent implements Refreshable {
if (!isDirectory())
throw new IllegalStateException(path + " is not a directory");
return root.retrieve().asPagedIterable(url, GHContent[].class, item -> item.wrap(repository));
return root.createRequest().setRawUrlPath(url).toIterable(GHContent[].class, item -> item.wrap(repository));
}
/**
@@ -304,9 +303,11 @@ public class GHContent implements Refreshable {
*/
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch)
throws IOException {
String encodedContent = Base64.encodeBase64String(newContentBytes);
String encodedContent = Base64.getEncoder().encodeToString(newContentBytes);
Requester requester = new Requester(root).with("path", path)
Requester requester = root.createRequest()
.method("POST")
.with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.with("content", encodedContent)
@@ -316,7 +317,8 @@ public class GHContent implements Refreshable {
requester.with("branch", branch);
}
GHContentUpdateResponse response = requester.to(getApiRoute(repository, path), GHContentUpdateResponse.class);
GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
.fetch(GHContentUpdateResponse.class);
response.getContent().wrap(repository);
response.getCommit().wrapUp(repository);
@@ -350,7 +352,9 @@ public class GHContent implements Refreshable {
* the io exception
*/
public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
Requester requester = new Requester(root).with("path", path)
Requester requester = root.createRequest()
.method("POST")
.with("path", path)
.with("message", commitMessage)
.with("sha", sha)
.method("DELETE");
@@ -359,7 +363,8 @@ public class GHContent implements Refreshable {
requester.with("branch", branch);
}
GHContentUpdateResponse response = requester.to(getApiRoute(repository, path), GHContentUpdateResponse.class);
GHContentUpdateResponse response = requester.withUrlPath(getApiRoute(repository, path))
.fetch(GHContentUpdateResponse.class);
response.getCommit().wrapUp(repository);
return response;
@@ -405,6 +410,6 @@ public class GHContent implements Refreshable {
*/
@Override
public synchronized void refresh() throws IOException {
root.retrieve().to(url, this);
root.createRequest().setRawUrlPath(url).fetchInto(this);
}
}

View File

@@ -1,9 +1,8 @@
package org.kohsuke.github;
import org.apache.commons.codec.binary.Base64;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
/**
* Used to create/update content.
@@ -11,7 +10,6 @@ import java.io.UnsupportedEncodingException;
* <p>
* Call various methods to build up parameters, then call {@link #commit()} to make the change effective.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#createContent() GHRepository#createContent()
*/
public final class GHContentBuilder {
@@ -21,7 +19,7 @@ public final class GHContentBuilder {
GHContentBuilder(GHRepository repo) {
this.repo = repo;
this.req = new Requester(repo.root).method("PUT");
this.req = repo.root.createRequest().method("PUT");
}
/**
@@ -50,7 +48,7 @@ public final class GHContentBuilder {
}
/**
* Used when updating (but not creating a new content) to specify Thetblob SHA of the file being replaced.
* Used when updating (but not creating a new content) to specify the blob SHA of the file being replaced.
*
* @param sha
* the sha
@@ -69,7 +67,7 @@ public final class GHContentBuilder {
* @return the gh content builder
*/
public GHContentBuilder content(byte[] content) {
req.with("content", Base64.encodeBase64String(content));
req.with("content", Base64.getEncoder().encodeToString(content));
return this;
}
@@ -81,11 +79,7 @@ public final class GHContentBuilder {
* @return the gh content builder
*/
public GHContentBuilder content(String content) {
try {
return content(content.getBytes("UTF-8"));
} catch (UnsupportedEncodingException x) {
throw new AssertionError();
}
return content(content.getBytes(StandardCharsets.UTF_8));
}
/**
@@ -108,7 +102,8 @@ public final class GHContentBuilder {
* the io exception
*/
public GHContentUpdateResponse commit() throws IOException {
GHContentUpdateResponse response = req.to(GHContent.getApiRoute(repo, path), GHContentUpdateResponse.class);
GHContentUpdateResponse response = req.withUrlPath(GHContent.getApiRoute(repo, path))
.fetch(GHContentUpdateResponse.class);
response.getContent().wrap(repo);
response.getCommit().wrapUp(repo);

View File

@@ -3,7 +3,6 @@ package org.kohsuke.github;
/**
* Search code for {@link GHContent}.
*
* @author Kohsuke Kawaguchi
* @see GitHub#searchContent() GitHub#searchContent()
*/
public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {

View File

@@ -3,7 +3,6 @@ package org.kohsuke.github;
/**
* {@link GHContent} with license information.
*
* @author Kohsuke Kawaguchi
* @see <a href="https://developer.github.com/v3/licenses/#get-a-repositorys-license">documentation</a>
* @see GHRepository#getLicense()
*/

View File

@@ -5,8 +5,6 @@ import java.net.URL;
/**
* Creates a repository
*
* @author Kohsuke Kawaguchi
*/
public class GHCreateRepositoryBuilder {
private final GitHub root;
@@ -16,7 +14,7 @@ public class GHCreateRepositoryBuilder {
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
this.root = root;
this.apiUrlTail = apiUrlTail;
this.builder = new Requester(root);
this.builder = root.createRequest();
this.builder.with("name", name);
}
@@ -196,7 +194,7 @@ public class GHCreateRepositoryBuilder {
* if repsitory cannot be created
*/
public GHRepository create() throws IOException {
return builder.method("POST").to(apiUrlTail, GHRepository.class).wrap(root);
return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHRepository.class).wrap(root);
}
}

View File

@@ -82,7 +82,9 @@ public class GHDeployKey {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE")
.to(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id));
owner.root.createRequest()
.method("DELETE")
.withUrlPath(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id))
.send();
}
}

View File

@@ -38,7 +38,7 @@ public class GHDeployment extends GHObject {
* @return the statuses url
*/
public URL getStatusesUrl() {
return GitHub.parseURL(statuses_url);
return GitHubClient.parseURL(statuses_url);
}
/**
@@ -47,7 +47,7 @@ public class GHDeployment extends GHObject {
* @return the repository url
*/
public URL getRepositoryUrl() {
return GitHub.parseURL(repository_url);
return GitHubClient.parseURL(repository_url);
}
/**
@@ -131,7 +131,9 @@ public class GHDeployment extends GHObject {
* @return the paged iterable
*/
public PagedIterable<GHDeploymentStatus> listStatuses() {
return root.retrieve().asPagedIterable(statuses_url, GHDeploymentStatus[].class, item -> item.wrap(owner));
return root.createRequest()
.withUrlPath(statuses_url)
.toIterable(GHDeploymentStatus[].class, item -> item.wrap(owner));
}
}

View File

@@ -19,7 +19,7 @@ public class GHDeploymentBuilder {
*/
public GHDeploymentBuilder(GHRepository repo) {
this.repo = repo;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
}
/**
@@ -127,6 +127,6 @@ public class GHDeploymentBuilder {
* the io exception
*/
public GHDeployment create() throws IOException {
return builder.to(repo.getApiTailUrl("deployments"), GHDeployment.class).wrap(repo);
return builder.withUrlPath(repo.getApiTailUrl("deployments")).fetch(GHDeployment.class).wrap(repo);
}
}

View File

@@ -37,7 +37,7 @@ public class GHDeploymentStatus extends GHObject {
* @return the target url
*/
public URL getTargetUrl() {
return GitHub.parseURL(target_url);
return GitHubClient.parseURL(target_url);
}
/**
@@ -46,7 +46,7 @@ public class GHDeploymentStatus extends GHObject {
* @return the deployment url
*/
public URL getDeploymentUrl() {
return GitHub.parseURL(deployment_url);
return GitHubClient.parseURL(deployment_url);
}
/**
@@ -55,7 +55,7 @@ public class GHDeploymentStatus extends GHObject {
* @return the repository url
*/
public URL getRepositoryUrl() {
return GitHub.parseURL(repository_url);
return GitHubClient.parseURL(repository_url);
}
/**

View File

@@ -30,7 +30,7 @@ public class GHDeploymentStatusBuilder {
GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
this.repo = repo;
this.deploymentId = deploymentId;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
this.builder.with("state", state);
}
@@ -66,7 +66,8 @@ public class GHDeploymentStatusBuilder {
* the io exception
*/
public GHDeploymentStatus create() throws IOException {
return builder.to(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"), GHDeploymentStatus.class)
return builder.withUrlPath(repo.getApiTailUrl("deployments/" + deploymentId + "/statuses"))
.fetch(GHDeploymentStatus.class)
.wrap(repo);
}
}

View File

@@ -2,8 +2,6 @@ package org.kohsuke.github;
/**
* Sort direction
*
* @author Kohsuke Kawaguchi
*/
public enum GHDirection {
ASC, DESC

View File

@@ -27,8 +27,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Represents an email of GitHub.
*
* @author Kelly Campbell
*/
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",

View File

@@ -5,55 +5,62 @@ import java.util.Locale;
/**
* Hook event type.
*
* @author Kohsuke Kawaguchi
* @see GHEventInfo
* @see <a href="https://developer.github.com/v3/activity/events/types/">Event type reference</a>
*/
public enum GHEvent {
CHECK_RUN,
CHECK_SUITE,
COMMIT_COMMENT,
CONTENT_REFERENCE,
CREATE,
DELETE,
DEPLOY_KEY,
DEPLOYMENT,
DEPLOYMENT_STATUS,
DOWNLOAD,
FOLLOW,
FORK,
FORK_APPLY,
GITHUB_APP_AUTHORIZATION,
GIST,
GOLLUM,
INSTALLATION,
INSTALLATION_REPOSITORIES,
INTEGRATION_INSTALLATION_REPOSITORIES,
CHECK_SUITE,
ISSUE_COMMENT,
ISSUES,
LABEL,
MARKETPLACE_PURCHASE,
MEMBER,
MEMBERSHIP,
META,
MILESTONE,
ORGANIZATION,
ORG_BLOCK,
PACKAGE,
PAGE_BUILD,
PROJECT_CARD,
PROJECT_COLUMN,
PROJECT,
PING,
PUBLIC,
PULL_REQUEST,
PULL_REQUEST_REVIEW,
PULL_REQUEST_REVIEW_COMMENT,
PUSH,
RELEASE,
REPOSITORY, // only
// valid
// for
// org
// hooks
REPOSITORY_DISPATCH, // only valid for org hooks
REPOSITORY,
REPOSITORY_IMPORT,
REPOSITORY_VULNERABILITY_ALERT,
SECURITY_ADVISORY,
STAR,
STATUS,
TEAM,
TEAM_ADD,
WATCH,
PING,
/**
* Special event type that means "every possible event"
*/

View File

@@ -8,8 +8,6 @@ import java.util.Date;
/**
* Represents an event.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHEventInfo {
@@ -78,7 +76,7 @@ public class GHEventInfo {
* @return the created at
*/
public Date getCreatedAt() {
return GitHub.parseDate(created_at);
return GitHubClient.parseDate(created_at);
}
/**
@@ -144,7 +142,7 @@ public class GHEventInfo {
* if payload cannot be parsed
*/
public <T extends GHEventPayload> T getPayload(Class<T> type) throws IOException {
T v = GitHub.MAPPER.readValue(payload.traverse(), type);
T v = GitHubClient.MAPPER.readValue(payload.traverse(), type);
v.wrapUp(root);
return v;
}

View File

@@ -47,6 +47,109 @@ public abstract class GHEventPayload {
}
}
// List of events that still need to be added:
// CheckRunEvent CheckSuiteEvent ContentReferenceEvent
// DeployKeyEvent DownloadEvent FollowEvent ForkApplyEvent GitHubAppAuthorizationEvent GistEvent GollumEvent
// InstallationEvent InstallationRepositoriesEvent IssuesEvent LabelEvent MarketplacePurchaseEvent MemberEvent
// MembershipEvent MetaEvent MilestoneEvent OrganizationEvent OrgBlockEvent PackageEvent PageBuildEvent
// ProjectCardEvent ProjectColumnEvent ProjectEvent RepositoryDispatchEvent RepositoryImportEvent
// RepositoryVulnerabilityAlertEvent SecurityAdvisoryEvent StarEvent StatusEvent TeamEvent TeamAddEvent WatchEvent
/**
* A check run event has been created, rerequested, completed, or has a requested_action.
*
* @see <a href="https://developer.github.com/v3/activity/events/types/#checkrunevent">authoritative source</a>
*/
@SuppressFBWarnings(
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public static class CheckRun extends GHEventPayload {
private String action;
private int number;
private GHCheckRun checkRun;
private GHRequestedAction requestedAction;
private GHRepository repository;
/**
* Gets action.
*
* @return the action
*/
public String getAction() {
return action;
}
/**
* Gets number.
*
* @return the number
*/
public int getNumber() {
return number;
}
/**
* Sets Check Run object
*
* @param currentCheckRun
* the check run object
*/
public void setCheckRun(GHCheckRun currentCheckRun) {
this.checkRun = currentCheckRun;
}
/**
* Gets Check Run object
*
* @return the current checkRun object
*/
public GHCheckRun getCheckRun() {
return checkRun;
}
/**
* Sets the Requested Action object
*
* @param currentRequestedAction
* the current action
*/
public void setCheckRun(GHRequestedAction currentRequestedAction) {
this.requestedAction = currentRequestedAction;
}
/**
* Gets the Requested Action object
*
* @return the requested action
*/
public GHRequestedAction getRequestedAction() {
return requestedAction;
}
/**
* Gets repository.
*
* @return the repository
*/
public GHRepository getRepository() {
return repository;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (checkRun == null)
throw new IllegalStateException(
"Expected check_run payload, but got something else. Maybe we've got another type of event?");
if (repository != null) {
repository.wrap(root);
checkRun.wrap(repository);
} else {
checkRun.wrap(root);
}
}
}
/**
* A pull request status has changed.
*
@@ -1325,6 +1428,107 @@ public abstract class GHEventPayload {
organization.wrapUp(root);
}
}
}
/**
* A git commit status was changed.
*
* @see <a href="https://developer.github.com/v3/activity/events/types/#statusevent">authoritative source</a>
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization")
public static class Status extends GHEventPayload {
private String context;
private String description;
private GHCommitState state;
private GHCommit commit;
private GHRepository repository;
/**
* Gets the status content.
*
* @return status content
*/
public String getContext() {
return context;
}
/**
* Gets the status description.
*
* @return status description
*/
public String getDescription() {
return description;
}
/**
* Gets the status state.
*
* @return status state
*/
public GHCommitState getState() {
return state;
}
/**
* Sets the status stage.
*
* @param state
* status state
*/
public void setState(GHCommitState state) {
this.state = state;
}
/**
* Gets the commit associated with the status event.
*
* @return commit
*/
public GHCommit getCommit() {
return commit;
}
/**
* Sets the commit associated with the status event.
*
* @param commit
* commit
*/
public void setCommit(GHCommit commit) {
this.commit = commit;
}
/**
* Gets the repository associated with the status event.
*
* @return repository
*/
public GHRepository getRepository() {
return repository;
}
/**
* Sets the repository associated with the status event.
*
* @param repository
* repository
*/
public void setRepository(GHRepository repository) {
this.repository = repository;
}
@Override
void wrapUp(GitHub root) {
super.wrapUp(root);
if (state == null) {
throw new IllegalStateException(
"Expected status payload, but got something else. Maybe we've got another type of event?");
}
if (repository != null) {
repository.wrap(root);
commit.wrapUp(repository);
}
}
}
}

View File

@@ -2,8 +2,6 @@ package org.kohsuke.github;
/**
* The type GHException.
*
* @author Kohsuke Kawaguchi
*/
public class GHException extends RuntimeException {
/**

View File

@@ -1,16 +1,14 @@
package org.kohsuke.github;
import java.io.FileNotFoundException;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
*
* @author Kanstantsin Shautsou
*/
public class GHFileNotFoundException extends FileNotFoundException {
protected Map<String, List<String>> responseHeaderFields;
@@ -24,11 +22,24 @@ public class GHFileNotFoundException extends FileNotFoundException {
/**
* Instantiates a new Gh file not found exception.
*
* @param s
* the s
* @param message
* the message
*/
public GHFileNotFoundException(String s) {
super(s);
public GHFileNotFoundException(String message) {
super(message);
}
/**
* Instantiates a new Gh file not found exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public GHFileNotFoundException(String message, Throwable cause) {
super(message);
this.initCause(cause);
}
/**
@@ -41,8 +52,8 @@ public class GHFileNotFoundException extends FileNotFoundException {
return responseHeaderFields;
}
GHFileNotFoundException withResponseHeaderFields(HttpURLConnection urlConnection) {
this.responseHeaderFields = urlConnection.getHeaderFields();
GHFileNotFoundException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
this.responseHeaderFields = headerFields;
return this;
}
}

View File

@@ -13,7 +13,6 @@ import java.util.Map.Entry;
/**
* Gist
*
* @author Kohsuke Kawaguchi
* @see GHUser#listGists() GHUser#listGists()
* @see GitHub#getGist(String) GitHub#getGist(String)
* @see GitHub#createGist() GitHub#createGist()
@@ -84,7 +83,7 @@ public class GHGist extends GHObject {
}
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -182,7 +181,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public void star() throws IOException {
new Requester(root).method("PUT").to(getApiTailUrl("star"));
root.createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send();
}
/**
@@ -192,7 +191,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public void unstar() throws IOException {
new Requester(root).method("DELETE").to(getApiTailUrl("star"));
root.createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send();
}
/**
@@ -203,7 +202,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public boolean isStarred() throws IOException {
return root.retrieve().asHttpStatusCode(getApiTailUrl("star")) / 100 == 2;
return root.createRequest().withUrlPath(getApiTailUrl("star")).fetchHttpStatusCode() / 100 == 2;
}
/**
@@ -214,7 +213,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public GHGist fork() throws IOException {
return new Requester(root).to(getApiTailUrl("forks"), GHGist.class).wrapUp(root);
return root.createRequest().method("POST").withUrlPath(getApiTailUrl("forks")).fetch(GHGist.class).wrapUp(root);
}
/**
@@ -223,7 +222,9 @@ public class GHGist extends GHObject {
* @return the paged iterable
*/
public PagedIterable<GHGist> listForks() {
return root.retrieve().asPagedIterable(getApiTailUrl("forks"), GHGist[].class, item -> item.wrapUp(root));
return root.createRequest()
.withUrlPath(getApiTailUrl("forks"))
.toIterable(GHGist[].class, item -> item.wrapUp(root));
}
/**
@@ -233,7 +234,7 @@ public class GHGist extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to("/gists/" + id);
root.createRequest().method("DELETE").withUrlPath("/gists/" + id).send();
}
/**

View File

@@ -7,7 +7,6 @@ import java.util.LinkedHashMap;
/**
* Builder pattern for creating a new Gist.
*
* @author Kohsuke Kawaguchi
* @see GitHub#createGist() GitHub#createGist()
*/
public class GHGistBuilder {
@@ -23,7 +22,7 @@ public class GHGistBuilder {
*/
public GHGistBuilder(GitHub root) {
this.root = root;
req = new Requester(root);
req = root.createRequest().method("POST");
}
/**
@@ -73,6 +72,6 @@ public class GHGistBuilder {
*/
public GHGist create() throws IOException {
req.with("files", files);
return req.to("/gists", GHGist.class).wrapUp(root);
return req.withUrlPath("/gists").fetch(GHGist.class).wrapUp(root);
}
}

View File

@@ -3,7 +3,6 @@ package org.kohsuke.github;
/**
* A file inside {@link GHGist}
*
* @author Kohsuke Kawaguchi
* @see GHGist#getFile(String) GHGist#getFile(String)
* @see GHGist#getFiles() GHGist#getFiles()
*/

View File

@@ -6,8 +6,6 @@ import java.util.LinkedHashMap;
/**
* Builder pattern for updating a Gist.
*
* @author Martin van Zijl
*/
public class GHGistUpdater {
private final GHGist base;
@@ -16,7 +14,7 @@ public class GHGistUpdater {
GHGistUpdater(GHGist base) {
this.base = base;
this.builder = new Requester(base.root);
this.builder = base.root.createRequest();
files = new LinkedHashMap<>();
}
@@ -96,6 +94,6 @@ public class GHGistUpdater {
*/
public GHGist update() throws IOException {
builder.with("files", files);
return builder.method("PATCH").to(base.getApiTailUrl(""), GHGist.class).wrap(base.owner);
return builder.method("PATCH").withUrlPath(base.getApiTailUrl("")).fetch(GHGist.class).wrap(base.owner);
}
}

View File

@@ -12,8 +12,6 @@ import java.util.Map;
/**
* The type GHHook.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
@@ -74,7 +72,7 @@ public abstract class GHHook extends GHObject {
* @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a>
*/
public void ping() throws IOException {
new Requester(getRoot()).method("POST").to(getApiRoute() + "/pings");
getRoot().createRequest().method("POST").withUrlPath(getApiRoute() + "/pings").send();
}
/**
@@ -84,7 +82,7 @@ public abstract class GHHook extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(getRoot()).method("DELETE").to(getApiRoute());
getRoot().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**

View File

@@ -28,8 +28,10 @@ class GHHooks {
*/
public List<GHHook> getHooks() throws IOException {
GHHook[] hookArray = root.retrieve().to(collection(), collectionClass()); // jdk/eclipse bug requires this
// to be on separate line
GHHook[] hookArray = root.createRequest().withUrlPath(collection()).fetch(collectionClass()); // jdk/eclipse
// bug
// requires this
// to be on separate line
List<GHHook> list = new ArrayList<GHHook>(Arrays.asList(hookArray));
for (GHHook h : list)
wrap(h);
@@ -46,7 +48,7 @@ class GHHooks {
* the io exception
*/
public GHHook getHook(int id) throws IOException {
GHHook hook = root.retrieve().to(collection() + "/" + id, clazz());
GHHook hook = root.createRequest().withUrlPath(collection() + "/" + id).fetch(clazz());
return wrap(hook);
}
@@ -74,11 +76,14 @@ class GHHooks {
ea.add(e.symbol());
}
GHHook hook = new Requester(root).with("name", name)
GHHook hook = root.createRequest()
.method("POST")
.with("name", name)
.with("active", active)
.with("config", config)
.with("events", ea)
.to(collection(), clazz());
.withUrlPath(collection())
.fetch(clazz());
return wrap(hook);
}

View File

@@ -1,16 +1,14 @@
package org.kohsuke.github;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
*
* @author Kanstantsin Shautsou
*/
public class GHIOException extends IOException {
protected Map<String, List<String>> responseHeaderFields;
@@ -31,6 +29,20 @@ public class GHIOException extends IOException {
super(message);
}
/**
* Constructs a {@code GHIOException} with the specified detail message and cause.
*
* @param message
* The detail message (which is saved for later retrieval by the {@link #getMessage()} method)
*
* @param cause
* The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
* permitted, and indicates that the cause is nonexistent or unknown.)
*/
public GHIOException(String message, Throwable cause) {
super(message, cause);
}
/**
* Gets response header fields.
*
@@ -41,8 +53,8 @@ public class GHIOException extends IOException {
return responseHeaderFields;
}
GHIOException withResponseHeaderFields(HttpURLConnection urlConnection) {
this.responseHeaderFields = urlConnection.getHeaderFields();
GHIOException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
this.responseHeaderFields = headerFields;
return this;
}
}

View File

@@ -36,7 +36,7 @@ public class GHInvitation extends GHObject {
* the io exception
*/
public void accept() throws IOException {
root.retrieve().method("PATCH").to("/user/repository_invitations/" + id);
root.createRequest().method("PATCH").withUrlPath("/user/repository_invitations/" + id).send();
}
/**
@@ -46,11 +46,11 @@ public class GHInvitation extends GHObject {
* the io exception
*/
public void decline() throws IOException {
root.retrieve().method("DELETE").to("/user/repository_invitations/" + id);
root.createRequest().method("DELETE").withUrlPath("/user/repository_invitations/" + id).send();
}
@Override
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
}

View File

@@ -26,6 +26,7 @@ package org.kohsuke.github;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URL;
@@ -42,7 +43,6 @@ import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
/**
* Represents an issue on GitHub.
*
* @author Eric Maupin
* @author Kohsuke Kawaguchi
* @see GHRepository#getIssue(int) GHRepository#getIssue(int)
* @see GitHub#searchIssues() GitHub#searchIssues()
@@ -137,7 +137,7 @@ public class GHIssue extends GHObject implements Reactable {
* The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
*/
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -187,7 +187,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the closed at
*/
public Date getClosedAt() {
return GitHub.parseDate(closed_at);
return GitHubClient.parseDate(closed_at);
}
/**
@@ -196,7 +196,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the api url
*/
public URL getApiURL() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -206,7 +206,7 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void lock() throws IOException {
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
}
/**
@@ -216,7 +216,7 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void unlock() throws IOException {
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
}
/**
@@ -230,17 +230,20 @@ public class GHIssue extends GHObject implements Reactable {
*/
@WithBridgeMethods(void.class)
public GHIssueComment comment(String message) throws IOException {
GHIssueComment r = new Requester(root).with("body", message)
.to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
GHIssueComment r = root.createRequest()
.method("POST")
.with("body", message)
.withUrlPath(getIssuesApiRoute() + "/comments")
.fetch(GHIssueComment.class);
return r.wrapUp(this);
}
private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
private void editIssue(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getIssuesApiRoute());
root.createRequest().with(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
}
/**
@@ -442,27 +445,30 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public PagedIterable<GHIssueComment> listComments() throws IOException {
return root.retrieve()
.asPagedIterable(getIssuesApiRoute() + "/comments",
GHIssueComment[].class,
item -> item.wrapUp(GHIssue.this));
return root.createRequest()
.withUrlPath(getIssuesApiRoute() + "/comments")
.toIterable(GHIssueComment[].class, item -> item.wrapUp(this));
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.withUrlPath(getApiRoute() + "/reactions")
.fetch(GHReaction.class)
.wrap(root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiRoute() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(root));
}
/**
@@ -486,10 +492,11 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void addAssignees(Collection<GHUser> assignees) throws IOException {
root.retrieve()
root.createRequest()
.method("POST")
.with(ASSIGNEES, getLogins(assignees))
.to(getIssuesApiRoute() + "/assignees", this);
.withUrlPath(getIssuesApiRoute() + "/assignees")
.fetchInto(this);
}
/**
@@ -513,7 +520,11 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void setAssignees(Collection<GHUser> assignees) throws IOException {
new Requester(root).with(ASSIGNEES, getLogins(assignees)).method("PATCH").to(getIssuesApiRoute());
root.createRequest()
.method("PATCH")
.with(ASSIGNEES, getLogins(assignees))
.withUrlPath(getIssuesApiRoute())
.send();
}
/**
@@ -537,11 +548,12 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
root.retrieve()
root.createRequest()
.method("DELETE")
.with(ASSIGNEES, getLogins(assignees))
.inBody()
.to(getIssuesApiRoute() + "/assignees", this);
.withUrlPath(getIssuesApiRoute() + "/assignees")
.fetchInto(this);
}
/**
@@ -559,6 +571,10 @@ public class GHIssue extends GHObject implements Reactable {
* @return the issues api route
*/
protected String getIssuesApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
}
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
}
@@ -665,7 +681,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the diff url
*/
public URL getDiffUrl() {
return GitHub.parseURL(diff_url);
return GitHubClient.parseURL(diff_url);
}
/**
@@ -674,7 +690,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the patch url
*/
public URL getPatchUrl() {
return GitHub.parseURL(patch_url);
return GitHubClient.parseURL(patch_url);
}
/**
@@ -683,7 +699,7 @@ public class GHIssue extends GHObject implements Reactable {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
}
@@ -703,9 +719,8 @@ public class GHIssue extends GHObject implements Reactable {
* the io exception
*/
public PagedIterable<GHIssueEvent> listEvents() throws IOException {
return root.retrieve()
.asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)),
GHIssueEvent[].class,
item -> item.wrapUp(GHIssue.this));
return root.createRequest()
.withUrlPath(owner.getApiTailUrl(String.format("/issues/%s/events", number)))
.toIterable(GHIssueEvent[].class, item -> item.wrapUp(this));
}
}

View File

@@ -6,8 +6,6 @@ import java.util.List;
/**
* The type GHIssueBuilder.
*
* @author Kohsuke Kawaguchi
*/
public class GHIssueBuilder {
private final GHRepository repo;
@@ -17,7 +15,7 @@ public class GHIssueBuilder {
GHIssueBuilder(GHRepository repo, String title) {
this.repo = repo;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
builder.with("title", title);
}
@@ -95,7 +93,8 @@ public class GHIssueBuilder {
public GHIssue create() throws IOException {
return builder.with("labels", labels)
.with("assignees", assignees)
.to(repo.getApiTailUrl("issues"), GHIssue.class)
.withUrlPath(repo.getApiTailUrl("issues"))
.fetch(GHIssue.class)
.wrap(repo);
}
}

View File

@@ -31,7 +31,6 @@ import static org.kohsuke.github.Previews.*;
/**
* Comment to the issue
*
* @author Kohsuke Kawaguchi
* @see GHIssue#comment(String) GHIssue#comment(String)
* @see GHIssue#listComments() GHIssue#listComments()
*/
@@ -87,7 +86,7 @@ public class GHIssueComment extends GHObject implements Reactable {
@Override
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -108,7 +107,11 @@ public class GHIssueComment extends GHObject implements Reactable {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).with("body", body).method("PATCH").to(getApiRoute(), GHIssueComment.class);
owner.root.createRequest()
.method("PATCH")
.with("body", body)
.withUrlPath(getApiRoute())
.fetch(GHIssueComment.class);
this.body = body;
}
@@ -119,24 +122,28 @@ public class GHIssueComment extends GHObject implements Reactable {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.withUrlPath(getApiRoute() + "/reactions")
.fetch(GHReaction.class)
.wrap(owner.root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return owner.root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiRoute() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
}
private String getApiRoute() {

View File

@@ -4,8 +4,6 @@ import java.util.Date;
/**
* The type GHIssueEvent.
*
* @author Martin van Zijl
*/
public class GHIssueEvent {
private GitHub root;
@@ -90,7 +88,7 @@ public class GHIssueEvent {
* @return the created at
*/
public Date getCreatedAt() {
return GitHub.parseDate(created_at);
return GitHubClient.parseDate(created_at);
}
/**

View File

@@ -3,7 +3,6 @@ package org.kohsuke.github;
/**
* Search issues.
*
* @author Kohsuke Kawaguchi
* @see GitHub#searchIssues() GitHub#searchIssues()
*/
public class GHIssueSearchBuilder extends GHSearchBuilder<GHIssue> {

View File

@@ -5,8 +5,6 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* SSH public key.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHKey {

View File

@@ -6,12 +6,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Objects;
import static org.kohsuke.github.Previews.SYMMETRA;
/**
* The type GHLabel.
*
* @author Kohsuke Kawaguchi
* @see GHIssue#getLabels() GHIssue#getLabels()
* @see GHRepository#listLabels() GHRepository#listLabels()
*/
@@ -51,8 +48,6 @@ public class GHLabel {
*
* @return the description
*/
@Preview
@Deprecated
public String getDescription() {
return description;
}
@@ -69,7 +64,7 @@ public class GHLabel {
* the io exception
*/
public void delete() throws IOException {
repo.root.retrieve().method("DELETE").to(url);
repo.root.createRequest().method("DELETE").setRawUrlPath(url).send();
}
/**
@@ -81,13 +76,13 @@ public class GHLabel {
* the io exception
*/
public void setColor(String newColor) throws IOException {
repo.root.retrieve()
repo.root.createRequest()
.method("PATCH")
.withPreview(SYMMETRA)
.with("name", name)
.with("color", newColor)
.with("description", description)
.to(url);
.setRawUrlPath(url)
.send();
}
/**
@@ -98,16 +93,14 @@ public class GHLabel {
* @throws IOException
* the io exception
*/
@Preview
@Deprecated
public void setDescription(String newDescription) throws IOException {
repo.root.retrieve()
repo.root.createRequest()
.method("PATCH")
.withPreview(SYMMETRA)
.with("name", name)
.with("color", color)
.with("description", newDescription)
.to(url);
.setRawUrlPath(url)
.send();
}
static Collection<String> toNames(Collection<GHLabel> labels) {

View File

@@ -35,7 +35,6 @@ import java.util.List;
/**
* The GitHub Preview API's license information
*
* @author Duncan Dickinson
* @see GitHub#getLicense(String) GitHub#getLicense(String)
* @see GHRepository#getLicense() GHRepository#getLicense()
* @see <a href="https://developer.github.com/v3/licenses/">https://developer.github.com/v3/licenses/</a>
@@ -83,7 +82,7 @@ public class GHLicense extends GHObject {
*/
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -100,7 +99,7 @@ public class GHLicense extends GHObject {
public URL getHtmlUrl() throws IOException {
populate();
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -199,7 +198,7 @@ public class GHLicense extends GHObject {
if (description != null)
return; // already populated
root.retrieve().to(url, this);
root.createRequest().withUrlPath(url).fetchInto(this);
}
@Override

View File

@@ -0,0 +1,87 @@
package org.kohsuke.github;
import java.net.URL;
/**
* Base class for Github Marketplace Account.
*
* @see GitHub#getMyMarketplacePurchases()
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplaceAccount {
protected GitHub root;
private String url;
private long id;
private String login;
private String email;
private String organizationBillingEmail;
private GHMarketplaceAccountType type;
/**
* Wrap up gh marketplace account.
*
* @param root
* the root
* @return an instance of the GHMarketplaceAccount class
*/
GHMarketplaceAccount wrapUp(GitHub root) {
this.root = root;
return this;
}
/**
* Gets url.
*
* @return the url
*/
public URL getUrl() {
return GitHubClient.parseURL(url);
}
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets login.
*
* @return the login
*/
public String getLogin() {
return login;
}
/**
* Gets email.
*
* @return the email
*/
public String getEmail() {
return email;
}
/**
* Gets organization billing email.
*
* @return the organization billing email
*/
public String getOrganizationBillingEmail() {
return organizationBillingEmail;
}
/**
* Gets type.
*
* @return the type
*/
public GHMarketplaceAccountType getType() {
return type;
}
}

View File

@@ -0,0 +1,52 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* A Github Marketplace Account Plan.
*
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplaceAccountPlan extends GHMarketplaceAccount {
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePendingChange marketplacePendingChange;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePurchase marketplacePurchase;
/**
* Wrap up gh marketplace account.
*
* @param root
* the root
* @return an instance of the GHMarketplaceAccount class
*/
GHMarketplaceAccountPlan wrapUp(GitHub root) {
super.wrapUp(root);
if (this.marketplacePendingChange != null)
this.marketplacePendingChange.wrapUp(this.root);
if (this.marketplacePurchase != null)
this.marketplacePurchase.wrapUp(this.root);
return this;
}
/**
* Gets marketplace pending change.
*
* @return the marketplace pending change
*/
public GHMarketplacePendingChange getMarketplacePendingChange() {
return marketplacePendingChange;
}
/**
* Gets marketplace purchase.
*
* @return the marketplace purchase
*/
public GHMarketplacePurchase getMarketplacePurchase() {
return marketplacePurchase;
}
}

View File

@@ -0,0 +1,21 @@
package org.kohsuke.github;
import org.apache.commons.lang3.StringUtils;
import java.util.Locale;
/**
* GitHub Marketplace Account type.
*
* @see GHMarketplaceAccount
*/
public enum GHMarketplaceAccountType {
ORGANIZATION, USER;
/**
* Returns GitHub's internal representation of this event.
*/
String symbol() {
return StringUtils.capitalize(name().toLowerCase(Locale.ENGLISH));
}
}

View File

@@ -0,0 +1,70 @@
package org.kohsuke.github;
import java.io.IOException;
/**
* Returns any accounts associated with a plan, including free plans
*
* @see GHMarketplacePlan#listAccounts()
*/
public class GHMarketplaceListAccountBuilder {
private final GitHub root;
private final Requester builder;
private final long planId;
GHMarketplaceListAccountBuilder(GitHub root, long planId) {
this.root = root;
this.builder = root.createRequest();
this.planId = planId;
}
/**
* Sorts the GitHub accounts by the date they were created or last updated. Can be one of created or updated.
* <p>
* If omitted, the default sorting strategy will be "CREATED"
*
* @param sort
* the sort strategy
* @return a GHMarketplaceListAccountBuilder
*/
public GHMarketplaceListAccountBuilder sort(Sort sort) {
this.builder.with("sort", sort);
return this;
}
/**
* Orders the GitHub accounts results, Can be one of asc or desc. Ignored without the sort parameter.
*
* @param direction
* the order strategy
* @return a GHMarketplaceListAccountBuilder
*/
public GHMarketplaceListAccountBuilder direction(GHDirection direction) {
this.builder.with("direction", direction);
return this;
}
/**
* The enum Sort.
*/
public enum Sort {
CREATED, UPDATED
}
/**
* List any accounts associated with the plan specified on construction with all the order/sort parameters set.
* <p>
* GitHub Apps must use a JWT to access this endpoint.
* <p>
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
*
* @return a paged iterable instance of GHMarketplaceAccountPlan
* @throws IOException
* on error
*/
public PagedIterable<GHMarketplaceAccountPlan> createRequest() throws IOException {
return builder.withUrlPath(String.format("/marketplace_listing/plans/%d/accounts", this.planId))
.toIterable(GHMarketplaceAccountPlan[].class, item -> item.wrapUp(root));
}
}

View File

@@ -0,0 +1,73 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
/**
* A Github Marketplace purchase pending change.
*
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePendingChange {
private GitHub root;
private long id;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private Long unitCount;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePlan plan;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private String effectiveDate;
/**
* Wrap up gh marketplace pending change.
*
* @param root
* the root
* @return an instance of the GHMarketplacePendingChange class
*/
GHMarketplacePendingChange wrapUp(GitHub root) {
this.root = root;
if (plan != null) { // sanity check
this.plan.wrapUp(this.root);
}
return this;
}
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets unit count.
*
* @return the unit count
*/
public Long getUnitCount() {
return unitCount;
}
/**
* Gets plan.
*
* @return the plan
*/
public GHMarketplacePlan getPlan() {
return plan;
}
/**
* Gets effective date.
*
* @return the effective date
*/
public Date getEffectiveDate() {
return GitHubClient.parseDate(effectiveDate);
}
}

View File

@@ -0,0 +1,183 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.net.URL;
import java.util.List;
/**
* A Github Marketplace plan.
*
* @see GitHub#listMarketplacePlans()
*/
public class GHMarketplacePlan {
private GitHub root;
private String url;
private String accountsUrl;
private long id;
private long number;
private String name;
private String description;
private long monthlyPriceInCents;
private long yearlyPriceInCents;
private GHMarketplacePriceModel priceModel;
@JsonProperty("has_free_trial")
private boolean freeTrial; // JavaBeans Spec 1.01 section 8.3.2 forces us to have is<propertyName>
private String unitName;
private String state;
private List<String> bullets;
/**
* Wrap up gh marketplace plan.
*
* @param root
* the root
* @return an instance of the GHMarketplacePlan class
*/
GHMarketplacePlan wrapUp(GitHub root) {
this.root = root;
return this;
}
/**
* Gets url.
*
* @return the url
*/
public URL getUrl() {
return GitHubClient.parseURL(url);
}
/**
* Gets accounts url.
*
* @return the accounts url
*/
public String getAccountsUrl() {
return accountsUrl;
}
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets number.
*
* @return the number
*/
public long getNumber() {
return number;
}
/**
* Gets name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets description.
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Gets monthly price in cents.
*
* @return the monthly price in cents
*/
public long getMonthlyPriceInCents() {
return monthlyPriceInCents;
}
/**
* Gets yearly price in cents.
*
* @return the yearly price in cents
*/
public long getYearlyPriceInCents() {
return yearlyPriceInCents;
}
/**
* Gets price model.
*
* @return the price model
*/
public GHMarketplacePriceModel getPriceModel() {
return priceModel;
}
/**
* Is free trial boolean.
*
* @return the boolean
*/
public boolean isFreeTrial() {
return freeTrial;
}
/**
* Gets unit name.
*
* @return the unit name
*/
public String getUnitName() {
return unitName;
}
/**
* Gets state.
*
* @return the state
*/
public String getState() {
return state;
}
/**
* Gets bullets.
*
* @return the bullets
*/
public List<String> getBullets() {
return bullets;
}
/**
* Starts a builder that list any accounts associated with a plan, including free plans. For per-seat pricing, you
* see the list of accounts that have purchased the plan, including the number of seats purchased. When someone
* submits a plan change that won't be processed until the end of their billing cycle, you will also see the
* upcoming pending change.
*
* <p>
* You use the returned builder to set various properties, then call
* {@link GHMarketplaceListAccountBuilder#createRequest()} to finally list the accounts related to this plan.
*
* <p>
* GitHub Apps must use a JWT to access this endpoint.
* <p>
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
*
* @return a GHMarketplaceListAccountBuilder instance
* @see <a href=
* "https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan">List
* all GitHub accounts (user or organization) on a specific plan</a>
*/
public GHMarketplaceListAccountBuilder listAccounts() {
return new GHMarketplaceListAccountBuilder(root, this.id);
}
}

View File

@@ -0,0 +1,28 @@
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* GitHub Marketplace plan pricing model.
*
* @see GHMarketplacePlan
*/
public enum GHMarketplacePriceModel {
FREE("free"), PER_UNIT("per-unit"), FLAT_RATE("flat-rate");
@JsonValue
private final String internalName;
GHMarketplacePriceModel(String internalName) {
this.internalName = internalName;
}
/**
* Returns GitHub's internal representation of this event.
*
* @return a string containing GitHub's internal representation of this event.
*/
public String symbol() {
return internalName;
}
}

View File

@@ -0,0 +1,101 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
/**
* A Github Marketplace purchase.
*
* @see GHMarketplaceListAccountBuilder#createRequest() GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePurchase {
private GitHub root;
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;
private String freeTrialEndsOn;
private Long unitCount;
private String updatedAt;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePlan plan;
/**
* Wrap up gh marketplace purchase.
*
* @param root
* the root
* @return an instance of the GHMarketplacePurchase class
*/
GHMarketplacePurchase wrapUp(GitHub root) {
this.root = root;
if (plan != null) { // sanity check
this.plan.wrapUp(this.root);
}
return this;
}
/**
* Gets billing cycle.
*
* @return the billing cycle
*/
public String getBillingCycle() {
return billingCycle;
}
/**
* Gets next billing date.
*
* @return the next billing date
*/
public Date getNextBillingDate() {
return GitHubClient.parseDate(nextBillingDate);
}
/**
* Is on free trial boolean.
*
* @return the boolean
*/
public boolean isOnFreeTrial() {
return onFreeTrial;
}
/**
* Gets free trial ends on.
*
* @return the free trial ends on
*/
public Date getFreeTrialEndsOn() {
return GitHubClient.parseDate(freeTrialEndsOn);
}
/**
* Gets unit count.
*
* @return the unit count
*/
public Long getUnitCount() {
return unitCount;
}
/**
* Gets updated at.
*
* @return the updated at
*/
public Date getUpdatedAt() {
return GitHubClient.parseDate(updatedAt);
}
/**
* Gets plan.
*
* @return the plan
*/
public GHMarketplacePlan getPlan() {
return plan;
}
}

View File

@@ -0,0 +1,112 @@
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
/**
* Github Marketplace User Purchase
*
* @see GitHub#getMyMarketplacePurchases()
*/
public class GHMarketplaceUserPurchase {
protected GitHub root;
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;
private String freeTrialEndsOn;
private Long unitCount;
private String updatedAt;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplaceAccount account;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private GHMarketplacePlan plan;
/**
* Wrap up GHMarketplaceUserPurchase.
*
* @param root
* the root
* @return an instance of the GHMarketplaceUserPurchase class
*/
GHMarketplaceUserPurchase wrapUp(GitHub root) {
this.root = root;
if (this.account != null)
this.account.wrapUp(this.root);
if (this.plan != null)
this.plan.wrapUp(this.root);
return this;
}
/**
* Gets billing cycle.
*
* @return the billing cycle
*/
public String getBillingCycle() {
return billingCycle;
}
/**
* Gets next billing date.
*
* @return the next billing date
*/
public Date getNextBillingDate() {
return GitHubClient.parseDate(nextBillingDate);
}
/**
* Is on free trial boolean.
*
* @return the boolean
*/
public boolean isOnFreeTrial() {
return onFreeTrial;
}
/**
* Gets free trial ends on.
*
* @return the free trial ends on
*/
public Date getFreeTrialEndsOn() {
return GitHubClient.parseDate(freeTrialEndsOn);
}
/**
* Gets unit count.
*
* @return the unit count
*/
public Long getUnitCount() {
return unitCount;
}
/**
* Gets updated at.
*
* @return the updated at
*/
public Date getUpdatedAt() {
return GitHubClient.parseDate(updatedAt);
}
/**
* Gets account.
*
* @return the account
*/
public GHMarketplaceAccount getAccount() {
return account;
}
/**
* Gets plan.
*
* @return the plan
*/
public GHMarketplacePlan getPlan() {
return plan;
}
}

View File

@@ -7,7 +7,6 @@ import java.util.Locale;
/**
* Represents a membership of a user in an organization.
*
* @author Kohsuke Kawaguchi
* @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships()
*/
public class GHMembership /* extends GHObject --- but it doesn't have id, created_at, etc. */ {
@@ -25,7 +24,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -72,7 +71,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
*/
public void activate() throws IOException {
root.retrieve().method("PATCH").with("state", State.ACTIVE).to(url, this);
root.createRequest().method("PATCH").with("state", State.ACTIVE).withUrlPath(url).fetchInto(this);
}
GHMembership wrap(GitHub root) {

View File

@@ -9,7 +9,6 @@ import java.util.List;
/**
* Class that wraps the list of GitHub's IP addresses.
*
* @author Paulo Miguel Almeida
* @see GitHub#getMeta() GitHub#getMeta()
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
*/

View File

@@ -7,8 +7,6 @@ import java.util.Locale;
/**
* The type GHMilestone.
*
* @author Yusuke Kokubo
*/
public class GHMilestone extends GHObject {
GitHub root;
@@ -56,7 +54,7 @@ public class GHMilestone extends GHObject {
public Date getDueOn() {
if (due_on == null)
return null;
return GitHub.parseDate(due_on);
return GitHubClient.parseDate(due_on);
}
/**
@@ -67,7 +65,7 @@ public class GHMilestone extends GHObject {
* the io exception
*/
public Date getClosedAt() throws IOException {
return GitHub.parseDate(closed_at);
return GitHubClient.parseDate(closed_at);
}
/**
@@ -116,7 +114,7 @@ public class GHMilestone extends GHObject {
}
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -155,11 +153,11 @@ public class GHMilestone extends GHObject {
* the io exception
*/
public void delete() throws IOException {
root.retrieve().method("DELETE").to(getApiRoute());
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
private void edit(String key, Object value) throws IOException {
new Requester(root).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
/**
@@ -195,7 +193,7 @@ public class GHMilestone extends GHObject {
* the io exception
*/
public void setDueOn(Date dueOn) throws IOException {
edit("due_on", GitHub.printDate(dueOn));
edit("due_on", GitHubClient.printDate(dueOn));
}
/**

View File

@@ -2,8 +2,6 @@ package org.kohsuke.github;
/**
* The enum GHMilestoneState.
*
* @author Yusuke Kokubo
*/
public enum GHMilestoneState {
OPEN, CLOSED

View File

@@ -12,8 +12,6 @@ import java.util.TreeMap;
/**
* Represents the account that's logging into GitHub.
*
* @author Kohsuke Kawaguchi
*/
public class GHMyself extends GHUser {
@@ -71,7 +69,7 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHEmail> getEmails2() throws IOException {
GHEmail[] addresses = root.retrieve().to("/user/emails", GHEmail[].class);
GHEmail[] addresses = root.createRequest().withUrlPath("/user/emails").fetchArray(GHEmail[].class);
return Collections.unmodifiableList(Arrays.asList(addresses));
}
@@ -86,7 +84,8 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHKey> getPublicKeys() throws IOException {
return Collections.unmodifiableList(Arrays.asList(root.retrieve().to("/user/keys", GHKey[].class)));
return Collections.unmodifiableList(
Arrays.asList(root.createRequest().withUrlPath("/user/keys").fetchArray(GHKey[].class)));
}
/**
@@ -100,8 +99,8 @@ public class GHMyself extends GHUser {
* the io exception
*/
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
return Collections.unmodifiableList(
Arrays.asList(root.retrieve().to("/users/" + getLogin() + "/keys", GHVerifiedKey[].class)));
return Collections.unmodifiableList(Arrays.asList(
root.createRequest().withUrlPath("/users/" + getLogin() + "/keys").fetchArray(GHVerifiedKey[].class)));
}
/**
@@ -114,7 +113,7 @@ public class GHMyself extends GHUser {
public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException {
GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>();
Set<String> names = new HashSet<String>();
for (GHOrganization o : root.retrieve().to("/user/orgs", GHOrganization[].class)) {
for (GHOrganization o : root.createRequest().withUrlPath("/user/orgs").fetchArray(GHOrganization[].class)) {
if (names.add(o.getLogin())) // in case of rumoured duplicates in the data
orgs.add(root.getOrganization(o.getLogin()));
}
@@ -175,9 +174,10 @@ public class GHMyself extends GHUser {
* @return the paged iterable
*/
public PagedIterable<GHRepository> listRepositories(final int pageSize, final RepositoryListFilter repoType) {
return root.retrieve()
return root.createRequest()
.with("type", repoType)
.asPagedIterable("/user/repos", GHRepository[].class, item -> item.wrap(root))
.withUrlPath("/user/repos")
.toIterable(GHRepository[].class, item -> item.wrap(root))
.withPageSize(pageSize);
}
@@ -208,9 +208,10 @@ public class GHMyself extends GHUser {
* @return the paged iterable
*/
public PagedIterable<GHMembership> listOrgMemberships(final GHMembership.State state) {
return root.retrieve()
return root.createRequest()
.with("state", state)
.asPagedIterable("/user/memberships/orgs", GHMembership[].class, item -> item.wrap(root));
.withUrlPath("/user/memberships/orgs")
.toIterable(GHMembership[].class, item -> item.wrap(root));
}
/**
@@ -223,7 +224,10 @@ public class GHMyself extends GHUser {
* the io exception
*/
public GHMembership getMembership(GHOrganization o) throws IOException {
return root.retrieve().to("/user/memberships/orgs/" + o.getLogin(), GHMembership.class).wrap(root);
return root.createRequest()
.withUrlPath("/user/memberships/orgs/" + o.getLogin())
.fetch(GHMembership.class)
.wrap(root);
}
// public void addEmails(Collection<String> emails) throws IOException {

View File

@@ -19,7 +19,6 @@ import java.util.NoSuchElementException;
* In the non-blocking mode, the iterator will only report the set of notifications initially retrieved from GitHub,
* then quit. This is useful for a batch application to process the current set of notifications.
*
* @author Kohsuke Kawaguchi
* @see GitHub#listNotifications() GitHub#listNotifications()
* @see GHRepository#listNotifications() GHRepository#listNotifications()
*/
@@ -79,7 +78,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
* @return the gh notification stream
*/
public GHNotificationStream since(Date dt) {
since = GitHub.printDate(dt);
since = GitHubClient.printDate(dt);
return this;
}
@@ -101,7 +100,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
*/
public Iterator<GHThread> iterator() {
// capture the configuration setting here
final Requester req = new Requester(root).method("GET")
final Requester req = root.createRequest()
.with("all", all)
.with("participating", participating)
.with("since", since);
@@ -180,7 +179,11 @@ public class GHNotificationStream implements Iterable<GHThread> {
req.setHeader("If-Modified-Since", lastModified);
threads = req.to(apiUrl, GHThread[].class);
Requester requester = req.withUrlPath(apiUrl);
GitHubResponse<GHThread[]> response = ((GitHubPageContentsIterable<GHThread>) requester
.toIterable(requester.client, GHThread[].class, null)).toResponse();
threads = response.body();
if (threads == null) {
threads = EMPTY_ARRAY; // if unmodified, we get empty array
} else {
@@ -189,18 +192,16 @@ public class GHNotificationStream implements Iterable<GHThread> {
}
idx = threads.length - 1;
nextCheckTime = calcNextCheckTime();
lastModified = req.getResponseHeader("Last-Modified");
nextCheckTime = calcNextCheckTime(response);
lastModified = response.headerField("Last-Modified");
}
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
private long calcNextCheckTime() {
String v = req.getResponseHeader("X-Poll-Interval");
private long calcNextCheckTime(GitHubResponse<GHThread[]> response) {
String v = response.headerField("X-Poll-Interval");
if (v == null)
v = "60";
long seconds = Integer.parseInt(v);
@@ -232,10 +233,10 @@ public class GHNotificationStream implements Iterable<GHThread> {
* the io exception
*/
public void markAsRead(long timestamp) throws IOException {
final Requester req = new Requester(root).method("PUT");
final Requester req = root.createRequest();
if (timestamp >= 0)
req.with("last_read_at", GitHub.printDate(new Date(timestamp)));
req.asHttpStatusCode(apiUrl);
req.with("last_read_at", GitHubClient.printDate(new Date(timestamp)));
req.withUrlPath(apiUrl).fetchHttpStatusCode();
}
private static final GHThread[] EMPTY_ARRAY = new GHThread[0];

View File

@@ -2,8 +2,6 @@ package org.kohsuke.github;
/**
* This exception is thrown when GitHub is requesting an OTP from the user
*
* @author Kevin Harrington mad.hephaestus@gmail.com
*/
public class GHOTPRequiredException extends GHIOException {
// ...

View File

@@ -60,7 +60,7 @@ public abstract class GHObject {
*/
@WithBridgeMethods(value = String.class, adapterMethod = "createdAtStr")
public Date getCreatedAt() throws IOException {
return GitHub.parseDate(created_at);
return GitHubClient.parseDate(created_at);
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
@@ -75,7 +75,7 @@ public abstract class GHObject {
*/
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -96,7 +96,7 @@ public abstract class GHObject {
* on error
*/
public Date getUpdatedAt() throws IOException {
return GitHub.parseDate(updated_at);
return GitHubClient.parseDate(updated_at);
}
/**

View File

@@ -14,8 +14,6 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* The type GHOrganization.
*
* @author Kohsuke Kawaguchi
*/
public class GHOrganization extends GHPerson {
GHOrganization wrapUp(GitHub root) {
@@ -88,7 +86,7 @@ public class GHOrganization extends GHPerson {
*
* <p>
* You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to
* finally createa repository.
* finally create a repository.
*
* @param name
* the name
@@ -121,10 +119,9 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public PagedIterable<GHTeam> listTeams() throws IOException {
return root.retrieve()
.asPagedIterable(String.format("/orgs/%s/teams", login),
GHTeam[].class,
item -> item.wrapUp(GHOrganization.this));
return root.createRequest()
.withUrlPath(String.format("/orgs/%s/teams", login))
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
}
/**
@@ -183,10 +180,11 @@ public class GHOrganization extends GHPerson {
* "https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership">documentation</a>
*/
public void add(GHUser user, Role role) throws IOException {
root.retrieve()
root.createRequest()
.method("PUT")
.with("role", role.name().toLowerCase())
.to("/orgs/" + login + "/memberships/" + user.getLogin());
.withUrlPath("/orgs/" + login + "/memberships/" + user.getLogin())
.send();
}
/**
@@ -198,7 +196,7 @@ public class GHOrganization extends GHPerson {
*/
public boolean hasMember(GHUser user) {
try {
root.retrieve().to("/orgs/" + login + "/members/" + user.getLogin());
root.createRequest().withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();
return true;
} catch (IOException ignore) {
return false;
@@ -215,7 +213,7 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public void remove(GHUser user) throws IOException {
root.retrieve().method("DELETE").to("/orgs/" + login + "/members/" + user.getLogin());
root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();
}
/**
@@ -227,7 +225,7 @@ public class GHOrganization extends GHPerson {
*/
public boolean hasPublicMember(GHUser user) {
try {
root.retrieve().to("/orgs/" + login + "/public_members/" + user.getLogin());
root.createRequest().withUrlPath("/orgs/" + login + "/public_members/" + user.getLogin()).send();
return true;
} catch (IOException ignore) {
return false;
@@ -243,7 +241,7 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public void publicize(GHUser u) throws IOException {
root.retrieve().method("PUT").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
root.createRequest().method("PUT").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();
}
/**
@@ -299,10 +297,9 @@ public class GHOrganization extends GHPerson {
private PagedIterable<GHUser> listMembers(final String suffix, final String filter) throws IOException {
String filterParams = (filter == null) ? "" : ("?filter=" + filter);
return root.retrieve()
.asPagedIterable(String.format("/orgs/%s/%s%s", login, suffix, filterParams),
GHUser[].class,
item -> item.wrapUp(root));
return root.createRequest()
.withUrlPath(String.format("/orgs/%s/%s%s", login, suffix, filterParams))
.toIterable(GHUser[].class, item -> item.wrapUp(root));
}
/**
@@ -314,7 +311,7 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public void conceal(GHUser u) throws IOException {
root.retrieve().method("DELETE").to("/orgs/" + login + "/public_members/" + u.getLogin(), null);
root.createRequest().method("DELETE").withUrlPath("/orgs/" + login + "/public_members/" + u.getLogin()).send();
}
/**
@@ -327,10 +324,11 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
return root.retrieve()
return root.createRequest()
.withPreview(INERTIA)
.with("state", status)
.asPagedIterable(String.format("/orgs/%s/projects", login), GHProject[].class, item -> item.wrap(root));
.withUrlPath(String.format("/orgs/%s/projects", login))
.toIterable(GHProject[].class, item -> item.wrap(root));
}
/**
@@ -356,12 +354,13 @@ public class GHOrganization extends GHPerson {
* the io exception
*/
public GHProject createProject(String name, String body) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("name", name)
.with("body", body)
.to(String.format("/orgs/%s/projects", login), GHProject.class)
.withUrlPath(String.format("/orgs/%s/projects", login))
.fetch(GHProject.class)
.wrap(root);
}
@@ -385,17 +384,17 @@ public class GHOrganization extends GHPerson {
* @throws IOException
* the io exception
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
* {@link #createTeam(String, Collection)}
* {@link #createTeam(String)}
*/
@Deprecated
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
Requester post = new Requester(root).with("name", name).with("permission", p);
Requester post = root.createRequest().method("POST").with("name", name).with("permission", p);
List<String> repo_names = new ArrayList<String>();
for (GHRepository r : repositories) {
repo_names.add(login + "/" + r.getName());
}
post.with("repo_names", repo_names);
return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this);
return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);
}
/**
@@ -411,7 +410,7 @@ public class GHOrganization extends GHPerson {
* @throws IOException
* the io exception
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
* {@link #createTeam(String, GHRepository...)}
* {@link #createTeam(String)}
*/
@Deprecated
public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException {
@@ -428,15 +427,17 @@ public class GHOrganization extends GHPerson {
* @return the gh team
* @throws IOException
* the io exception
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHTeam createTeam(String name, Collection<GHRepository> repositories) throws IOException {
Requester post = new Requester(root).with("name", name);
Requester post = root.createRequest().method("POST").with("name", name);
List<String> repo_names = new ArrayList<String>();
for (GHRepository r : repositories) {
repo_names.add(login + "/" + r.getName());
}
post.with("repo_names", repo_names);
return post.method("POST").to("/orgs/" + login + "/teams", GHTeam.class).wrapUp(this);
return post.withUrlPath("/orgs/" + login + "/teams").fetch(GHTeam.class).wrapUp(this);
}
/**
@@ -449,11 +450,28 @@ public class GHOrganization extends GHPerson {
* @return the gh team
* @throws IOException
* the io exception
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHTeam createTeam(String name, GHRepository... repositories) throws IOException {
return createTeam(name, Arrays.asList(repositories));
}
/**
* Starts a builder that creates a new team.
*
* <p>
* You use the returned builder to set various properties, then call {@link GHTeamBuilder#create()} to finally
* create a team.
*
* @param name
* the name
* @return the gh create repository builder
*/
public GHTeamBuilder createTeam(String name) {
return new GHTeamBuilder(root, login, name);
}
/**
* List up repositories that has some open pull requests.
* <p>
@@ -495,10 +513,9 @@ public class GHOrganization extends GHPerson {
* Lists events performed by a user (this includes private events if the caller is authenticated.
*/
public PagedIterable<GHEventInfo> listEvents() throws IOException {
return root.retrieve()
.asPagedIterable(String.format("/orgs/%s/events", login),
GHEventInfo[].class,
item -> item.wrapUp(root));
return root.createRequest()
.withUrlPath(String.format("/orgs/%s/events", login))
.toIterable(GHEventInfo[].class, item -> item.wrapUp(root));
}
/**
@@ -511,8 +528,9 @@ public class GHOrganization extends GHPerson {
*/
@Override
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
return root.retrieve()
.asPagedIterable("/orgs/" + login + "/repos", GHRepository[].class, item -> item.wrap(root))
return root.createRequest()
.withUrlPath("/orgs/" + login + "/repos")
.toIterable(GHRepository[].class, item -> item.wrap(root))
.withPageSize(pageSize);
}

View File

@@ -2,8 +2,6 @@ package org.kohsuke.github;
/**
* The enum GHPermissionType.
*
* @author Kohsuke Kawaguchi
*/
public enum GHPermissionType {
ADMIN, WRITE, READ, NONE

View File

@@ -9,12 +9,11 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
/**
* Common part of {@link GHUser} and {@link GHOrganization}.
*
* @author Kohsuke Kawaguchi
*/
public abstract class GHPerson extends GHObject {
/* package almost final */ GitHub root;
@@ -23,9 +22,13 @@ public abstract class GHPerson extends GHObject {
protected String login, avatar_url, gravatar_id;
// other fields (that only show up in full data)
protected String location, blog, email, name, company;
protected String location, blog, email, name, company, type;
protected String html_url;
protected int followers, following, public_repos, public_gists;
protected boolean site_admin;
// other fields (that only show up in full data) that require privileged scope
protected Integer total_private_repos;
GHPerson wrapUp(GitHub root) {
this.root = root;
@@ -47,7 +50,7 @@ public abstract class GHPerson extends GHObject {
if (root == null || root.isOffline()) {
return; // cannot populate, will have to live with what we have
}
root.retrieve().to(url, this);
root.createRequest().withUrlPath(url).fetchInto(this);
}
/**
@@ -88,8 +91,9 @@ public abstract class GHPerson extends GHObject {
* @return the paged iterable
*/
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
return root.retrieve()
.asPagedIterable("/users/" + login + "/repos", GHRepository[].class, item -> item.wrap(root))
return root.createRequest()
.withUrlPath("/users/" + login + "/repos")
.toIterable(GHRepository[].class, item -> item.wrap(root))
.withPageSize(pageSize);
}
@@ -112,8 +116,9 @@ public abstract class GHPerson extends GHObject {
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
return new Iterable<List<GHRepository>>() {
public Iterator<List<GHRepository>> iterator() {
final Iterator<GHRepository[]> pager = root.retrieve()
.asIterator("/users/" + login + "/repos", GHRepository[].class, pageSize);
final Iterator<GHRepository[]> pager = GitHubPageIterator.create(root.getClient(),
GHRepository[].class,
root.createRequest().withUrlPath("users", login, "repos").withPageSize(pageSize));
return new Iterator<List<GHRepository>>() {
public boolean hasNext() {
@@ -146,7 +151,10 @@ public abstract class GHPerson extends GHObject {
*/
public GHRepository getRepository(String name) throws IOException {
try {
return root.retrieve().to("/repos/" + login + '/' + name, GHRepository.class).wrap(root);
return root.createRequest()
.withUrlPath("/repos/" + login + '/' + name)
.fetch(GHRepository.class)
.wrap(root);
} catch (FileNotFoundException e) {
return null;
}
@@ -254,7 +262,7 @@ public abstract class GHPerson extends GHObject {
@Override
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -316,4 +324,40 @@ public abstract class GHPerson extends GHObject {
populate();
return followers;
}
/**
* Gets the type. This is either "User" or "Organization".
*
* @return the type
* @throws IOException
* the io exception
*/
public String getType() throws IOException {
populate();
return type;
}
/**
* Gets the site_admin field
*
* @return the site_admin field
* @throws IOException
* the io exception
*/
public boolean isSiteAdmin() throws IOException {
populate();
return site_admin;
}
/**
* Gets total private repo count.
*
* @return the total private repo count
* @throws IOException
* the io exception
*/
public Optional<Integer> getTotalPrivateRepoCount() throws IOException {
populate();
return Optional.ofNullable(total_private_repos);
}
}

View File

@@ -9,7 +9,6 @@ import java.util.HashSet;
*
* @param <T>
* the type parameter
* @author Kohsuke Kawaguchi
*/
public class GHPersonSet<T extends GHPerson> extends HashSet<T> {
private static final long serialVersionUID = 1L;

View File

@@ -33,7 +33,6 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* A GitHub project.
*
* @author Martin van Zijl
* @see <a href="https://developer.github.com/v3/projects/">Projects</a>
*/
public class GHProject extends GHObject {
@@ -51,7 +50,7 @@ public class GHProject extends GHObject {
@Override
public URL getHtmlUrl() throws IOException {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -74,11 +73,17 @@ public class GHProject extends GHObject {
if (owner == null) {
try {
if (owner_url.contains("/orgs/")) {
owner = root.retrieve().to(getOwnerUrl().getPath(), GHOrganization.class).wrapUp(root);
owner = root.createRequest()
.withUrlPath(getOwnerUrl().getPath())
.fetch(GHOrganization.class)
.wrapUp(root);
} else if (owner_url.contains("/users/")) {
owner = root.retrieve().to(getOwnerUrl().getPath(), GHUser.class).wrapUp(root);
owner = root.createRequest().withUrlPath(getOwnerUrl().getPath()).fetch(GHUser.class).wrapUp(root);
} else if (owner_url.contains("/repos/")) {
owner = root.retrieve().to(getOwnerUrl().getPath(), GHRepository.class).wrap(root);
owner = root.createRequest()
.withUrlPath(getOwnerUrl().getPath())
.fetch(GHRepository.class)
.wrap(root);
}
} catch (FileNotFoundException e) {
return null;
@@ -93,7 +98,7 @@ public class GHProject extends GHObject {
* @return the owner url
*/
public URL getOwnerUrl() {
return GitHub.parseURL(owner_url);
return GitHubClient.parseURL(owner_url);
}
/**
@@ -176,7 +181,7 @@ public class GHProject extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
}
/**
@@ -270,7 +275,7 @@ public class GHProject extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute());
root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -282,11 +287,10 @@ public class GHProject extends GHObject {
*/
public PagedIterable<GHProjectColumn> listColumns() throws IOException {
final GHProject project = this;
return root.retrieve()
return root.createRequest()
.withPreview(INERTIA)
.asPagedIterable(String.format("/projects/%d/columns", id),
GHProjectColumn[].class,
item -> item.wrap(project));
.withUrlPath(String.format("/projects/%d/columns", id))
.toIterable(GHProjectColumn[].class, item -> item.wrap(project));
}
/**
@@ -299,11 +303,12 @@ public class GHProject extends GHObject {
* the io exception
*/
public GHProjectColumn createColumn(String name) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("name", name)
.to(String.format("/projects/%d/columns", id), GHProjectColumn.class)
.withUrlPath(String.format("/projects/%d/columns", id))
.fetch(GHProjectColumn.class)
.wrap(this);
}
}

View File

@@ -10,8 +10,6 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* The type GHProjectCard.
*
* @author Gunnar Skjold
*/
public class GHProjectCard extends GHObject {
private GitHub root;
@@ -72,7 +70,7 @@ public class GHProjectCard extends GHObject {
public GHProject getProject() throws IOException {
if (project == null) {
try {
project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root);
project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);
} catch (FileNotFoundException e) {
return null;
}
@@ -90,7 +88,10 @@ public class GHProjectCard extends GHObject {
public GHProjectColumn getColumn() throws IOException {
if (column == null) {
try {
column = root.retrieve().to(getColumnUrl().getPath(), GHProjectColumn.class).wrap(root);
column = root.createRequest()
.withUrlPath(getColumnUrl().getPath())
.fetch(GHProjectColumn.class)
.wrap(root);
} catch (FileNotFoundException e) {
return null;
}
@@ -110,9 +111,12 @@ public class GHProjectCard extends GHObject {
return null;
try {
if (content_url.contains("/pulls")) {
return root.retrieve().to(getContentUrl().getPath(), GHPullRequest.class).wrap(root);
return root.createRequest()
.withUrlPath(getContentUrl().getPath())
.fetch(GHPullRequest.class)
.wrap(root);
} else {
return root.retrieve().to(getContentUrl().getPath(), GHIssue.class).wrap(root);
return root.createRequest().withUrlPath(getContentUrl().getPath()).fetch(GHIssue.class).wrap(root);
}
} catch (FileNotFoundException e) {
return null;
@@ -143,7 +147,7 @@ public class GHProjectCard extends GHObject {
* @return the content url
*/
public URL getContentUrl() {
return GitHub.parseURL(content_url);
return GitHubClient.parseURL(content_url);
}
/**
@@ -152,7 +156,7 @@ public class GHProjectCard extends GHObject {
* @return the project url
*/
public URL getProjectUrl() {
return GitHub.parseURL(project_url);
return GitHubClient.parseURL(project_url);
}
/**
@@ -161,7 +165,7 @@ public class GHProjectCard extends GHObject {
* @return the column url
*/
public URL getColumnUrl() {
return GitHub.parseURL(column_url);
return GitHubClient.parseURL(column_url);
}
/**
@@ -198,7 +202,7 @@ public class GHProjectCard extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
}
/**
@@ -217,6 +221,6 @@ public class GHProjectCard extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute());
root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();
}
}

View File

@@ -8,8 +8,6 @@ import static org.kohsuke.github.Previews.INERTIA;
/**
* The type GHProjectColumn.
*
* @author Gunnar Skjold
*/
public class GHProjectColumn extends GHObject {
protected GitHub root;
@@ -67,7 +65,7 @@ public class GHProjectColumn extends GHObject {
public GHProject getProject() throws IOException {
if (project == null) {
try {
project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root);
project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);
} catch (FileNotFoundException e) {
return null;
}
@@ -90,7 +88,7 @@ public class GHProjectColumn extends GHObject {
* @return the project url
*/
public URL getProjectUrl() {
return GitHub.parseURL(project_url);
return GitHubClient.parseURL(project_url);
}
/**
@@ -106,7 +104,7 @@ public class GHProjectColumn extends GHObject {
}
private void edit(String key, Object value) throws IOException {
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
}
/**
@@ -125,7 +123,7 @@ public class GHProjectColumn extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).withPreview(INERTIA).method("DELETE").to(getApiRoute());
root.createRequest().withPreview(INERTIA).method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -137,11 +135,10 @@ public class GHProjectColumn extends GHObject {
*/
public PagedIterable<GHProjectCard> listCards() throws IOException {
final GHProjectColumn column = this;
return root.retrieve()
return root.createRequest()
.withPreview(INERTIA)
.asPagedIterable(String.format("/projects/columns/%d/cards", id),
GHProjectCard[].class,
item -> item.wrap(column));
.withUrlPath(String.format("/projects/columns/%d/cards", id))
.toIterable(GHProjectCard[].class, item -> item.wrap(column));
}
/**
@@ -154,11 +151,12 @@ public class GHProjectColumn extends GHObject {
* the io exception
*/
public GHProjectCard createCard(String note) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("note", note)
.to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class)
.withUrlPath(String.format("/projects/columns/%d/cards", id))
.fetch(GHProjectCard.class)
.wrap(this);
}
@@ -172,12 +170,13 @@ public class GHProjectColumn extends GHObject {
* the io exception
*/
public GHProjectCard createCard(GHIssue issue) throws IOException {
return root.retrieve()
return root.createRequest()
.method("POST")
.withPreview(INERTIA)
.with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")
.with("content_id", issue.getId())
.to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class)
.withUrlPath(String.format("/projects/columns/%d/cards", id))
.fetch(GHProjectCard.class)
.wrap(this);
}
}

View File

@@ -23,6 +23,8 @@
*/
package org.kohsuke.github;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@@ -39,7 +41,6 @@ import static org.kohsuke.github.Previews.SHADOW_CAT;
/**
* A pull request.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#getPullRequest(int) GHRepository#getPullRequest(int)
*/
@SuppressWarnings({ "UnusedDeclaration" })
@@ -99,6 +100,10 @@ public class GHPullRequest extends GHIssue implements Refreshable {
@Override
protected String getApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
}
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
}
@@ -108,7 +113,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the patch url
*/
public URL getPatchUrl() {
return GitHub.parseURL(patch_url);
return GitHubClient.parseURL(patch_url);
}
/**
@@ -117,7 +122,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the issue url
*/
public URL getIssueUrl() {
return GitHub.parseURL(issue_url);
return GitHubClient.parseURL(issue_url);
}
/**
@@ -156,7 +161,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the diff url
*/
public URL getDiffUrl() {
return GitHub.parseURL(diff_url);
return GitHubClient.parseURL(diff_url);
}
/**
@@ -165,7 +170,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the merged at
*/
public Date getMergedAt() {
return GitHub.parseDate(merged_at);
return GitHubClient.parseDate(merged_at);
}
@Override
@@ -384,7 +389,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
if (root.isOffline()) {
return; // cannot populate, will have to live with what we have
}
root.retrieve().withPreview(SHADOW_CAT).to(url, this).wrapUp(owner);
root.createRequest().withPreview(SHADOW_CAT).withUrlPath(url).fetchInto(this).wrapUp(owner);
}
/**
@@ -393,8 +398,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the paged iterable
*/
public PagedIterable<GHPullRequestFileDetail> listFiles() {
return root.retrieve()
.asPagedIterable(String.format("%s/files", getApiRoute()), GHPullRequestFileDetail[].class, null);
return root.createRequest()
.withUrlPath(String.format("%s/files", getApiRoute()))
.toIterable(GHPullRequestFileDetail[].class, null);
}
/**
@@ -403,10 +409,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the paged iterable
*/
public PagedIterable<GHPullRequestReview> listReviews() {
return root.retrieve()
.asPagedIterable(String.format("%s/reviews", getApiRoute()),
GHPullRequestReview[].class,
item -> item.wrapUp(GHPullRequest.this));
return root.createRequest()
.withUrlPath(String.format("%s/reviews", getApiRoute()))
.toIterable(GHPullRequestReview[].class, item -> item.wrapUp(this));
}
/**
@@ -417,10 +422,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
*/
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
return root.retrieve()
.asPagedIterable(getApiRoute() + COMMENTS_ACTION,
GHPullRequestReviewComment[].class,
item -> item.wrapUp(GHPullRequest.this));
return root.createRequest()
.withUrlPath(getApiRoute() + COMMENTS_ACTION)
.toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(this));
}
/**
@@ -429,10 +433,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* @return the paged iterable
*/
public PagedIterable<GHPullRequestCommitDetail> listCommits() {
return root.retrieve()
.asPagedIterable(String.format("%s/commits", getApiRoute()),
GHPullRequestCommitDetail[].class,
item -> item.wrapUp(GHPullRequest.this));
return root.createRequest()
.withUrlPath(String.format("%s/commits", getApiRoute()))
.toIterable(GHPullRequestCommitDetail[].class, item -> item.wrapUp(this));
}
/**
@@ -505,12 +508,14 @@ public class GHPullRequest extends GHIssue implements Refreshable {
*/
public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position)
throws IOException {
return new Requester(root).method("POST")
return root.createRequest()
.method("POST")
.with("body", body)
.with("commit_id", sha)
.with("path", path)
.with("position", position)
.to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class)
.withUrlPath(getApiRoute() + COMMENTS_ACTION)
.fetch(GHPullRequestReviewComment.class)
.wrapUp(this);
}
@@ -523,9 +528,11 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
*/
public void requestReviewers(List<GHUser> reviewers) throws IOException {
new Requester(root).method("POST")
root.createRequest()
.method("POST")
.with("reviewers", getLogins(reviewers))
.to(getApiRoute() + REQUEST_REVIEWERS);
.withUrlPath(getApiRoute() + REQUEST_REVIEWERS)
.send();
}
/**
@@ -541,7 +548,11 @@ public class GHPullRequest extends GHIssue implements Refreshable {
for (GHTeam team : teams) {
teamReviewers.add(team.getSlug());
}
new Requester(root).method("POST").with("team_reviewers", teamReviewers).to(getApiRoute() + REQUEST_REVIEWERS);
root.createRequest()
.method("POST")
.with("team_reviewers", teamReviewers)
.withUrlPath(getApiRoute() + REQUEST_REVIEWERS)
.send();
}
/**
@@ -589,11 +600,13 @@ public class GHPullRequest extends GHIssue implements Refreshable {
* the io exception
*/
public void merge(String msg, String sha, MergeMethod method) throws IOException {
new Requester(root).method("PUT")
root.createRequest()
.method("PUT")
.with("commit_message", msg)
.with("sha", sha)
.with("merge_method", method)
.to(getApiRoute() + "/merge");
.withUrlPath(getApiRoute() + "/merge")
.send();
}
/**
@@ -605,7 +618,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
private void fetchIssue() throws IOException {
if (!fetchedIssueDetails) {
new Requester(root).method("GET").to(getIssuesApiRoute(), this);
root.createRequest().withUrlPath(getIssuesApiRoute()).fetchInto(this);
fetchedIssueDetails = true;
}
}

View File

@@ -31,7 +31,6 @@ import java.net.URL;
/**
* Commit detail inside a {@link GHPullRequest}.
*
* @author Luca Milanesio
* @see GHPullRequest#listCommits() GHPullRequest#listCommits()
*/
@SuppressFBWarnings(
@@ -75,7 +74,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
}
@@ -125,7 +124,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -161,7 +160,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -170,7 +169,7 @@ public class GHPullRequestCommitDetail {
* @return the html url
*/
public URL getHtml_url() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -214,7 +213,7 @@ public class GHPullRequestCommitDetail {
* @return the api url
*/
public URL getApiUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -223,7 +222,7 @@ public class GHPullRequestCommitDetail {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -232,7 +231,7 @@ public class GHPullRequestCommitDetail {
* @return the comments url
*/
public URL getCommentsUrl() {
return GitHub.parseURL(comments_url);
return GitHubClient.parseURL(comments_url);
}
/**

View File

@@ -28,7 +28,6 @@ import java.net.URL;
/**
* File detail inside a {@link GHPullRequest}.
*
* @author Julien Henry
* @see GHPullRequest#listFiles() GHPullRequest#listFiles()
*/
public class GHPullRequestFileDetail {
@@ -105,7 +104,7 @@ public class GHPullRequestFileDetail {
* @return the blob url
*/
public URL getBlobUrl() {
return GitHub.parseURL(blob_url);
return GitHubClient.parseURL(blob_url);
}
/**
@@ -114,7 +113,7 @@ public class GHPullRequestFileDetail {
* @return the raw url
*/
public URL getRawUrl() {
return GitHub.parseURL(raw_url);
return GitHubClient.parseURL(raw_url);
}
/**
@@ -123,7 +122,7 @@ public class GHPullRequestFileDetail {
* @return the contents url
*/
public URL getContentsUrl() {
return GitHub.parseURL(contents_url);
return GitHubClient.parseURL(contents_url);
}
/**

View File

@@ -5,7 +5,6 @@ import static org.kohsuke.github.Previews.SHADOW_CAT;
/**
* Lists up pull requests with some filtering and sorting.
*
* @author Kohsuke Kawaguchi
* @see GHRepository#queryPullRequests() GHRepository#queryPullRequests()
*/
public class GHPullRequestQueryBuilder extends GHQueryBuilder<GHPullRequest> {
@@ -89,6 +88,7 @@ public class GHPullRequestQueryBuilder extends GHQueryBuilder<GHPullRequest> {
@Override
public PagedIterable<GHPullRequest> list() {
return req.withPreview(SHADOW_CAT)
.asPagedIterable(repo.getApiTailUrl("pulls"), GHPullRequest[].class, item -> item.wrapUp(repo));
.withUrlPath(repo.getApiTailUrl("pulls"))
.toIterable(GHPullRequest[].class, item -> item.wrapUp(repo));
}
}

View File

@@ -122,7 +122,7 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public Date getSubmittedAt() throws IOException {
return GitHub.parseDate(submitted_at);
return GitHubClient.parseDate(submitted_at);
}
/**
@@ -160,10 +160,12 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public void submit(String body, GHPullRequestReviewEvent event) throws IOException {
new Requester(owner.root).method("POST")
owner.root.createRequest()
.method("POST")
.with("body", body)
.with("event", event.action())
.to(getApiRoute() + "/events", this);
.withUrlPath(getApiRoute() + "/events")
.fetchInto(this);
this.body = body;
this.state = event.toState();
}
@@ -175,7 +177,7 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -187,7 +189,11 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public void dismiss(String message) throws IOException {
new Requester(owner.root).method("PUT").with("message", message).to(getApiRoute() + "/dismissals");
owner.root.createRequest()
.method("PUT")
.with("message", message)
.withUrlPath(getApiRoute() + "/dismissals")
.send();
state = GHPullRequestReviewState.DISMISSED;
}
@@ -199,9 +205,8 @@ public class GHPullRequestReview extends GHObject {
* the io exception
*/
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
return owner.root.retrieve()
.asPagedIterable(getApiRoute() + "/comments",
GHPullRequestReviewComment[].class,
item -> item.wrapUp(owner));
return owner.root.createRequest()
.withUrlPath(getApiRoute() + "/comments")
.toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(owner));
}
}

View File

@@ -7,7 +7,6 @@ import java.util.List;
/**
* Builds up a creation of new {@link GHPullRequestReview}.
*
* @author Kohsuke Kawaguchi
* @see GHPullRequest#createReview() GHPullRequest#createReview()
*/
public class GHPullRequestReviewBuilder {
@@ -17,7 +16,7 @@ public class GHPullRequestReviewBuilder {
GHPullRequestReviewBuilder(GHPullRequest pr) {
this.pr = pr;
this.builder = new Requester(pr.root);
this.builder = pr.root.createRequest();
}
// public GHPullRequestReview createReview(@Nullable String commitId, String body, GHPullRequestReviewEvent event,
@@ -91,7 +90,8 @@ public class GHPullRequestReviewBuilder {
public GHPullRequestReview create() throws IOException {
return builder.method("POST")
.with("comments", comments)
.to(pr.getApiRoute() + "/reviews", GHPullRequestReview.class)
.withUrlPath(pr.getApiRoute() + "/reviews")
.fetch(GHPullRequestReview.class)
.wrapUp(pr);
}

View File

@@ -33,7 +33,6 @@ import static org.kohsuke.github.Previews.*;
/**
* Review comment to the pull request
*
* @author Julien Henry
* @see GHPullRequest#listReviewComments() GHPullRequest#listReviewComments()
* @see GHPullRequest#createReviewComment(String, String, String, int) GHPullRequest#createReviewComment(String, String,
* String, int)
@@ -163,7 +162,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* the io exception
*/
public void update(String body) throws IOException {
new Requester(owner.root).method("PATCH").with("body", body).to(getApiRoute(), this);
owner.root.createRequest().method("PATCH").with("body", body).withUrlPath(getApiRoute()).fetchInto(this);
this.body = body;
}
@@ -174,7 +173,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* the io exception
*/
public void delete() throws IOException {
new Requester(owner.root).method("DELETE").to(getApiRoute());
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
@@ -187,27 +186,33 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* the io exception
*/
public GHPullRequestReviewComment reply(String body) throws IOException {
return new Requester(owner.root).method("POST")
return owner.root.createRequest()
.method("POST")
.with("body", body)
.with("in_reply_to", getId())
.to(getApiRoute() + "/comments", GHPullRequestReviewComment.class)
.withUrlPath(getApiRoute() + "/comments")
.fetch(GHPullRequestReviewComment.class)
.wrapUp(owner);
}
@Preview
@Deprecated
public GHReaction createReaction(ReactionContent content) throws IOException {
return new Requester(owner.root).withPreview(SQUIRREL_GIRL)
return owner.root.createRequest()
.method("POST")
.withPreview(SQUIRREL_GIRL)
.with("content", content.getContent())
.to(getApiRoute() + "/reactions", GHReaction.class)
.withUrlPath(getApiRoute() + "/reactions")
.fetch(GHReaction.class)
.wrap(owner.root);
}
@Preview
@Deprecated
public PagedIterable<GHReaction> listReactions() {
return owner.root.retrieve()
return owner.root.createRequest()
.withPreview(SQUIRREL_GIRL)
.asPagedIterable(getApiRoute() + "/reactions", GHReaction[].class, item -> item.wrap(owner.root));
.withUrlPath(getApiRoute() + "/reactions")
.toIterable(GHReaction[].class, item -> item.wrap(owner.root));
}
}

View File

@@ -5,7 +5,6 @@ package org.kohsuke.github;
*
* @param <T>
* the type parameter
* @author Kohsuke Kawaguchi
*/
public abstract class GHQueryBuilder<T> {
protected final GitHub root;
@@ -13,7 +12,7 @@ public abstract class GHQueryBuilder<T> {
GHQueryBuilder(GitHub root) {
this.root = root;
this.req = root.retrieve();
this.req = root.createRequest();
}
/**

View File

@@ -12,14 +12,13 @@ import java.util.Date;
import java.util.Objects;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import static java.util.logging.Level.FINEST;
/**
* Rate limit.
*
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHRateLimit {
@@ -41,7 +40,10 @@ public class GHRateLimit {
public int limit;
/**
* The time at which the current rate limit window resets in UTC epoch seconds. NOTE: that means to
* The time at which the current rate limit window resets in UTC epoch seconds. WARNING: this field was implemented
* using {@link Date#Date(long)} which expects UTC epoch milliseconds, so this Date instance is meaningless as a
* date. To use this field in any meaningful way, it must be converted to a long using {@link Date#getTime()}
* multiplied by 1000.
*
* @deprecated This value should never have been made public. Use {@link #getResetDate()}
*/
@@ -60,6 +62,7 @@ public class GHRateLimit {
@Nonnull
private final Record integrationManifest;
@Nonnull
static GHRateLimit Unknown() {
return new GHRateLimit(new UnknownLimitRecord(),
new UnknownLimitRecord(),
@@ -67,6 +70,7 @@ public class GHRateLimit {
new UnknownLimitRecord());
}
@Nonnull
static GHRateLimit fromHeaderRecord(Record header) {
return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord());
}
@@ -76,6 +80,12 @@ public class GHRateLimit {
@Nonnull @JsonProperty("search") Record search,
@Nonnull @JsonProperty("graphql") Record graphql,
@Nonnull @JsonProperty("integration_manifest") Record integrationManifest) {
// The Nonnull annotation is ignored by Jackson, we have to check manually
Objects.requireNonNull(core);
Objects.requireNonNull(search);
Objects.requireNonNull(graphql);
Objects.requireNonNull(integrationManifest);
this.core = core;
this.search = search;
this.graphql = graphql;
@@ -84,6 +94,7 @@ public class GHRateLimit {
// Deprecated fields
this.remaining = core.getRemaining();
this.limit = core.getLimit();
// This is wrong but is how this was implemented. Kept for backward compat.
this.reset = new Date(core.getResetEpochSeconds());
}
@@ -206,6 +217,28 @@ public class GHRateLimit {
return Objects.hash(getCore(), getSearch(), getGraphQL(), getIntegrationManifest());
}
/**
* Gets the appropriate {@link Record} for a particular url path.
*
* @param urlPath
* the url path of the request
* @return the {@link Record} for a url path.
*/
@Nonnull
Record getRecordForUrlPath(@Nonnull String urlPath) {
if (urlPath.equals("/rate_limit")) {
return new UnknownLimitRecord();
} else if (urlPath.startsWith("/search")) {
return getSearch();
} else if (urlPath.startsWith("/graphql")) {
return getGraphQL();
} else if (urlPath.startsWith("/app-manifests")) {
return getIntegrationManifest();
} else {
return getCore();
}
}
/**
* A limit record used as a placeholder when the the actual limit is not known.
* <p>
@@ -244,6 +277,8 @@ public class GHRateLimit {
/**
* The time at which the current rate limit window resets in UTC epoch seconds.
*
* This is the raw value returned by the server.
*/
private final long resetEpochSeconds;
@@ -253,8 +288,12 @@ public class GHRateLimit {
private final long createdAtEpochSeconds = System.currentTimeMillis() / 1000;
/**
* The calculated time at which the rate limit will reset. Recalculated if {@link #recalculateResetDate} is
* called.
* The time at which the rate limit will reset. This value is calculated based on
* {@link #getResetEpochSeconds()} by calling {@link #recalculateResetDate}. If the clock on the local machine
* not synchronized with the server clock, this time value will be adjusted to match the local machine's clock.
* <p>
* Recalculated by calling {@link #recalculateResetDate}.
* </p>
*/
@Nonnull
private Date resetDate;
@@ -270,9 +309,9 @@ public class GHRateLimit {
* the reset epoch seconds
*/
@JsonCreator
public Record(@JsonProperty("limit") int limit,
@JsonProperty("remaining") int remaining,
@JsonProperty("reset") long resetEpochSeconds) {
public Record(@JsonProperty(value = "limit", required = true) int limit,
@JsonProperty(value = "remaining", required = true) int remaining,
@JsonProperty(value = "reset", required = true) long resetEpochSeconds) {
this(limit, remaining, resetEpochSeconds, null);
}
@@ -289,7 +328,7 @@ public class GHRateLimit {
* the updated at
*/
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "Deprecated")
public Record(int limit, int remaining, long resetEpochSeconds, String updatedAt) {
public Record(int limit, int remaining, long resetEpochSeconds, @CheckForNull String updatedAt) {
this.limit = limit;
this.remaining = remaining;
this.resetEpochSeconds = resetEpochSeconds;
@@ -297,14 +336,33 @@ public class GHRateLimit {
}
/**
* Recalculates the reset date using the server response date to calculate a time duration and then add that to
* the local created time for this record.
* Recalculates the {@link #resetDate} relative to the local machine clock.
* <p>
* {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetDate()} to make decisions about
* how long to wait for until for the rate limit to reset. That means that {@link #getResetDate()} needs to be
* accurate to the local machine.
* </p>
* <p>
* When we say that the clock on two machines is "synchronized", we mean that the UTC time returned from
* {@link System#currentTimeMillis()} on each machine is basically the same. For the purposes of rate limits an
* differences of up to a second can be ignored.
* </p>
* <p>
* When the clock on the local machine is synchronized to the same time as the clock on the GitHub server (via a
* time service for example), the {@link #resetDate} generated directly from {@link #resetEpochSeconds} will be
* accurate for the local machine as well.
* </p>
* <p>
* When the clock on the local machine is not synchronized with the server, the {@link #resetDate} must be
* recalculated relative to the local machine clock. This is done by taking the number of seconds between the
* response "Date" header and {@link #resetEpochSeconds} and then adding that to this record's
* {@link #createdAtEpochSeconds}.
*
* @param updatedAt
* a string date in RFC 1123
* @return reset date based on the passed date
*/
Date recalculateResetDate(String updatedAt) {
Date recalculateResetDate(@CheckForNull String updatedAt) {
long updatedAtEpochSeconds = createdAtEpochSeconds;
if (!StringUtils.isBlank(updatedAt)) {
try {
@@ -319,7 +377,7 @@ public class GHRateLimit {
}
// This may seem odd but it results in an accurate or slightly pessimistic reset date
// based on system time rather than on the system being in sync with the server
// based on system time rather than assuming the system time synchronized with the server
long calculatedSecondsUntilReset = resetEpochSeconds - updatedAtEpochSeconds;
return resetDate = new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
}
@@ -345,14 +403,19 @@ public class GHRateLimit {
/**
* Gets the time in epoch seconds when the rate limit will reset.
*
* @return a long
* This is the raw value returned by the server. This value is not adjusted if local machine time is not
* synchronized with server time. If attempting to check when the rate limit will reset, use
* {@link #getResetDate()} or implement a {@link RateLimitChecker} instead.
*
* @return a long representing the time in epoch seconds when the rate limit will reset
* @see #getResetDate() #getResetDate()
*/
public long getResetEpochSeconds() {
return resetEpochSeconds;
}
/**
* Whether the rate limit reset date indicated by this instance is in the
* Whether the rate limit reset date indicated by this instance is expired
*
* @return true if the rate limit reset date has passed. Otherwise false.
*/
@@ -361,7 +424,10 @@ public class GHRateLimit {
}
/**
* Returns the date at which the rate limit will reset.
* Returns the date at which the rate limit will reset, adjusted to local machine time if the local machine's
* clock not synchronized with to the same clock as the GitHub server.
*
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
*
* @return the calculated date at which the rate limit has or will reset.
*/

View File

@@ -8,7 +8,6 @@ import static org.kohsuke.github.Previews.*;
/**
* Reaction to issue, comment, PR, and so on.
*
* @author Kohsuke Kawaguchi
* @see Reactable
*/
@Preview
@@ -58,6 +57,6 @@ public class GHReaction extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").withPreview(SQUIRREL_GIRL).to("/reactions/" + id);
root.createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + id).send();
}
}

View File

@@ -7,8 +7,6 @@ import java.net.URL;
/**
* Provides information on a Git ref from GitHub.
*
* @author Michael Clarke
*/
public class GHRef {
/* package almost final */ GitHub root;
@@ -31,7 +29,7 @@ public class GHRef {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
/**
@@ -66,7 +64,13 @@ public class GHRef {
* the io exception
*/
public void updateTo(String sha, Boolean force) throws IOException {
new Requester(root).with("sha", sha).with("force", force).method("PATCH").to(url, GHRef.class).wrap(root);
root.createRequest()
.method("PATCH")
.with("sha", sha)
.with("force", force)
.withUrlPath(url)
.fetch(GHRef.class)
.wrap(root);
}
/**
@@ -76,7 +80,7 @@ public class GHRef {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to(url);
root.createRequest().method("DELETE").withUrlPath(url).send();
}
GHRef wrap(GitHub root) {
@@ -125,7 +129,7 @@ public class GHRef {
* @return the url
*/
public URL getUrl() {
return GitHub.parseURL(url);
return GitHubClient.parseURL(url);
}
}
}

View File

@@ -77,7 +77,7 @@ public class GHRelease extends GHObject {
}
public URL getHtmlUrl() {
return GitHub.parseURL(html_url);
return GitHubClient.parseURL(html_url);
}
/**
@@ -240,12 +240,12 @@ public class GHRelease extends GHObject {
* the io exception
*/
public GHAsset uploadAsset(String filename, InputStream stream, String contentType) throws IOException {
Requester builder = new Requester(owner.root);
Requester builder = owner.root.createRequest().method("POST");
String url = getUploadUrl();
// strip the helpful garbage from the url
url = url.substring(0, url.indexOf('{'));
url += "?name=" + URLEncoder.encode(filename, "UTF-8");
return builder.contentType(contentType).with(stream).to(url, GHAsset.class).wrap(this);
return builder.contentType(contentType).with(stream).withUrlPath(url).fetch(GHAsset.class).wrap(this);
}
/**
@@ -256,9 +256,9 @@ public class GHRelease extends GHObject {
* the io exception
*/
public List<GHAsset> getAssets() throws IOException {
Requester builder = new Requester(owner.root);
Requester builder = owner.root.createRequest();
GHAsset[] assets = builder.method("GET").to(getApiTailUrl("assets"), GHAsset[].class);
GHAsset[] assets = builder.withUrlPath(getApiTailUrl("assets")).fetchArray(GHAsset[].class);
return Arrays.asList(GHAsset.wrap(assets, this));
}
@@ -269,7 +269,7 @@ public class GHRelease extends GHObject {
* the io exception
*/
public void delete() throws IOException {
new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/" + id));
root.createRequest().method("DELETE").withUrlPath(owner.getApiTailUrl("releases/" + id)).send();
}
/**

View File

@@ -21,7 +21,7 @@ public class GHReleaseBuilder {
*/
public GHReleaseBuilder(GHRepository ghRepository, String tag) {
this.repo = ghRepository;
this.builder = new Requester(repo.root);
this.builder = repo.root.createRequest().method("POST");
builder.with("tag_name", tag);
}
@@ -95,6 +95,6 @@ public class GHReleaseBuilder {
* the io exception
*/
public GHRelease create() throws IOException {
return builder.to(repo.getApiTailUrl("releases"), GHRelease.class).wrap(repo);
return builder.withUrlPath(repo.getApiTailUrl("releases")).fetch(GHRelease.class).wrap(repo);
}
}

Some files were not shown because too many files have changed in this diff Show More