mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-11 00:11:25 +00:00
Compare commits
594 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7a792251a | ||
|
|
aec2308144 | ||
|
|
0741b8aa6a | ||
|
|
3082622394 | ||
|
|
965c9cb0af | ||
|
|
495a46e2d8 | ||
|
|
05bda1192e | ||
|
|
6058af0ca1 | ||
|
|
1eb8bf9719 | ||
|
|
afc02faeda | ||
|
|
66f22de90f | ||
|
|
2949a2e0ff | ||
|
|
ba12efea9d | ||
|
|
e1180a12fb | ||
|
|
1393706f13 | ||
|
|
6f994f31f7 | ||
|
|
38aa99a063 | ||
|
|
85c44b3529 | ||
|
|
e1a2768de5 | ||
|
|
e1c9b27203 | ||
|
|
969f6ef826 | ||
|
|
7abc4d4e76 | ||
|
|
ac97147c1f | ||
|
|
dbd20fe396 | ||
|
|
44e57c9c4b | ||
|
|
488e5e531f | ||
|
|
42a6a8d770 | ||
|
|
f8e877ea05 | ||
|
|
65d6fc7272 | ||
|
|
63ce8e461b | ||
|
|
fbf4c48461 | ||
|
|
81a55db644 | ||
|
|
4d4edfa181 | ||
|
|
6f9182f1f6 | ||
|
|
fa600c03e2 | ||
|
|
4a53301e9f | ||
|
|
676984b3d5 | ||
|
|
e6d7f7248b | ||
|
|
50903b5c4a | ||
|
|
01e399fb91 | ||
|
|
911aeb7af0 | ||
|
|
7e5cd9abbc | ||
|
|
115527a21a | ||
|
|
eff4f4f601 | ||
|
|
16e0099a0d | ||
|
|
2c8c678275 | ||
|
|
3b51e87fbf | ||
|
|
6c6eef5e2b | ||
|
|
6e5910f44c | ||
|
|
a967189bc6 | ||
|
|
7069176cf6 | ||
|
|
44dcbe773d | ||
|
|
ca76975461 | ||
|
|
83122ac99e | ||
|
|
c3e9458555 | ||
|
|
057ba38873 | ||
|
|
81d7d6236b | ||
|
|
191dd49653 | ||
|
|
21e9dd6f51 | ||
|
|
cc2d14acc6 | ||
|
|
87f37e9f1c | ||
|
|
d536a9f874 | ||
|
|
b45f353fa9 | ||
|
|
a3073ec14e | ||
|
|
f77eb33029 | ||
|
|
c1c919097a | ||
|
|
e05348463c | ||
|
|
fdcf74eaf2 | ||
|
|
6d57a3e3b9 | ||
|
|
1f449c866e | ||
|
|
e12deccd24 | ||
|
|
3184ebb5ee | ||
|
|
4a35ed2b35 | ||
|
|
5c9474d1c8 | ||
|
|
2321dc50c5 | ||
|
|
4efd2e8184 | ||
|
|
e30e153bfa | ||
|
|
2724211535 | ||
|
|
81068de0f1 | ||
|
|
7d842175f7 | ||
|
|
e0aee9f361 | ||
|
|
df576e2738 | ||
|
|
bb1356b25d | ||
|
|
1b67960da4 | ||
|
|
d76718e8b2 | ||
|
|
76c51922f1 | ||
|
|
f95e89a136 | ||
|
|
2dff60a23c | ||
|
|
95f83d1a29 | ||
|
|
b875ccecc1 | ||
|
|
e4c3802f16 | ||
|
|
081e485f4f | ||
|
|
4adf88da19 | ||
|
|
31e2b1b8d3 | ||
|
|
bd28abd343 | ||
|
|
955690b124 | ||
|
|
fa6f06ae15 | ||
|
|
263de140c5 | ||
|
|
ed85d06d69 | ||
|
|
4ff0870df8 | ||
|
|
410bac2040 | ||
|
|
38b1e367b1 | ||
|
|
3cddffa37f | ||
|
|
ea7a1a7175 | ||
|
|
36b5601588 | ||
|
|
7fc68f2969 | ||
|
|
c5ee07add4 | ||
|
|
32ff315b6b | ||
|
|
f919346f8f | ||
|
|
279df00404 | ||
|
|
bfd4b17fa0 | ||
|
|
5fe2817164 | ||
|
|
b337bb39bc | ||
|
|
65ae41c5f1 | ||
|
|
796c644c4a | ||
|
|
bfd9023a27 | ||
|
|
c9cdf5d03e | ||
|
|
f60bb41ad9 | ||
|
|
c333903b4a | ||
|
|
dd55e8a22c | ||
|
|
3ab9381d0a | ||
|
|
58f1fe0671 | ||
|
|
82b9c05d0f | ||
|
|
7c9397f7f6 | ||
|
|
6214b6a3ff | ||
|
|
883c8cc4c8 | ||
|
|
8d47c72913 | ||
|
|
89a6664e45 | ||
|
|
30d792d6e1 | ||
|
|
3745bf3157 | ||
|
|
a7fda3e50d | ||
|
|
7f07204fef | ||
|
|
8b51a44b7c | ||
|
|
c499c73dcc | ||
|
|
c01f3f5e8a | ||
|
|
2aef35655f | ||
|
|
7ddf1f5830 | ||
|
|
b2c513ea42 | ||
|
|
4c30f94355 | ||
|
|
e911e86c4c | ||
|
|
ca640b3f64 | ||
|
|
b4c4a05f3b | ||
|
|
fd3c36a259 | ||
|
|
d8274ac2d4 | ||
|
|
9c7479f953 | ||
|
|
b5dc3c4366 | ||
|
|
26b8082155 | ||
|
|
418df15f7b | ||
|
|
31ed0125b8 | ||
|
|
494318b879 | ||
|
|
f554ddc372 | ||
|
|
03de12c221 | ||
|
|
6c41f22b57 | ||
|
|
7ae96388e3 | ||
|
|
e8b4de00d2 | ||
|
|
cd7963b30d | ||
|
|
0dc44cffcf | ||
|
|
7a650132c5 | ||
|
|
c7fb390c38 | ||
|
|
572ff9df19 | ||
|
|
b715e0cef7 | ||
|
|
36ab2a889f | ||
|
|
a78d2f28d7 | ||
|
|
7d5a39ed89 | ||
|
|
772272ff36 | ||
|
|
2ab4eafee9 | ||
|
|
b15e0d4c45 | ||
|
|
b8180314d8 | ||
|
|
fcb8d03a0f | ||
|
|
09ec89bc2e | ||
|
|
863ad0f486 | ||
|
|
79a1bb3571 | ||
|
|
9f1d7323c7 | ||
|
|
64a82f4785 | ||
|
|
f37e4bd76e | ||
|
|
98ef2cc640 | ||
|
|
134222fd69 | ||
|
|
0cb2371517 | ||
|
|
b7de4359fd | ||
|
|
2607d6a107 | ||
|
|
db46b1ce13 | ||
|
|
d7b08d5207 | ||
|
|
29fbba832c | ||
|
|
fd621a442a | ||
|
|
a1a73568ae | ||
|
|
3daccbd6ec | ||
|
|
293deadb48 | ||
|
|
452b56c47b | ||
|
|
5cb6bfa633 | ||
|
|
0515cee6f3 | ||
|
|
4247112539 | ||
|
|
8d3374f574 | ||
|
|
26833e5f7c | ||
|
|
6752b46f67 | ||
|
|
b9429ffcaa | ||
|
|
10827c7e21 | ||
|
|
23cb4a34a4 | ||
|
|
adfd09565f | ||
|
|
78b9ff49d4 | ||
|
|
fca425d25e | ||
|
|
1a4238156c | ||
|
|
f6210cc014 | ||
|
|
6c8b466e59 | ||
|
|
2aebe97f9f | ||
|
|
157724bff8 | ||
|
|
6cbb1a0bee | ||
|
|
960a13dd38 | ||
|
|
9213f80435 | ||
|
|
bccae94c7a | ||
|
|
d71f77ce06 | ||
|
|
2787f3dc71 | ||
|
|
fb00baab5b | ||
|
|
9e22155d31 | ||
|
|
963373435d | ||
|
|
377987fa92 | ||
|
|
0b6980639e | ||
|
|
4f1cc9f94f | ||
|
|
6e5434a0ec | ||
|
|
3244f7c38f | ||
|
|
f27b676e89 | ||
|
|
4f2a80a4a3 | ||
|
|
a51bc27829 | ||
|
|
4fd321c93d | ||
|
|
bbd62bdef5 | ||
|
|
4bb1d78939 | ||
|
|
53c37ef413 | ||
|
|
a6511b6c5a | ||
|
|
829e96a2d0 | ||
|
|
2e25f37433 | ||
|
|
fbf6c73226 | ||
|
|
aab54e3f23 | ||
|
|
a6eff7fbfb | ||
|
|
d5667d2473 | ||
|
|
a42305dd59 | ||
|
|
c22a718d14 | ||
|
|
d0b23c79e2 | ||
|
|
76da04afd8 | ||
|
|
768f60709f | ||
|
|
8cd3acd318 | ||
|
|
ce7cfc0648 | ||
|
|
8b6cf55473 | ||
|
|
75d95d844c | ||
|
|
f54bfd3fb5 | ||
|
|
f8a8ee9b9d | ||
|
|
16faaae199 | ||
|
|
375417527b | ||
|
|
10b01ca6b3 | ||
|
|
f9006af04c | ||
|
|
57f947576e | ||
|
|
5a8f8c345b | ||
|
|
e96067e3c8 | ||
|
|
2242174515 | ||
|
|
73179c118b | ||
|
|
5b575134fc | ||
|
|
c11c06b896 | ||
|
|
ba8d2a251f | ||
|
|
c9589b73f4 | ||
|
|
32f4425100 | ||
|
|
05e81484f1 | ||
|
|
10cc79f737 | ||
|
|
957d9b180d | ||
|
|
883204fc43 | ||
|
|
6d3904fbbd | ||
|
|
56a51f18e7 | ||
|
|
307508b7a0 | ||
|
|
66fce79427 | ||
|
|
5e5708d8d4 | ||
|
|
944d92bbb4 | ||
|
|
0155d5aa39 | ||
|
|
fe4f45c2b0 | ||
|
|
1b63a58e63 | ||
|
|
46a141db9c | ||
|
|
66de06956c | ||
|
|
713dd62bd1 | ||
|
|
5ac65aafad | ||
|
|
4aef92e6fe | ||
|
|
a1b0e771e5 | ||
|
|
5baeac4706 | ||
|
|
87aa9bd673 | ||
|
|
2ec5ca56d5 | ||
|
|
b5c7f83ec8 | ||
|
|
eb3ebdbf52 | ||
|
|
c60698ff7e | ||
|
|
f8c2cda257 | ||
|
|
48f6c195e0 | ||
|
|
804fa60317 | ||
|
|
d77b99d3d4 | ||
|
|
006f1271d6 | ||
|
|
0d14514712 | ||
|
|
f25e5f9488 | ||
|
|
9e8bbfd175 | ||
|
|
3d11c96e23 | ||
|
|
a670737ca5 | ||
|
|
9fdd982e73 | ||
|
|
8024918e08 | ||
|
|
cda7607e1c | ||
|
|
816c83c80a | ||
|
|
0c3c490d58 | ||
|
|
99da6fb66f | ||
|
|
fa2601386c | ||
|
|
122833b0e3 | ||
|
|
8618dbf0d5 | ||
|
|
a0baf33459 | ||
|
|
0ee66ea928 | ||
|
|
f68d4aaf5b | ||
|
|
888abc9e2a | ||
|
|
c8115b1c10 | ||
|
|
137d4f591f | ||
|
|
337d49770d | ||
|
|
614c5578b0 | ||
|
|
d456e60800 | ||
|
|
064206fb9a | ||
|
|
a68fe3b39d | ||
|
|
1904c82941 | ||
|
|
6fc9dd4b30 | ||
|
|
158a31e924 | ||
|
|
b70b924db4 | ||
|
|
9018d72e97 | ||
|
|
5c395138ed | ||
|
|
af157adc1b | ||
|
|
1db4fca9db | ||
|
|
013f475859 | ||
|
|
b5bc38fa52 | ||
|
|
bd0e0cdfa4 | ||
|
|
dade4c4cc4 | ||
|
|
acc5a89dff | ||
|
|
d34881aa25 | ||
|
|
b8ad48997b | ||
|
|
77754b7246 | ||
|
|
6d5bf49a51 | ||
|
|
b7af635a9a | ||
|
|
f53b4e959c | ||
|
|
6716d156bb | ||
|
|
dc33e28452 | ||
|
|
9da4781759 | ||
|
|
0c6959cb4a | ||
|
|
ff3136df70 | ||
|
|
326c627221 | ||
|
|
075f382a8f | ||
|
|
dabb8fe49e | ||
|
|
90489e4392 | ||
|
|
ad45a74f87 | ||
|
|
60c045a713 | ||
|
|
f6c75e1f99 | ||
|
|
dd9245f6f2 | ||
|
|
7310a70743 | ||
|
|
82276837ac | ||
|
|
bd68252b44 | ||
|
|
6b1258e33a | ||
|
|
0400032923 | ||
|
|
d9563322f1 | ||
|
|
ab965969dd | ||
|
|
2f32e034d8 | ||
|
|
d7bb171c1e | ||
|
|
1cf7931f43 | ||
|
|
edc697dd73 | ||
|
|
54a059ff68 | ||
|
|
289282e235 | ||
|
|
825c36c15e | ||
|
|
1234c2e99e | ||
|
|
b8fae1308d | ||
|
|
dddcf624e6 | ||
|
|
b33fe9f7fe | ||
|
|
5a799400a9 | ||
|
|
76919a819f | ||
|
|
9c30f846b2 | ||
|
|
9230f51988 | ||
|
|
712035dc9a | ||
|
|
32e5c5b4ad | ||
|
|
134a6fab7e | ||
|
|
82e27cb962 | ||
|
|
8bcad7b3f9 | ||
|
|
d767575f76 | ||
|
|
7214c7d393 | ||
|
|
205e5ab03d | ||
|
|
6576beae76 | ||
|
|
001f8f1f50 | ||
|
|
3b694a87ef | ||
|
|
84dd06d769 | ||
|
|
c5cb16abfb | ||
|
|
79fb34324d | ||
|
|
303aef3548 | ||
|
|
fd278f8c32 | ||
|
|
53041a4117 | ||
|
|
9b3fe3b13a | ||
|
|
5c6c5081e9 | ||
|
|
e087ea0ac7 | ||
|
|
71c44dc805 | ||
|
|
c5c8596664 | ||
|
|
92a86f4d1c | ||
|
|
8098b68b8e | ||
|
|
7356001723 | ||
|
|
aba60587ab | ||
|
|
936a6a04fb | ||
|
|
9675126298 | ||
|
|
6a5886ea1c | ||
|
|
648c6a5a8f | ||
|
|
14b7bf4753 | ||
|
|
0e310fa96a | ||
|
|
0f6c282c80 | ||
|
|
ed3cd0c9c8 | ||
|
|
398f029f6d | ||
|
|
ad9c2b917b | ||
|
|
d0d65182c0 | ||
|
|
4c3a0d329b | ||
|
|
7c495c2177 | ||
|
|
2f86a9e534 | ||
|
|
12c3a0b1fa | ||
|
|
14f3660f55 | ||
|
|
5a8b032d74 | ||
|
|
57c4613b1f | ||
|
|
e008021a42 | ||
|
|
7e600c43ed | ||
|
|
963478e206 | ||
|
|
0f32783488 | ||
|
|
756d470715 | ||
|
|
2c47b7535b | ||
|
|
4cc90b4929 | ||
|
|
32754ffcf5 | ||
|
|
64aae75680 | ||
|
|
69d2160a0d | ||
|
|
99e326539e | ||
|
|
1dde975cfe | ||
|
|
58c069ec5c | ||
|
|
7916600a7b | ||
|
|
3e4f160c5d | ||
|
|
aeb5e5f681 | ||
|
|
1c2e491845 | ||
|
|
eb4000f26b | ||
|
|
74dd887c79 | ||
|
|
764599a7d9 | ||
|
|
ad683fee89 | ||
|
|
85a53fc68f | ||
|
|
3bf8baee85 | ||
|
|
8792213594 | ||
|
|
d9ebc9455c | ||
|
|
9ab8bdfe4a | ||
|
|
418ea9a19e | ||
|
|
20f04febf2 | ||
|
|
a65783201e | ||
|
|
a5f04d44a4 | ||
|
|
cbe1022f20 | ||
|
|
90301ae9ee | ||
|
|
4f38ab3640 | ||
|
|
fca179abab | ||
|
|
e426237c35 | ||
|
|
3dae361d7b | ||
|
|
967831388e | ||
|
|
f9794f20d4 | ||
|
|
f98efd6af0 | ||
|
|
69bf0641f8 | ||
|
|
5791843d16 | ||
|
|
58d0a20074 | ||
|
|
5884c7b3ba | ||
|
|
dd1da268a2 | ||
|
|
473f3954c7 | ||
|
|
5aad5406a2 | ||
|
|
98b606287d | ||
|
|
9792fc0daa | ||
|
|
a9bb9302bc | ||
|
|
30c70bc8d4 | ||
|
|
0df48c37ac | ||
|
|
ec31e94e7a | ||
|
|
ea631d0e88 | ||
|
|
66a180346e | ||
|
|
63ee878789 | ||
|
|
3479e4f2fd | ||
|
|
54f4152f89 | ||
|
|
06334bf272 | ||
|
|
839f096f39 | ||
|
|
f3b2fdc4fc | ||
|
|
16d34f3268 | ||
|
|
61e8dd09d6 | ||
|
|
90d7fea7aa | ||
|
|
b9c8bf07ea | ||
|
|
a3ba07d45f | ||
|
|
5a6a29cbb5 | ||
|
|
72aedbb76c | ||
|
|
e7e3be6ea7 | ||
|
|
62e1b9eb01 | ||
|
|
3fff92dc35 | ||
|
|
352d77719e | ||
|
|
ff397dfa4d | ||
|
|
34d64c0dff | ||
|
|
b5fdc2f956 | ||
|
|
38602965db | ||
|
|
df1ea62883 | ||
|
|
afaff52888 | ||
|
|
5b7829c288 | ||
|
|
2462eb2c79 | ||
|
|
edc26b0a55 | ||
|
|
cc94e8b0ca | ||
|
|
80f3a6e507 | ||
|
|
5709be7ff7 | ||
|
|
46fce8cf4b | ||
|
|
e84049367e | ||
|
|
f213ead595 | ||
|
|
ba540b0725 | ||
|
|
eb55691c89 | ||
|
|
dd508e7dea | ||
|
|
66357866c5 | ||
|
|
6e3728b458 | ||
|
|
31d4eef4b1 | ||
|
|
f58f32a7a8 | ||
|
|
28d8fb686a | ||
|
|
4c7fc2ef47 | ||
|
|
a3f99978c2 | ||
|
|
136b55d310 | ||
|
|
617e90259b | ||
|
|
959eb46162 | ||
|
|
998bda9de7 | ||
|
|
37a2018fe3 | ||
|
|
2c80e07c9d | ||
|
|
a115f34766 | ||
|
|
cd66c1e7c3 | ||
|
|
4f9975dc6d | ||
|
|
9da487d962 | ||
|
|
c7123b016b | ||
|
|
efb13ddaf0 | ||
|
|
3539b73c08 | ||
|
|
2c084ef4d5 | ||
|
|
754e66f4dd | ||
|
|
41b698f0a8 | ||
|
|
de78da4fa6 | ||
|
|
3d241d6fa1 | ||
|
|
1d983a0090 | ||
|
|
78fb860305 | ||
|
|
c699a84f42 | ||
|
|
d8a178d93d | ||
|
|
ada4243548 | ||
|
|
fa2e3aad6c | ||
|
|
0cf457a46f | ||
|
|
bb7b98d448 | ||
|
|
e8d90848f2 | ||
|
|
7c791451ba | ||
|
|
16d8c2b221 | ||
|
|
dceecbef0a | ||
|
|
3cbddf1de9 | ||
|
|
650340fcb3 | ||
|
|
ce5b893224 | ||
|
|
7869afa4ff | ||
|
|
9085606082 | ||
|
|
1e3f646814 | ||
|
|
933f0cb4b8 | ||
|
|
7497761fcc | ||
|
|
12b3d4ec7a | ||
|
|
8fd5ed57c4 | ||
|
|
7bc301bc70 | ||
|
|
30321d3a0e | ||
|
|
511a0ae503 | ||
|
|
1057636666 | ||
|
|
564b1d2a98 | ||
|
|
20cd0e2de2 | ||
|
|
6bc617c488 | ||
|
|
049db83423 | ||
|
|
52dd90e85d | ||
|
|
305267d07f | ||
|
|
20369aa1b5 | ||
|
|
40f05e4dbb | ||
|
|
a23d19f208 | ||
|
|
cb1d1e8ed7 | ||
|
|
4f67f32719 | ||
|
|
a80b5b6abc | ||
|
|
0be3d88872 | ||
|
|
48bb996350 | ||
|
|
ee2dde4cd1 | ||
|
|
c10a31c933 | ||
|
|
d6a846f58d | ||
|
|
945873231d | ||
|
|
5dc494978e | ||
|
|
c870ec10c0 | ||
|
|
2085b8fd14 | ||
|
|
e065b6435c | ||
|
|
da5331ceb0 | ||
|
|
8f81982de4 | ||
|
|
499b46ecf3 | ||
|
|
a7d232e15f | ||
|
|
8fdb394ec5 | ||
|
|
7a1da64bf2 | ||
|
|
95ae155fc0 | ||
|
|
d1507f2666 | ||
|
|
7e4f98d328 | ||
|
|
f9a956905e | ||
|
|
e7d95f9da6 | ||
|
|
bc8f0aa223 | ||
|
|
6f2ae94e12 | ||
|
|
8f787e9976 | ||
|
|
321d8240a2 | ||
|
|
0f9482864c | ||
|
|
60700d59fe | ||
|
|
3296cef02d | ||
|
|
1b55b5fa3c | ||
|
|
b2701f5ba4 | ||
|
|
5d9a4b42a6 |
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -7,4 +7,6 @@ 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 clean compile` locally. This may reformat your code, commit those changes.
|
||||
- [ ] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
|
||||
|
||||
|
||||
66
.github/workflows/maven-build.yml
vendored
66
.github/workflows/maven-build.yml
vendored
@@ -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: [ 13 ]
|
||||
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: [ 8, 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, 15-ea ]
|
||||
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
4
.gitignore
vendored
@@ -7,3 +7,7 @@ target
|
||||
.project
|
||||
.settings/
|
||||
.DS_Store
|
||||
|
||||
dependency-reduced-pom.xml
|
||||
.factorypath
|
||||
.vscode/settings.json
|
||||
|
||||
1326
CHANGELOG.md
1326
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
||||
# Java API for GitHub
|
||||
|
||||
[](https://mvnrepository.com/artifact/org.kohsuke/github-api)
|
||||
[](https://gitter.im/github-api/github-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://gitter.im/hub4j/github-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||

|
||||
|
||||
|
||||
|
||||
See https://github-api.kohsuke.org/ for more details
|
||||
|
||||
406
pom.xml
406
pom.xml
@@ -1,46 +1,49 @@
|
||||
<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.101</version>
|
||||
<version>1.112</version>
|
||||
<name>GitHub API for Java</name>
|
||||
<url>https://github-api.kohsuke.org/</url>
|
||||
<description>GitHub API for Java</description>
|
||||
|
||||
<scm>
|
||||
<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.101</tag>
|
||||
<connection>scm:git:git@github.com/hub4j/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git</developerConnection>
|
||||
<url>https://github.com/hub4j/github-api/</url>
|
||||
<tag>github-api-1.112</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>
|
||||
<url>gitsite:git@github.com/hub4j/${project.artifactId}.git</url>
|
||||
</site>
|
||||
</distributionManagement>
|
||||
|
||||
<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-maven-plugin.version>4.0.0</spotbugs-maven-plugin.version>
|
||||
<spotbugs.version>4.0.3</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.1</okhttp3.version>
|
||||
<okio.version>2.5.0</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.60</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,19 +79,152 @@
|
||||
</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.Previews</exclude>
|
||||
|
||||
<!-- Deprecated -->
|
||||
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
|
||||
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
|
||||
<exclude>org.kohsuke.github.GHPerson.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.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>
|
||||
</excludes>
|
||||
</rule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
<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>
|
||||
@@ -89,7 +233,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.8.2</version>
|
||||
<version>3.9.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -102,10 +246,14 @@
|
||||
<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>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
@@ -133,6 +281,10 @@
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<!-- SUREFIRE-1226 workaround -->
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
@@ -185,7 +337,7 @@
|
||||
<plugin>
|
||||
<groupId>net.revelc.code</groupId>
|
||||
<artifactId>impsort-maven-plugin</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>1.4.1</version>
|
||||
<configuration>
|
||||
<groups>*,java.,javax.</groups>
|
||||
<removeUnused>true</removeUnused>
|
||||
@@ -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.7.0.202003110725-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.3.3</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.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -374,119 +531,54 @@
|
||||
</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.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
@@ -506,7 +598,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>
|
||||
@@ -514,6 +625,18 @@
|
||||
</profiles>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<!-- select non-aggregate reports -->
|
||||
<report>report</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
@@ -540,4 +663,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>
|
||||
|
||||
165
src/main/java/org/kohsuke/github/AbstractBuilder.java
Normal file
165
src/main/java/org/kohsuke/github/AbstractBuilder.java
Normal file
@@ -0,0 +1,165 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* An abstract data object builder/updater.
|
||||
*
|
||||
* This class can be use to make a Builder that supports both batch and single property changes.
|
||||
* <p>
|
||||
* Batching looks like this:
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* update().someName(value).otherName(value).done()
|
||||
* </pre>
|
||||
* <p>
|
||||
* Single changes look like this:
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* set().someName(value);
|
||||
* set().otherName(value);
|
||||
* </pre>
|
||||
* <p>
|
||||
* If {@link S} is the same as {@link R}, {@link #with(String, Object)} will commit changes after the first value change
|
||||
* and return a {@link R} from {@link #done()}.
|
||||
* </p>
|
||||
* <p>
|
||||
* If {@link S} is not the same as {@link R}, {@link #with(String, Object)} will batch together multiple changes and let
|
||||
* the user call {@link #done()} when they are ready.
|
||||
*
|
||||
* @param <R>
|
||||
* Final return type built by this builder returned when {@link #done()}} is called.
|
||||
* @param <S>
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
|
||||
* the same as {@link R}, this builder will commit changes after each call to {@link #with(String, Object)}.
|
||||
*/
|
||||
abstract class AbstractBuilder<R, S> {
|
||||
|
||||
@Nonnull
|
||||
private final Class<R> returnType;
|
||||
|
||||
private final boolean commitChangesImmediately;
|
||||
|
||||
@CheckForNull
|
||||
private final R baseInstance;
|
||||
|
||||
@Nonnull
|
||||
protected final Requester requester;
|
||||
|
||||
// TODO: Not sure how update-in-place behavior should be controlled
|
||||
// However, it certainly can be controlled dynamically down to the instance level or inherited for all children of
|
||||
// some
|
||||
// connection.
|
||||
protected boolean updateInPlace;
|
||||
|
||||
/**
|
||||
* Creates a builder.
|
||||
*
|
||||
* @param root
|
||||
* the GitHub instance to connect to.
|
||||
* @param intermediateReturnType
|
||||
* the intermediate return type of type {@link S} returned by calls to {@link #with(String, Object)}.
|
||||
* Must either be equal to {@code builtReturnType} or this instance must be castable to this class. If
|
||||
* not, the constructor will throw {@link IllegalArgumentException}.
|
||||
* @param finalReturnType
|
||||
* the final return type for built by this builder returned when {@link #done()}} is called.
|
||||
* @param baseInstance
|
||||
* optional instance on which to base this builder.
|
||||
*/
|
||||
protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
|
||||
@Nonnull Class<S> intermediateReturnType,
|
||||
@Nonnull GitHub root,
|
||||
@CheckForNull R baseInstance) {
|
||||
this.requester = root.createRequest();
|
||||
this.returnType = finalReturnType;
|
||||
this.commitChangesImmediately = returnType.equals(intermediateReturnType);
|
||||
if (!commitChangesImmediately && !intermediateReturnType.isInstance(this)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Argument \"intermediateReturnType\": This instance must be castable to intermediateReturnType or finalReturnType must be equal to intermediateReturnType.");
|
||||
}
|
||||
|
||||
this.baseInstance = baseInstance;
|
||||
this.updateInPlace = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes an update, committing changes.
|
||||
*
|
||||
* This method may update-in-place or not. Either way it returns the resulting instance.
|
||||
*
|
||||
* @return an instance with updated current data
|
||||
* @throws IOException
|
||||
* if there is an I/O Exception
|
||||
*/
|
||||
@Nonnull
|
||||
@Preview
|
||||
@Deprecated
|
||||
public R done() throws IOException {
|
||||
R result;
|
||||
if (updateInPlace && baseInstance != null) {
|
||||
result = requester.fetchInto(baseInstance);
|
||||
} else {
|
||||
result = requester.fetch(returnType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a value to a name for this builder.
|
||||
*
|
||||
* If {@link S} is the same as {@link R}, this method will commit changes after the first value change and return a
|
||||
* {@link R} from {@link #done()}.
|
||||
*
|
||||
* If {@link S} is not the same as {@link R}, this method will return an {@link S} and letting the caller batch
|
||||
* together multiple changes and call {@link #done()} when they are ready.
|
||||
*
|
||||
* @param name
|
||||
* the name of the field
|
||||
* @param value
|
||||
* the value of the field
|
||||
* @return either a continuing builder or an updated data record
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
*/
|
||||
@Nonnull
|
||||
@Preview
|
||||
@Deprecated
|
||||
protected S with(@Nonnull String name, Object value) throws IOException {
|
||||
requester.with(name, value);
|
||||
return continueOrDone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Chooses whether to return a continuing builder or an updated data record
|
||||
*
|
||||
* If {@link S} is the same as {@link R}, this method will commit changes after the first value change and return a
|
||||
* {@link R} from {@link #done()}.
|
||||
*
|
||||
* If {@link S} is not the same as {@link R}, this method will return an {@link S} and letting the caller batch
|
||||
* together multiple changes and call {@link #done()} when they are ready.
|
||||
*
|
||||
* @return either a continuing builder or an updated data record
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
*/
|
||||
@Nonnull
|
||||
@Preview
|
||||
@Deprecated
|
||||
protected S continueOrDone() throws IOException {
|
||||
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
|
||||
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
|
||||
// well.
|
||||
if (commitChangesImmediately) {
|
||||
// These casts look strange and risky, but they they're actually guaranteed safe due to the return path
|
||||
// being based on the previous comparison of class instances passed to the constructor.
|
||||
return (S) done();
|
||||
} else {
|
||||
return (S) this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,10 @@ 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;
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010, Kohsuke Kawaguchi
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
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 {
|
||||
public String delete_token;
|
||||
}
|
||||
@@ -39,7 +39,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param owner
|
||||
* the owner
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOwner(GHUser owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
@@ -58,7 +60,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -77,7 +81,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param description
|
||||
* the description
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
@@ -96,7 +102,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param externalUrl
|
||||
* the external url
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setExternalUrl(String externalUrl) {
|
||||
this.externalUrl = externalUrl;
|
||||
}
|
||||
@@ -115,7 +123,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param events
|
||||
* the events
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEvents(List<GHEvent> events) {
|
||||
this.events = events;
|
||||
}
|
||||
@@ -134,13 +144,15 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param installationsCount
|
||||
* the installations count
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setInstallationsCount(long installationsCount) {
|
||||
this.installationsCount = installationsCount;
|
||||
}
|
||||
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(htmlUrl);
|
||||
return GitHubClient.parseURL(htmlUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +169,9 @@ public class GHApp extends GHObject {
|
||||
*
|
||||
* @param permissions
|
||||
* the permissions
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPermissions(Map<String, String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
@@ -178,9 +192,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 +213,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 +236,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 +261,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 +283,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
|
||||
*
|
||||
* @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 +21,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 +50,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 +83,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GHAppInstallation extends GHObject {
|
||||
private String htmlUrl;
|
||||
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(htmlUrl);
|
||||
return GitHubClient.parseURL(htmlUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRoot(GitHub root) {
|
||||
this.root = root;
|
||||
}
|
||||
@@ -78,7 +80,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param account
|
||||
* the account
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAccount(GHUser account) {
|
||||
this.account = account;
|
||||
}
|
||||
@@ -97,7 +101,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param accessTokenUrl
|
||||
* the access token url
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAccessTokenUrl(String accessTokenUrl) {
|
||||
this.accessTokenUrl = accessTokenUrl;
|
||||
}
|
||||
@@ -116,7 +122,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param repositoriesUrl
|
||||
* the repositories url
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositoriesUrl(String repositoriesUrl) {
|
||||
this.repositoriesUrl = repositoriesUrl;
|
||||
}
|
||||
@@ -135,7 +143,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param appId
|
||||
* the app id
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAppId(long appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
@@ -154,7 +164,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param targetId
|
||||
* the target id
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTargetId(long targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
@@ -173,7 +185,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param targetType
|
||||
* the target type
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTargetType(GHTargetType targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
@@ -192,7 +206,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param permissions
|
||||
* the permissions
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPermissions(Map<String, GHPermissionType> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
@@ -211,7 +227,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param events
|
||||
* the events
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEvents(List<GHEvent> events) {
|
||||
this.events = events;
|
||||
}
|
||||
@@ -230,7 +248,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param singleFileName
|
||||
* the single file name
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSingleFileName(String singleFileName) {
|
||||
this.singleFileName = singleFileName;
|
||||
}
|
||||
@@ -249,7 +269,9 @@ public class GHAppInstallation extends GHObject {
|
||||
*
|
||||
* @param repositorySelection
|
||||
* the repository selection
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
|
||||
this.repositorySelection = repositorySelection;
|
||||
}
|
||||
@@ -271,7 +293,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", getId()))
|
||||
.send();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,11 +309,29 @@ 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);
|
||||
return new GHAppCreateTokenBuilder(root,
|
||||
String.format("/app/installations/%d/access_tokens", getId()),
|
||||
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", getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param root
|
||||
* the root
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRoot(GitHub root) {
|
||||
this.root = root;
|
||||
}
|
||||
@@ -56,7 +58,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param permissions
|
||||
* the permissions
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPermissions(Map<String, String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
@@ -75,7 +79,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param token
|
||||
* the token
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
@@ -94,7 +100,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param repositories
|
||||
* the repositories
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositories(List<GHRepository> repositories) {
|
||||
this.repositories = repositories;
|
||||
}
|
||||
@@ -113,7 +121,9 @@ public class GHAppInstallationToken {
|
||||
*
|
||||
* @param repositorySelection
|
||||
* the repository selection
|
||||
* @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
|
||||
this.repositorySelection = repositorySelection;
|
||||
}
|
||||
@@ -127,7 +137,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")
|
||||
|
||||
@@ -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,11 +145,11 @@ 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() {
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + id;
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
|
||||
}
|
||||
|
||||
GHAsset wrap(GHRelease release) {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class GHAuthorization extends GHObject {
|
||||
* @return the app url
|
||||
*/
|
||||
public URL getAppUrl() {
|
||||
return GitHub.parseURL(app.url);
|
||||
return GitHubClient.parseURL(app.url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,10 +112,12 @@ public class GHAuthorization extends GHObject {
|
||||
* Gets api url.
|
||||
*
|
||||
* @return the api url
|
||||
* @deprecated use {@link #getUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed")
|
||||
public URL getApiURL() {
|
||||
return GitHub.parseURL(url);
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +143,7 @@ public class GHAuthorization extends GHObject {
|
||||
* @return the note url
|
||||
*/
|
||||
public URL getNoteUrl() {
|
||||
return GitHub.parseURL(note_url);
|
||||
return GitHubClient.parseURL(note_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
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.
|
||||
@@ -26,7 +24,7 @@ public class GHBlob {
|
||||
* @return API URL of this blob.
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +71,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
|
||||
/**
|
||||
* A branch in a repository.
|
||||
*
|
||||
@@ -92,7 +90,7 @@ public class GHBranch {
|
||||
@Preview
|
||||
@Deprecated
|
||||
public URL getProtectionUrl() {
|
||||
return GitHub.parseURL(protection_url);
|
||||
return GitHubClient.parseURL(protection_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +101,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().setRawUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +120,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").setRawUrlPath(protection_url).send();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
|
||||
259
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
259
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
@@ -0,0 +1,259 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 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 String nodeId;
|
||||
private String externalId;
|
||||
private String startedAt;
|
||||
private String completedAt;
|
||||
private URL htmlUrl;
|
||||
private URL detailsUrl;
|
||||
private Output output;
|
||||
private GHApp app;
|
||||
private GHPullRequest[] pullRequests;
|
||||
private GHCheckSuite checkSuite;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status of the check run.
|
||||
*
|
||||
* @return Status of the check run
|
||||
* @see Status
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public static enum Status {
|
||||
QUEUED, IN_PROGRESS, COMPLETED
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets conclusion of a completed check run.
|
||||
*
|
||||
* @return Status of the check run
|
||||
* @see Conclusion
|
||||
*/
|
||||
public String getConclusion() {
|
||||
return conclusion;
|
||||
}
|
||||
|
||||
public static enum Conclusion {
|
||||
SUCCESS, FAILURE, NEUTRAL, CANCELLED, TIMED_OUT, ACTION_REQUIRED
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom name of this check run.
|
||||
*
|
||||
* @return Name of the check run
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HEAD SHA.
|
||||
*
|
||||
* @return sha for the HEAD commit
|
||||
*/
|
||||
public String getHeadSha() {
|
||||
return headSha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pull requests participated in this check run.
|
||||
*
|
||||
* @return Pull requests of this check run
|
||||
*/
|
||||
GHPullRequest[] getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.refresh();
|
||||
}
|
||||
}
|
||||
return pullRequests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTML URL: https://github.com/[owner]/[repo-name]/runs/[check-run-id], usually an GitHub Action page of
|
||||
* the check run.
|
||||
*
|
||||
* @return HTML URL
|
||||
*/
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return htmlUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global node id to access most objects in GitHub.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">documentation</a>
|
||||
* @return Global node id
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference for the check run on the integrator's system.
|
||||
*
|
||||
* @return Reference id
|
||||
*/
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the details URL from which to find full details of the check run on the integrator's site.
|
||||
*
|
||||
* @return Details URL
|
||||
*/
|
||||
public URL getDetailsUrl() {
|
||||
return detailsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
||||
*
|
||||
* @return Timestamp of the start time
|
||||
*/
|
||||
public Date getStartedAt() {
|
||||
return GitHubClient.parseDate(startedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the completed time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
||||
*
|
||||
* @return Timestamp of the completed time
|
||||
*/
|
||||
public Date getCompletedAt() {
|
||||
return GitHubClient.parseDate(completedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GitHub app this check run belongs to, included in response.
|
||||
*
|
||||
* @return GitHub App
|
||||
*/
|
||||
public GHApp getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the check suite this check run belongs to
|
||||
*
|
||||
* @return Check suite
|
||||
*/
|
||||
public GHCheckSuite getCheckSuite() {
|
||||
return checkSuite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an output for a check run.
|
||||
*
|
||||
* @return Output of a check run
|
||||
*/
|
||||
public Output getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an output in a check run to include summary and other results.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#output-object">documentation</a>
|
||||
*/
|
||||
public static class Output {
|
||||
private String title;
|
||||
private String summary;
|
||||
private String text;
|
||||
private int annotationsCount;
|
||||
private URL annotationsUrl;
|
||||
|
||||
/**
|
||||
* Gets the title of check run.
|
||||
*
|
||||
* @return title of check run
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the summary of the check run, note that it supports Markdown.
|
||||
*
|
||||
* @return summary of check run
|
||||
*/
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the details of the check run, note that it supports Markdown.
|
||||
*
|
||||
* @return Details of the check run
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotation count of a check run.
|
||||
*
|
||||
* @return annotation count of a check run
|
||||
*/
|
||||
public int getAnnotationsCount() {
|
||||
return annotationsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL of annotations.
|
||||
*
|
||||
* @return URL of annotations
|
||||
*/
|
||||
public URL getAnnotationsUrl() {
|
||||
return annotationsUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum AnnotationLevel {
|
||||
NOTICE, WARNING, FAILURE
|
||||
}
|
||||
|
||||
}
|
||||
291
src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Normal file
291
src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2020 CloudBees, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import edu.umd.cs.findbugs.annotations.CheckForNull;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Drafts a check run.
|
||||
*
|
||||
* @see GHCheckRun
|
||||
* @see GHRepository#createCheckRun
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#create-a-check-run">documentation</a>
|
||||
*/
|
||||
@SuppressFBWarnings(value = "URF_UNREAD_FIELD", justification = "Jackson serializes these even without a getter")
|
||||
@Preview
|
||||
@Deprecated
|
||||
public final class GHCheckRunBuilder {
|
||||
|
||||
private final GHRepository repo;
|
||||
private final Requester requester;
|
||||
private Output output;
|
||||
private List<Action> actions;
|
||||
|
||||
GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
|
||||
this.repo = repo;
|
||||
requester = repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("POST")
|
||||
.with("name", name)
|
||||
.with("head_sha", headSHA)
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs"));
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withDetailsURL(@CheckForNull String detailsURL) {
|
||||
requester.with("details_url", detailsURL);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withExternalID(@CheckForNull String externalID) {
|
||||
requester.with("external_id", externalID);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withStatus(@CheckForNull GHCheckRun.Status status) {
|
||||
if (status != null) {
|
||||
// Do *not* use the overload taking Enum, as that s/_/-/g which would be wrong here.
|
||||
requester.with("status", status.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withConclusion(@CheckForNull GHCheckRun.Conclusion conclusion) {
|
||||
if (conclusion != null) {
|
||||
requester.with("conclusion", conclusion.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Date startedAt) {
|
||||
if (startedAt != null) {
|
||||
requester.with("started_at", GitHubClient.printDate(startedAt));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Date completedAt) {
|
||||
if (completedAt != null) {
|
||||
requester.with("completed_at", GitHubClient.printDate(completedAt));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder add(@NonNull Output output) {
|
||||
if (this.output != null) {
|
||||
throw new IllegalStateException("cannot add Output twice");
|
||||
}
|
||||
this.output = output;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull GHCheckRunBuilder add(@NonNull Action action) {
|
||||
if (actions == null) {
|
||||
actions = new LinkedList<>();
|
||||
}
|
||||
actions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
private static final int MAX_ANNOTATIONS = 50;
|
||||
/**
|
||||
* Actually creates the check run. (If more than fifty annotations were requested, this is done in batches.)
|
||||
*
|
||||
* @return the resulting run
|
||||
* @throws IOException
|
||||
* for the usual reasons
|
||||
*/
|
||||
public @NonNull GHCheckRun create() throws IOException {
|
||||
List<Annotation> extraAnnotations;
|
||||
if (output != null && output.annotations != null && output.annotations.size() > MAX_ANNOTATIONS) {
|
||||
extraAnnotations = output.annotations.subList(MAX_ANNOTATIONS, output.annotations.size());
|
||||
output.annotations = output.annotations.subList(0, MAX_ANNOTATIONS);
|
||||
} else {
|
||||
extraAnnotations = Collections.emptyList();
|
||||
}
|
||||
GHCheckRun run = requester.with("output", output).with("actions", actions).fetch(GHCheckRun.class).wrap(repo);
|
||||
while (!extraAnnotations.isEmpty()) {
|
||||
Output output2 = new Output(output.title, output.summary);
|
||||
int i = Math.min(extraAnnotations.size(), MAX_ANNOTATIONS);
|
||||
output2.annotations = extraAnnotations.subList(0, i);
|
||||
extraAnnotations = extraAnnotations.subList(i, extraAnnotations.size());
|
||||
run = repo.root.createRequest()
|
||||
.withPreview(Previews.ANTIOPE)
|
||||
.method("PATCH")
|
||||
.with("output", output2)
|
||||
.withUrlPath(repo.getApiTailUrl("check-runs/" + run.getId()))
|
||||
.fetch(GHCheckRun.class)
|
||||
.wrap(repo);
|
||||
}
|
||||
return run;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#output-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Output {
|
||||
|
||||
private final String title;
|
||||
private final String summary;
|
||||
private String text;
|
||||
private List<Annotation> annotations;
|
||||
private List<Image> images;
|
||||
|
||||
public Output(@NonNull String title, @NonNull String summary) {
|
||||
this.title = title;
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public @NonNull Output withText(@CheckForNull String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Output add(@NonNull Annotation annotation) {
|
||||
if (annotations == null) {
|
||||
annotations = new LinkedList<>();
|
||||
}
|
||||
annotations.add(annotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Output add(@NonNull Image image) {
|
||||
if (images == null) {
|
||||
images = new LinkedList<>();
|
||||
}
|
||||
images.add(image);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#annotations-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Annotation {
|
||||
|
||||
private final String path;
|
||||
private final int start_line;
|
||||
private final int end_line;
|
||||
private final String annotation_level;
|
||||
private final String message;
|
||||
private Integer start_column;
|
||||
private Integer end_column;
|
||||
private String title;
|
||||
private String raw_details;
|
||||
|
||||
public Annotation(@NonNull String path,
|
||||
int line,
|
||||
@NonNull GHCheckRun.AnnotationLevel annotationLevel,
|
||||
@NonNull String message) {
|
||||
this(path, line, line, annotationLevel, message);
|
||||
}
|
||||
|
||||
public Annotation(@NonNull String path,
|
||||
int startLine,
|
||||
int endLine,
|
||||
@NonNull GHCheckRun.AnnotationLevel annotationLevel,
|
||||
@NonNull String message) {
|
||||
this.path = path;
|
||||
start_line = startLine;
|
||||
end_line = endLine;
|
||||
annotation_level = annotationLevel.toString().toLowerCase(Locale.ROOT);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withStartColumn(@CheckForNull Integer startColumn) {
|
||||
start_column = startColumn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withEndColumn(@CheckForNull Integer endColumn) {
|
||||
end_column = endColumn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withTitle(@CheckForNull String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Annotation withRawDetails(@CheckForNull String rawDetails) {
|
||||
raw_details = rawDetails;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#images-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Image {
|
||||
|
||||
private final String alt;
|
||||
private final String image_url;
|
||||
private String caption;
|
||||
|
||||
public Image(@NonNull String alt, @NonNull String imageURL) {
|
||||
this.alt = alt;
|
||||
image_url = imageURL;
|
||||
}
|
||||
|
||||
public @NonNull Image withCaption(@CheckForNull String caption) {
|
||||
this.caption = caption;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://developer.github.com/v3/checks/runs/#actions-object">documentation</a>
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public static final class Action {
|
||||
|
||||
private final String label;
|
||||
private final String description;
|
||||
private final String identifier;
|
||||
|
||||
public Action(@NonNull String label, @NonNull String description, @NonNull String identifier) {
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
44
src/main/java/org/kohsuke/github/GHCheckRunsIterable.java
Normal file
44
src/main/java/org/kohsuke/github/GHCheckRunsIterable.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Iterable for check-runs listing.
|
||||
*/
|
||||
class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
|
||||
private GitHub root;
|
||||
private final GitHubRequest request;
|
||||
|
||||
private GHCheckRunsPage result;
|
||||
|
||||
public GHCheckRunsIterable(GitHub root, GitHubRequest request) {
|
||||
this.root = root;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PagedIterator<GHCheckRun> _iterator(int pageSize) {
|
||||
return new PagedIterator<>(
|
||||
adapt(GitHubPageIterator.create(root.getClient(), GHCheckRunsPage.class, request, pageSize)),
|
||||
null);
|
||||
}
|
||||
|
||||
protected Iterator<GHCheckRun[]> adapt(final Iterator<GHCheckRunsPage> base) {
|
||||
return new Iterator<GHCheckRun[]>() {
|
||||
public boolean hasNext() {
|
||||
return base.hasNext();
|
||||
}
|
||||
|
||||
public GHCheckRun[] next() {
|
||||
GHCheckRunsPage v = base.next();
|
||||
if (result == null) {
|
||||
result = v;
|
||||
}
|
||||
return v.getCheckRuns(root);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
20
src/main/java/org/kohsuke/github/GHCheckRunsPage.java
Normal file
20
src/main/java/org/kohsuke/github/GHCheckRunsPage.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
/**
|
||||
* Represents the one page of check-runs result when listing check-runs.
|
||||
*/
|
||||
class GHCheckRunsPage {
|
||||
private int total_count;
|
||||
private GHCheckRun[] check_runs;
|
||||
|
||||
public int getTotalCount() {
|
||||
return total_count;
|
||||
}
|
||||
|
||||
GHCheckRun[] getCheckRuns(GitHub root) {
|
||||
for (GHCheckRun check_run : check_runs) {
|
||||
check_run.wrap(root);
|
||||
}
|
||||
return check_runs;
|
||||
}
|
||||
}
|
||||
239
src/main/java/org/kohsuke/github/GHCheckSuite.java
Normal file
239
src/main/java/org/kohsuke/github/GHCheckSuite.java
Normal file
@@ -0,0 +1,239 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Represents a check suite.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/checks/suites/">documentation</a>
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHCheckSuite extends GHObject {
|
||||
GHRepository owner;
|
||||
GitHub root;
|
||||
|
||||
private String nodeId;
|
||||
private String headBranch;
|
||||
private String headSha;
|
||||
private String status;
|
||||
private String conclusion;
|
||||
private String before;
|
||||
private String after;
|
||||
private int latestCheckRunsCount;
|
||||
private URL checkRunsUrl;
|
||||
private HeadCommit headCommit;
|
||||
private GHApp app;
|
||||
private GHPullRequest[] pullRequests;
|
||||
|
||||
GHCheckSuite wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
return this;
|
||||
}
|
||||
|
||||
GHCheckSuite wrap(GitHub root) {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
GHPullRequest[] wrap() {
|
||||
return pullRequests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global node id to access most objects in GitHub.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">documentation</a>
|
||||
* @return global node id
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The head branch name the changes are on.
|
||||
*
|
||||
* @return head branch name
|
||||
*/
|
||||
public String getHeadBranch() {
|
||||
return headBranch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HEAD SHA.
|
||||
*
|
||||
* @return sha for the HEAD commit
|
||||
*/
|
||||
public String getHeadSha() {
|
||||
return headSha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status of the check suite. It can be one of request, in_progress, or completed.
|
||||
*
|
||||
* @return status of the check suite
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets conclusion of a completed check suite. It can be one of success, failure, neutral, cancelled, time_out,
|
||||
* action_required, or stale. The check suite will report the highest priority check run conclusion in the check
|
||||
* suite's conclusion.
|
||||
*
|
||||
* @return conclusion of the check suite
|
||||
*/
|
||||
public String getConclusion() {
|
||||
return conclusion;
|
||||
}
|
||||
|
||||
/**
|
||||
* The SHA of the most recent commit on ref before the push.
|
||||
*
|
||||
* @return sha of a commit
|
||||
*/
|
||||
public String getBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
/**
|
||||
* The SHA of the most recent commit on ref after the push.
|
||||
*
|
||||
* @return sha of a commit
|
||||
*/
|
||||
public String getAfter() {
|
||||
return after;
|
||||
}
|
||||
|
||||
/**
|
||||
* The quantity of check runs that had run as part of the latest push.
|
||||
*
|
||||
* @return sha of the most recent commit
|
||||
*/
|
||||
public int getLatestCheckRunsCount() {
|
||||
return latestCheckRunsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* The url used to list all the check runs belonged to this suite.
|
||||
*
|
||||
* @return url containing all check runs
|
||||
*/
|
||||
public URL getCheckRunsUrl() {
|
||||
return checkRunsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The commit of current head.
|
||||
*
|
||||
* @return head commit
|
||||
*/
|
||||
public HeadCommit getHeadCommit() {
|
||||
return headCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GitHub app this check suite belongs to, included in response.
|
||||
*
|
||||
* @return GitHub App
|
||||
*/
|
||||
public GHApp getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pull requests participated in this check suite.
|
||||
*
|
||||
* @return Pull requests
|
||||
*/
|
||||
GHPullRequest[] getPullRequests() throws IOException {
|
||||
if (pullRequests != null && pullRequests.length != 0) {
|
||||
for (GHPullRequest singlePull : pullRequests) {
|
||||
singlePull.refresh();
|
||||
}
|
||||
}
|
||||
return pullRequests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check suite doesn't have a HTML URL.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class HeadCommit {
|
||||
private String id;
|
||||
private String treeId;
|
||||
private String message;
|
||||
private String timestamp;
|
||||
private GitUser author;
|
||||
private GitUser committer;
|
||||
|
||||
/**
|
||||
* Gets id of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes
|
||||
*
|
||||
* @return id of the commit
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id of the tree.
|
||||
*
|
||||
* @return id of the tree
|
||||
*/
|
||||
public String getTreeId() {
|
||||
return treeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets message.
|
||||
*
|
||||
* @return commit message.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets timestamp of the commit.
|
||||
*
|
||||
* @return timestamp of the commit
|
||||
*/
|
||||
public Date getTimestamp() {
|
||||
return GitHubClient.parseDate(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets author.
|
||||
*
|
||||
* @return the author
|
||||
*/
|
||||
public GitUser getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets committer.
|
||||
*
|
||||
* @return the committer
|
||||
*/
|
||||
public GitUser getCommitter() {
|
||||
return committer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@ public class GHCommit {
|
||||
|
||||
private int comment_count;
|
||||
|
||||
private GHVerification verification;
|
||||
|
||||
static class Tree {
|
||||
String sha;
|
||||
}
|
||||
@@ -61,7 +63,7 @@ public class GHCommit {
|
||||
* @return the authored date
|
||||
*/
|
||||
public Date getAuthoredDate() {
|
||||
return GitHub.parseDate(author.date);
|
||||
return GitHubClient.parseDate(author.date);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +82,7 @@ public class GHCommit {
|
||||
* @return the commit date
|
||||
*/
|
||||
public Date getCommitDate() {
|
||||
return GitHub.parseDate(committer.date);
|
||||
return GitHubClient.parseDate(committer.date);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,6 +102,15 @@ public class GHCommit {
|
||||
public int getCommentCount() {
|
||||
return comment_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Verification Status.
|
||||
*
|
||||
* @return the Verification status
|
||||
*/
|
||||
public GHVerification getVerification() {
|
||||
return verification;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +212,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 +223,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 +337,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 +452,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 +476,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);
|
||||
}
|
||||
|
||||
@@ -510,6 +523,19 @@ public class GHCommit {
|
||||
return owner.getLastCommitStatus(sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets check-runs for given sha.
|
||||
*
|
||||
* @return check runs for given sha.
|
||||
* @throws IOException
|
||||
* on error
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public PagedIterable<GHCheckRun> getCheckRuns() throws IOException {
|
||||
return owner.getCheckRuns(sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some of the fields are not always filled in when this object is retrieved as a part of another API call.
|
||||
*
|
||||
@@ -518,7 +544,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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,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 +113,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,11 +149,11 @@ 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() {
|
||||
return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), id);
|
||||
return String.format("/repos/%s/%s/comments/%s", owner.getOwnerName(), owner.getName(), getId());
|
||||
}
|
||||
|
||||
GHCommitComment wrap(GHRepository owner) {
|
||||
|
||||
@@ -24,7 +24,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 +83,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 +106,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 +127,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,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];
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class GHCompare {
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public class GHCompare {
|
||||
* @return the html url
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ public class GHCompare {
|
||||
* @return the permalink url
|
||||
*/
|
||||
public URL getPermalinkUrl() {
|
||||
return GitHub.parseURL(permalink_url);
|
||||
return GitHubClient.parseURL(permalink_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class GHCompare {
|
||||
* @return the diff url
|
||||
*/
|
||||
public URL getDiffUrl() {
|
||||
return GitHub.parseURL(diff_url);
|
||||
return GitHubClient.parseURL(diff_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class GHCompare {
|
||||
* @return the patch url
|
||||
*/
|
||||
public URL getPatchUrl() {
|
||||
return GitHub.parseURL(patch_url);
|
||||
return GitHubClient.parseURL(patch_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
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.
|
||||
@@ -114,7 +113,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 +174,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 +223,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 +237,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 +304,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 +318,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 +353,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 +364,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;
|
||||
@@ -382,22 +388,6 @@ public class GHContent implements Refreshable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap gh content [ ].
|
||||
*
|
||||
* @param contents
|
||||
* the contents
|
||||
* @param repository
|
||||
* the repository
|
||||
* @return the gh content [ ]
|
||||
*/
|
||||
public static GHContent[] wrap(GHContent[] contents, GHRepository repository) {
|
||||
for (GHContent unwrappedContent : contents) {
|
||||
unwrappedContent.wrap(repository);
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fully populate the data by retrieving missing data.
|
||||
*
|
||||
@@ -405,6 +395,6 @@ public class GHContent implements Refreshable {
|
||||
*/
|
||||
@Override
|
||||
public synchronized void refresh() throws IOException {
|
||||
root.retrieve().to(url, this);
|
||||
root.createRequest().setRawUrlPath(url).fetchInto(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -21,7 +20,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 +49,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 +68,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 +80,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 +103,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);
|
||||
|
||||
@@ -16,7 +16,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);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,18 @@ public class GHCreateRepositoryBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables projects
|
||||
*
|
||||
* @param enabled
|
||||
* true if enabled
|
||||
* @return a builder to continue with building
|
||||
*/
|
||||
public GHCreateRepositoryBuilder projects(boolean enabled) {
|
||||
this.builder.with("has_projects", enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables wiki
|
||||
*
|
||||
@@ -196,7 +208,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ public class GHDeployment extends GHObject {
|
||||
* @return the gh deployment status builder
|
||||
*/
|
||||
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
|
||||
return new GHDeploymentStatusBuilder(owner, id, state);
|
||||
return new GHDeploymentStatusBuilder(owner, getId(), state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ public class GHDeploymentStatusBuilder {
|
||||
* the state
|
||||
* @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
|
||||
this(repo, (long) deploymentId, state);
|
||||
}
|
||||
@@ -30,7 +31,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 +67,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,50 +10,59 @@ import java.util.Locale;
|
||||
* @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,
|
||||
REGISTRY_PACKAGE,
|
||||
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"
|
||||
*/
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GHEventInfo {
|
||||
* @return the created at
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return GitHub.parseDate(created_at);
|
||||
return GitHubClient.parseDate(created_at);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,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.getMappingObjectReader(root).readValue(payload.traverse(), type);
|
||||
v.wrapUp(root);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.kohsuke.github;
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,6 +48,313 @@ public abstract class GHEventPayload {
|
||||
}
|
||||
}
|
||||
|
||||
// List of events that still need to be added:
|
||||
// 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() {
|
||||
repository.root = root;
|
||||
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 check suite event has been requested, rerequested or completed.
|
||||
*
|
||||
* @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 CheckSuite extends GHEventPayload {
|
||||
private String action;
|
||||
private GHCheckSuite checkSuite;
|
||||
private GHRepository repository;
|
||||
|
||||
/**
|
||||
* Gets action.
|
||||
*
|
||||
* @return the action
|
||||
*/
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Check Suite object
|
||||
*
|
||||
* @return the Check Suite object
|
||||
*/
|
||||
public GHCheckSuite getCheckSuite() {
|
||||
return checkSuite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repository.
|
||||
*
|
||||
* @return the repository
|
||||
*/
|
||||
public GHRepository getRepository() {
|
||||
repository.root = root;
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
void wrapUp(GitHub root) {
|
||||
super.wrapUp(root);
|
||||
if (checkSuite == null)
|
||||
throw new IllegalStateException(
|
||||
"Expected check_suite payload, but got something else. Maybe we've got another type of event?");
|
||||
if (repository != null) {
|
||||
repository.wrap(root);
|
||||
checkSuite.wrap(repository);
|
||||
} else {
|
||||
checkSuite.wrap(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An installation has been installed, uninstalled, or its permissions have been changed.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/activity/events/types/#installationevent">authoritative source</a>
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
|
||||
public static class Installation extends GHEventPayload {
|
||||
private String action;
|
||||
private GHAppInstallation installation;
|
||||
private List<GHRepository> repositories;
|
||||
|
||||
/**
|
||||
* Gets action
|
||||
*
|
||||
* @return the action
|
||||
*/
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets installation
|
||||
*
|
||||
* @return the installation
|
||||
*/
|
||||
public GHAppInstallation getInstallation() {
|
||||
return installation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repositories
|
||||
*
|
||||
* @return the repositories
|
||||
*/
|
||||
public List<GHRepository> getRepositories() {
|
||||
return repositories;
|
||||
};
|
||||
|
||||
@Override
|
||||
void wrapUp(GitHub root) {
|
||||
super.wrapUp(root);
|
||||
if (installation == null)
|
||||
throw new IllegalStateException(
|
||||
"Expected check_suite payload, but got something else. Maybe we've got another type of event?");
|
||||
else
|
||||
installation.wrapUp(root);
|
||||
|
||||
if (repositories != null && !repositories.isEmpty()) {
|
||||
try {
|
||||
for (GHRepository singleRepo : repositories) { // warp each of the repository
|
||||
singleRepo.wrap(root);
|
||||
singleRepo.populate();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new GHException("Failed to refresh repositories", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A repository has been added or removed from an installation.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/activity/events/types/#installationrepositoriesevent">authoritative
|
||||
* source</a>
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
|
||||
public static class InstallationRepositories extends GHEventPayload {
|
||||
private String action;
|
||||
private GHAppInstallation installation;
|
||||
private String repositorySelection;
|
||||
private List<GHRepository> repositoriesAdded;
|
||||
private List<GHRepository> repositoriesRemoved;
|
||||
|
||||
/**
|
||||
* Gets action
|
||||
*
|
||||
* @return the action
|
||||
*/
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets installation
|
||||
*
|
||||
* @return the installation
|
||||
*/
|
||||
public GHAppInstallation getInstallation() {
|
||||
return installation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets installation selection
|
||||
*
|
||||
* @return the installation selection
|
||||
*/
|
||||
public String getRepositorySelection() {
|
||||
return repositorySelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repositories added
|
||||
*
|
||||
* @return the repositories
|
||||
*/
|
||||
public List<GHRepository> getRepositoriesAdded() {
|
||||
return repositoriesAdded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repositories removed
|
||||
*
|
||||
* @return the repositories
|
||||
*/
|
||||
public List<GHRepository> getRepositoriesRemoved() {
|
||||
return repositoriesRemoved;
|
||||
}
|
||||
|
||||
@Override
|
||||
void wrapUp(GitHub root) {
|
||||
super.wrapUp(root);
|
||||
if (installation == null)
|
||||
throw new IllegalStateException(
|
||||
"Expected check_suite payload, but got something else. Maybe we've got another type of event?");
|
||||
else
|
||||
installation.wrapUp(root);
|
||||
|
||||
List<GHRepository> repositories;
|
||||
if ("added".equals(action))
|
||||
repositories = repositoriesAdded;
|
||||
else // action == "removed"
|
||||
repositories = repositoriesRemoved;
|
||||
|
||||
if (repositories != null && !repositories.isEmpty()) {
|
||||
try {
|
||||
for (GHRepository singleRepo : repositories) { // warp each of the repository
|
||||
singleRepo.wrap(root);
|
||||
singleRepo.populate();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new GHException("Failed to refresh repositories", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A pull request status has changed.
|
||||
*
|
||||
@@ -1325,6 +1633,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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.
|
||||
@@ -24,11 +24,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 +54,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -20,8 +21,9 @@ import java.util.Map.Entry;
|
||||
* @see <a href="https://developer.github.com/v3/gists/">documentation</a>
|
||||
*/
|
||||
public class GHGist extends GHObject {
|
||||
/* package almost final */ GHUser owner;
|
||||
/* package almost final */ GitHub root;
|
||||
|
||||
final GHUser owner;
|
||||
final GitHub root;
|
||||
|
||||
private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url;
|
||||
|
||||
@@ -34,7 +36,43 @@ public class GHGist extends GHObject {
|
||||
|
||||
private String comments_url;
|
||||
|
||||
private Map<String, GHGistFile> files = new HashMap<String, GHGistFile>();
|
||||
private final Map<String, GHGistFile> files;
|
||||
|
||||
@JsonCreator
|
||||
private GHGist(@JacksonInject GitHub root,
|
||||
@JsonProperty("owner") GHUser owner,
|
||||
@JsonProperty("files") Map<String, GHGistFile> files) {
|
||||
this.root = root;
|
||||
for (Entry<String, GHGistFile> e : files.entrySet()) {
|
||||
e.getValue().fileName = e.getKey();
|
||||
}
|
||||
this.files = Collections.unmodifiableMap(files);
|
||||
this.owner = root.getUser(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlike most other GitHub objects, the id for Gists can be non-numeric, such as "aa5a315d61ae9438b18d". If the id
|
||||
* is numeric, this method will get it. If id is not numeric, this will throw a runtime
|
||||
* {@link NumberFormatException}.
|
||||
*
|
||||
* @return id of the Gist.
|
||||
* @deprecated Use {@link #getGistId()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getId() {
|
||||
return Long.parseLong(getGistId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id for this Gist. Unlike most other GitHub objects, the id for Gists can be non-numeric, such as
|
||||
* "aa5a315d61ae9438b18d". This should be used instead of {@link #getId()}.
|
||||
*
|
||||
* @return id of this Gist
|
||||
*/
|
||||
public String getGistId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets owner.
|
||||
@@ -44,7 +82,7 @@ public class GHGist extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getOwner() throws IOException {
|
||||
return root.intern(owner);
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,8 +121,13 @@ public class GHGist extends GHObject {
|
||||
return git_push_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the html url.
|
||||
*
|
||||
* @return the github html url
|
||||
*/
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,31 +183,7 @@ public class GHGist extends GHObject {
|
||||
* @return the files
|
||||
*/
|
||||
public Map<String, GHGistFile> getFiles() {
|
||||
return Collections.unmodifiableMap(files);
|
||||
}
|
||||
|
||||
GHGist wrapUp(GHUser owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
wrapUp();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when caller obtains {@link GHGist} without knowing its owner. A partially constructed owner object is
|
||||
* interned.
|
||||
*/
|
||||
GHGist wrapUp(GitHub root) {
|
||||
this.owner = root.getUser(owner);
|
||||
this.root = root;
|
||||
wrapUp();
|
||||
return this;
|
||||
}
|
||||
|
||||
private void wrapUp() {
|
||||
for (Entry<String, GHGistFile> e : files.entrySet()) {
|
||||
e.getValue().fileName = e.getKey();
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
String getApiTailUrl(String tail) {
|
||||
@@ -182,7 +201,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 +211,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 +222,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 +233,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +242,7 @@ 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, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +252,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,10 +281,4 @@ public class GHGist extends GHObject {
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
GHGist wrap(GHUser owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Builder pattern for creating a new Gist.
|
||||
*
|
||||
@@ -23,7 +25,7 @@ public class GHGistBuilder {
|
||||
*/
|
||||
public GHGistBuilder(GitHub root) {
|
||||
this.root = root;
|
||||
req = new Requester(root);
|
||||
req = root.createRequest().method("POST");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +61,7 @@ public class GHGistBuilder {
|
||||
* the content
|
||||
* @return Adds a new file.
|
||||
*/
|
||||
public GHGistBuilder file(String fileName, String content) {
|
||||
public GHGistBuilder file(@Nonnull String fileName, @Nonnull String content) {
|
||||
files.put(fileName, Collections.singletonMap("content", content));
|
||||
return this;
|
||||
}
|
||||
@@ -73,6 +75,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Builder pattern for updating a Gist.
|
||||
@@ -12,11 +15,11 @@ import java.util.LinkedHashMap;
|
||||
public class GHGistUpdater {
|
||||
private final GHGist base;
|
||||
private final Requester builder;
|
||||
LinkedHashMap<String, Object> files;
|
||||
LinkedHashMap<String, Map<String, String>> files;
|
||||
|
||||
GHGistUpdater(GHGist base) {
|
||||
this.base = base;
|
||||
this.builder = new Requester(base.root);
|
||||
this.builder = base.root.createRequest();
|
||||
|
||||
files = new LinkedHashMap<>();
|
||||
}
|
||||
@@ -32,16 +35,15 @@ public class GHGistUpdater {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater addFile(String fileName, String content) throws IOException {
|
||||
public GHGistUpdater addFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
|
||||
updateFile(fileName, content);
|
||||
return this;
|
||||
}
|
||||
|
||||
// // This method does not work.
|
||||
// public GHGistUpdater deleteFile(String fileName) throws IOException {
|
||||
// files.put(fileName, Collections.singletonMap("filename", null));
|
||||
// return this;
|
||||
// }
|
||||
public GHGistUpdater deleteFile(@Nonnull String fileName) throws IOException {
|
||||
files.put(fileName, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename file gh gist updater.
|
||||
@@ -54,8 +56,9 @@ public class GHGistUpdater {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException {
|
||||
files.put(fileName, Collections.singletonMap("filename", newFileName));
|
||||
public GHGistUpdater renameFile(@Nonnull String fileName, @Nonnull String newFileName) throws IOException {
|
||||
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
|
||||
file.put("filename", newFileName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -70,8 +73,31 @@ public class GHGistUpdater {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater updateFile(String fileName, String content) throws IOException {
|
||||
files.put(fileName, Collections.singletonMap("content", content));
|
||||
public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
|
||||
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
|
||||
file.put("content", content);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update file name and content
|
||||
*
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param newFileName
|
||||
* the new file name
|
||||
* @param content
|
||||
* the content
|
||||
* @return the gh gist updater
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String newFileName, @Nonnull String content)
|
||||
throws IOException {
|
||||
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
|
||||
file.put("content", content);
|
||||
file.put("filename", newFileName);
|
||||
files.put(fileName, file);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -96,6 +122,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,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 +84,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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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.
|
||||
@@ -31,6 +31,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 +55,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -36,6 +37,7 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
||||
|
||||
@@ -63,8 +65,7 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
protected int comments;
|
||||
@SkipFromToString
|
||||
protected String body;
|
||||
// for backward compatibility with < 1.63, this collection needs to hold instances of Label, not GHLabel
|
||||
protected List<Label> labels;
|
||||
protected List<GHLabel> labels;
|
||||
protected GHUser user;
|
||||
protected String title, html_url;
|
||||
protected GHIssue.PullRequest pull_request;
|
||||
@@ -72,14 +73,6 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
protected GHUser closed_by;
|
||||
protected boolean locked;
|
||||
|
||||
/**
|
||||
* The type Label.
|
||||
*
|
||||
* @deprecated use {@link GHLabel}
|
||||
*/
|
||||
public static class Label extends GHLabel {
|
||||
}
|
||||
|
||||
GHIssue wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
if (milestone != null)
|
||||
@@ -100,12 +93,6 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
return this;
|
||||
}
|
||||
|
||||
static GHIssue[] wrap(GHIssue[] issues, GHRepository owner) {
|
||||
for (GHIssue i : issues)
|
||||
i.wrap(owner);
|
||||
return issues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repository to which the issue belongs.
|
||||
*
|
||||
@@ -137,7 +124,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +165,7 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
if (labels == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.<GHLabel>unmodifiableList(labels);
|
||||
return Collections.unmodifiableList(labels);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,16 +174,18 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
* @return the closed at
|
||||
*/
|
||||
public Date getClosedAt() {
|
||||
return GitHub.parseDate(closed_at);
|
||||
return GitHubClient.parseDate(closed_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets api url.
|
||||
*
|
||||
* @return the api url
|
||||
* @return API URL of this object.
|
||||
* @deprecated use {@link #getUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
public URL getApiURL() {
|
||||
return GitHub.parseURL(url);
|
||||
return getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +195,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 +205,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 +219,27 @@ 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Identical to edit(), but allows null for the value.
|
||||
*/
|
||||
private void editNullable(String key, Object value) throws IOException {
|
||||
root.createRequest().withNullable(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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,15 +287,19 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets milestone.
|
||||
* Sets the milestone for this issue.
|
||||
*
|
||||
* @param milestone
|
||||
* the milestone
|
||||
* The milestone to assign this issue to. Use null to remove the milestone for this issue.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* The io exception
|
||||
*/
|
||||
public void setMilestone(GHMilestone milestone) throws IOException {
|
||||
edit("milestone", milestone.getNumber());
|
||||
if (milestone == null) {
|
||||
editNullable("milestone", null);
|
||||
} else {
|
||||
edit("milestone", milestone.getNumber());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,7 +434,7 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
* @see #listComments() #listComments()
|
||||
*/
|
||||
public List<GHIssueComment> getComments() throws IOException {
|
||||
return listComments().asList();
|
||||
return listComments().toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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,11 @@ 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.
|
||||
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
|
||||
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
|
||||
}
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
|
||||
}
|
||||
|
||||
@@ -665,7 +682,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 +691,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 +700,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 +720,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,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 +95,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class GHIssueComment extends GHObject implements Reactable {
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +108,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,28 +123,32 @@ 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() {
|
||||
return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()
|
||||
+ "/issues/comments/" + id;
|
||||
+ "/issues/comments/" + getId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.Date;
|
||||
/**
|
||||
* The type GHIssueEvent.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v3/issues/events/">Github documentation for issue events</a>
|
||||
*
|
||||
* @author Martin van Zijl
|
||||
*/
|
||||
public class GHIssueEvent {
|
||||
@@ -18,6 +20,9 @@ public class GHIssueEvent {
|
||||
private String commit_id;
|
||||
private String commit_url;
|
||||
private String created_at;
|
||||
private GHMilestone milestone;
|
||||
private GHLabel label;
|
||||
private GHUser assignee;
|
||||
|
||||
private GHIssue issue;
|
||||
|
||||
@@ -90,7 +95,7 @@ public class GHIssueEvent {
|
||||
* @return the created at
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return GitHub.parseDate(created_at);
|
||||
return GitHubClient.parseDate(created_at);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +116,36 @@ public class GHIssueEvent {
|
||||
return issue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link GHMilestone} that this issue was added to or removed from. Only present for events "milestoned"
|
||||
* and "demilestoned", <code>null</code> otherwise.
|
||||
*
|
||||
* @return the milestone
|
||||
*/
|
||||
public GHMilestone getMilestone() {
|
||||
return milestone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link GHLabel} that was added to or removed from the issue. Only present for events "labeled" and
|
||||
* "unlabeled", <code>null</code> otherwise.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public GHLabel getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link GHUser} that was assigned or unassigned from the issue. Only present for events "assigned" and
|
||||
* "unassigned", <code>null</code> otherwise.
|
||||
*
|
||||
* @return the user
|
||||
*/
|
||||
public GHUser getAssignee() {
|
||||
return assignee;
|
||||
}
|
||||
|
||||
GHIssueEvent wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
return this;
|
||||
|
||||
@@ -1,29 +1,56 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.kohsuke.github.Previews.SYMMETRA;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* The type GHLabel.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see <a href="https://developer.github.com/v3/issues/labels/">Labels</a>
|
||||
* @see GHIssue#getLabels() GHIssue#getLabels()
|
||||
* @see GHRepository#listLabels() GHRepository#listLabels()
|
||||
*/
|
||||
public class GHLabel {
|
||||
private String url, name, color, description;
|
||||
private GHRepository repo;
|
||||
|
||||
@Nonnull
|
||||
private String url, name, color;
|
||||
|
||||
@CheckForNull
|
||||
private String description;
|
||||
|
||||
@Nonnull
|
||||
private final GitHub root;
|
||||
|
||||
@JsonCreator
|
||||
private GHLabel(@JacksonInject @Nonnull GitHub root) {
|
||||
this.root = root;
|
||||
url = "";
|
||||
name = "";
|
||||
color = "";
|
||||
description = null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
GitHub getApiRoot() {
|
||||
return Objects.requireNonNull(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
@Nonnull
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
@@ -33,6 +60,7 @@ public class GHLabel {
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -42,6 +70,7 @@ public class GHLabel {
|
||||
*
|
||||
* @return the color
|
||||
*/
|
||||
@Nonnull
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
@@ -51,27 +80,11 @@ public class GHLabel {
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
@CheckForNull
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
GHLabel wrapUp(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
repo.root.retrieve().method("DELETE").to(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets color.
|
||||
*
|
||||
@@ -79,15 +92,11 @@ public class GHLabel {
|
||||
* 6-letter hex color code, like "f29513"
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated use {@link #set()} or {@link #update()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setColor(String newColor) throws IOException {
|
||||
repo.root.retrieve()
|
||||
.method("PATCH")
|
||||
.withPreview(SYMMETRA)
|
||||
.with("name", name)
|
||||
.with("color", newColor)
|
||||
.with("description", description)
|
||||
.to(url);
|
||||
set().color(newColor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,27 +106,106 @@ public class GHLabel {
|
||||
* Description of label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @deprecated use {@link #set()} or {@link #update()} instead
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public void setDescription(String newDescription) throws IOException {
|
||||
repo.root.retrieve()
|
||||
.method("PATCH")
|
||||
.withPreview(SYMMETRA)
|
||||
.with("name", name)
|
||||
.with("color", color)
|
||||
.with("description", newDescription)
|
||||
.to(url);
|
||||
set().description(newDescription);
|
||||
}
|
||||
|
||||
static Collection<String> toNames(Collection<GHLabel> labels) {
|
||||
List<String> r = new ArrayList<String>();
|
||||
List<String> r = new ArrayList<>();
|
||||
for (GHLabel l : labels) {
|
||||
r.add(l.getName());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the creation of a new instance.
|
||||
*
|
||||
* Consumer must call {@link Creator#done()} to commit changes.
|
||||
*
|
||||
* @param repository
|
||||
* the repository in which the label will be created.
|
||||
* @return a {@link Creator}
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
static Creator create(GHRepository repository) throws IOException {
|
||||
return new Creator(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a label from a repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @param name
|
||||
* the name of the label
|
||||
* @return a label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
static GHLabel read(@Nonnull GHRepository repository, @Nonnull String name) throws IOException {
|
||||
return repository.root.createRequest()
|
||||
.withUrlPath(repository.getApiTailUrl("labels"), name)
|
||||
.fetch(GHLabel.class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads all labels from a repository.
|
||||
*
|
||||
* @param repository
|
||||
* the repository to read from
|
||||
* @return iterable of all labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
static PagedIterable<GHLabel> readAll(@Nonnull final GHRepository repository) throws IOException {
|
||||
return repository.root.createRequest()
|
||||
.withUrlPath(repository.getApiTailUrl("labels"))
|
||||
.toIterable(GHLabel[].class, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins a batch update
|
||||
*
|
||||
* Consumer must call {@link Updater#done()} to commit changes.
|
||||
*
|
||||
* @return a {@link Updater}
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public Updater update() {
|
||||
return new Updater(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins a single property update.
|
||||
*
|
||||
* @return a {@link Setter}
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public Setter set() {
|
||||
return new Setter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete this label from the repository.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
root.createRequest().method("DELETE").setRawUrlPath(getUrl()).send();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o)
|
||||
@@ -126,11 +214,54 @@ public class GHLabel {
|
||||
return false;
|
||||
final GHLabel ghLabel = (GHLabel) o;
|
||||
return Objects.equals(url, ghLabel.url) && Objects.equals(name, ghLabel.name)
|
||||
&& Objects.equals(color, ghLabel.color) && Objects.equals(repo, ghLabel.repo);
|
||||
&& Objects.equals(color, ghLabel.color) && Objects.equals(description, ghLabel.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(url, name, color, repo);
|
||||
return Objects.hash(url, name, color, description);
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that updates a single property per request
|
||||
*
|
||||
* {@link #done()} is called automatically after the property is set.
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public static class Setter extends GHLabelBuilder<GHLabel> {
|
||||
private Setter(@Nonnull GHLabel base) {
|
||||
super(GHLabel.class, base.getApiRoot(), base);
|
||||
requester.method("PATCH").setRawUrlPath(base.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
|
||||
*
|
||||
* Consumer must call {@link #done()} to commit changes.
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public static class Updater extends GHLabelBuilder<Updater> {
|
||||
private Updater(@Nonnull GHLabel base) {
|
||||
super(Updater.class, base.getApiRoot(), base);
|
||||
requester.method("PATCH").setRawUrlPath(base.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link GHLabelBuilder} that creates a new {@link GHLabel}
|
||||
*
|
||||
* Consumer must call {@link #done()} to create the new instance.
|
||||
*/
|
||||
@Preview
|
||||
@Deprecated
|
||||
public static class Creator extends GHLabelBuilder<Creator> {
|
||||
private Creator(@Nonnull GHRepository repository) {
|
||||
super(Creator.class, repository.root, null);
|
||||
requester.method("POST").withUrlPath(repository.getApiTailUrl("labels"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
60
src/main/java/org/kohsuke/github/GHLabelBuilder.java
Normal file
60
src/main/java/org/kohsuke/github/GHLabelBuilder.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param <S>
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
|
||||
* the same as {@link GHLabel}, this builder will commit changes after each call to
|
||||
* {@link #with(String, Object)}.
|
||||
*/
|
||||
class GHLabelBuilder<S> extends AbstractBuilder<GHLabel, S> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param intermediateReturnType
|
||||
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If
|
||||
* {@link S} the same as {@link GHLabel}, this builder will commit changes after each call to
|
||||
* {@link #with(String, Object)}.
|
||||
* @param root
|
||||
* the GitHub instance to which updates will be sent
|
||||
* @param baseInstance
|
||||
* instance on which to base this builder. If {@code null} a new instance will be created.
|
||||
*/
|
||||
protected GHLabelBuilder(@Nonnull Class<S> intermediateReturnType,
|
||||
@Nonnull GitHub root,
|
||||
@CheckForNull GHLabel baseInstance) {
|
||||
super(GHLabel.class, intermediateReturnType, root, baseInstance);
|
||||
|
||||
if (baseInstance != null) {
|
||||
requester.with("name", baseInstance.getName());
|
||||
requester.with("color", baseInstance.getColor());
|
||||
requester.with("description", baseInstance.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Preview
|
||||
@Deprecated
|
||||
public S name(String value) throws IOException {
|
||||
return with("name", value);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Preview
|
||||
@Deprecated
|
||||
public S color(String value) throws IOException {
|
||||
return with("color", value);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Preview
|
||||
@Deprecated
|
||||
public S description(String value) throws IOException {
|
||||
return with("description", value);
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,13 @@
|
||||
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The GitHub Preview API's license information
|
||||
@@ -78,14 +78,6 @@ public class GHLicense extends GHObject {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return API URL of this object.
|
||||
*/
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Featured licenses are bold in the new repository drop-down
|
||||
*
|
||||
@@ -100,7 +92,7 @@ public class GHLicense extends GHObject {
|
||||
|
||||
public URL getHtmlUrl() throws IOException {
|
||||
populate();
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +191,14 @@ public class GHLicense extends GHObject {
|
||||
if (description != null)
|
||||
return; // already populated
|
||||
|
||||
root.retrieve().to(url, this);
|
||||
if (root == null || root.isOffline()) {
|
||||
return; // cannot populate, will have to live with what we have
|
||||
}
|
||||
|
||||
URL url = getUrl();
|
||||
if (url != null) {
|
||||
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,12 +209,12 @@ public class GHLicense extends GHObject {
|
||||
return false;
|
||||
|
||||
GHLicense that = (GHLicense) o;
|
||||
return this.url.equals(that.url);
|
||||
return Objects.equals(getUrl(), that.getUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return url.hashCode();
|
||||
return Objects.hashCode(getUrl());
|
||||
}
|
||||
|
||||
GHLicense wrap(GitHub root) {
|
||||
|
||||
88
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
88
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Base class for Github Marketplace Account.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
* A Github Marketplace Account Plan.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* GitHub Marketplace Account type.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @see GHMarketplaceAccount
|
||||
*/
|
||||
public enum GHMarketplaceAccountType {
|
||||
ORGANIZATION, USER;
|
||||
|
||||
/**
|
||||
* Returns GitHub's internal representation of this event.
|
||||
*/
|
||||
String symbol() {
|
||||
return StringUtils.capitalize(name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Returns any accounts associated with a plan, including free plans
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A Github Marketplace purchase pending change.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
184
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
184
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
@@ -0,0 +1,184 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A Github Marketplace plan.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* GitHub Marketplace plan pricing model.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
102
src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
Normal file
102
src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A Github Marketplace purchase.
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
113
src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
Normal file
113
src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Github Marketplace User Purchase
|
||||
*
|
||||
* @author Paulo Miguel Almeida
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,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 +72,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) {
|
||||
@@ -84,11 +84,6 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
||||
return this;
|
||||
}
|
||||
|
||||
static void wrap(GHMembership[] page, GitHub root) {
|
||||
for (GHMembership m : page)
|
||||
m.wrap(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Role of a user in an organization.
|
||||
*/
|
||||
|
||||
@@ -56,7 +56,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 +67,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 +116,7 @@ public class GHMilestone extends GHObject {
|
||||
}
|
||||
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,11 +155,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 +195,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -71,8 +70,7 @@ public class GHMyself extends GHUser {
|
||||
* the io exception
|
||||
*/
|
||||
public List<GHEmail> getEmails2() throws IOException {
|
||||
GHEmail[] addresses = root.retrieve().to("/user/emails", GHEmail[].class);
|
||||
return Collections.unmodifiableList(Arrays.asList(addresses));
|
||||
return root.createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +84,7 @@ 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 root.createRequest().withUrlPath("/user/keys").toIterable(GHKey[].class, null).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +98,10 @@ 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 root.createRequest()
|
||||
.withUrlPath("/users/" + getLogin() + "/keys")
|
||||
.toIterable(GHVerifiedKey[].class, null)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,10 @@ 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")
|
||||
.toIterable(GHOrganization[].class, null)
|
||||
.toArray()) {
|
||||
if (names.add(o.getLogin())) // in case of rumoured duplicates in the data
|
||||
orgs.add(root.getOrganization(o.getLogin()));
|
||||
}
|
||||
@@ -175,9 +178,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);
|
||||
}
|
||||
|
||||
@@ -187,6 +191,7 @@ public class GHMyself extends GHUser {
|
||||
* @return the paged iterable
|
||||
* @deprecated Use {@link #listRepositories()}
|
||||
*/
|
||||
@Deprecated
|
||||
public PagedIterable<GHRepository> listAllRepositories() {
|
||||
return listRepositories();
|
||||
}
|
||||
@@ -208,9 +213,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 +229,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 {
|
||||
|
||||
@@ -79,7 +79,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 +101,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 +180,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(GHThread[].class, null)).toResponse();
|
||||
threads = response.body();
|
||||
|
||||
if (threads == null) {
|
||||
threads = EMPTY_ARRAY; // if unmodified, we get empty array
|
||||
} else {
|
||||
@@ -189,27 +193,21 @@ 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);
|
||||
return System.currentTimeMillis() + seconds * 1000;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -232,10 +230,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];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
@@ -23,16 +24,31 @@ public abstract class GHObject {
|
||||
/**
|
||||
* Capture response HTTP headers on the state object.
|
||||
*/
|
||||
protected Map<String, List<String>> responseHeaderFields;
|
||||
protected transient Map<String, List<String>> responseHeaderFields;
|
||||
|
||||
protected String url;
|
||||
protected long id;
|
||||
protected String created_at;
|
||||
protected String updated_at;
|
||||
private String url;
|
||||
|
||||
private long id;
|
||||
private String nodeId;
|
||||
private String createdAt;
|
||||
private String updatedAt;
|
||||
|
||||
GHObject() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by Jackson
|
||||
*
|
||||
* @param responseInfo
|
||||
* the {@link GitHubResponse.ResponseInfo} to get headers from.
|
||||
*/
|
||||
@JacksonInject
|
||||
protected void setResponseHeaderFields(@CheckForNull GitHubResponse.ResponseInfo responseInfo) {
|
||||
if (responseInfo != null) {
|
||||
responseHeaderFields = responseInfo.headers();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP response headers given along with the state of this object.
|
||||
*
|
||||
@@ -60,12 +76,12 @@ public abstract class GHObject {
|
||||
*/
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "createdAtStr")
|
||||
public Date getCreatedAt() throws IOException {
|
||||
return GitHub.parseDate(created_at);
|
||||
return GitHubClient.parseDate(createdAt);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
|
||||
private Object createdAtStr(Date id, Class type) {
|
||||
return created_at;
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +91,7 @@ public abstract class GHObject {
|
||||
*/
|
||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +112,18 @@ public abstract class GHObject {
|
||||
* on error
|
||||
*/
|
||||
public Date getUpdatedAt() throws IOException {
|
||||
return GitHub.parseDate(updated_at);
|
||||
return GitHubClient.parseDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Global node_id from Github object.
|
||||
*
|
||||
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">Using Global Node IDs</a>
|
||||
*
|
||||
* @return Global Node ID.
|
||||
*/
|
||||
public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,6 @@ class GHOrgHook extends GHHook {
|
||||
|
||||
@Override
|
||||
String getApiRoute() {
|
||||
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), id);
|
||||
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class GHOrganization extends GHPerson {
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||
*/
|
||||
@Deprecated
|
||||
public GHRepository createRepository(String name,
|
||||
String description,
|
||||
String homepage,
|
||||
@@ -69,6 +70,7 @@ public class GHOrganization extends GHPerson {
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||
*/
|
||||
@Deprecated
|
||||
public GHRepository createRepository(String name,
|
||||
String description,
|
||||
String homepage,
|
||||
@@ -88,7 +90,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 +123,43 @@ 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single team by ID.
|
||||
*
|
||||
* @param teamId
|
||||
* id of the team that we want to query for
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @deprecated Use {@link GHOrganization#getTeam(long)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam getTeam(int teamId) throws IOException {
|
||||
return getTeam((long) teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single team by ID.
|
||||
*
|
||||
* @param teamId
|
||||
* id of the team that we want to query for
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeam(long teamId) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/organizations/%d/team/%d", getId(), teamId))
|
||||
.fetch(GHTeam.class)
|
||||
.wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,19 +181,19 @@ public class GHOrganization extends GHPerson {
|
||||
|
||||
/**
|
||||
* Finds a team that has the given slug in its {@link GHTeam#getSlug()}
|
||||
*
|
||||
*
|
||||
* @param slug
|
||||
* the slug
|
||||
* @return the team by slug
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see <a href= "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeamBySlug(String slug) throws IOException {
|
||||
for (GHTeam t : listTeams()) {
|
||||
if (t.getSlug().equals(slug))
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))
|
||||
.fetch(GHTeam.class)
|
||||
.wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,10 +218,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 +234,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 +251,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 +263,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 +279,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +291,7 @@ public class GHOrganization extends GHPerson {
|
||||
* @deprecated use {@link #listMembers()}
|
||||
*/
|
||||
public List<GHUser> getMembers() throws IOException {
|
||||
return listMembers().asList();
|
||||
return listMembers().toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,7 +317,7 @@ public class GHOrganization extends GHPerson {
|
||||
}
|
||||
|
||||
private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
|
||||
return listMembers(suffix, null);
|
||||
return listMembers(suffix, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,15 +330,29 @@ public class GHOrganization extends GHPerson {
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembersWithFilter(String filter) throws IOException {
|
||||
return listMembers("members", filter);
|
||||
return listMembers("members", filter, null);
|
||||
}
|
||||
|
||||
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));
|
||||
/**
|
||||
* List members with specified role paged iterable.
|
||||
*
|
||||
* @param role
|
||||
* the role
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHUser> listMembersWithRole(String role) throws IOException {
|
||||
return listMembers("members", null, role);
|
||||
}
|
||||
|
||||
private PagedIterable<GHUser> listMembers(final String suffix, final String filter, String role)
|
||||
throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/%s", login, suffix))
|
||||
.with("filter", filter)
|
||||
.with("role", role)
|
||||
.toIterable(GHUser[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,7 +364,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 +377,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 +407,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 +437,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 +463,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 +480,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 +503,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 +566,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 +581,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@ package org.kohsuke.github;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
@@ -20,12 +21,16 @@ public abstract class GHPerson extends GHObject {
|
||||
/* package almost final */ GitHub root;
|
||||
|
||||
// core data fields that exist even for "small" user data (such as the user info in pull request)
|
||||
protected String login, avatar_url, gravatar_id;
|
||||
protected String login, avatar_url;
|
||||
|
||||
// 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;
|
||||
@@ -41,13 +46,16 @@ public abstract class GHPerson extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
protected synchronized void populate() throws IOException {
|
||||
if (created_at != null) {
|
||||
if (super.getCreatedAt() != null) {
|
||||
return; // already populated
|
||||
}
|
||||
if (root == null || root.isOffline()) {
|
||||
return; // cannot populate, will have to live with what we have
|
||||
}
|
||||
root.retrieve().to(url, this);
|
||||
URL url = getUrl();
|
||||
if (url != null) {
|
||||
root.createRequest().setRawUrlPath(url.toString()).fetchInto(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,8 +96,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);
|
||||
}
|
||||
|
||||
@@ -110,28 +119,27 @@ public abstract class GHPerson extends GHObject {
|
||||
*/
|
||||
@Deprecated
|
||||
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);
|
||||
|
||||
return new Iterator<List<GHRepository>>() {
|
||||
public boolean hasNext() {
|
||||
return pager.hasNext();
|
||||
}
|
||||
|
||||
public List<GHRepository> next() {
|
||||
GHRepository[] batch = pager.next();
|
||||
for (GHRepository r : batch)
|
||||
r.root = root;
|
||||
return Arrays.asList(batch);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
return () -> {
|
||||
final PagedIterator<GHRepository> pager;
|
||||
try {
|
||||
GitHubPageIterator<GHRepository[]> iterator = GitHubPageIterator.create(root.getClient(),
|
||||
GHRepository[].class,
|
||||
root.createRequest().withUrlPath("users", login, "repos").build(),
|
||||
pageSize);
|
||||
pager = new PagedIterator<>(iterator, item -> item.wrap(root));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new GHException("Unable to build GitHub API URL", e);
|
||||
}
|
||||
|
||||
return new Iterator<List<GHRepository>>() {
|
||||
public boolean hasNext() {
|
||||
return pager.hasNext();
|
||||
}
|
||||
|
||||
public List<GHRepository> next() {
|
||||
return pager.nextPage();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -146,7 +154,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;
|
||||
}
|
||||
@@ -167,22 +178,18 @@ public abstract class GHPerson extends GHObject {
|
||||
* @return the gravatar id
|
||||
* @deprecated No longer available in the v3 API.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getGravatarId() {
|
||||
return gravatar_id;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' that indicates the
|
||||
* avatar image URL.
|
||||
* Returns a string of the avatar image URL.
|
||||
*
|
||||
* @return the avatar url
|
||||
*/
|
||||
public String getAvatarUrl() {
|
||||
if (avatar_url != null)
|
||||
return avatar_url;
|
||||
if (gravatar_id != null)
|
||||
return "https://secure.gravatar.com/avatar/" + gravatar_id;
|
||||
return null;
|
||||
return avatar_url;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +261,7 @@ public abstract class GHPerson extends GHObject {
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,4 +323,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ public class GHProject extends GHObject {
|
||||
|
||||
private String owner_url;
|
||||
private String html_url;
|
||||
private String node_id;
|
||||
private String name;
|
||||
private String body;
|
||||
private int number;
|
||||
@@ -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,16 +98,18 @@ public class GHProject extends GHObject {
|
||||
* @return the owner url
|
||||
*/
|
||||
public URL getOwnerUrl() {
|
||||
return GitHub.parseURL(owner_url);
|
||||
return GitHubClient.parseURL(owner_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets node id.
|
||||
*
|
||||
* @deprecated Use {@link GHObject#getNodeId()}
|
||||
* @return the node id
|
||||
*/
|
||||
@Deprecated
|
||||
public String getNode_id() {
|
||||
return node_id;
|
||||
return getNodeId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +183,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +192,7 @@ public class GHProject extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return "/projects/" + id;
|
||||
return "/projects/" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +277,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 +289,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", getId()))
|
||||
.toIterable(GHProjectColumn[].class, item -> item.wrap(project));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,11 +305,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", getId()))
|
||||
.fetch(GHProjectColumn.class)
|
||||
.wrap(this);
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,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 +90,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 +113,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 +149,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 +158,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 +167,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 +204,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +213,7 @@ public class GHProjectCard extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return String.format("/projects/columns/cards/%d", id);
|
||||
return String.format("/projects/columns/cards/%d", getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,6 +223,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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,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 +90,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 +106,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ public class GHProjectColumn extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return String.format("/projects/columns/%d", id);
|
||||
return String.format("/projects/columns/%d", getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,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 +137,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", getId()))
|
||||
.toIterable(GHProjectCard[].class, item -> item.wrap(column));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,11 +153,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", getId()))
|
||||
.fetch(GHProjectCard.class)
|
||||
.wrap(this);
|
||||
}
|
||||
|
||||
@@ -172,12 +172,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", getId()))
|
||||
.fetch(GHProjectCard.class)
|
||||
.wrap(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -31,6 +33,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
@@ -99,6 +102,12 @@ 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.
|
||||
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
|
||||
return StringUtils.prependIfMissing(url.toString().replace(root.getApiUrl(), ""), "/");
|
||||
|
||||
}
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
|
||||
}
|
||||
|
||||
@@ -108,7 +117,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 +126,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 +165,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 +174,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
|
||||
@@ -381,10 +390,14 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
* Repopulates this object.
|
||||
*/
|
||||
public void refresh() throws IOException {
|
||||
if (root.isOffline()) {
|
||||
if (root == null || root.isOffline()) {
|
||||
return; // cannot populate, will have to live with what we have
|
||||
}
|
||||
root.retrieve().withPreview(SHADOW_CAT).to(url, this).wrapUp(owner);
|
||||
|
||||
URL url = getUrl();
|
||||
if (url != null) {
|
||||
root.createRequest().withPreview(SHADOW_CAT).setRawUrlPath(url.toString()).fetchInto(this).wrapUp(owner);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,8 +406,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 +417,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 +430,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 +441,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,6 +460,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createReview()}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHPullRequestReview createReview(String body,
|
||||
@CheckForNull GHPullRequestReviewState event,
|
||||
GHPullRequestReviewComment... comments) throws IOException {
|
||||
@@ -469,6 +481,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
* the io exception
|
||||
* @deprecated Use {@link #createReview()}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHPullRequestReview createReview(String body,
|
||||
@CheckForNull GHPullRequestReviewState event,
|
||||
List<GHPullRequestReviewComment> comments) throws IOException {
|
||||
@@ -505,12 +518,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 +538,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 +558,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 +610,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 +628,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class GHPullRequestCommitDetail {
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class GHPullRequestCommitDetail {
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ public class GHPullRequestCommitDetail {
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ public class GHPullRequestCommitDetail {
|
||||
* @return the html url
|
||||
*/
|
||||
public URL getHtml_url() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ public class GHPullRequestCommitDetail {
|
||||
* @return the api url
|
||||
*/
|
||||
public URL getApiUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +223,7 @@ public class GHPullRequestCommitDetail {
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +232,7 @@ public class GHPullRequestCommitDetail {
|
||||
* @return the comments url
|
||||
*/
|
||||
public URL getCommentsUrl() {
|
||||
return GitHub.parseURL(comments_url);
|
||||
return GitHubClient.parseURL(comments_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -105,7 +105,7 @@ public class GHPullRequestFileDetail {
|
||||
* @return the blob url
|
||||
*/
|
||||
public URL getBlobUrl() {
|
||||
return GitHub.parseURL(blob_url);
|
||||
return GitHubClient.parseURL(blob_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ public class GHPullRequestFileDetail {
|
||||
* @return the raw url
|
||||
*/
|
||||
public URL getRawUrl() {
|
||||
return GitHub.parseURL(raw_url);
|
||||
return GitHubClient.parseURL(raw_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ public class GHPullRequestFileDetail {
|
||||
* @return the contents url
|
||||
*/
|
||||
public URL getContentsUrl() {
|
||||
return GitHub.parseURL(contents_url);
|
||||
return GitHubClient.parseURL(contents_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,6 +89,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class GHPullRequestReview extends GHObject {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return owner.getApiRoute() + "/reviews/" + id;
|
||||
return owner.getApiRoute() + "/reviews/" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,6 +145,7 @@ public class GHPullRequestReview extends GHObject {
|
||||
* @deprecated Former preview method that changed when it got public. Left here for backward compatibility. Use
|
||||
* {@link #submit(String, GHPullRequestReviewEvent)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void submit(String body, GHPullRequestReviewState state) throws IOException {
|
||||
submit(body, state.toEvent());
|
||||
}
|
||||
@@ -160,10 +161,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 +178,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 +190,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 +206,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,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 +91,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
private String body;
|
||||
private GHUser user;
|
||||
private String path;
|
||||
private String html_url;
|
||||
private int position = -1;
|
||||
private int original_position = -1;
|
||||
private long in_reply_to_id = -1L;
|
||||
@@ -60,6 +61,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
* @return the gh pull request review comment
|
||||
* @deprecated You should be using {@link GHPullRequestReviewBuilder#comment(String, String, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static GHPullRequestReviewComment draft(String body, String path, int position) {
|
||||
GHPullRequestReviewComment result = new GHPullRequestReviewComment();
|
||||
result.body = body;
|
||||
@@ -142,7 +144,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
return GitHubClient.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +153,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + id;
|
||||
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +165,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 +176,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 +189,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public abstract class GHQueryBuilder<T> {
|
||||
|
||||
GHQueryBuilder(GitHub root) {
|
||||
this.root = root;
|
||||
this.req = root.retrieve();
|
||||
this.req = root.createRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
@@ -12,6 +13,7 @@ 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;
|
||||
@@ -41,7 +43,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 +65,7 @@ public class GHRateLimit {
|
||||
@Nonnull
|
||||
private final Record integrationManifest;
|
||||
|
||||
@Nonnull
|
||||
static GHRateLimit Unknown() {
|
||||
return new GHRateLimit(new UnknownLimitRecord(),
|
||||
new UnknownLimitRecord(),
|
||||
@@ -67,6 +73,7 @@ public class GHRateLimit {
|
||||
new UnknownLimitRecord());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static GHRateLimit fromHeaderRecord(Record header) {
|
||||
return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord());
|
||||
}
|
||||
@@ -76,6 +83,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 +97,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 +220,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 +280,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,11 +291,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 #calculateResetDate}. 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.
|
||||
*/
|
||||
@Nonnull
|
||||
private Date resetDate;
|
||||
private final Date resetDate;
|
||||
|
||||
/**
|
||||
* Instantiates a new Record.
|
||||
@@ -269,15 +308,14 @@ public class GHRateLimit {
|
||||
* @param resetEpochSeconds
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Record.
|
||||
* Instantiates a new Record. Called by Jackson data binding or during header parsing.
|
||||
*
|
||||
* @param limit
|
||||
* the limit
|
||||
@@ -285,26 +323,53 @@ public class GHRateLimit {
|
||||
* the remaining
|
||||
* @param resetEpochSeconds
|
||||
* the reset epoch seconds
|
||||
* @param updatedAt
|
||||
* the updated at
|
||||
* @param responseInfo
|
||||
* the response info
|
||||
*/
|
||||
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "Deprecated")
|
||||
public Record(int limit, int remaining, long resetEpochSeconds, String updatedAt) {
|
||||
@JsonCreator
|
||||
Record(@JsonProperty(value = "limit", required = true) int limit,
|
||||
@JsonProperty(value = "remaining", required = true) int remaining,
|
||||
@JsonProperty(value = "reset", required = true) long resetEpochSeconds,
|
||||
@JacksonInject @CheckForNull GitHubResponse.ResponseInfo responseInfo) {
|
||||
this.limit = limit;
|
||||
this.remaining = remaining;
|
||||
this.resetEpochSeconds = resetEpochSeconds;
|
||||
this.resetDate = recalculateResetDate(updatedAt);
|
||||
String updatedAt = null;
|
||||
if (responseInfo != null) {
|
||||
updatedAt = responseInfo.headerField("Date");
|
||||
}
|
||||
this.resetDate = calculateResetDate(updatedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
@Nonnull
|
||||
private Date calculateResetDate(@CheckForNull String updatedAt) {
|
||||
long updatedAtEpochSeconds = createdAtEpochSeconds;
|
||||
if (!StringUtils.isBlank(updatedAt)) {
|
||||
try {
|
||||
@@ -319,9 +384,9 @@ 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);
|
||||
return new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,14 +410,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 +431,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.
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,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/" + getId()).send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GHRef {
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,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 +82,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) {
|
||||
@@ -84,13 +90,6 @@ public class GHRef {
|
||||
return this;
|
||||
}
|
||||
|
||||
static GHRef[] wrap(GHRef[] in, GitHub root) {
|
||||
for (GHRef r : in) {
|
||||
r.wrap(root);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type GHObject.
|
||||
*/
|
||||
@@ -125,7 +124,7 @@ public class GHRef {
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(url);
|
||||
return GitHubClient.parseURL(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -72,12 +71,13 @@ public class GHRelease extends GHObject {
|
||||
* the io exception
|
||||
* @deprecated Use {@link #update()}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHRelease setDraft(boolean draft) throws IOException {
|
||||
return update().draft(draft).update();
|
||||
}
|
||||
|
||||
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,10 +256,11 @@ 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);
|
||||
return Arrays.asList(GHAsset.wrap(assets, this));
|
||||
return builder.withUrlPath(getApiTailUrl("assets"))
|
||||
.toIterable(GHAsset[].class, item -> item.wrap(this))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +270,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/" + getId())).send();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,6 +283,6 @@ public class GHRelease extends GHObject {
|
||||
}
|
||||
|
||||
private String getApiTailUrl(String end) {
|
||||
return owner.getApiTailUrl(format("releases/%s/%s", id, end));
|
||||
return owner.getApiTailUrl(format("releases/%s/%s", getId(), end));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class GHReleaseUpdater {
|
||||
|
||||
GHReleaseUpdater(GHRelease base) {
|
||||
this.base = base;
|
||||
this.builder = new Requester(base.root);
|
||||
this.builder = base.root.createRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,8 @@ public class GHReleaseUpdater {
|
||||
*/
|
||||
public GHRelease update() throws IOException {
|
||||
return builder.method("PATCH")
|
||||
.to(base.owner.getApiTailUrl("releases/" + base.id), GHRelease.class)
|
||||
.withUrlPath(base.owner.getApiTailUrl("releases/" + base.getId()))
|
||||
.fetch(GHRelease.class)
|
||||
.wrap(base.owner);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,6 @@ class GHRepoHook extends GHHook {
|
||||
|
||||
@Override
|
||||
String getApiRoute() {
|
||||
return String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), id);
|
||||
return String.format("/repos/%s/%s/hooks/%d", repository.getOwnerName(), repository.getName(), getId());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,13 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@@ -87,8 +86,9 @@ public class GHRepositoryStatistics {
|
||||
* This gets the actual statistics from the server. Returns null if they are still being cached.
|
||||
*/
|
||||
private PagedIterable<ContributorStats> getContributorStatsImpl() throws IOException {
|
||||
return root.retrieve()
|
||||
.asPagedIterable(getApiTailUrl("contributors"), ContributorStats[].class, item -> item.wrapUp(root));
|
||||
return root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("contributors"))
|
||||
.toIterable(ContributorStats[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,8 +243,9 @@ public class GHRepositoryStatistics {
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<CommitActivity> getCommitActivity() throws IOException {
|
||||
return root.retrieve()
|
||||
.asPagedIterable(getApiTailUrl("commit_activity"), CommitActivity[].class, item -> item.wrapUp(root));
|
||||
return root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("commit_activity"))
|
||||
.toIterable(CommitActivity[].class, item -> item.wrapUp(root));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,24 +316,12 @@ public class GHRepositoryStatistics {
|
||||
* the io exception
|
||||
*/
|
||||
public List<CodeFrequency> getCodeFrequency() throws IOException {
|
||||
// Map to ArrayLists first, since there are no field names in the
|
||||
// returned JSON.
|
||||
try {
|
||||
InputStream stream = root.retrieve().asStream(getApiTailUrl("code_frequency"));
|
||||
CodeFrequency[] list = root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("code_frequency"))
|
||||
.fetch(CodeFrequency[].class);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
TypeReference<ArrayList<ArrayList<Integer>>> typeRef = new TypeReference<ArrayList<ArrayList<Integer>>>() {
|
||||
};
|
||||
ArrayList<ArrayList<Integer>> list = mapper.readValue(stream, typeRef);
|
||||
|
||||
// Convert to proper objects.
|
||||
ArrayList<CodeFrequency> returnList = new ArrayList<CodeFrequency>();
|
||||
for (ArrayList<Integer> item : list) {
|
||||
CodeFrequency cf = new CodeFrequency(item);
|
||||
returnList.add(cf);
|
||||
}
|
||||
|
||||
return returnList;
|
||||
return Arrays.asList(list);
|
||||
} catch (MismatchedInputException e) {
|
||||
// This sometimes happens when retrieving code frequency statistics
|
||||
// for a repository for the first time. It is probably still being
|
||||
@@ -345,11 +334,13 @@ public class GHRepositoryStatistics {
|
||||
* The type CodeFrequency.
|
||||
*/
|
||||
public static class CodeFrequency {
|
||||
private int week;
|
||||
private int additions;
|
||||
private int deletions;
|
||||
|
||||
private CodeFrequency(ArrayList<Integer> item) {
|
||||
private final int week;
|
||||
private final int additions;
|
||||
private final int deletions;
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
private CodeFrequency(List<Integer> item) {
|
||||
week = item.get(0);
|
||||
additions = item.get(1);
|
||||
deletions = item.get(2);
|
||||
@@ -400,7 +391,7 @@ public class GHRepositoryStatistics {
|
||||
* the io exception
|
||||
*/
|
||||
public Participation getParticipation() throws IOException {
|
||||
return root.retrieve().to(getApiTailUrl("participation"), Participation.class);
|
||||
return root.createRequest().withUrlPath(getApiTailUrl("participation")).fetch(Participation.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,7 +422,7 @@ public class GHRepositoryStatistics {
|
||||
* @return The list of commit counts for everyone combined, for the last 52 weeks.
|
||||
*/
|
||||
public List<Integer> getAllCommits() {
|
||||
return all;
|
||||
return Collections.unmodifiableList(all);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,7 +431,7 @@ public class GHRepositoryStatistics {
|
||||
* @return The list of commit counts for the owner, for the last 52 weeks.
|
||||
*/
|
||||
public List<Integer> getOwnerCommits() {
|
||||
return owner;
|
||||
return Collections.unmodifiableList(owner);
|
||||
}
|
||||
|
||||
Participation wrapUp(GitHub root) {
|
||||
@@ -458,34 +449,23 @@ public class GHRepositoryStatistics {
|
||||
* the io exception
|
||||
*/
|
||||
public List<PunchCardItem> getPunchCard() throws IOException {
|
||||
// Map to ArrayLists first, since there are no field names in the
|
||||
// returned JSON.
|
||||
InputStream stream = root.retrieve().asStream(getApiTailUrl("punch_card"));
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
TypeReference<ArrayList<ArrayList<Integer>>> typeRef = new TypeReference<ArrayList<ArrayList<Integer>>>() {
|
||||
};
|
||||
ArrayList<ArrayList<Integer>> list = mapper.readValue(stream, typeRef);
|
||||
|
||||
// Convert to proper objects.
|
||||
ArrayList<PunchCardItem> returnList = new ArrayList<PunchCardItem>();
|
||||
for (ArrayList<Integer> item : list) {
|
||||
PunchCardItem pci = new PunchCardItem(item);
|
||||
returnList.add(pci);
|
||||
}
|
||||
|
||||
return returnList;
|
||||
PunchCardItem[] list = root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("punch_card"))
|
||||
.fetch(PunchCardItem[].class);
|
||||
return Arrays.asList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type PunchCardItem.
|
||||
*/
|
||||
public static class PunchCardItem {
|
||||
private int dayOfWeek;
|
||||
private int hourOfDay;
|
||||
private int numberOfCommits;
|
||||
|
||||
private PunchCardItem(ArrayList<Integer> item) {
|
||||
private final int dayOfWeek;
|
||||
private final int hourOfDay;
|
||||
private final int numberOfCommits;
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
private PunchCardItem(List<Integer> item) {
|
||||
dayOfWeek = item.get(0);
|
||||
hourOfDay = item.get(1);
|
||||
numberOfCommits = item.get(2);
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class GHRepositoryTraffic implements TrafficInfo {
|
||||
* @return the timestamp
|
||||
*/
|
||||
public Date getTimestamp() {
|
||||
return GitHub.parseDate(timestamp);
|
||||
return GitHubClient.parseDate(timestamp);
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
|
||||
49
src/main/java/org/kohsuke/github/GHRequestedAction.java
Normal file
49
src/main/java/org/kohsuke/github/GHRequestedAction.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||
justification = "JSON API")
|
||||
public class GHRequestedAction extends GHObject {
|
||||
private GHRepository owner;
|
||||
private GitHub root;
|
||||
private String identifier;
|
||||
private String label;
|
||||
private String description;
|
||||
|
||||
GHRequestedAction wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
wrap(owner.root);
|
||||
return this;
|
||||
}
|
||||
GHRequestedAction wrap(GitHub root) {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This object has no HTML URL.
|
||||
*/
|
||||
@Override
|
||||
public URL getHtmlUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,6 +24,7 @@ public abstract class GHSearchBuilder<T> extends GHQueryBuilder<T> {
|
||||
GHSearchBuilder(GitHub root, Class<? extends SearchResult<T>> receiverType) {
|
||||
super(root);
|
||||
this.receiverType = receiverType;
|
||||
req.withUrlPath(getApiUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,16 +44,13 @@ public abstract class GHSearchBuilder<T> extends GHQueryBuilder<T> {
|
||||
*/
|
||||
@Override
|
||||
public PagedSearchIterable<T> list() {
|
||||
return new PagedSearchIterable<T>(root) {
|
||||
public PagedIterator<T> _iterator(int pageSize) {
|
||||
req.set("q", StringUtils.join(terms, " "));
|
||||
return new PagedIterator<T>(adapt(req.asIterator(getApiUrl(), receiverType, pageSize))) {
|
||||
protected void wrapUp(T[] page) {
|
||||
// SearchResult.getItems() should do it
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
req.set("q", StringUtils.join(terms, " "));
|
||||
try {
|
||||
return new PagedSearchIterable<>(root, req.build(), receiverType);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new GHException("", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ public class GHStargazer {
|
||||
* @return the date the stargazer was added
|
||||
*/
|
||||
public Date getStarredAt() {
|
||||
return GitHub.parseDate(starred_at);
|
||||
return GitHubClient.parseDate(starred_at);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GHSubscription {
|
||||
* @return the created at
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return GitHub.parseDate(created_at);
|
||||
return GitHubClient.parseDate(created_at);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class GHSubscription {
|
||||
* the io exception
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
new Requester(root).method("DELETE").to(repo.getApiTailUrl("subscription"));
|
||||
root.createRequest().method("DELETE").withUrlPath(repo.getApiTailUrl("subscription")).send();
|
||||
}
|
||||
|
||||
GHSubscription wrapUp(GHRepository repo) {
|
||||
|
||||
@@ -19,6 +19,7 @@ public class GHTagObject {
|
||||
private String message;
|
||||
private GitUser tagger;
|
||||
private GHRef.GHObject object;
|
||||
private GHVerification verification;
|
||||
|
||||
GHTagObject wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
@@ -97,4 +98,13 @@ public class GHTagObject {
|
||||
public GHRef.GHObject getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Verification Status.
|
||||
*
|
||||
* @return the Verification status
|
||||
*/
|
||||
public GHVerification getVerification() {
|
||||
return verification;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user