mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-11 08:21:23 +00:00
Compare commits
1303 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1ff0a4453 | ||
|
|
6564648230 | ||
|
|
48cadbc814 | ||
|
|
fbfba70714 | ||
|
|
30a6cc504e | ||
|
|
54d8fe93a8 | ||
|
|
4abf33acdb | ||
|
|
c00d562b48 | ||
|
|
fad4753f0f | ||
|
|
c24df1d022 | ||
|
|
823465590e | ||
|
|
804db70049 | ||
|
|
1782e5a483 | ||
|
|
b6283a0493 | ||
|
|
0bb18ee7c5 | ||
|
|
1a77dd270f | ||
|
|
1c6ab19d59 | ||
|
|
ef4e64dcdd | ||
|
|
946b4e963b | ||
|
|
0d7867daf6 | ||
|
|
3044b5437b | ||
|
|
4a2886531d | ||
|
|
c5e2d8b2ae | ||
|
|
3041431468 | ||
|
|
63b9188dad | ||
|
|
2436ed0431 | ||
|
|
0295ad82fa | ||
|
|
c197dc6b7b | ||
|
|
a79971e406 | ||
|
|
1a56f9d093 | ||
|
|
35852055e8 | ||
|
|
196ee25452 | ||
|
|
7d8335423d | ||
|
|
eac4990eac | ||
|
|
0f17812732 | ||
|
|
3bafb965c5 | ||
|
|
0e02444c07 | ||
|
|
4dcc479d48 | ||
|
|
a564c97763 | ||
|
|
80e17109de | ||
|
|
c395b9d6b3 | ||
|
|
e34d33f1cd | ||
|
|
1c920dee06 | ||
|
|
955d2e0a07 | ||
|
|
d0912009dd | ||
|
|
e68950e619 | ||
|
|
93c026b7af | ||
|
|
5254839ff7 | ||
|
|
6ca0d83b70 | ||
|
|
8ed832a303 | ||
|
|
dbf6d3bf37 | ||
|
|
081a454ec8 | ||
|
|
543b643fdb | ||
|
|
d02f194668 | ||
|
|
9c8c00b77c | ||
|
|
a23de4707b | ||
|
|
301303bd90 | ||
|
|
4689b8f885 | ||
|
|
c4de682493 | ||
|
|
b23934a5a1 | ||
|
|
f2eecc3cc5 | ||
|
|
f5310965dc | ||
|
|
47ffff3407 | ||
|
|
f2a70a46ad | ||
|
|
acd5c6baa6 | ||
|
|
06d02059cb | ||
|
|
603288c361 | ||
|
|
09ee3168f9 | ||
|
|
1559d063c7 | ||
|
|
cfdcb182a4 | ||
|
|
d526b13d7d | ||
|
|
fffe31220e | ||
|
|
ce17396ea6 | ||
|
|
d18e81dc74 | ||
|
|
6ae5acba5d | ||
|
|
0a1c803f69 | ||
|
|
fa0865b208 | ||
|
|
886887913c | ||
|
|
5c64fec032 | ||
|
|
892f60ea16 | ||
|
|
f28f966040 | ||
|
|
0e9cc90d31 | ||
|
|
72dc5c5d18 | ||
|
|
02e02d39b0 | ||
|
|
e629a23bd4 | ||
|
|
f6e8a2c7c6 | ||
|
|
76bea5174f | ||
|
|
2be27d1a41 | ||
|
|
cd1454ac03 | ||
|
|
b550910f4c | ||
|
|
d13e490be2 | ||
|
|
3d451526ef | ||
|
|
bd38897d48 | ||
|
|
63ccbaf064 | ||
|
|
2beb806b8a | ||
|
|
552ba6693e | ||
|
|
2452add4d7 | ||
|
|
0dc931ceed | ||
|
|
1dfedc6a58 | ||
|
|
e33046a624 | ||
|
|
002b3f03da | ||
|
|
fd1817d111 | ||
|
|
7526b46f9d | ||
|
|
169fd18a54 | ||
|
|
0708812456 | ||
|
|
7d86070ac8 | ||
|
|
713b85f9de | ||
|
|
4fef5bb1fc | ||
|
|
f3eadcddb6 | ||
|
|
237171727d | ||
|
|
31212d33ae | ||
|
|
8af66133d2 | ||
|
|
9578e027b1 | ||
|
|
2c75b42b4e | ||
|
|
7854b30a76 | ||
|
|
cf2571858c | ||
|
|
092815747a | ||
|
|
649d7ed87f | ||
|
|
684560ef67 | ||
|
|
adf054ba5d | ||
|
|
dcdfee67cd | ||
|
|
9d7209ec62 | ||
|
|
b97e8a2c38 | ||
|
|
8bd3f391da | ||
|
|
5d0dbf6e2f | ||
|
|
38f3595552 | ||
|
|
b72e7fa2ee | ||
|
|
659b32f5ec | ||
|
|
d0c326bbf5 | ||
|
|
4a5aceb1f9 | ||
|
|
884248930e | ||
|
|
530d524366 | ||
|
|
5957da3d6d | ||
|
|
6efe428f57 | ||
|
|
25b9a2ce33 | ||
|
|
0ce78016cc | ||
|
|
696dd90b23 | ||
|
|
e66a72387e | ||
|
|
874ce23dd7 | ||
|
|
7479cac9a7 | ||
|
|
064ce1b0bc | ||
|
|
941573af49 | ||
|
|
2f9ff32176 | ||
|
|
b84d5a7c39 | ||
|
|
bd19f23b3f | ||
|
|
ee047ea9b5 | ||
|
|
601f18016a | ||
|
|
93abb0ed36 | ||
|
|
6453e585a9 | ||
|
|
3a1ed5a5b7 | ||
|
|
c5b45523d6 | ||
|
|
bf082f2a46 | ||
|
|
672febd88b | ||
|
|
927843ea83 | ||
|
|
8fac7d317e | ||
|
|
626574ae36 | ||
|
|
8c9eb3393b | ||
|
|
0c4728f46a | ||
|
|
837526ce5d | ||
|
|
afcfa906b8 | ||
|
|
8b3f50d4d3 | ||
|
|
9022455d85 | ||
|
|
8e20f4d9f5 | ||
|
|
7c8a7ff26e | ||
|
|
064d6944f3 | ||
|
|
b8b3cf9c80 | ||
|
|
18e7138812 | ||
|
|
bfb3b94478 | ||
|
|
6167d196d9 | ||
|
|
43ed7c7ac7 | ||
|
|
fc98e72569 | ||
|
|
258acf79f6 | ||
|
|
b509076d6f | ||
|
|
f57ea4c4e9 | ||
|
|
578fe085ce | ||
|
|
2553a79b02 | ||
|
|
4770316898 | ||
|
|
99f192d33c | ||
|
|
fc3bac0e77 | ||
|
|
ad2990b1b6 | ||
|
|
fab848a0d3 | ||
|
|
4a2244e661 | ||
|
|
bab5399327 | ||
|
|
52705ac695 | ||
|
|
73d2e1db5c | ||
|
|
83aa9d04ef | ||
|
|
97652c6803 | ||
|
|
f40daf8488 | ||
|
|
3e6a5bc718 | ||
|
|
78ffe5a759 | ||
|
|
9abfdc805b | ||
|
|
9e47a2b8c6 | ||
|
|
feba6ed8b6 | ||
|
|
acab40b704 | ||
|
|
435272065f | ||
|
|
c5c04672fc | ||
|
|
5eef764cba | ||
|
|
2682e0a1e2 | ||
|
|
a68d16d5de | ||
|
|
304ab10cf9 | ||
|
|
dc46341432 | ||
|
|
99aea9296e | ||
|
|
b0693037f3 | ||
|
|
c19cfd98d1 | ||
|
|
cdc0e2ad6b | ||
|
|
6606b5c7d1 | ||
|
|
551dbf2a06 | ||
|
|
d734237788 | ||
|
|
47e2a5aea1 | ||
|
|
57cdc308e8 | ||
|
|
8919c5f8c7 | ||
|
|
b8f00bc699 | ||
|
|
042038f480 | ||
|
|
fb03e749bd | ||
|
|
e522239832 | ||
|
|
ae69324196 | ||
|
|
5194c2d9bc | ||
|
|
daf5c5eb98 | ||
|
|
a7b4c97020 | ||
|
|
420d5d06f3 | ||
|
|
a7cd052b7c | ||
|
|
6e1b943823 | ||
|
|
8a3559ada5 | ||
|
|
ea3cbd4c71 | ||
|
|
34a1f9d6e4 | ||
|
|
629bd510c1 | ||
|
|
40937a5cc6 | ||
|
|
8509957102 | ||
|
|
b0aea0c575 | ||
|
|
1f7f646bec | ||
|
|
a59ee6a82d | ||
|
|
1fefc77582 | ||
|
|
199eee4e25 | ||
|
|
854df5321b | ||
|
|
bd509070ac | ||
|
|
a8c7c97d06 | ||
|
|
6d86cfb4f6 | ||
|
|
fb3e956502 | ||
|
|
9b0dbe6f34 | ||
|
|
c10c7237a7 | ||
|
|
36612fe97f | ||
|
|
18e2056a10 | ||
|
|
8c8f1451d4 | ||
|
|
be67f1d9e2 | ||
|
|
90bc250269 | ||
|
|
1bd178654f | ||
|
|
f22bf160f9 | ||
|
|
4261c42949 | ||
|
|
40cfb85a8e | ||
|
|
f08299b134 | ||
|
|
a04ab45abc | ||
|
|
0647df2d2b | ||
|
|
d4cc3af1e9 | ||
|
|
936ab499ce | ||
|
|
453f475b4e | ||
|
|
bda3855b86 | ||
|
|
772a6c112b | ||
|
|
9b4134cada | ||
|
|
ed9f54006d | ||
|
|
3b1f176544 | ||
|
|
d2732bcf54 | ||
|
|
a1461f401a | ||
|
|
f9fd30275c | ||
|
|
eeea14dab4 | ||
|
|
1df807a198 | ||
|
|
0848287069 | ||
|
|
334b37a256 | ||
|
|
8776a3b672 | ||
|
|
657550f767 | ||
|
|
45a0114f75 | ||
|
|
a8ddd3e12a | ||
|
|
b668396151 | ||
|
|
9e7c33369c | ||
|
|
8943ca6d1a | ||
|
|
b3460c1f9d | ||
|
|
5166c9265f | ||
|
|
35c8cfa01d | ||
|
|
8e6dbf3772 | ||
|
|
cb381dfa06 | ||
|
|
80124e3b85 | ||
|
|
7aae27e36f | ||
|
|
b212956fbb | ||
|
|
d033355e84 | ||
|
|
59d7a117d0 | ||
|
|
dfbb38c5f1 | ||
|
|
3f9954144a | ||
|
|
1b84efdbfa | ||
|
|
c33e78a7dc | ||
|
|
747c759bbb | ||
|
|
e0a709676e | ||
|
|
a96275c286 | ||
|
|
ca7c809feb | ||
|
|
a8a0bcb7db | ||
|
|
0e2bf23830 | ||
|
|
44a8b797fb | ||
|
|
cdede298a9 | ||
|
|
f6ac4d3559 | ||
|
|
7e1531dbca | ||
|
|
9aeb422157 | ||
|
|
fba0f8cf8e | ||
|
|
0f4a5227e1 | ||
|
|
d16a752b43 | ||
|
|
4d9aed90d6 | ||
|
|
4bec27fd49 | ||
|
|
be3bd74bb7 | ||
|
|
f1720b7bbc | ||
|
|
7a79a18d8f | ||
|
|
472034c950 | ||
|
|
0b14cee817 | ||
|
|
b50ab56f9e | ||
|
|
26d30663c4 | ||
|
|
ffecc390eb | ||
|
|
252ca04084 | ||
|
|
aae5c56a31 | ||
|
|
6670446037 | ||
|
|
bd39b07bb5 | ||
|
|
a9438b6121 | ||
|
|
f546cf4521 | ||
|
|
43efa78750 | ||
|
|
9e3de43802 | ||
|
|
dc615e432e | ||
|
|
cf9caa6af5 | ||
|
|
15f748358d | ||
|
|
b30d648623 | ||
|
|
33d70560b8 | ||
|
|
865a49d2e8 | ||
|
|
4fca68c25c | ||
|
|
f131a0c1c2 | ||
|
|
cd4368fa79 | ||
|
|
4ec4b160b0 | ||
|
|
a585b4957f | ||
|
|
e6b02b3bed | ||
|
|
1ef0ec0432 | ||
|
|
2e87bd86a1 | ||
|
|
0228a0d023 | ||
|
|
6365f3749d | ||
|
|
25c18130f9 | ||
|
|
436c19634d | ||
|
|
1a6facc685 | ||
|
|
bd0093c8ea | ||
|
|
e150280010 | ||
|
|
827fd5e472 | ||
|
|
f89fbc67b9 | ||
|
|
c567a88892 | ||
|
|
6a39d7fca5 | ||
|
|
a15e67f065 | ||
|
|
7a1bce9578 | ||
|
|
f2b4de7943 | ||
|
|
b3ff4ac6d9 | ||
|
|
1c56e7fab5 | ||
|
|
70ba4df385 | ||
|
|
8062c705e8 | ||
|
|
fafb23c1a6 | ||
|
|
4e7ac7030c | ||
|
|
4803daca5a | ||
|
|
facfc61316 | ||
|
|
e3e495bfb1 | ||
|
|
e007284d2f | ||
|
|
1da8416ebd | ||
|
|
79b49a469c | ||
|
|
5888efcaef | ||
|
|
459d1b4f56 | ||
|
|
9151102bda | ||
|
|
3819984add | ||
|
|
3b58fbc186 | ||
|
|
55e589b3d9 | ||
|
|
e64d64d8d8 | ||
|
|
37c2d9135b | ||
|
|
30c96221bd | ||
|
|
bf7305e3f8 | ||
|
|
3b12a229c3 | ||
|
|
5726ceb8dc | ||
|
|
c06c06624d | ||
|
|
ad40d7071e | ||
|
|
f55a39eb90 | ||
|
|
c3869bee31 | ||
|
|
6eac15df0f | ||
|
|
6f5d3c32c3 | ||
|
|
68ef40e4d0 | ||
|
|
4046bc4f72 | ||
|
|
1b8d131915 | ||
|
|
f5ad332d28 | ||
|
|
938603ff60 | ||
|
|
17af78f2bb | ||
|
|
7588267743 | ||
|
|
ed4f9c8176 | ||
|
|
bbb46e88b0 | ||
|
|
3db7aac0d8 | ||
|
|
fdbbd2e563 | ||
|
|
e92f1321d4 | ||
|
|
da2aaff9e5 | ||
|
|
208904b634 | ||
|
|
a433bcda2e | ||
|
|
4bba692170 | ||
|
|
59b61cd8be | ||
|
|
247b013e16 | ||
|
|
77baafa643 | ||
|
|
3c56f1f076 | ||
|
|
224d8c7cb4 | ||
|
|
0feb520549 | ||
|
|
ca365b12f6 | ||
|
|
bde6ad9a06 | ||
|
|
4953f4500d | ||
|
|
7fee1fcc74 | ||
|
|
4415ac8fd2 | ||
|
|
8c81e48a31 | ||
|
|
9ad0329c56 | ||
|
|
78f533bbfc | ||
|
|
79c7dd9ecf | ||
|
|
5d796d1f79 | ||
|
|
68a82be6c4 | ||
|
|
2676ef2b73 | ||
|
|
04b283c539 | ||
|
|
98b067937a | ||
|
|
8ababb60bf | ||
|
|
b51d655f77 | ||
|
|
74496d32da | ||
|
|
316e278be1 | ||
|
|
d881bf6504 | ||
|
|
c74fbbe1fd | ||
|
|
929d9fb7bd | ||
|
|
5d069d0531 | ||
|
|
dd9e6dc5d3 | ||
|
|
d22c77c41d | ||
|
|
3a11b7ccbf | ||
|
|
d7931777bc | ||
|
|
9d161b28bb | ||
|
|
9b16a1caa0 | ||
|
|
9a918e3bac | ||
|
|
d4c5c6a1e0 | ||
|
|
63fda3555c | ||
|
|
6a2381c06b | ||
|
|
e9c0a16c26 | ||
|
|
2101a67ac1 | ||
|
|
ddac568aaa | ||
|
|
262ae9f635 | ||
|
|
381502fb80 | ||
|
|
92fb441eb2 | ||
|
|
29e08037a8 | ||
|
|
84cc6d9315 | ||
|
|
b8d5a1c732 | ||
|
|
0197ab9661 | ||
|
|
b7915e61a6 | ||
|
|
586db99450 | ||
|
|
5377d0dd18 | ||
|
|
bb48d55bd4 | ||
|
|
c5d3a7d573 | ||
|
|
8267050f06 | ||
|
|
610b02968e | ||
|
|
a7112c42df | ||
|
|
8a474a3b00 | ||
|
|
59e18d155e | ||
|
|
12ca5d8063 | ||
|
|
c959e0a928 | ||
|
|
89a08b021d | ||
|
|
04b553cdec | ||
|
|
15e9ee30ee | ||
|
|
a0d650a86c | ||
|
|
1a6ad48e08 | ||
|
|
7c82eeb018 | ||
|
|
b188e74ee0 | ||
|
|
c21bd5765a | ||
|
|
b78c37a695 | ||
|
|
2f151d45c3 | ||
|
|
3ebe3afdbd | ||
|
|
f4845df6c0 | ||
|
|
272b87f04d | ||
|
|
ff790eeefb | ||
|
|
97e918da03 | ||
|
|
4f30998873 | ||
|
|
a0fc478a28 | ||
|
|
bb03fd1968 | ||
|
|
0c65f74662 | ||
|
|
29ac2bd4f5 | ||
|
|
0d8b4f32e8 | ||
|
|
83db7f24eb | ||
|
|
5f9976a193 | ||
|
|
9480ef485b | ||
|
|
a9b7432584 | ||
|
|
6d7081910f | ||
|
|
aa96089ab4 | ||
|
|
58ae681417 | ||
|
|
c038e0af5e | ||
|
|
4f9976c0cb | ||
|
|
e308e5ed57 | ||
|
|
7b1b1ca994 | ||
|
|
551be49a1a | ||
|
|
a3888e6902 | ||
|
|
43bb6a0dd8 | ||
|
|
6e3f754366 | ||
|
|
6360112432 | ||
|
|
f1ca0b5417 | ||
|
|
0894c8007c | ||
|
|
05863acbcd | ||
|
|
0e4cd06137 | ||
|
|
85d2d974e7 | ||
|
|
3f021f9552 | ||
|
|
0456f10709 | ||
|
|
b7d03f7463 | ||
|
|
07a392c2a7 | ||
|
|
5b69de770f | ||
|
|
4688870984 | ||
|
|
bf67069768 | ||
|
|
91764c1c74 | ||
|
|
8b2a3e1221 | ||
|
|
def2f0b37d | ||
|
|
5d7479a3dd | ||
|
|
ceb2d35f9f | ||
|
|
fc38dba59a | ||
|
|
75b383d398 | ||
|
|
ee2d9491fb | ||
|
|
bf86a7c75a | ||
|
|
70f6d129e2 | ||
|
|
a4ac2aa99a | ||
|
|
ae3b6fbe6b | ||
|
|
e357fca963 | ||
|
|
c84cc89805 | ||
|
|
181238cd50 | ||
|
|
214c24c736 | ||
|
|
cf51ce8f26 | ||
|
|
2b7ed40d01 | ||
|
|
349ef7a54c | ||
|
|
94df5fc389 | ||
|
|
906238a297 | ||
|
|
7963fa82b5 | ||
|
|
1aba6012fb | ||
|
|
ff4324ac67 | ||
|
|
11bc669e1d | ||
|
|
dcf26d58e4 | ||
|
|
4d46872c35 | ||
|
|
4f0d62f421 | ||
|
|
f7ad1f517b | ||
|
|
345d6197f3 | ||
|
|
bb4d44138a | ||
|
|
a8ef0cde53 | ||
|
|
77dc009c95 | ||
|
|
aa298c93cc | ||
|
|
dfb0a5240e | ||
|
|
9cfc3c22b5 | ||
|
|
b177d98e29 | ||
|
|
5405fb0370 | ||
|
|
72a1c24b3b | ||
|
|
f146ae94ec | ||
|
|
a0bbba748a | ||
|
|
81bf818573 | ||
|
|
d5913dc292 | ||
|
|
e1e901b794 | ||
|
|
2f2f26767e | ||
|
|
bffa78c1b8 | ||
|
|
c55719c67a | ||
|
|
cb3b4a6642 | ||
|
|
92c141cee6 | ||
|
|
fd1a1a1c23 | ||
|
|
b835884b2e | ||
|
|
660763908d | ||
|
|
fe8bdb755a | ||
|
|
67dc6d2d23 | ||
|
|
9c8d73cbe2 | ||
|
|
5db97d92dd | ||
|
|
ac470dddb5 | ||
|
|
43063fe8ce | ||
|
|
59e0046c1e | ||
|
|
36ab05c265 | ||
|
|
2b2be05dae | ||
|
|
fb1adbd1ef | ||
|
|
ab68a59b25 | ||
|
|
9c7de767e9 | ||
|
|
8ba5cf7c2e | ||
|
|
b194a19b98 | ||
|
|
1d344b016f | ||
|
|
474f3ef4ca | ||
|
|
9830927020 | ||
|
|
727932a442 | ||
|
|
cd92b51845 | ||
|
|
fe26d16411 | ||
|
|
d68c66ce2b | ||
|
|
e7bfbfb48f | ||
|
|
f2a88ae61c | ||
|
|
e2113f6ee5 | ||
|
|
3867224024 | ||
|
|
9ee0bf43bc | ||
|
|
2844542efa | ||
|
|
e3fcae9392 | ||
|
|
c6ccfa91f3 | ||
|
|
b6fcee1cb9 | ||
|
|
9071befb04 | ||
|
|
bdd5fe98f3 | ||
|
|
a3d3e83a49 | ||
|
|
08bde72028 | ||
|
|
108a136368 | ||
|
|
57d87ad6b1 | ||
|
|
0c22815ff7 | ||
|
|
0ca792ecfd | ||
|
|
987c34c69e | ||
|
|
c1c02bc8ab | ||
|
|
4ee369f27c | ||
|
|
c9012efdcb | ||
|
|
41524fc67d | ||
|
|
04ff61e981 | ||
|
|
532468dc67 | ||
|
|
9c9a2dae47 | ||
|
|
c8a868b57f | ||
|
|
4b3f81ee34 | ||
|
|
afa170ba7c | ||
|
|
46e3b2272e | ||
|
|
52472e90ec | ||
|
|
4ef0d00846 | ||
|
|
580f2537f2 | ||
|
|
3d9fd96026 | ||
|
|
f449b92721 | ||
|
|
3b0216b023 | ||
|
|
98cf839737 | ||
|
|
0bb0846505 | ||
|
|
70969400a3 | ||
|
|
147e8d5d12 | ||
|
|
cacc3e6edd | ||
|
|
a284eca147 | ||
|
|
0d3ba9d7f0 | ||
|
|
be8064d642 | ||
|
|
e30dba742d | ||
|
|
44b72ed647 | ||
|
|
666bd77dac | ||
|
|
0a6613e60d | ||
|
|
62e186c123 | ||
|
|
50dd8f5bcc | ||
|
|
d5fcac9c45 | ||
|
|
c2bed85190 | ||
|
|
183b463ef2 | ||
|
|
92fdac44a0 | ||
|
|
12829ecc73 | ||
|
|
51319c3b26 | ||
|
|
8fd827040b | ||
|
|
5ec46eae0d | ||
|
|
32c03301be | ||
|
|
df7f29b2ab | ||
|
|
e863113c36 | ||
|
|
8e2c1d7382 | ||
|
|
ab7b9cccba | ||
|
|
81bf61a161 | ||
|
|
b40f008647 | ||
|
|
734e41702b | ||
|
|
038dd20a91 | ||
|
|
1dd62b8550 | ||
|
|
715deebe05 | ||
|
|
b3fe3d8590 | ||
|
|
f74c3ed3ea | ||
|
|
2c9aebeeed | ||
|
|
7474f1e11f | ||
|
|
dba9c55b64 | ||
|
|
b432364397 | ||
|
|
696967bdd1 | ||
|
|
b76889efc3 | ||
|
|
e6a7b64ebe | ||
|
|
9daa0df311 | ||
|
|
612800bda5 | ||
|
|
a6bbb1dec9 | ||
|
|
873c93ab64 | ||
|
|
d15242e2d2 | ||
|
|
992d2b937c | ||
|
|
1e05ddad4b | ||
|
|
4f8a64610b | ||
|
|
b82366218c | ||
|
|
acbe1f4cb3 | ||
|
|
4c5e018583 | ||
|
|
6c0380e85c | ||
|
|
fde48e604f | ||
|
|
e83a4de5fb | ||
|
|
927d2799dc | ||
|
|
1ad701fe5d | ||
|
|
086425d2da | ||
|
|
beca54416a | ||
|
|
c92f5c5713 | ||
|
|
dee4e6caff | ||
|
|
dd5a39e72e | ||
|
|
e5ed52165c | ||
|
|
9484f8e0f5 | ||
|
|
947caffe0a | ||
|
|
870090e8df | ||
|
|
73f07f13c5 | ||
|
|
d1952bf591 | ||
|
|
5a612e1332 | ||
|
|
b00a9faea6 | ||
|
|
74db42a703 | ||
|
|
ddf625ca04 | ||
|
|
eca2f017d8 | ||
|
|
3190bde343 | ||
|
|
c6ebf42a47 | ||
|
|
c116b60d12 | ||
|
|
5d09e6d9ab | ||
|
|
2613ce0ac9 | ||
|
|
a88e9b28ea | ||
|
|
f0a3c26ee6 | ||
|
|
84c87ecb32 | ||
|
|
6573f44d41 | ||
|
|
3cacbc552c | ||
|
|
343d623e02 | ||
|
|
6b80bb2b11 | ||
|
|
56fe7452eb | ||
|
|
d3a66f6605 | ||
|
|
dd7b4712f1 | ||
|
|
9df5871f6b | ||
|
|
29aab9e9f4 | ||
|
|
af67eb7f0b | ||
|
|
10482c0141 | ||
|
|
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 | ||
|
|
d667b2f822 | ||
|
|
d7f511363d | ||
|
|
39e7c5c3de | ||
|
|
60acd5c864 | ||
|
|
b92cf6fd35 | ||
|
|
0f9482864c | ||
|
|
60700d59fe | ||
|
|
3296cef02d | ||
|
|
1b55b5fa3c | ||
|
|
b2701f5ba4 | ||
|
|
5d9a4b42a6 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.java text eol=lf
|
||||||
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,10 +1,16 @@
|
|||||||
# Description
|
# Description
|
||||||
** Describe your change here**
|
|
||||||
|
<!-- Describe your change here -->
|
||||||
|
|
||||||
# Before submitting a PR:
|
# Before submitting a PR:
|
||||||
We love getting PRs, but we hate asking people for the same basic changes every time.
|
We love getting PRs, but we hate asking people for the same basic changes every time.
|
||||||
|
|
||||||
- [ ] Push your changes to a branch other than `master`. Create your PR from that branch.
|
- [ ] Push your changes to a branch other than `main`. Create your PR from that branch.
|
||||||
- [ ] Add JavaDocs and other comments
|
- [ ] 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.
|
- [ ] Write tests that run and pass in CI. See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to capture snapshot data.
|
||||||
- [ ] Run `mvn install site` locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.
|
- [ ] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
|
||||||
|
|
||||||
|
# When creating a PR:
|
||||||
|
|
||||||
|
- [ ] Fill in the "Description" above.
|
||||||
|
- [ ] Enable "Allow edits from maintainers".
|
||||||
|
|||||||
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "maven"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
time: "02:00"
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
time: "02:00"
|
||||||
5
.github/release-drafter.yml
vendored
5
.github/release-drafter.yml
vendored
@@ -1,5 +1,6 @@
|
|||||||
name-template: 'v$NEXT_PATCH_VERSION 🌈'
|
name-template: 'v$NEXT_MINOR_VERSION 🌈'
|
||||||
tag-template: 'v$NEXT_PATCH_VERSION'
|
tag-template: 'github-api-$NEXT_MINOR_VERSION'
|
||||||
|
version-template: '$MAJOR.$MINOR'
|
||||||
categories:
|
categories:
|
||||||
- title: '🚀 Features'
|
- title: '🚀 Features'
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, gh-pages ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ main ]
|
||||||
|
schedule:
|
||||||
|
- cron: '20 0 * * 6'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'java' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||||
|
# Learn more:
|
||||||
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
||||||
94
.github/workflows/maven-build.yml
vendored
94
.github/workflows/maven-build.yml
vendored
@@ -1,22 +1,98 @@
|
|||||||
name: Java CI Build and Test
|
name: CI
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
# this is required by spotless for JDK 16+
|
||||||
|
env:
|
||||||
|
JAVA_11_PLUS_MAVEN_OPTS: "--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
name: build-only (Java ${{ matrix.java }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
java: [ '1.8.0', '11.0.x', '13.0.x' ]
|
java: [ 16 ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
distribution: 'adopt'
|
||||||
|
- name: Cached .m2
|
||||||
|
uses: actions/cache@v2.1.6
|
||||||
|
with:
|
||||||
|
path: ~/.m2/repository
|
||||||
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven-
|
||||||
|
- name: Maven Install (skipTests)
|
||||||
|
env:
|
||||||
|
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
|
||||||
|
run: mvn -B install -DskipTests --file pom.xml
|
||||||
|
site:
|
||||||
|
name: site (Java ${{ matrix.java }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
java: [ 8, 11 ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
distribution: 'adopt'
|
||||||
|
- uses: actions/cache@v2.1.6
|
||||||
|
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:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ ubuntu, windows ]
|
||||||
|
java: [ 8, 11, 16 ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
- name: Maven Download all dependencies
|
distribution: 'adopt'
|
||||||
run: mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
|
- uses: actions/cache@v2.1.6
|
||||||
- name: Maven Build
|
with:
|
||||||
run: mvn -B install site -P ci --file pom.xml
|
path: ~/.m2/repository
|
||||||
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven-
|
||||||
|
# JDK 8
|
||||||
|
- name: Maven Install without Code Coverage
|
||||||
|
if: matrix.os == 'windows' && matrix.java == '8'
|
||||||
|
run: mvn -B install --file pom.xml
|
||||||
|
- name: Maven Install with Code Coverage
|
||||||
|
if: matrix.os != 'windows' && matrix.java == '8'
|
||||||
|
run: mvn -B install -D enable-ci --file pom.xml
|
||||||
|
- name: Codecov Report
|
||||||
|
if: matrix.os != 'windows' && matrix.java == '8'
|
||||||
|
uses: codecov/codecov-action@v1.5.0
|
||||||
|
# JDK 11+
|
||||||
|
- name: Maven Install without Code Coverage
|
||||||
|
if: matrix.os == 'windows' && matrix.java != '8'
|
||||||
|
env:
|
||||||
|
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
|
||||||
|
run: mvn -B install --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
|
||||||
|
- name: Maven Install with Code Coverage
|
||||||
|
if: matrix.os != 'windows' && matrix.java != '8'
|
||||||
|
env:
|
||||||
|
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
|
||||||
|
run: mvn -B install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
|
||||||
|
|||||||
14
.github/workflows/release-drafter.yml
vendored
Normal file
14
.github/workflows/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
name: Release Drafter
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_release_draft:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Release Drafter
|
||||||
|
uses: release-drafter/release-drafter@v5.15.0
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -7,3 +7,7 @@ target
|
|||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
.factorypath
|
||||||
|
.vscode/settings.json
|
||||||
|
|||||||
1328
CHANGELOG.md
1328
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@@ -14,10 +14,14 @@ Example:
|
|||||||
|
|
||||||
This the default behavior.
|
This the default behavior.
|
||||||
|
|
||||||
|
Example for a single test case:
|
||||||
|
|
||||||
|
`mvn install -Dtest=WireMockStatusReporterTest#user_whenProxying_AuthCorrectlyConfigured`
|
||||||
|
|
||||||
|
|
||||||
### Setting up credential
|
### Setting up credential
|
||||||
|
|
||||||
1. Create an OAuth token on github.com
|
1. Create a "Personal access token" on https://github.com/ (`Settings` > `Developer settings` > `Personal access tokens`)
|
||||||
2. Set the GITHUB_OAUTH environment variable to the value of that token
|
2. Set the GITHUB_OAUTH environment variable to the value of that token
|
||||||
3. Set the system property `test.github.useProxy` (usually like "-Dtest.github.useProxy" as a Java VM option)
|
3. Set the system property `test.github.useProxy` (usually like "-Dtest.github.useProxy" as a Java VM option)
|
||||||
|
|
||||||
@@ -27,21 +31,37 @@ This the default behavior.
|
|||||||
|
|
||||||
`WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user login: <your login>`
|
`WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user login: <your login>`
|
||||||
|
|
||||||
Whenever you run tests with `-Dtest.github.useProxy`, they will try to get data from local files but will fallback to proxying to github if not found.
|
Whenever you run tests with `-Dtest.github.useProxy`, they will try to get data from local files but will fallback to proxying to GitHub if not found.
|
||||||
|
|
||||||
|
|
||||||
### Writing a new test
|
### Writing a new test
|
||||||
|
|
||||||
Once you have credentials setup, you add new test classes and test methods as you would normally.
|
Once you have credentials setup, you add new test classes and test methods as you would normally.
|
||||||
Keep `useProxy` enabled and iterate on your tests as needed. Remember, while proxying your tests are interacting with GitHub - you will need to clean up your state between runs.
|
|
||||||
|
|
||||||
When you are ready to create a snapshot of your test data,
|
#### Running tests using GitHub test proxy
|
||||||
run your test with `test.github.takeSnapshot` ("-Dtest.github.takeSnapshot" as a Java VM option). For example:
|
|
||||||
|
|
||||||
`mvn install -Dtest.github.takeSnapshot -Dtest=YourTestClassName`
|
Keep `useProxy` enabled and iterate on your tests as needed. With `useProxy` enabled your tests will interact with
|
||||||
|
GitHub - you will need to clean up your server-state between runs. This can be done manually to start with.
|
||||||
|
Once your test code is somewhat stable, use `getNonRecordingGitHub()` to get a `GitHub` instance for test setup and cleanup.
|
||||||
|
Interactions with that `GitHub` instance will not be recorded as part of the test, keeping the test data files to a minimum.
|
||||||
|
|
||||||
The above command would create snapshot WireMock data files under the path `src/test/resources/org/kohsuhke/github/YourTestClassName/wiremock`.
|
#### Running tests against your personal GitHub user account
|
||||||
Each method would get a separate director that would hold the data files for that test method.
|
|
||||||
|
By default, test helper methods such as `getTempRepository()` target the `hub4j-test-org` GitHub organization.
|
||||||
|
Please request access to this org to record your tests before submitting a PR. This helps keep the project stable and nimble.
|
||||||
|
Until you have access (or if you don't want access), you can set the following additional system property to target
|
||||||
|
your personal github account.
|
||||||
|
|
||||||
|
`mvn install -Dtest.github.org=false -Dtest=YourTestClassName`
|
||||||
|
|
||||||
|
#### Taking a snapshot
|
||||||
|
|
||||||
|
When you are ready to create a snapshot of your test data, run your test with `test.github.takeSnapshot` ("-Dtest.github.takeSnapshot" as
|
||||||
|
a Java VM option). For example:
|
||||||
|
|
||||||
|
`mvn install -Dtest.github.takeSnapshot -Dtest.github.org=false -Dtest=YourTestClassName`
|
||||||
|
|
||||||
|
The above command will create snapshot WireMock data files under the path `src/test/resources/org/kohsuhke/github/YourTestClassName/wiremock`.
|
||||||
|
Each method will get a separate directory that will hold the data files for that test method.
|
||||||
|
|
||||||
Add all files including the generated data to your commit and submit a PR.
|
Add all files including the generated data to your commit and submit a PR.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
# Java API for GitHub
|
# Java API for GitHub
|
||||||
|
|
||||||
[](https://mvnrepository.com/artifact/org.kohsuke/github-api)
|
[](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
|
See https://github-api.kohsuke.org/ for more details
|
||||||
|
|||||||
7
codecov.yml
Normal file
7
codecov.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
ignore:
|
||||||
|
- "**/extras/okhttp3/ObsoleteUrlFactory**"
|
||||||
|
- "**/extras/OkHttpConnector"
|
||||||
|
- "**/extras/OkHttp3Connector"
|
||||||
|
- "**/example/**"
|
||||||
|
- "**/github/EnforcementLevel"
|
||||||
|
|
||||||
543
pom.xml
543
pom.xml
@@ -1,48 +1,53 @@
|
|||||||
<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">
|
<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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<groupId>org.kohsuke</groupId>
|
||||||
<groupId>org.kohsuke</groupId>
|
|
||||||
<artifactId>pom</artifactId>
|
|
||||||
<version>21</version>
|
|
||||||
<relativePath />
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>github-api</artifactId>
|
<artifactId>github-api</artifactId>
|
||||||
<version>1.100</version>
|
<version>1.130</version>
|
||||||
<name>GitHub API for Java</name>
|
<name>GitHub API for Java</name>
|
||||||
<url>https://github-api.kohsuke.org/</url>
|
<url>https://github-api.kohsuke.org/</url>
|
||||||
<description>GitHub API for Java</description>
|
<description>GitHub API for Java</description>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com/github-api/${project.artifactId}.git</connection>
|
<connection>scm:git:git@github.com/hub4j/${project.artifactId}.git</connection>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/github-api/${project.artifactId}.git</developerConnection>
|
<developerConnection>scm:git:ssh://git@github.com/hub4j/${project.artifactId}.git</developerConnection>
|
||||||
<url>https://${project.artifactId}.kohsuke.org/</url>
|
<url>https://github.com/hub4j/github-api/</url>
|
||||||
<tag>github-api-1.100</tag>
|
<tag>github-api-1.130</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<distributionManagement>
|
<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>
|
<site>
|
||||||
<id>github-pages</id>
|
<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>
|
</site>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<spotbugs-maven-plugin.version>3.1.12.2</spotbugs-maven-plugin.version>
|
<spotbugs-maven-plugin.version>4.2.3</spotbugs-maven-plugin.version>
|
||||||
<spotbugs.version>3.1.12</spotbugs.version>
|
<spotbugs.version>4.2.3</spotbugs.version>
|
||||||
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
|
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
|
||||||
<hamcrest.version>2.2</hamcrest.version>
|
<hamcrest.version>2.2</hamcrest.version>
|
||||||
<okhttp3.version>4.2.2</okhttp3.version>
|
<okhttp3.version>4.4.1</okhttp3.version>
|
||||||
<okio.version>2.4.1</okio.version>
|
<okio.version>2.5.0</okio.version>
|
||||||
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
|
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
|
||||||
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
|
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
|
||||||
<jacoco.coverage.target.class>.80</jacoco.coverage.target.class>
|
<jacoco.coverage.target.class.method>0.50</jacoco.coverage.target.class.method>
|
||||||
<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>
|
|
||||||
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
|
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
|
||||||
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
|
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
|
||||||
|
<jjwt.suite.version>0.11.2</jjwt.suite.version>
|
||||||
|
|
||||||
|
<jacoco.surefire.argLine />
|
||||||
|
<surefire.argLine />
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -57,6 +62,14 @@
|
|||||||
<artifactId>maven-scm-manager-plexus</artifactId>
|
<artifactId>maven-scm-manager-plexus</artifactId>
|
||||||
<version>1.11.2</version>
|
<version>1.11.2</version>
|
||||||
</extension>
|
</extension>
|
||||||
|
<!-- Doing site publishing manually for now -->
|
||||||
|
<!--
|
||||||
|
<extension>
|
||||||
|
<groupId>org.kohsuke</groupId>
|
||||||
|
<artifactId>wagon-gitsite</artifactId>
|
||||||
|
<version>0.3.5</version>
|
||||||
|
</extension>
|
||||||
|
-->
|
||||||
</extensions>
|
</extensions>
|
||||||
<testResources>
|
<testResources>
|
||||||
<testResource>
|
<testResource>
|
||||||
@@ -68,19 +81,147 @@
|
|||||||
</testResources>
|
</testResources>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- adds jacoco coverage -->
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.2</version>
|
||||||
|
<configuration>
|
||||||
|
<!-- SUREFIRE-1226 workaround -->
|
||||||
|
<trimStackTrace>false</trimStackTrace>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<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>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.5</version>
|
<version>0.8.7</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<propertyName>jacoco.surefire.argLine</propertyName>
|
||||||
|
<!-- no need to get data about external code. It dramatically reduces performance of JaCoCo for nothing -->
|
||||||
|
<include>org.kohsuke.*</include>
|
||||||
|
</configuration>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Deprecated -->
|
||||||
|
<exclude>org.kohsuke.github.extras.OkHttpConnector</exclude>
|
||||||
|
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
|
||||||
|
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPerson.1</exclude>
|
||||||
|
|
||||||
|
<!-- TODO: Some coverage, but more needed -->
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestReviewBuilder.DraftReviewComment</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHIssue.PullRequest</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCommitSearchBuilder</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHRepositorySearchBuilder</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHUserSearchBuilder</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.GHCompare.Commit</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCompare.InnerCommit</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.GHEmail</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHInvitation</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.GHReleaseUpdater</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHRequestedAction</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
|
||||||
|
</excludes>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>8</source>
|
||||||
<failOnWarnings>true</failOnWarnings>
|
<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>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@@ -89,7 +230,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
<version>3.8.2</version>
|
<version>3.9.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -102,15 +243,19 @@
|
|||||||
<goals>deploy</goals>
|
<goals>deploy</goals>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.sonatype.plugins</groupId>
|
||||||
|
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.2</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.bcel</groupId>
|
<groupId>org.apache.bcel</groupId>
|
||||||
<artifactId>bcel</artifactId>
|
<artifactId>bcel</artifactId>
|
||||||
<version>6.4.1</version>
|
<version>6.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
@@ -132,12 +277,20 @@
|
|||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.22.2</version>
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-test</id>
|
||||||
|
<configuration>
|
||||||
|
<excludesFile>src/test/resources/slow-or-flaky-tests.txt</excludesFile>
|
||||||
|
<argLine>@{jacoco.surefire.argLine} ${surefire.argLine}</argLine>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||||
<version>1.18</version>
|
<version>1.20</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<signature>
|
<signature>
|
||||||
<groupId>org.codehaus.mojo.signature</groupId>
|
<groupId>org.codehaus.mojo.signature</groupId>
|
||||||
@@ -168,36 +321,35 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.revelc.code.formatter</groupId>
|
<groupId>com.diffplug.spotless</groupId>
|
||||||
<artifactId>formatter-maven-plugin</artifactId>
|
<artifactId>spotless-maven-plugin</artifactId>
|
||||||
<version>2.11.0</version>
|
<version>2.11.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<id>spotless-check</id>
|
||||||
|
<!-- runs in verify phase by default -->
|
||||||
<goals>
|
<goals>
|
||||||
<goal>${formatter-maven-plugin.goal}</goal>
|
<!-- can be disabled using -Dspotless.check.skip=true -->
|
||||||
|
<goal>check</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
|
||||||
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.revelc.code</groupId>
|
|
||||||
<artifactId>impsort-maven-plugin</artifactId>
|
|
||||||
<version>1.3.2</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<groups>*,java.,javax.</groups>
|
<java>
|
||||||
<removeUnused>true</removeUnused>
|
<eclipse>
|
||||||
<staticAfter>true</staticAfter>
|
<file>${basedir}/src/build/eclipse/formatter.xml</file>
|
||||||
|
</eclipse>
|
||||||
|
|
||||||
|
<importOrder>
|
||||||
|
<file>${basedir}/src/build/eclipse/eclipse.importorder</file>
|
||||||
|
</importOrder>
|
||||||
|
<removeUnusedImports />
|
||||||
|
|
||||||
|
<trimTrailingWhitespace />
|
||||||
|
<endWithNewline />
|
||||||
|
|
||||||
|
</java>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>${impsort-maven-plugin.goal}</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.github.spotbugs</groupId>
|
<groupId>com.github.spotbugs</groupId>
|
||||||
@@ -225,17 +377,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Do not use gmaven plugin -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.gmaven</groupId>
|
|
||||||
<artifactId>gmaven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@@ -246,9 +387,10 @@
|
|||||||
<version>3.9</version>
|
<version>3.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>com.tngtech.archunit</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>archunit</artifactId>
|
||||||
<version>1.13</version>
|
<version>0.19.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
@@ -272,25 +414,52 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.13.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.awaitility</groupId>
|
||||||
|
<artifactId>awaitility</artifactId>
|
||||||
|
<version>4.1.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.12.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.6</version>
|
<version>2.8.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.infradna.tool</groupId>
|
<groupId>com.infradna.tool</groupId>
|
||||||
<artifactId>bridge-method-annotation</artifactId>
|
<artifactId>bridge-method-annotation</artifactId>
|
||||||
<version>1.18</version>
|
<version>1.21</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</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.263</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kohsuke.stapler</groupId>
|
<groupId>org.kohsuke.stapler</groupId>
|
||||||
<artifactId>stapler-jetty</artifactId>
|
<artifactId>stapler-jetty</artifactId>
|
||||||
@@ -300,9 +469,27 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jgit</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>org.eclipse.jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
<version>5.5.1.201910021850-r</version>
|
<version>5.11.1.202105131744-r</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>${jjwt.suite.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>${jjwt.suite.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>${jjwt.suite.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okio</groupId>
|
<groupId>com.squareup.okio</groupId>
|
||||||
<artifactId>okio</artifactId>
|
<artifactId>okio</artifactId>
|
||||||
@@ -332,31 +519,37 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kohsuke</groupId>
|
<groupId>org.kohsuke</groupId>
|
||||||
<artifactId>wordnet-random-name</artifactId>
|
<artifactId>wordnet-random-name</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.5</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.10.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.spotbugs</groupId>
|
<groupId>com.github.spotbugs</groupId>
|
||||||
<artifactId>spotbugs-annotations</artifactId>
|
<artifactId>spotbugs-annotations</artifactId>
|
||||||
<version>${spotbugs.version}</version>
|
<version>${spotbugs.version}</version>
|
||||||
<optional>true</optional>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.tomakehurst</groupId>
|
<groupId>com.github.tomakehurst</groupId>
|
||||||
<artifactId>wiremock-jre8-standalone</artifactId>
|
<artifactId>wiremock-jre8-standalone</artifactId>
|
||||||
<version>2.25.1</version>
|
<version>2.28.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.8.6</version>
|
<version>2.8.7</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
<version>1.7.30</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@@ -373,20 +566,58 @@
|
|||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
<profiles>
|
<profiles>
|
||||||
|
<!-- only enable slow-or-flaky-test if -Dtest= is not present -->
|
||||||
<profile>
|
<profile>
|
||||||
<id>ci</id>
|
<id>slow-or-flaky-test</id>
|
||||||
<properties>
|
<activation>
|
||||||
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
|
<property>
|
||||||
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
|
<name>!test</name>
|
||||||
</properties>
|
</property>
|
||||||
|
</activation>
|
||||||
<build>
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>slow-or-flaky-test</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rerunFailingTestsCount>2</rerunFailingTestsCount>
|
||||||
|
<!-- There are some tests that take longer or are a little
|
||||||
|
flaky. Run them here. -->
|
||||||
|
<includesFile>src/test/resources/slow-or-flaky-tests.txt</includesFile>
|
||||||
|
<argLine>@{jacoco.surefire.argLine} ${surefire.argLine}</argLine>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>jacoco</id>
|
<id>ci-non-windows</id>
|
||||||
<activation>
|
<activation>
|
||||||
<property>
|
<property>
|
||||||
<name>enable-jacoco</name>
|
<name>enable-ci</name>
|
||||||
|
</property>
|
||||||
|
<os>
|
||||||
|
<family>!windows</family>
|
||||||
|
</os>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<!-- Only fail code coverage on non-windows machines -->
|
||||||
|
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>ci-all</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>enable-ci</name>
|
||||||
</property>
|
</property>
|
||||||
</activation>
|
</activation>
|
||||||
<build>
|
<build>
|
||||||
@@ -394,84 +625,41 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.5</version>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.diffplug.spotless</groupId>
|
||||||
|
<artifactId>spotless-maven-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<id>spotless-check</id>
|
||||||
<goal>prepare-agent</goal>
|
<!-- In CI, run check early in the build -->
|
||||||
</goals>
|
<phase>process-sources</phase>
|
||||||
</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>
|
<goals>
|
||||||
<goal>check</goal>
|
<goal>check</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
<version>3.0.0-M3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>enforce-jacoco-exist</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>enforce</goal>
|
||||||
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<rules>
|
<rules>
|
||||||
<rule>
|
<requireFilesExist>
|
||||||
<!--We end up with chatty logs, but it shows us which particular classes -->
|
<files>
|
||||||
<!--are lacking in coverage. If this is too much, just remove the -->
|
<file>${project.build.directory}/jacoco.exec</file>
|
||||||
<!--<element>CLASS</element> tag below. -->
|
</files>
|
||||||
<element>CLASS</element>
|
</requireFilesExist>
|
||||||
<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>
|
</rules>
|
||||||
|
<fail>true</fail>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@@ -483,10 +671,13 @@
|
|||||||
<id>release</id>
|
<id>release</id>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
<version>1.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>sign-artifacts</id>
|
<id>sign-artifacts</id>
|
||||||
@@ -506,7 +697,26 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<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>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
@@ -514,6 +724,18 @@
|
|||||||
</profiles>
|
</profiles>
|
||||||
<reporting>
|
<reporting>
|
||||||
<plugins>
|
<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>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
@@ -540,4 +762,13 @@
|
|||||||
<archive>https://groups.google.com/forum/#!forum/github-api</archive>
|
<archive>https://groups.google.com/forum/#!forum/github-api</archive>
|
||||||
</mailingList>
|
</mailingList>
|
||||||
</mailingLists>
|
</mailingLists>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<name>Kohsuke Kawaguchi</name>
|
||||||
|
<id>kohsuke</id>
|
||||||
|
<email>kk@kohsuke.org</email>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
6
src/build/eclipse/eclipse.importorder
Normal file
6
src/build/eclipse/eclipse.importorder
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Organize Import Order
|
||||||
|
# Import this file in Window -> Preferences -> Java -> Code Style -> Organize Imports -> Import...
|
||||||
|
0=
|
||||||
|
1=java
|
||||||
|
2=javax
|
||||||
|
3=\#
|
||||||
166
src/main/java/org/kohsuke/github/AbstractBuilder.java
Normal file
166
src/main/java/org/kohsuke/github/AbstractBuilder.java
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
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> extends GitHubInteractiveObject {
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
super(root);
|
||||||
|
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
|
||||||
|
@BetaApi
|
||||||
|
@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
|
||||||
|
@BetaApi
|
||||||
|
@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
|
||||||
|
@BetaApi
|
||||||
|
@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
|
* @throws IOException
|
||||||
* on failure
|
* 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/#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;
|
public abstract void onError(IOException e, HttpURLConnection uc) throws IOException;
|
||||||
|
|
||||||
|
|||||||
18
src/main/java/org/kohsuke/github/BetaApi.java
Normal file
18
src/main/java/org/kohsuke/github/BetaApi.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that the method/class/etc marked is a beta implementation of an sdk feature.
|
||||||
|
* <p>
|
||||||
|
* These APIs are subject to change and not a part of the backward compatibility commitment. Always used in conjunction
|
||||||
|
* with 'deprecated' to raise awareness to clients.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface BetaApi {
|
||||||
|
}
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import org.kohsuke.github.internal.EnumUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Github App.
|
* A Github App.
|
||||||
@@ -15,13 +18,12 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
|
|||||||
*/
|
*/
|
||||||
public class GHApp extends GHObject {
|
public class GHApp extends GHObject {
|
||||||
|
|
||||||
private GitHub root;
|
|
||||||
private GHUser owner;
|
private GHUser owner;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private String externalUrl;
|
private String externalUrl;
|
||||||
private Map<String, String> permissions;
|
private Map<String, String> permissions;
|
||||||
private List<GHEvent> events;
|
private List<String> events;
|
||||||
private long installationsCount;
|
private long installationsCount;
|
||||||
private String htmlUrl;
|
private String htmlUrl;
|
||||||
|
|
||||||
@@ -39,7 +41,9 @@ public class GHApp extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param owner
|
* @param owner
|
||||||
* the 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) {
|
public void setOwner(GHUser owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
@@ -58,7 +62,9 @@ public class GHApp extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* the 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) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@@ -77,7 +83,9 @@ public class GHApp extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param description
|
* @param description
|
||||||
* the 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) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
@@ -96,7 +104,9 @@ public class GHApp extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param externalUrl
|
* @param externalUrl
|
||||||
* the external url
|
* 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) {
|
public void setExternalUrl(String externalUrl) {
|
||||||
this.externalUrl = externalUrl;
|
this.externalUrl = externalUrl;
|
||||||
}
|
}
|
||||||
@@ -107,7 +117,9 @@ public class GHApp extends GHObject {
|
|||||||
* @return the events
|
* @return the events
|
||||||
*/
|
*/
|
||||||
public List<GHEvent> getEvents() {
|
public List<GHEvent> getEvents() {
|
||||||
return events;
|
return events.stream()
|
||||||
|
.map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,9 +127,11 @@ public class GHApp extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param events
|
* @param events
|
||||||
* the 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) {
|
public void setEvents(List<GHEvent> events) {
|
||||||
this.events = events;
|
this.events = events.stream().map(GHEvent::symbol).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,13 +148,15 @@ public class GHApp extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param installationsCount
|
* @param installationsCount
|
||||||
* the installations count
|
* 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) {
|
public void setInstallationsCount(long installationsCount) {
|
||||||
this.installationsCount = installationsCount;
|
this.installationsCount = installationsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(htmlUrl);
|
return GitHubClient.parseURL(htmlUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,7 +173,9 @@ public class GHApp extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param permissions
|
* @param permissions
|
||||||
* the 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) {
|
public void setPermissions(Map<String, String> permissions) {
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
@@ -175,12 +193,13 @@ public class GHApp extends GHObject {
|
|||||||
* @return a list of App installations
|
* @return a list of App installations
|
||||||
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
|
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(MACHINE_MAN)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PagedIterable<GHAppInstallation> listInstallations() {
|
public PagedIterable<GHAppInstallation> listInstallations() {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(MACHINE_MAN)
|
.withPreview(MACHINE_MAN)
|
||||||
.asPagedIterable("/app/installations", GHAppInstallation[].class, item -> item.wrapUp(root));
|
.withUrlPath("/app/installations")
|
||||||
|
.toIterable(GHAppInstallation[].class, item -> item.wrapUp(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,12 +214,13 @@ public class GHApp extends GHObject {
|
|||||||
* on error
|
* on error
|
||||||
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
|
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(MACHINE_MAN)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHAppInstallation getInstallationById(long id) throws IOException {
|
public GHAppInstallation getInstallationById(long id) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(MACHINE_MAN)
|
.withPreview(MACHINE_MAN)
|
||||||
.to(String.format("/app/installations/%d", id), GHAppInstallation.class)
|
.withUrlPath(String.format("/app/installations/%d", id))
|
||||||
|
.fetch(GHAppInstallation.class)
|
||||||
.wrapUp(root);
|
.wrapUp(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,12 +237,13 @@ public class GHApp extends GHObject {
|
|||||||
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
|
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
|
||||||
* installation</a>
|
* installation</a>
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(MACHINE_MAN)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
|
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(MACHINE_MAN)
|
.withPreview(MACHINE_MAN)
|
||||||
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class)
|
.withUrlPath(String.format("/orgs/%s/installation", name))
|
||||||
|
.fetch(GHAppInstallation.class)
|
||||||
.wrapUp(root);
|
.wrapUp(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,12 +262,13 @@ public class GHApp extends GHObject {
|
|||||||
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
|
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
|
||||||
* installation</a>
|
* installation</a>
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(MACHINE_MAN)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
|
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(MACHINE_MAN)
|
.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);
|
.wrapUp(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,12 +284,13 @@ public class GHApp extends GHObject {
|
|||||||
* on error
|
* on error
|
||||||
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
|
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(MACHINE_MAN)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHAppInstallation getInstallationByUser(String name) throws IOException {
|
public GHAppInstallation getInstallationByUser(String name) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(MACHINE_MAN)
|
.withPreview(MACHINE_MAN)
|
||||||
.to(String.format("/users/%s/installation", name), GHAppInstallation.class)
|
.withUrlPath(String.format("/users/%s/installation", name))
|
||||||
|
.fetch(GHAppInstallation.class)
|
||||||
.wrapUp(root);
|
.wrapUp(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,26 +5,32 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a access token for a GitHub App Installation
|
* Creates a access token for a GitHub App Installation
|
||||||
*
|
*
|
||||||
* @author Paulo Miguel Almeida
|
* @author Paulo Miguel Almeida
|
||||||
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
||||||
|
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
|
||||||
*/
|
*/
|
||||||
public class GHAppCreateTokenBuilder {
|
public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
|
||||||
private final GitHub root;
|
|
||||||
protected final Requester builder;
|
protected final Requester builder;
|
||||||
private final String apiUrlTail;
|
private final String apiUrlTail;
|
||||||
|
|
||||||
@Preview
|
@BetaApi
|
||||||
@Deprecated
|
@Deprecated
|
||||||
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
|
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.apiUrlTail = apiUrlTail;
|
this.apiUrlTail = apiUrlTail;
|
||||||
this.builder = new Requester(root);
|
this.builder = root.createRequest();
|
||||||
withPermissions(builder, permissions);
|
}
|
||||||
|
|
||||||
|
@BetaApi
|
||||||
|
@Deprecated
|
||||||
|
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
|
||||||
|
this(root, apiUrlTail);
|
||||||
|
permissions(permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,13 +42,32 @@ public class GHAppCreateTokenBuilder {
|
|||||||
* Array containing the repositories Ids
|
* Array containing the repositories Ids
|
||||||
* @return a GHAppCreateTokenBuilder
|
* @return a GHAppCreateTokenBuilder
|
||||||
*/
|
*/
|
||||||
@Preview
|
@BetaApi
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
|
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
|
||||||
this.builder.with("repository_ids", repositoryIds);
|
this.builder.with("repository_ids", repositoryIds);
|
||||||
return this;
|
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
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@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.
|
* Creates an app token with all the parameters.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -52,21 +77,14 @@ public class GHAppCreateTokenBuilder {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* on error
|
* on error
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(MACHINE_MAN)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHAppInstallationToken create() throws IOException {
|
public GHAppInstallationToken create() throws IOException {
|
||||||
return builder.method("POST")
|
return builder.method("POST")
|
||||||
.withPreview(MACHINE_MAN)
|
.withPreview(MACHINE_MAN)
|
||||||
.to(apiUrlTail, GHAppInstallationToken.class)
|
.withUrlPath(apiUrlTail)
|
||||||
|
.fetch(GHAppInstallationToken.class)
|
||||||
.wrapUp(root);
|
.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.kohsuke.github.internal.EnumUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.GAMBIT;
|
import static org.kohsuke.github.internal.Previews.GAMBIT;
|
||||||
|
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Github App Installation.
|
* A Github App Installation.
|
||||||
@@ -20,7 +24,6 @@ import static org.kohsuke.github.Previews.GAMBIT;
|
|||||||
* @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String)
|
* @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String)
|
||||||
*/
|
*/
|
||||||
public class GHAppInstallation extends GHObject {
|
public class GHAppInstallation extends GHObject {
|
||||||
private GitHub root;
|
|
||||||
private GHUser account;
|
private GHUser account;
|
||||||
|
|
||||||
@JsonProperty("access_tokens_url")
|
@JsonProperty("access_tokens_url")
|
||||||
@@ -34,7 +37,7 @@ public class GHAppInstallation extends GHObject {
|
|||||||
@JsonProperty("target_type")
|
@JsonProperty("target_type")
|
||||||
private GHTargetType targetType;
|
private GHTargetType targetType;
|
||||||
private Map<String, GHPermissionType> permissions;
|
private Map<String, GHPermissionType> permissions;
|
||||||
private List<GHEvent> events;
|
private List<String> events;
|
||||||
@JsonProperty("single_file_name")
|
@JsonProperty("single_file_name")
|
||||||
private String singleFileName;
|
private String singleFileName;
|
||||||
@JsonProperty("repository_selection")
|
@JsonProperty("repository_selection")
|
||||||
@@ -42,7 +45,7 @@ public class GHAppInstallation extends GHObject {
|
|||||||
private String htmlUrl;
|
private String htmlUrl;
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(htmlUrl);
|
return GitHubClient.parseURL(htmlUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +62,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param root
|
* @param root
|
||||||
* the 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) {
|
public void setRoot(GitHub root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
}
|
}
|
||||||
@@ -78,7 +83,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param account
|
* @param account
|
||||||
* the 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) {
|
public void setAccount(GHUser account) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
}
|
}
|
||||||
@@ -97,7 +104,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param accessTokenUrl
|
* @param accessTokenUrl
|
||||||
* the access token url
|
* 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) {
|
public void setAccessTokenUrl(String accessTokenUrl) {
|
||||||
this.accessTokenUrl = accessTokenUrl;
|
this.accessTokenUrl = accessTokenUrl;
|
||||||
}
|
}
|
||||||
@@ -111,12 +120,44 @@ public class GHAppInstallation extends GHObject {
|
|||||||
return repositoriesUrl;
|
return repositoriesUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List repositories that this app installation can access.
|
||||||
|
*
|
||||||
|
* @return the paged iterable
|
||||||
|
*/
|
||||||
|
@Preview(MACHINE_MAN)
|
||||||
|
@Deprecated
|
||||||
|
public PagedSearchIterable<GHRepository> listRepositories() {
|
||||||
|
GitHubRequest request;
|
||||||
|
|
||||||
|
try {
|
||||||
|
request = root.createRequest().withPreview(MACHINE_MAN).withUrlPath("/installation/repositories").build();
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new GHException("", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PagedSearchIterable<>(root, request, GHAppInstallationRepositoryResult.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class GHAppInstallationRepositoryResult extends SearchResult<GHRepository> {
|
||||||
|
private GHRepository[] repositories;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
GHRepository[] getItems(GitHub root) {
|
||||||
|
for (GHRepository item : repositories)
|
||||||
|
item.wrap(root);
|
||||||
|
return repositories;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets repositories url.
|
* Sets repositories url.
|
||||||
*
|
*
|
||||||
* @param repositoriesUrl
|
* @param repositoriesUrl
|
||||||
* the repositories url
|
* 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) {
|
public void setRepositoriesUrl(String repositoriesUrl) {
|
||||||
this.repositoriesUrl = repositoriesUrl;
|
this.repositoriesUrl = repositoriesUrl;
|
||||||
}
|
}
|
||||||
@@ -135,7 +176,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param appId
|
* @param appId
|
||||||
* the app id
|
* 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) {
|
public void setAppId(long appId) {
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
}
|
}
|
||||||
@@ -154,7 +197,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param targetId
|
* @param targetId
|
||||||
* the target id
|
* 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) {
|
public void setTargetId(long targetId) {
|
||||||
this.targetId = targetId;
|
this.targetId = targetId;
|
||||||
}
|
}
|
||||||
@@ -173,7 +218,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param targetType
|
* @param targetType
|
||||||
* the target type
|
* 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) {
|
public void setTargetType(GHTargetType targetType) {
|
||||||
this.targetType = targetType;
|
this.targetType = targetType;
|
||||||
}
|
}
|
||||||
@@ -192,7 +239,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param permissions
|
* @param permissions
|
||||||
* the 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) {
|
public void setPermissions(Map<String, GHPermissionType> permissions) {
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
@@ -203,7 +252,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
* @return the events
|
* @return the events
|
||||||
*/
|
*/
|
||||||
public List<GHEvent> getEvents() {
|
public List<GHEvent> getEvents() {
|
||||||
return events;
|
return events.stream()
|
||||||
|
.map(e -> EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,9 +262,11 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param events
|
* @param events
|
||||||
* the 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) {
|
public void setEvents(List<GHEvent> events) {
|
||||||
this.events = events;
|
this.events = events.stream().map(GHEvent::symbol).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,7 +283,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param singleFileName
|
* @param singleFileName
|
||||||
* the single file name
|
* 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) {
|
public void setSingleFileName(String singleFileName) {
|
||||||
this.singleFileName = singleFileName;
|
this.singleFileName = singleFileName;
|
||||||
}
|
}
|
||||||
@@ -249,7 +304,9 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param repositorySelection
|
* @param repositorySelection
|
||||||
* the repository selection
|
* 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) {
|
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
|
||||||
this.repositorySelection = repositorySelection;
|
this.repositorySelection = repositorySelection;
|
||||||
}
|
}
|
||||||
@@ -268,10 +325,14 @@ public class GHAppInstallation extends GHObject {
|
|||||||
* on error
|
* on error
|
||||||
* @see <a href="https://developer.github.com/v3/apps/#delete-an-installation">Delete an installation</a>
|
* @see <a href="https://developer.github.com/v3/apps/#delete-an-installation">Delete an installation</a>
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(GAMBIT)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void deleteInstallation() throws IOException {
|
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 +344,29 @@ public class GHAppInstallation extends GHObject {
|
|||||||
*
|
*
|
||||||
* @param permissions
|
* @param permissions
|
||||||
* map of permissions for the created token
|
* map of permissions for the created token
|
||||||
* @return a GHAppCreateTokenBuilder on error
|
* @return a GHAppCreateTokenBuilder instance
|
||||||
|
* @deprecated Use {@link GHAppInstallation#createToken()} instead.
|
||||||
*/
|
*/
|
||||||
@Preview
|
@BetaApi
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
|
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
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@Deprecated
|
||||||
|
public GHAppCreateTokenBuilder createToken() {
|
||||||
|
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ import java.util.Map;
|
|||||||
* @author Paulo Miguel Almeida
|
* @author Paulo Miguel Almeida
|
||||||
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
||||||
*/
|
*/
|
||||||
public class GHAppInstallationToken {
|
public class GHAppInstallationToken extends GitHubInteractiveObject {
|
||||||
private GitHub root;
|
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
protected String expires_at;
|
protected String expires_at;
|
||||||
private Map<String, String> permissions;
|
private Map<String, String> permissions;
|
||||||
@@ -37,7 +35,9 @@ public class GHAppInstallationToken {
|
|||||||
*
|
*
|
||||||
* @param root
|
* @param root
|
||||||
* the 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) {
|
public void setRoot(GitHub root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,9 @@ public class GHAppInstallationToken {
|
|||||||
*
|
*
|
||||||
* @param permissions
|
* @param permissions
|
||||||
* the 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) {
|
public void setPermissions(Map<String, String> permissions) {
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
@@ -75,7 +77,9 @@ public class GHAppInstallationToken {
|
|||||||
*
|
*
|
||||||
* @param token
|
* @param token
|
||||||
* the 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) {
|
public void setToken(String token) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
@@ -94,7 +98,9 @@ public class GHAppInstallationToken {
|
|||||||
*
|
*
|
||||||
* @param repositories
|
* @param repositories
|
||||||
* the 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) {
|
public void setRepositories(List<GHRepository> repositories) {
|
||||||
this.repositories = repositories;
|
this.repositories = repositories;
|
||||||
}
|
}
|
||||||
@@ -113,7 +119,9 @@ public class GHAppInstallationToken {
|
|||||||
*
|
*
|
||||||
* @param repositorySelection
|
* @param repositorySelection
|
||||||
* the repository selection
|
* 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) {
|
public void setRepositorySelection(GHRepositorySelection repositorySelection) {
|
||||||
this.repositorySelection = repositorySelection;
|
this.repositorySelection = repositorySelection;
|
||||||
}
|
}
|
||||||
@@ -127,7 +135,7 @@ public class GHAppInstallationToken {
|
|||||||
*/
|
*/
|
||||||
@WithBridgeMethods(value = String.class, adapterMethod = "expiresAtStr")
|
@WithBridgeMethods(value = String.class, adapterMethod = "expiresAtStr")
|
||||||
public Date getExpiresAt() throws IOException {
|
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")
|
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getExpiresAt")
|
||||||
|
|||||||
140
src/main/java/org/kohsuke/github/GHArtifact.java
Normal file
140
src/main/java/org/kohsuke/github/GHArtifact.java
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.kohsuke.github.function.InputStreamFunction;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An artifact from a workflow run.
|
||||||
|
*
|
||||||
|
* @author Guillaume Smet
|
||||||
|
*/
|
||||||
|
public class GHArtifact extends GHObject {
|
||||||
|
|
||||||
|
// Not provided by the API.
|
||||||
|
@JsonIgnore
|
||||||
|
private GHRepository owner;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private long sizeInBytes;
|
||||||
|
private String archiveDownloadUrl;
|
||||||
|
private boolean expired;
|
||||||
|
private String expiresAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name.
|
||||||
|
*
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the size of the artifact in bytes.
|
||||||
|
*
|
||||||
|
* @return the size
|
||||||
|
*/
|
||||||
|
public long getSizeInBytes() {
|
||||||
|
return sizeInBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the archive download URL.
|
||||||
|
*
|
||||||
|
* @return the archive download URL
|
||||||
|
*/
|
||||||
|
public URL getArchiveDownloadUrl() {
|
||||||
|
return GitHubClient.parseURL(archiveDownloadUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this artifact has expired.
|
||||||
|
*
|
||||||
|
* @return if the artifact has expired
|
||||||
|
*/
|
||||||
|
public boolean isExpired() {
|
||||||
|
return expired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the date at which this artifact will expire.
|
||||||
|
*
|
||||||
|
* @return the date of expiration
|
||||||
|
*/
|
||||||
|
public Date getExpiresAt() {
|
||||||
|
return GitHubClient.parseDate(expiresAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository to which the artifact belongs.
|
||||||
|
*
|
||||||
|
* @return the repository
|
||||||
|
*/
|
||||||
|
public GHRepository getRepository() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This object has no HTML URL.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public URL getHtmlUrl() throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the artifact.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
public void delete() throws IOException {
|
||||||
|
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).fetchHttpStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads the artifact.
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* the type of result
|
||||||
|
* @param streamFunction
|
||||||
|
* The {@link InputStreamFunction} that will process the stream
|
||||||
|
* @throws IOException
|
||||||
|
* The IO exception.
|
||||||
|
* @return the result of reading the stream.
|
||||||
|
*/
|
||||||
|
public <T> T download(InputStreamFunction<T> streamFunction) throws IOException {
|
||||||
|
requireNonNull(streamFunction, "Stream function must not be null");
|
||||||
|
|
||||||
|
return root.createRequest().method("GET").withUrlPath(getApiRoute(), "zip").fetchStream(streamFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getApiRoute() {
|
||||||
|
if (owner == null) {
|
||||||
|
// Workflow runs 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() + "/actions/artifacts/" + getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
GHArtifact wrapUp(GHRepository owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return wrapUp(owner.root);
|
||||||
|
}
|
||||||
|
|
||||||
|
GHArtifact wrapUp(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
if (owner != null)
|
||||||
|
owner.wrap(root);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/main/java/org/kohsuke/github/GHArtifactsIterable.java
Normal file
49
src/main/java/org/kohsuke/github/GHArtifactsIterable.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterable for artifacts listing.
|
||||||
|
*/
|
||||||
|
class GHArtifactsIterable extends PagedIterable<GHArtifact> {
|
||||||
|
private final transient GHRepository owner;
|
||||||
|
private final GitHubRequest request;
|
||||||
|
|
||||||
|
private GHArtifactsPage result;
|
||||||
|
|
||||||
|
public GHArtifactsIterable(GHRepository owner, GitHubRequest.Builder<?> requestBuilder) {
|
||||||
|
this.owner = owner;
|
||||||
|
try {
|
||||||
|
this.request = requestBuilder.build();
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new GHException("Malformed URL", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public PagedIterator<GHArtifact> _iterator(int pageSize) {
|
||||||
|
return new PagedIterator<>(
|
||||||
|
adapt(GitHubPageIterator.create(owner.getRoot().getClient(), GHArtifactsPage.class, request, pageSize)),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Iterator<GHArtifact[]> adapt(final Iterator<GHArtifactsPage> base) {
|
||||||
|
return new Iterator<GHArtifact[]>() {
|
||||||
|
public boolean hasNext() {
|
||||||
|
return base.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GHArtifact[] next() {
|
||||||
|
GHArtifactsPage v = base.next();
|
||||||
|
if (result == null) {
|
||||||
|
result = v;
|
||||||
|
}
|
||||||
|
return v.getArtifacts(owner);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/java/org/kohsuke/github/GHArtifactsPage.java
Normal file
20
src/main/java/org/kohsuke/github/GHArtifactsPage.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the one page of artifacts result when listing artifacts.
|
||||||
|
*/
|
||||||
|
class GHArtifactsPage {
|
||||||
|
private int total_count;
|
||||||
|
private GHArtifact[] artifacts;
|
||||||
|
|
||||||
|
public int getTotalCount() {
|
||||||
|
return total_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHArtifact[] getArtifacts(GHRepository owner) {
|
||||||
|
for (GHArtifact artifact : artifacts) {
|
||||||
|
artifact.wrapUp(owner);
|
||||||
|
}
|
||||||
|
return artifacts;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ import java.net.URL;
|
|||||||
* @see GHRelease#getAssets() GHRelease#getAssets()
|
* @see GHRelease#getAssets() GHRelease#getAssets()
|
||||||
*/
|
*/
|
||||||
public class GHAsset extends GHObject {
|
public class GHAsset extends GHObject {
|
||||||
GitHub root;
|
|
||||||
GHRepository owner;
|
GHRepository owner;
|
||||||
private String name;
|
private String name;
|
||||||
private String label;
|
private String label;
|
||||||
@@ -135,7 +134,7 @@ public class GHAsset extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void edit(String key, Object value) throws IOException {
|
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 +144,11 @@ public class GHAsset extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(root).method("DELETE").to(getApiRoute());
|
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getApiRoute() {
|
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) {
|
GHAsset wrap(GHRelease release) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ public class GHAuthorization extends GHObject {
|
|||||||
public static final String WRITE_KEY = "write:public_key";
|
public static final String WRITE_KEY = "write:public_key";
|
||||||
public static final String ADMIN_KEY = "admin:public_key";
|
public static final String ADMIN_KEY = "admin:public_key";
|
||||||
|
|
||||||
private GitHub root;
|
|
||||||
private List<String> scopes;
|
private List<String> scopes;
|
||||||
private String token;
|
private String token;
|
||||||
private String token_last_eight;
|
private String token_last_eight;
|
||||||
@@ -96,7 +95,7 @@ public class GHAuthorization extends GHObject {
|
|||||||
* @return the app url
|
* @return the app url
|
||||||
*/
|
*/
|
||||||
public URL getAppUrl() {
|
public URL getAppUrl() {
|
||||||
return GitHub.parseURL(app.url);
|
return GitHubClient.parseURL(app.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,10 +111,12 @@ public class GHAuthorization extends GHObject {
|
|||||||
* Gets api url.
|
* Gets api url.
|
||||||
*
|
*
|
||||||
* @return the 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")
|
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed")
|
||||||
public URL getApiURL() {
|
public URL getApiURL() {
|
||||||
return GitHub.parseURL(url);
|
return getUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,7 +142,7 @@ public class GHAuthorization extends GHObject {
|
|||||||
* @return the note url
|
* @return the note url
|
||||||
*/
|
*/
|
||||||
public URL getNoteUrl() {
|
public URL getNoteUrl() {
|
||||||
return GitHub.parseURL(note_url);
|
return GitHubClient.parseURL(note_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64InputStream;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHBlob.
|
* The type GHBlob.
|
||||||
@@ -26,7 +24,7 @@ public class GHBlob {
|
|||||||
* @return API URL of this blob.
|
* @return API URL of this blob.
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +71,9 @@ public class GHBlob {
|
|||||||
public InputStream read() {
|
public InputStream read() {
|
||||||
if (encoding.equals("base64")) {
|
if (encoding.equals("base64")) {
|
||||||
try {
|
try {
|
||||||
return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false);
|
Base64.Decoder decoder = Base64.getMimeDecoder();
|
||||||
} catch (UnsupportedEncodingException e) {
|
return new ByteArrayInputStream(decoder.decode(content));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
throw new AssertionError(e); // US-ASCII is mandatory
|
throw new AssertionError(e); // US-ASCII is mandatory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
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
|
* 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) {
|
GHBlobBuilder(GHRepository repo) {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
req = new Requester(repo.root);
|
req = repo.root.createRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +36,7 @@ public class GHBlobBuilder {
|
|||||||
* @return a GHBlobBuilder
|
* @return a GHBlobBuilder
|
||||||
*/
|
*/
|
||||||
public GHBlobBuilder binaryContent(byte[] content) {
|
public GHBlobBuilder binaryContent(byte[] content) {
|
||||||
String base64Content = Base64.encodeBase64String(content);
|
String base64Content = Base64.getEncoder().encodeToString(content);
|
||||||
req.with("content", base64Content);
|
req.with("content", base64Content);
|
||||||
req.with("encoding", "base64");
|
req.with("encoding", "base64");
|
||||||
return this;
|
return this;
|
||||||
@@ -55,6 +54,6 @@ public class GHBlobBuilder {
|
|||||||
* if the blob cannot be created.
|
* if the blob cannot be created.
|
||||||
*/
|
*/
|
||||||
public GHBlob create() throws IOException {
|
public GHBlob create() throws IOException {
|
||||||
return req.method("POST").to(getApiTail(), GHBlob.class);
|
return req.method("POST").withUrlPath(getApiTail()).fetch(GHBlob.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ package org.kohsuke.github;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.*;
|
import javax.annotation.CheckForNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A branch in a repository.
|
* A branch in a repository.
|
||||||
@@ -20,8 +21,7 @@ import static org.kohsuke.github.Previews.*;
|
|||||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||||
"URF_UNREAD_FIELD" },
|
"URF_UNREAD_FIELD" },
|
||||||
justification = "JSON API")
|
justification = "JSON API")
|
||||||
public class GHBranch {
|
public class GHBranch extends GitHubInteractiveObject {
|
||||||
private GitHub root;
|
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
@@ -78,7 +78,7 @@ public class GHBranch {
|
|||||||
*
|
*
|
||||||
* @return true if the push to this branch is restricted via branch protection.
|
* @return true if the push to this branch is restricted via branch protection.
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(Previews.LUKE_CAGE)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isProtected() {
|
public boolean isProtected() {
|
||||||
return protection;
|
return protection;
|
||||||
@@ -89,10 +89,10 @@ public class GHBranch {
|
|||||||
*
|
*
|
||||||
* @return API URL that deals with the protection of this branch.
|
* @return API URL that deals with the protection of this branch.
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(Previews.LUKE_CAGE)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public URL getProtectionUrl() {
|
public URL getProtectionUrl() {
|
||||||
return GitHub.parseURL(protection_url);
|
return GitHubClient.parseURL(protection_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,8 +102,14 @@ public class GHBranch {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
|
@Preview(Previews.LUKE_CAGE)
|
||||||
|
@Deprecated
|
||||||
public GHBranchProtection getProtection() throws IOException {
|
public GHBranchProtection getProtection() throws IOException {
|
||||||
return root.retrieve().to(protection_url, GHBranchProtection.class).wrap(this);
|
return root.createRequest()
|
||||||
|
.withPreview(Previews.LUKE_CAGE)
|
||||||
|
.setRawUrlPath(protection_url)
|
||||||
|
.fetch(GHBranchProtection.class)
|
||||||
|
.wrap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +128,7 @@ public class GHBranch {
|
|||||||
* if disabling protection fails
|
* if disabling protection fails
|
||||||
*/
|
*/
|
||||||
public void disableProtection() throws IOException {
|
public void disableProtection() throws IOException {
|
||||||
new Requester(root).method("DELETE").to(protection_url);
|
root.createRequest().method("DELETE").setRawUrlPath(protection_url).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,7 +137,7 @@ public class GHBranch {
|
|||||||
* @return GHBranchProtectionBuilder for enabling protection
|
* @return GHBranchProtectionBuilder for enabling protection
|
||||||
* @see GHCommitStatus#getContext() GHCommitStatus#getContext()
|
* @see GHCommitStatus#getContext() GHCommitStatus#getContext()
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(Previews.LUKE_CAGE)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHBranchProtectionBuilder enableProtection() {
|
public GHBranchProtectionBuilder enableProtection() {
|
||||||
return new GHBranchProtectionBuilder(this);
|
return new GHBranchProtectionBuilder(this);
|
||||||
@@ -163,6 +169,59 @@ public class GHBranch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge a branch into this branch.
|
||||||
|
*
|
||||||
|
* @param headBranch
|
||||||
|
* the branch whose head will be merged
|
||||||
|
*
|
||||||
|
* @param commitMessage
|
||||||
|
* the commit message
|
||||||
|
*
|
||||||
|
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
|
||||||
|
* merge).
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* if merging fails
|
||||||
|
*/
|
||||||
|
@CheckForNull
|
||||||
|
public GHCommit merge(GHBranch headBranch, String commitMessage) throws IOException {
|
||||||
|
return merge(headBranch.getName(), commitMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge a ref into this branch.
|
||||||
|
*
|
||||||
|
* @param head
|
||||||
|
* the ref name that will be merged into this branch. Follows the usual ref naming rules, could be a
|
||||||
|
* branch name, tag, or commit sha.
|
||||||
|
*
|
||||||
|
* @param commitMessage
|
||||||
|
* the commit message
|
||||||
|
*
|
||||||
|
* @return the merge {@link GHCommit} created, or {@code null} if the base already contains the head (nothing to
|
||||||
|
* merge).
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* if merging fails
|
||||||
|
*/
|
||||||
|
@CheckForNull
|
||||||
|
public GHCommit merge(String head, String commitMessage) throws IOException {
|
||||||
|
GHCommit result = root.createRequest()
|
||||||
|
.withUrlPath(owner.getApiTailUrl("merges"))
|
||||||
|
.method("POST")
|
||||||
|
.with("commit_message", commitMessage)
|
||||||
|
.with("base", this.name)
|
||||||
|
.with("head", head)
|
||||||
|
.fetch(GHCommit.class);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
result.wrapUp(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
String getApiRoute() {
|
String getApiRoute() {
|
||||||
return owner.getApiTailUrl("/branches/" + name);
|
return owner.getApiTailUrl("/branches/" + name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.ZZZAX;
|
import static org.kohsuke.github.internal.Previews.ZZZAX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHBranchProtection.
|
* The type GHBranchProtection.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.github.com/en/rest/reference/repos#get-branch-protection">GitHub Branch Protection</a>
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(
|
@SuppressFBWarnings(
|
||||||
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
|
||||||
"URF_UNREAD_FIELD" },
|
"URF_UNREAD_FIELD" },
|
||||||
justification = "JSON API")
|
justification = "JSON API")
|
||||||
public class GHBranchProtection {
|
public class GHBranchProtection extends GitHubInteractiveObject {
|
||||||
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";
|
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private EnforceAdmins enforceAdmins;
|
private EnforceAdmins enforceAdmins;
|
||||||
|
|
||||||
private GitHub root;
|
|
||||||
|
|
||||||
@JsonProperty("required_pull_request_reviews")
|
@JsonProperty("required_pull_request_reviews")
|
||||||
private RequiredReviews requiredReviews;
|
private RequiredReviews requiredReviews;
|
||||||
|
|
||||||
@@ -41,10 +41,10 @@ public class GHBranchProtection {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(ZZZAX)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void enabledSignedCommits() throws IOException {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,10 +53,10 @@ public class GHBranchProtection {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(ZZZAX)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void disableSignedCommits() throws IOException {
|
public void disableSignedCommits() throws IOException {
|
||||||
requester().method("DELETE").to(url + REQUIRE_SIGNATURES_URI);
|
requester().method("DELETE").withUrlPath(url + REQUIRE_SIGNATURES_URI).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,10 +84,10 @@ public class GHBranchProtection {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(ZZZAX)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean getRequiredSignatures() throws IOException {
|
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() {
|
private Requester requester() {
|
||||||
return new Requester(root).withPreview(ZZZAX);
|
return root.createRequest().withPreview(ZZZAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.*;
|
import static org.kohsuke.github.internal.Previews.LUKE_CAGE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder to configure the branch protection settings.
|
* Builder to configure the branch protection settings.
|
||||||
@@ -93,7 +93,8 @@ public class GHBranchProtectionBuilder {
|
|||||||
.withNullable("required_pull_request_reviews", prReviews)
|
.withNullable("required_pull_request_reviews", prReviews)
|
||||||
.withNullable("restrictions", restrictions)
|
.withNullable("restrictions", restrictions)
|
||||||
.withNullable("enforce_admins", enforceAdmins)
|
.withNullable("enforce_admins", enforceAdmins)
|
||||||
.to(branch.getProtectionUrl().toString(), GHBranchProtection.class)
|
.withUrlPath(branch.getProtectionUrl().toString())
|
||||||
|
.fetch(GHBranchProtection.class)
|
||||||
.wrap(branch);
|
.wrap(branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +353,7 @@ public class GHBranchProtectionBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Requester requester() {
|
private Requester requester() {
|
||||||
return new Requester(branch.getRoot()).withPreview(LUKE_CAGE);
|
return branch.getRoot().createRequest().withPreview(LUKE_CAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Restrictions {
|
private static class Restrictions {
|
||||||
|
|||||||
342
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
342
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
|
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
import org.kohsuke.github.GHWorkflowRun.Conclusion;
|
||||||
|
import org.kohsuke.github.GHWorkflowRun.Status;
|
||||||
|
import org.kohsuke.github.internal.EnumUtils;
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
||||||
|
|
||||||
|
@JsonProperty("repository")
|
||||||
|
GHRepository owner;
|
||||||
|
|
||||||
|
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;
|
||||||
|
wrap(owner.root);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHCheckRun wrap(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
if (owner != null) {
|
||||||
|
owner.wrap(root);
|
||||||
|
if (pullRequests != null && pullRequests.length != 0) {
|
||||||
|
for (GHPullRequest singlePull : pullRequests) {
|
||||||
|
singlePull.wrap(owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (checkSuite != null) {
|
||||||
|
if (owner != null) {
|
||||||
|
checkSuite.wrap(owner);
|
||||||
|
} else {
|
||||||
|
checkSuite.wrap(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (app != null) {
|
||||||
|
app.wrapUp(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHPullRequest[] wrap() {
|
||||||
|
return pullRequests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets status of the check run.
|
||||||
|
*
|
||||||
|
* @return Status of the check run
|
||||||
|
* @see Status
|
||||||
|
*/
|
||||||
|
@WithBridgeMethods(value = String.class, adapterMethod = "statusAsStr")
|
||||||
|
public Status getStatus() {
|
||||||
|
return Status.from(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getStatus")
|
||||||
|
private Object statusAsStr(Status status, Class type) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum Status {
|
||||||
|
QUEUED, IN_PROGRESS, COMPLETED, UNKNOWN;
|
||||||
|
|
||||||
|
public static Status from(String value) {
|
||||||
|
return EnumUtils.getNullableEnumOrDefault(Status.class, value, Status.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets conclusion of a completed check run.
|
||||||
|
*
|
||||||
|
* @return Status of the check run
|
||||||
|
* @see Conclusion
|
||||||
|
*/
|
||||||
|
@WithBridgeMethods(value = String.class, adapterMethod = "conclusionAsStr")
|
||||||
|
public Conclusion getConclusion() {
|
||||||
|
return Conclusion.from(conclusion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getConclusion")
|
||||||
|
private Object conclusionAsStr(Conclusion conclusion, Class type) {
|
||||||
|
return conclusion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Final conclusion of the check.
|
||||||
|
*
|
||||||
|
* From <a href="https://docs.github.com/en/rest/reference/checks#create-a-check-run--parameters">Check Run
|
||||||
|
* Parameters - <code>conclusion</code></a>.
|
||||||
|
*/
|
||||||
|
public static enum Conclusion {
|
||||||
|
ACTION_REQUIRED, CANCELLED, FAILURE, NEUTRAL, SUCCESS, SKIPPED, STALE, TIMED_OUT, UNKNOWN;
|
||||||
|
|
||||||
|
public static Conclusion from(String value) {
|
||||||
|
return EnumUtils.getNullableEnumOrDefault(Conclusion.class, value, Conclusion.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
|
||||||
|
* always empty.
|
||||||
|
*
|
||||||
|
* @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||||
|
if (pullRequests != null && pullRequests.length != 0) {
|
||||||
|
for (GHPullRequest singlePull : pullRequests) {
|
||||||
|
// Only refresh if we haven't do so before
|
||||||
|
singlePull.refresh(singlePull.getTitle());
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates this check run.
|
||||||
|
*
|
||||||
|
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
|
||||||
|
*/
|
||||||
|
@Preview(Previews.ANTIOPE)
|
||||||
|
@Deprecated
|
||||||
|
public @NonNull GHCheckRunBuilder update() {
|
||||||
|
return new GHCheckRunBuilder(owner, getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
307
src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Normal file
307
src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
|
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 or updates a check run.
|
||||||
|
*
|
||||||
|
* @see GHCheckRun
|
||||||
|
* @see GHRepository#createCheckRun
|
||||||
|
* @see <a href="https://developer.github.com/v3/checks/runs/#create-a-check-run">documentation</a>
|
||||||
|
* @see GHCheckRun#update()
|
||||||
|
* @see <a href="https://developer.github.com/v3/checks/runs/#update-a-check-run">documentation</a>
|
||||||
|
*/
|
||||||
|
@SuppressFBWarnings(value = "URF_UNREAD_FIELD", justification = "Jackson serializes these even without a getter")
|
||||||
|
@Preview(Previews.ANTIOPE)
|
||||||
|
@Deprecated
|
||||||
|
public final class GHCheckRunBuilder {
|
||||||
|
|
||||||
|
protected final GHRepository repo;
|
||||||
|
protected final Requester requester;
|
||||||
|
private Output output;
|
||||||
|
private List<Action> actions;
|
||||||
|
|
||||||
|
private GHCheckRunBuilder(GHRepository repo, Requester requester) {
|
||||||
|
this.repo = repo;
|
||||||
|
this.requester = requester;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHCheckRunBuilder(GHRepository repo, String name, String headSHA) {
|
||||||
|
this(repo,
|
||||||
|
repo.root.createRequest()
|
||||||
|
.withPreview(Previews.ANTIOPE)
|
||||||
|
.method("POST")
|
||||||
|
.with("name", name)
|
||||||
|
.with("head_sha", headSHA)
|
||||||
|
.withUrlPath(repo.getApiTailUrl("check-runs")));
|
||||||
|
}
|
||||||
|
|
||||||
|
GHCheckRunBuilder(GHRepository repo, long checkId) {
|
||||||
|
this(repo,
|
||||||
|
repo.root.createRequest()
|
||||||
|
.withPreview(Previews.ANTIOPE)
|
||||||
|
.method("PATCH")
|
||||||
|
.withUrlPath(repo.getApiTailUrl("check-runs/" + checkId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
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).withText(output.text);
|
||||||
|
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 final GHRepository owner;
|
||||||
|
private final GitHubRequest request;
|
||||||
|
|
||||||
|
private GHCheckRunsPage result;
|
||||||
|
|
||||||
|
public GHCheckRunsIterable(GHRepository owner, GitHubRequest request) {
|
||||||
|
this.owner = owner;
|
||||||
|
this.request = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public PagedIterator<GHCheckRun> _iterator(int pageSize) {
|
||||||
|
return new PagedIterator<>(
|
||||||
|
adapt(GitHubPageIterator.create(owner.getRoot().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(owner);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
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(GHRepository owner) {
|
||||||
|
for (GHCheckRun check_run : check_runs) {
|
||||||
|
check_run.wrap(owner);
|
||||||
|
}
|
||||||
|
return check_runs;
|
||||||
|
}
|
||||||
|
}
|
||||||
259
src/main/java/org/kohsuke/github/GHCheckSuite.java
Normal file
259
src/main/java/org/kohsuke/github/GHCheckSuite.java
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
||||||
|
|
||||||
|
@JsonProperty("repository")
|
||||||
|
GHRepository owner;
|
||||||
|
|
||||||
|
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.wrap(owner.root);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHCheckSuite wrap(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
if (owner != null) {
|
||||||
|
owner.wrap(root);
|
||||||
|
if (pullRequests != null && pullRequests.length != 0) {
|
||||||
|
for (GHPullRequest singlePull : pullRequests) {
|
||||||
|
singlePull.wrap(owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (app != null) {
|
||||||
|
app.wrapUp(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.
|
||||||
|
*
|
||||||
|
* Note this field is only populated for events. When getting a {@link GHCheckSuite} outside of an event, this is
|
||||||
|
* always empty.
|
||||||
|
*
|
||||||
|
* @return the list of {@link GHPullRequest}s for this check suite. Only populated for events.
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
public List<GHPullRequest> getPullRequests() throws IOException {
|
||||||
|
if (pullRequests != null && pullRequests.length != 0) {
|
||||||
|
for (GHPullRequest singlePull : pullRequests) {
|
||||||
|
// Only refresh if we haven't do so before
|
||||||
|
singlePull.refresh(singlePull.getTitle());
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableList(Arrays.asList(pullRequests));
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,9 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.kohsuke.github.internal.Previews.ANTIOPE;
|
||||||
|
import static org.kohsuke.github.internal.Previews.GROOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A commit in a repository.
|
* A commit in a repository.
|
||||||
*
|
*
|
||||||
@@ -39,6 +42,8 @@ public class GHCommit {
|
|||||||
|
|
||||||
private int comment_count;
|
private int comment_count;
|
||||||
|
|
||||||
|
private GHVerification verification;
|
||||||
|
|
||||||
static class Tree {
|
static class Tree {
|
||||||
String sha;
|
String sha;
|
||||||
}
|
}
|
||||||
@@ -61,7 +66,7 @@ public class GHCommit {
|
|||||||
* @return the authored date
|
* @return the authored date
|
||||||
*/
|
*/
|
||||||
public Date getAuthoredDate() {
|
public Date getAuthoredDate() {
|
||||||
return GitHub.parseDate(author.date);
|
return author.getDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +85,7 @@ public class GHCommit {
|
|||||||
* @return the commit date
|
* @return the commit date
|
||||||
*/
|
*/
|
||||||
public Date getCommitDate() {
|
public Date getCommitDate() {
|
||||||
return GitHub.parseDate(committer.date);
|
return committer.getDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,6 +105,15 @@ public class GHCommit {
|
|||||||
public int getCommentCount() {
|
public int getCommentCount() {
|
||||||
return comment_count;
|
return comment_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Verification Status.
|
||||||
|
*
|
||||||
|
* @return the Verification status
|
||||||
|
*/
|
||||||
|
public GHVerification getVerification() {
|
||||||
|
return verification;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +122,6 @@ public class GHCommit {
|
|||||||
* @deprecated Use {@link GitUser} instead.
|
* @deprecated Use {@link GitUser} instead.
|
||||||
*/
|
*/
|
||||||
public static class GHAuthor extends GitUser {
|
public static class GHAuthor extends GitUser {
|
||||||
private String date;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,7 +214,7 @@ public class GHCommit {
|
|||||||
* resolves to the actual content of the file.
|
* resolves to the actual content of the file.
|
||||||
*/
|
*/
|
||||||
public URL getRawUrl() {
|
public URL getRawUrl() {
|
||||||
return GitHub.parseURL(raw_url);
|
return GitHubClient.parseURL(raw_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,7 +225,7 @@ public class GHCommit {
|
|||||||
* that resolves to the HTML page that describes this file.
|
* that resolves to the HTML page that describes this file.
|
||||||
*/
|
*/
|
||||||
public URL getBlobUrl() {
|
public URL getBlobUrl() {
|
||||||
return GitHub.parseURL(blob_url);
|
return GitHubClient.parseURL(blob_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -326,7 +339,7 @@ public class GHCommit {
|
|||||||
* "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000"
|
* "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000"
|
||||||
*/
|
*/
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -435,17 +448,49 @@ public class GHCommit {
|
|||||||
return owner.root.getUser(author.login);
|
return owner.root.getUser(author.login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of pull requests which contain this commit.
|
||||||
|
*
|
||||||
|
* @return {@link PagedIterable} with the pull requests which contain this commit
|
||||||
|
*/
|
||||||
|
@Preview(GROOT)
|
||||||
|
@Deprecated
|
||||||
|
public PagedIterable<GHPullRequest> listPullRequests() {
|
||||||
|
return owner.root.createRequest()
|
||||||
|
.withPreview(GROOT)
|
||||||
|
.withUrlPath(String.format("/repos/%s/%s/commits/%s/pulls", owner.getOwnerName(), owner.getName(), sha))
|
||||||
|
.toIterable(GHPullRequest[].class, item -> item.wrapUp(owner));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of branches where this commit is the head commit.
|
||||||
|
*
|
||||||
|
* @return {@link PagedIterable} with the branches where the commit is the head commit
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
@Preview(GROOT)
|
||||||
|
@Deprecated
|
||||||
|
public PagedIterable<GHBranch> listBranchesWhereHead() throws IOException {
|
||||||
|
return owner.root.createRequest()
|
||||||
|
.withPreview(GROOT)
|
||||||
|
.withUrlPath(String.format("/repos/%s/%s/commits/%s/branches-where-head",
|
||||||
|
owner.getOwnerName(),
|
||||||
|
owner.getName(),
|
||||||
|
sha))
|
||||||
|
.toIterable(GHBranch[].class, item -> item.wrap(owner));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List comments paged iterable.
|
* List comments paged iterable.
|
||||||
*
|
*
|
||||||
* @return {@link PagedIterable} with all the commit comments in this repository.
|
* @return {@link PagedIterable} with all the commit comments in this repository.
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHCommitComment> listComments() {
|
public PagedIterable<GHCommitComment> listComments() {
|
||||||
return owner.root.retrieve()
|
return owner.root.createRequest()
|
||||||
.asPagedIterable(
|
.withUrlPath(
|
||||||
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
|
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
|
||||||
GHCommitComment[].class,
|
.toIterable(GHCommitComment[].class, item -> item.wrap(owner));
|
||||||
item -> item.wrap(owner));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -466,12 +511,15 @@ public class GHCommit {
|
|||||||
* if comment is not created
|
* if comment is not created
|
||||||
*/
|
*/
|
||||||
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException {
|
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("path", path)
|
||||||
.with("line", line)
|
.with("line", line)
|
||||||
.with("position", position)
|
.with("position", position)
|
||||||
.to(String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha),
|
.withUrlPath(
|
||||||
GHCommitComment.class);
|
String.format("/repos/%s/%s/commits/%s/comments", owner.getOwnerName(), owner.getName(), sha))
|
||||||
|
.fetch(GHCommitComment.class);
|
||||||
return r.wrap(owner);
|
return r.wrap(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,15 +558,28 @@ public class GHCommit {
|
|||||||
return owner.getLastCommitStatus(sha);
|
return owner.getLastCommitStatus(sha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets check-runs for given sha.
|
||||||
|
*
|
||||||
|
* @return check runs for given sha.
|
||||||
|
* @throws IOException
|
||||||
|
* on error
|
||||||
|
*/
|
||||||
|
@Preview(ANTIOPE)
|
||||||
|
@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.
|
* Some of the fields are not always filled in when this object is retrieved as a part of another API call.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* on error
|
* on error
|
||||||
*/
|
*/
|
||||||
void populate() throws IOException {
|
void populate() throws IOException {
|
||||||
if (files == null && stats == null)
|
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) {
|
GHCommit wrapUp(GHRepository owner) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class GHCommitBuilder {
|
|||||||
|
|
||||||
GHCommitBuilder(GHRepository repo) {
|
GHCommitBuilder(GHRepository repo) {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
req = new Requester(repo.root);
|
req = repo.root.createRequest().method("POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,6 +89,19 @@ public class GHCommitBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the PGP signature of this commit.
|
||||||
|
*
|
||||||
|
* @param signature
|
||||||
|
* the signature calculated from the commit
|
||||||
|
*
|
||||||
|
* @return the gh commit builder
|
||||||
|
*/
|
||||||
|
public GHCommitBuilder withSignature(String signature) {
|
||||||
|
req.with("signature", signature);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the committer of this commit.
|
* Configures the committer of this commit.
|
||||||
*
|
*
|
||||||
@@ -118,6 +131,6 @@ public class GHCommitBuilder {
|
|||||||
*/
|
*/
|
||||||
public GHCommit create() throws IOException {
|
public GHCommit create() throws IOException {
|
||||||
req.with("parents", parents);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.*;
|
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A comment attached to a commit (or a specific line in a specific file of a commit.)
|
* A comment attached to a commit (or a specific line in a specific file of a commit.)
|
||||||
@@ -41,7 +41,7 @@ public class GHCommitComment extends GHObject implements Reactable {
|
|||||||
* show this commit comment in a browser.
|
* show this commit comment in a browser.
|
||||||
*/
|
*/
|
||||||
public URL getHtmlUrl() {
|
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
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void update(String body) throws IOException {
|
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;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview(SQUIRREL_GIRL)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHReaction createReaction(ReactionContent content) throws IOException {
|
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())
|
.with("content", content.getContent())
|
||||||
.to(getApiTail() + "/reactions", GHReaction.class)
|
.withUrlPath(getApiTail() + "/reactions")
|
||||||
|
.fetch(GHReaction.class)
|
||||||
.wrap(owner.root);
|
.wrap(owner.root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview(SQUIRREL_GIRL)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PagedIterable<GHReaction> listReactions() {
|
public PagedIterable<GHReaction> listReactions() {
|
||||||
return owner.root.retrieve()
|
return owner.root.createRequest()
|
||||||
.withPreview(SQUIRREL_GIRL)
|
.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
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(owner.root).method("DELETE").to(getApiTail());
|
owner.root.createRequest().method("DELETE").withUrlPath(getApiTail()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getApiTail() {
|
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) {
|
GHCommitComment wrap(GHRepository owner) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class GHCommitQueryBuilder {
|
|||||||
|
|
||||||
GHCommitQueryBuilder(GHRepository repo) {
|
GHCommitQueryBuilder(GHRepository repo) {
|
||||||
this.repo = 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
|
* @return the gh commit query builder
|
||||||
*/
|
*/
|
||||||
public GHCommitQueryBuilder since(Date dt) {
|
public GHCommitQueryBuilder since(Date dt) {
|
||||||
req.with("since", GitHub.printDate(dt));
|
req.with("since", GitHubClient.printDate(dt));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public class GHCommitQueryBuilder {
|
|||||||
* @return the gh commit query builder
|
* @return the gh commit query builder
|
||||||
*/
|
*/
|
||||||
public GHCommitQueryBuilder until(Date dt) {
|
public GHCommitQueryBuilder until(Date dt) {
|
||||||
req.with("until", GitHub.printDate(dt));
|
req.with("until", GitHubClient.printDate(dt));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +127,6 @@ public class GHCommitQueryBuilder {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHCommit> list() {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ import java.io.IOException;
|
|||||||
* @author Marc de Verdelhan
|
* @author Marc de Verdelhan
|
||||||
* @see GitHub#searchCommits() GitHub#searchCommits()
|
* @see GitHub#searchCommits() GitHub#searchCommits()
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview(Previews.CLOAK)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
|
public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
|
||||||
GHCommitSearchBuilder(GitHub root) {
|
GHCommitSearchBuilder(GitHub root) {
|
||||||
@@ -259,7 +260,7 @@ public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
|
|||||||
if (StringUtils.isBlank(commitUrl)) {
|
if (StringUtils.isBlank(commitUrl)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int indexOfUsername = (GitHub.GITHUB_URL + "/repos/").length();
|
int indexOfUsername = (GitHubClient.GITHUB_URL + "/repos/").length();
|
||||||
String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);
|
String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);
|
||||||
return tokens[0] + '/' + tokens[1];
|
return tokens[0] + '/' + tokens[1];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ public class GHCommitStatus extends GHObject {
|
|||||||
String context;
|
String context;
|
||||||
GHUser creator;
|
GHUser creator;
|
||||||
|
|
||||||
private GitHub root;
|
|
||||||
|
|
||||||
GHCommitStatus wrapUp(GitHub root) {
|
GHCommitStatus wrapUp(GitHub root) {
|
||||||
if (creator != null)
|
if (creator != null)
|
||||||
creator.wrapUp(root);
|
creator.wrapUp(root);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class GHCompare {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +36,7 @@ public class GHCompare {
|
|||||||
* @return the html url
|
* @return the html url
|
||||||
*/
|
*/
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +45,7 @@ public class GHCompare {
|
|||||||
* @return the permalink url
|
* @return the permalink url
|
||||||
*/
|
*/
|
||||||
public URL getPermalinkUrl() {
|
public URL getPermalinkUrl() {
|
||||||
return GitHub.parseURL(permalink_url);
|
return GitHubClient.parseURL(permalink_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +54,7 @@ public class GHCompare {
|
|||||||
* @return the diff url
|
* @return the diff url
|
||||||
*/
|
*/
|
||||||
public URL getDiffUrl() {
|
public URL getDiffUrl() {
|
||||||
return GitHub.parseURL(diff_url);
|
return GitHubClient.parseURL(diff_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +63,7 @@ public class GHCompare {
|
|||||||
* @return the patch url
|
* @return the patch url
|
||||||
*/
|
*/
|
||||||
public URL getPatchUrl() {
|
public URL getPatchUrl() {
|
||||||
return GitHub.parseURL(patch_url);
|
return GitHubClient.parseURL(patch_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
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.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Content of a repository.
|
* A Content of a repository.
|
||||||
@@ -16,21 +15,20 @@ import java.io.UnsupportedEncodingException;
|
|||||||
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
|
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "UnusedDeclaration" })
|
@SuppressWarnings({ "UnusedDeclaration" })
|
||||||
public class GHContent implements Refreshable {
|
public class GHContent extends GitHubInteractiveObject implements Refreshable {
|
||||||
/*
|
/*
|
||||||
* In normal use of this class, repository field is set via wrap(), but in the code search API, there's a nested
|
* In normal use of this class, repository field is set via wrap(), but in the code search API, there's a nested
|
||||||
* 'repository' field that gets populated from JSON.
|
* 'repository' field that gets populated from JSON.
|
||||||
*/
|
*/
|
||||||
private GHRepository repository;
|
private GHRepository repository;
|
||||||
|
|
||||||
private GitHub root;
|
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
private String encoding;
|
private String encoding;
|
||||||
private long size;
|
private long size;
|
||||||
private String sha;
|
private String sha;
|
||||||
private String name;
|
private String name;
|
||||||
private String path;
|
private String path;
|
||||||
|
private String target;
|
||||||
private String content;
|
private String content;
|
||||||
private String url; // this is the API url
|
private String url; // this is the API url
|
||||||
private String git_url; // this is the Blob url
|
private String git_url; // this is the Blob url
|
||||||
@@ -100,6 +98,15 @@ public class GHContent implements Refreshable {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets target of a symlink. This will only be set if {@code "symlink".equals(getType())}
|
||||||
|
*
|
||||||
|
* @return the target
|
||||||
|
*/
|
||||||
|
public String getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the decoded content that is stored at this location.
|
* Retrieve the decoded content that is stored at this location.
|
||||||
*
|
*
|
||||||
@@ -114,7 +121,7 @@ public class GHContent implements Refreshable {
|
|||||||
*/
|
*/
|
||||||
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||||
public String getContent() throws IOException {
|
public String getContent() throws IOException {
|
||||||
return new String(Base64.decodeBase64(getEncodedContent()));
|
return new String(Base64.getMimeDecoder().decode(getEncodedContent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,8 +182,9 @@ public class GHContent implements Refreshable {
|
|||||||
refresh(content);
|
refresh(content);
|
||||||
if (encoding.equals("base64")) {
|
if (encoding.equals("base64")) {
|
||||||
try {
|
try {
|
||||||
return new Base64InputStream(new ByteArrayInputStream(content.getBytes("US-ASCII")), false);
|
Base64.Decoder decoder = Base64.getMimeDecoder();
|
||||||
} catch (UnsupportedEncodingException e) {
|
return new ByteArrayInputStream(decoder.decode(content.getBytes(StandardCharsets.US_ASCII)));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
throw new AssertionError(e); // US-ASCII is mandatory
|
throw new AssertionError(e); // US-ASCII is mandatory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +231,7 @@ public class GHContent implements Refreshable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
protected synchronized void populate() throws IOException {
|
protected synchronized void populate() throws IOException {
|
||||||
root.retrieve().to(url, this);
|
root.createRequest().withUrlPath(url).fetchInto(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -237,7 +245,7 @@ public class GHContent implements Refreshable {
|
|||||||
if (!isDirectory())
|
if (!isDirectory())
|
||||||
throw new IllegalStateException(path + " is not a directory");
|
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 +312,11 @@ public class GHContent implements Refreshable {
|
|||||||
*/
|
*/
|
||||||
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch)
|
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch)
|
||||||
throws IOException {
|
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("message", commitMessage)
|
||||||
.with("sha", sha)
|
.with("sha", sha)
|
||||||
.with("content", encodedContent)
|
.with("content", encodedContent)
|
||||||
@@ -316,7 +326,8 @@ public class GHContent implements Refreshable {
|
|||||||
requester.with("branch", branch);
|
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.getContent().wrap(repository);
|
||||||
response.getCommit().wrapUp(repository);
|
response.getCommit().wrapUp(repository);
|
||||||
@@ -350,7 +361,9 @@ public class GHContent implements Refreshable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHContentUpdateResponse delete(String commitMessage, String branch) throws IOException {
|
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("message", commitMessage)
|
||||||
.with("sha", sha)
|
.with("sha", sha)
|
||||||
.method("DELETE");
|
.method("DELETE");
|
||||||
@@ -359,7 +372,8 @@ public class GHContent implements Refreshable {
|
|||||||
requester.with("branch", branch);
|
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);
|
response.getCommit().wrapUp(repository);
|
||||||
return response;
|
return response;
|
||||||
@@ -382,22 +396,6 @@ public class GHContent implements Refreshable {
|
|||||||
return this;
|
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.
|
* Fully populate the data by retrieving missing data.
|
||||||
*
|
*
|
||||||
@@ -405,6 +403,6 @@ public class GHContent implements Refreshable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void refresh() throws IOException {
|
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;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to create/update content.
|
* Used to create/update content.
|
||||||
@@ -21,7 +20,7 @@ public final class GHContentBuilder {
|
|||||||
|
|
||||||
GHContentBuilder(GHRepository repo) {
|
GHContentBuilder(GHRepository repo) {
|
||||||
this.repo = 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
|
* @param sha
|
||||||
* the sha
|
* the sha
|
||||||
@@ -69,7 +68,7 @@ public final class GHContentBuilder {
|
|||||||
* @return the gh content builder
|
* @return the gh content builder
|
||||||
*/
|
*/
|
||||||
public GHContentBuilder content(byte[] content) {
|
public GHContentBuilder content(byte[] content) {
|
||||||
req.with("content", Base64.encodeBase64String(content));
|
req.with("content", Base64.getEncoder().encodeToString(content));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,11 +80,7 @@ public final class GHContentBuilder {
|
|||||||
* @return the gh content builder
|
* @return the gh content builder
|
||||||
*/
|
*/
|
||||||
public GHContentBuilder content(String content) {
|
public GHContentBuilder content(String content) {
|
||||||
try {
|
return content(content.getBytes(StandardCharsets.UTF_8));
|
||||||
return content(content.getBytes("UTF-8"));
|
|
||||||
} catch (UnsupportedEncodingException x) {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +103,8 @@ public final class GHContentBuilder {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHContentUpdateResponse commit() throws IOException {
|
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.getContent().wrap(repo);
|
||||||
response.getCommit().wrapUp(repo);
|
response.getCommit().wrapUp(repo);
|
||||||
|
|||||||
@@ -118,6 +118,41 @@ public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {
|
|||||||
return q("repo:" + v);
|
return q("repo:" + v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order gh content search builder.
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
* the v
|
||||||
|
* @return the gh content search builder
|
||||||
|
*/
|
||||||
|
public GHContentSearchBuilder order(GHDirection v) {
|
||||||
|
req.with("order", v);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort gh content search builder.
|
||||||
|
*
|
||||||
|
* @param sort
|
||||||
|
* the sort
|
||||||
|
* @return the gh content search builder
|
||||||
|
*/
|
||||||
|
public GHContentSearchBuilder sort(GHContentSearchBuilder.Sort sort) {
|
||||||
|
if (Sort.BEST_MATCH.equals(sort)) {
|
||||||
|
req.remove("sort");
|
||||||
|
} else {
|
||||||
|
req.with("sort", sort);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum Sort.
|
||||||
|
*/
|
||||||
|
public enum Sort {
|
||||||
|
BEST_MATCH, INDEXED
|
||||||
|
}
|
||||||
|
|
||||||
private static class ContentSearchResult extends SearchResult<GHContent> {
|
private static class ContentSearchResult extends SearchResult<GHContent> {
|
||||||
private GHContent[] items;
|
private GHContent[] items;
|
||||||
|
|
||||||
|
|||||||
@@ -1,154 +1,25 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
|
||||||
|
import static org.kohsuke.github.internal.Previews.BAPTISTE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a repository
|
* Creates a repository
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
public class GHCreateRepositoryBuilder {
|
public class GHCreateRepositoryBuilder extends GHRepositoryBuilder<GHCreateRepositoryBuilder> {
|
||||||
private final GitHub root;
|
|
||||||
protected final Requester builder;
|
|
||||||
private final String apiUrlTail;
|
|
||||||
|
|
||||||
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
|
public GHCreateRepositoryBuilder(String name, GitHub root, String apiTail) {
|
||||||
this.root = root;
|
super(GHCreateRepositoryBuilder.class, root, null);
|
||||||
this.apiUrlTail = apiUrlTail;
|
requester.method("POST").withUrlPath(apiTail);
|
||||||
this.builder = new Requester(root);
|
|
||||||
this.builder.with("name", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
try {
|
||||||
* Description for repository
|
name(name);
|
||||||
*
|
} catch (IOException e) {
|
||||||
* @param description
|
// not going to happen here
|
||||||
* description of repository
|
}
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder description(String description) {
|
|
||||||
this.builder.with("description", description);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Homepage for repository
|
|
||||||
*
|
|
||||||
* @param homepage
|
|
||||||
* homepage of repository
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder homepage(URL homepage) {
|
|
||||||
return homepage(homepage.toExternalForm());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Homepage for repository
|
|
||||||
*
|
|
||||||
* @param homepage
|
|
||||||
* homepage of repository
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder homepage(String homepage) {
|
|
||||||
this.builder.with("homepage", homepage);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a private repository
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* private if true
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder private_(boolean enabled) {
|
|
||||||
this.builder.with("private", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables issue tracker
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* true if enabled
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder issues(boolean enabled) {
|
|
||||||
this.builder.with("has_issues", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables wiki
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* true if enabled
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder wiki(boolean enabled) {
|
|
||||||
this.builder.with("has_wiki", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables downloads
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* true if enabled
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder downloads(boolean enabled) {
|
|
||||||
this.builder.with("has_downloads", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If true, create an initial commit with empty README.
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* true if enabled
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder autoInit(boolean enabled) {
|
|
||||||
this.builder.with("auto_init", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow or disallow squash-merging pull requests.
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* true if enabled
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder allowSquashMerge(boolean enabled) {
|
|
||||||
this.builder.with("allow_squash_merge", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow or disallow merging pull requests with a merge commit.
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* true if enabled
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder allowMergeCommit(boolean enabled) {
|
|
||||||
this.builder.with("allow_merge_commit", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow or disallow rebase-merging pull requests.
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* true if enabled
|
|
||||||
* @return a builder to continue with building
|
|
||||||
*/
|
|
||||||
public GHCreateRepositoryBuilder allowRebaseMerge(boolean enabled) {
|
|
||||||
this.builder.with("allow_rebase_merge", enabled);
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,10 +28,11 @@ public class GHCreateRepositoryBuilder {
|
|||||||
* @param language
|
* @param language
|
||||||
* template to base the ignore file on
|
* template to base the ignore file on
|
||||||
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
|
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
|
||||||
|
* @throws IOException
|
||||||
|
* In case of any networking error or error from the server.
|
||||||
*/
|
*/
|
||||||
public GHCreateRepositoryBuilder gitignoreTemplate(String language) {
|
public GHCreateRepositoryBuilder gitignoreTemplate(String language) throws IOException {
|
||||||
this.builder.with("gitignore_template", language);
|
return with("gitignore_template", language);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,10 +41,24 @@ public class GHCreateRepositoryBuilder {
|
|||||||
* @param license
|
* @param license
|
||||||
* template to base the license file on
|
* template to base the license file on
|
||||||
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
|
* @return a builder to continue with building See https://developer.github.com/v3/repos/#create
|
||||||
|
* @throws IOException
|
||||||
|
* In case of any networking error or error from the server.
|
||||||
*/
|
*/
|
||||||
public GHCreateRepositoryBuilder licenseTemplate(String license) {
|
public GHCreateRepositoryBuilder licenseTemplate(String license) throws IOException {
|
||||||
this.builder.with("license_template", license);
|
return with("license_template", license);
|
||||||
return this;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, create an initial commit with empty README.
|
||||||
|
*
|
||||||
|
* @param enabled
|
||||||
|
* true if enabled
|
||||||
|
* @return a builder to continue with building
|
||||||
|
* @throws IOException
|
||||||
|
* In case of any networking error or error from the server.
|
||||||
|
*/
|
||||||
|
public GHCreateRepositoryBuilder autoInit(boolean enabled) throws IOException {
|
||||||
|
return with("auto_init", enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,10 +67,57 @@ public class GHCreateRepositoryBuilder {
|
|||||||
* @param team
|
* @param team
|
||||||
* team to grant access to
|
* team to grant access to
|
||||||
* @return a builder to continue with building
|
* @return a builder to continue with building
|
||||||
|
* @throws IOException
|
||||||
|
* In case of any networking error or error from the server.
|
||||||
*/
|
*/
|
||||||
public GHCreateRepositoryBuilder team(GHTeam team) {
|
public GHCreateRepositoryBuilder team(GHTeam team) throws IOException {
|
||||||
if (team != null)
|
if (team != null)
|
||||||
this.builder.with("team_id", team.getId());
|
return with("team_id", team.getId());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether the repository is a template.
|
||||||
|
*
|
||||||
|
* @param enabled
|
||||||
|
* true if enabled
|
||||||
|
* @return a builder to continue with building
|
||||||
|
* @throws IOException
|
||||||
|
* In case of any networking error or error from the server.
|
||||||
|
* @deprecated Use {@link #isTemplate(boolean)} method instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public GHCreateRepositoryBuilder templateRepository(boolean enabled) throws IOException {
|
||||||
|
return isTemplate(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the ownership of the repository.
|
||||||
|
*
|
||||||
|
* @param owner
|
||||||
|
* organization or personage
|
||||||
|
* @return a builder to continue with building
|
||||||
|
* @throws IOException
|
||||||
|
* In case of any networking error or error from the server.
|
||||||
|
*/
|
||||||
|
public GHCreateRepositoryBuilder owner(String owner) throws IOException {
|
||||||
|
return with("owner", owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create repository from template repository
|
||||||
|
*
|
||||||
|
* @param templateOwner
|
||||||
|
* template repository owner
|
||||||
|
* @param templateRepo
|
||||||
|
* template repository
|
||||||
|
* @return a builder to continue with building
|
||||||
|
* @see <a href="https://developer.github.com/v3/previews/">GitHub API Previews</a>
|
||||||
|
*/
|
||||||
|
@Preview(BAPTISTE)
|
||||||
|
@Deprecated
|
||||||
|
public GHCreateRepositoryBuilder fromTemplateRepository(String templateOwner, String templateRepo) {
|
||||||
|
requester.withPreview(BAPTISTE).withUrlPath("/repos/" + templateOwner + "/" + templateRepo + "/generate");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,10 +126,9 @@ public class GHCreateRepositoryBuilder {
|
|||||||
*
|
*
|
||||||
* @return the gh repository
|
* @return the gh repository
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if repsitory cannot be created
|
* if repository cannot be created
|
||||||
*/
|
*/
|
||||||
public GHRepository create() throws IOException {
|
public GHRepository create() throws IOException {
|
||||||
return builder.method("POST").to(apiUrlTail, GHRepository.class).wrap(root);
|
return done();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ public class GHDeployKey {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(owner.root).method("DELETE")
|
owner.root.createRequest()
|
||||||
.to(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id));
|
.method("DELETE")
|
||||||
|
.withUrlPath(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id))
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a deployment
|
* Represents a deployment
|
||||||
@@ -13,7 +16,6 @@ import java.net.URL;
|
|||||||
*/
|
*/
|
||||||
public class GHDeployment extends GHObject {
|
public class GHDeployment extends GHObject {
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
private GitHub root;
|
|
||||||
protected String sha;
|
protected String sha;
|
||||||
protected String ref;
|
protected String ref;
|
||||||
protected String task;
|
protected String task;
|
||||||
@@ -23,6 +25,9 @@ public class GHDeployment extends GHObject {
|
|||||||
protected String statuses_url;
|
protected String statuses_url;
|
||||||
protected String repository_url;
|
protected String repository_url;
|
||||||
protected GHUser creator;
|
protected GHUser creator;
|
||||||
|
protected String original_environment;
|
||||||
|
protected boolean transient_environment;
|
||||||
|
protected boolean production_environment;
|
||||||
|
|
||||||
GHDeployment wrap(GHRepository owner) {
|
GHDeployment wrap(GHRepository owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@@ -38,7 +43,7 @@ public class GHDeployment extends GHObject {
|
|||||||
* @return the statuses url
|
* @return the statuses url
|
||||||
*/
|
*/
|
||||||
public URL getStatusesUrl() {
|
public URL getStatusesUrl() {
|
||||||
return GitHub.parseURL(statuses_url);
|
return GitHubClient.parseURL(statuses_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,7 +52,7 @@ public class GHDeployment extends GHObject {
|
|||||||
* @return the repository url
|
* @return the repository url
|
||||||
*/
|
*/
|
||||||
public URL getRepositoryUrl() {
|
public URL getRepositoryUrl() {
|
||||||
return GitHub.parseURL(repository_url);
|
return GitHubClient.parseURL(repository_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +65,8 @@ public class GHDeployment extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets payload.
|
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a simple string,
|
||||||
|
* otherwise use {@link #getPayloadObject()}.
|
||||||
*
|
*
|
||||||
* @return the payload
|
* @return the payload
|
||||||
*/
|
*/
|
||||||
@@ -68,6 +74,38 @@ public class GHDeployment extends GHObject {
|
|||||||
return (String) payload;
|
return (String) payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a JSON object (Map),
|
||||||
|
* otherwise use {@link #getPayloadObject()}.
|
||||||
|
*
|
||||||
|
* @return the payload
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getPayloadMap() {
|
||||||
|
return (Map<String, Object>) payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets payload without assuming its type. It could be a String or a Map.
|
||||||
|
*
|
||||||
|
* @return the payload
|
||||||
|
*/
|
||||||
|
public Object getPayloadObject() {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The environment defined when the deployment was first created.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @return the original deployment environment
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.FLASH)
|
||||||
|
public String getOriginalEnvironment() {
|
||||||
|
return original_environment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets environment.
|
* Gets environment.
|
||||||
*
|
*
|
||||||
@@ -77,6 +115,33 @@ public class GHDeployment extends GHObject {
|
|||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
|
||||||
|
* future.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @return the environment is transient
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public boolean isTransientEnvironment() {
|
||||||
|
return transient_environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if the given environment is one that end-users directly interact with.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @return the environment is used by end-users directly
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public boolean isProductionEnvironment() {
|
||||||
|
return production_environment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets creator.
|
* Gets creator.
|
||||||
*
|
*
|
||||||
@@ -122,7 +187,7 @@ public class GHDeployment extends GHObject {
|
|||||||
* @return the gh deployment status builder
|
* @return the gh deployment status builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
|
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
|
||||||
return new GHDeploymentStatusBuilder(owner, id, state);
|
return new GHDeploymentStatusBuilder(owner, getId(), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,7 +196,11 @@ public class GHDeployment extends GHObject {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHDeploymentStatus> listStatuses() {
|
public PagedIterable<GHDeploymentStatus> listStatuses() {
|
||||||
return root.retrieve().asPagedIterable(statuses_url, GHDeploymentStatus[].class, item -> item.wrap(owner));
|
return root.createRequest()
|
||||||
|
.withUrlPath(statuses_url)
|
||||||
|
.withPreview(Previews.ANT_MAN)
|
||||||
|
.withPreview(Previews.FLASH)
|
||||||
|
.toIterable(GHDeploymentStatus[].class, item -> item.wrap(owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -19,7 +21,10 @@ public class GHDeploymentBuilder {
|
|||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder(GHRepository repo) {
|
public GHDeploymentBuilder(GHRepository repo) {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.builder = new Requester(repo.root);
|
this.builder = repo.root.createRequest()
|
||||||
|
.withPreview(Previews.ANT_MAN)
|
||||||
|
.withPreview(Previews.FLASH)
|
||||||
|
.method("POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +45,7 @@ public class GHDeploymentBuilder {
|
|||||||
*
|
*
|
||||||
* @param branch
|
* @param branch
|
||||||
* the branch
|
* the branch
|
||||||
|
*
|
||||||
* @return the gh deployment builder
|
* @return the gh deployment builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder ref(String branch) {
|
public GHDeploymentBuilder ref(String branch) {
|
||||||
@@ -52,6 +58,7 @@ public class GHDeploymentBuilder {
|
|||||||
*
|
*
|
||||||
* @param task
|
* @param task
|
||||||
* the task
|
* the task
|
||||||
|
*
|
||||||
* @return the gh deployment builder
|
* @return the gh deployment builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder task(String task) {
|
public GHDeploymentBuilder task(String task) {
|
||||||
@@ -64,6 +71,7 @@ public class GHDeploymentBuilder {
|
|||||||
*
|
*
|
||||||
* @param autoMerge
|
* @param autoMerge
|
||||||
* the auto merge
|
* the auto merge
|
||||||
|
*
|
||||||
* @return the gh deployment builder
|
* @return the gh deployment builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder autoMerge(boolean autoMerge) {
|
public GHDeploymentBuilder autoMerge(boolean autoMerge) {
|
||||||
@@ -76,6 +84,7 @@ public class GHDeploymentBuilder {
|
|||||||
*
|
*
|
||||||
* @param requiredContexts
|
* @param requiredContexts
|
||||||
* the required contexts
|
* the required contexts
|
||||||
|
*
|
||||||
* @return the gh deployment builder
|
* @return the gh deployment builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder requiredContexts(List<String> requiredContexts) {
|
public GHDeploymentBuilder requiredContexts(List<String> requiredContexts) {
|
||||||
@@ -88,6 +97,7 @@ public class GHDeploymentBuilder {
|
|||||||
*
|
*
|
||||||
* @param payload
|
* @param payload
|
||||||
* the payload
|
* the payload
|
||||||
|
*
|
||||||
* @return the gh deployment builder
|
* @return the gh deployment builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder payload(String payload) {
|
public GHDeploymentBuilder payload(String payload) {
|
||||||
@@ -100,6 +110,7 @@ public class GHDeploymentBuilder {
|
|||||||
*
|
*
|
||||||
* @param environment
|
* @param environment
|
||||||
* the environment
|
* the environment
|
||||||
|
*
|
||||||
* @return the gh deployment builder
|
* @return the gh deployment builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder environment(String environment) {
|
public GHDeploymentBuilder environment(String environment) {
|
||||||
@@ -107,11 +118,47 @@ public class GHDeploymentBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
|
||||||
|
* future.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @param transientEnvironment
|
||||||
|
* the environment is transient
|
||||||
|
*
|
||||||
|
* @return the gh deployment builder
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public GHDeploymentBuilder transientEnvironment(boolean transientEnvironment) {
|
||||||
|
builder.with("transient_environment", transientEnvironment);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if the given environment is one that end-users directly interact with.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @param productionEnvironment
|
||||||
|
* the environment is used by end-users directly
|
||||||
|
*
|
||||||
|
* @return the gh deployment builder
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public GHDeploymentBuilder productionEnvironment(boolean productionEnvironment) {
|
||||||
|
builder.with("production_environment", productionEnvironment);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description gh deployment builder.
|
* Description gh deployment builder.
|
||||||
*
|
*
|
||||||
* @param description
|
* @param description
|
||||||
* the description
|
* the description
|
||||||
|
*
|
||||||
* @return the gh deployment builder
|
* @return the gh deployment builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentBuilder description(String description) {
|
public GHDeploymentBuilder description(String description) {
|
||||||
@@ -123,10 +170,11 @@ public class GHDeploymentBuilder {
|
|||||||
* Create gh deployment.
|
* Create gh deployment.
|
||||||
*
|
*
|
||||||
* @return the gh deployment
|
* @return the gh deployment
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHDeployment create() throws IOException {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,40 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of deployment
|
* Represents the state of deployment
|
||||||
*/
|
*/
|
||||||
public enum GHDeploymentState {
|
public enum GHDeploymentState {
|
||||||
PENDING, SUCCESS, ERROR, FAILURE
|
PENDING,
|
||||||
|
SUCCESS,
|
||||||
|
ERROR,
|
||||||
|
FAILURE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of the deployment currently reflects it's in progress.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.FLASH)
|
||||||
|
IN_PROGRESS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of the deployment currently reflects it's queued up for processing.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.FLASH)
|
||||||
|
QUEUED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of the deployment currently reflects it's no longer active.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
INACTIVE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -8,19 +10,21 @@ import java.util.Locale;
|
|||||||
*/
|
*/
|
||||||
public class GHDeploymentStatus extends GHObject {
|
public class GHDeploymentStatus extends GHObject {
|
||||||
private GHRepository owner;
|
private GHRepository owner;
|
||||||
private GitHub root;
|
|
||||||
protected GHUser creator;
|
protected GHUser creator;
|
||||||
protected String state;
|
protected String state;
|
||||||
protected String description;
|
protected String description;
|
||||||
protected String target_url;
|
protected String target_url;
|
||||||
|
protected String log_url;
|
||||||
protected String deployment_url;
|
protected String deployment_url;
|
||||||
protected String repository_url;
|
protected String repository_url;
|
||||||
|
protected String environment_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap gh deployment status.
|
* Wrap gh deployment status.
|
||||||
*
|
*
|
||||||
* @param owner
|
* @param owner
|
||||||
* the owner
|
* the owner
|
||||||
|
*
|
||||||
* @return the gh deployment status
|
* @return the gh deployment status
|
||||||
*/
|
*/
|
||||||
public GHDeploymentStatus wrap(GHRepository owner) {
|
public GHDeploymentStatus wrap(GHRepository owner) {
|
||||||
@@ -34,10 +38,28 @@ public class GHDeploymentStatus extends GHObject {
|
|||||||
/**
|
/**
|
||||||
* Gets target url.
|
* Gets target url.
|
||||||
*
|
*
|
||||||
|
* @deprecated Target url is deprecated in favor of {@link #getLogUrl() getLogUrl}
|
||||||
|
*
|
||||||
* @return the target url
|
* @return the target url
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public URL getTargetUrl() {
|
public URL getTargetUrl() {
|
||||||
return GitHub.parseURL(target_url);
|
return GitHubClient.parseURL(target_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets target url.
|
||||||
|
* <p>
|
||||||
|
* This method replaces {@link #getTargetUrl() getTargetUrl}}.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @return the target url
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public URL getLogUrl() {
|
||||||
|
return GitHubClient.parseURL(log_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +68,20 @@ public class GHDeploymentStatus extends GHObject {
|
|||||||
* @return the deployment url
|
* @return the deployment url
|
||||||
*/
|
*/
|
||||||
public URL getDeploymentUrl() {
|
public URL getDeploymentUrl() {
|
||||||
return GitHub.parseURL(deployment_url);
|
return GitHubClient.parseURL(deployment_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets deployment environment url.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @return the deployment environment url
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public URL getEnvironmentUrl() {
|
||||||
|
return GitHubClient.parseURL(environment_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +90,7 @@ public class GHDeploymentStatus extends GHObject {
|
|||||||
* @return the repository url
|
* @return the repository url
|
||||||
*/
|
*/
|
||||||
public URL getRepositoryUrl() {
|
public URL getRepositoryUrl() {
|
||||||
return GitHub.parseURL(repository_url);
|
return GitHubClient.parseURL(repository_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,8 +23,10 @@ public class GHDeploymentStatusBuilder {
|
|||||||
* the deployment id
|
* the deployment id
|
||||||
* @param state
|
* @param state
|
||||||
* the state
|
* the state
|
||||||
|
*
|
||||||
* @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)}
|
* @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
|
public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
|
||||||
this(repo, (long) deploymentId, state);
|
this(repo, (long) deploymentId, state);
|
||||||
}
|
}
|
||||||
@@ -30,15 +34,38 @@ public class GHDeploymentStatusBuilder {
|
|||||||
GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
|
GHDeploymentStatusBuilder(GHRepository repo, long deploymentId, GHDeploymentState state) {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.deploymentId = deploymentId;
|
this.deploymentId = deploymentId;
|
||||||
this.builder = new Requester(repo.root);
|
this.builder = repo.root.createRequest()
|
||||||
|
.withPreview(Previews.ANT_MAN)
|
||||||
|
.withPreview(Previews.FLASH)
|
||||||
|
.method("POST");
|
||||||
|
|
||||||
this.builder.with("state", state);
|
this.builder.with("state", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an inactive status to all prior non-transient, non-production environment deployments with the same
|
||||||
|
* repository and environment name as the created status's deployment.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @param autoInactive
|
||||||
|
* Add inactive status flag
|
||||||
|
*
|
||||||
|
* @return the gh deployment status builder
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview({ Previews.ANT_MAN, Previews.FLASH })
|
||||||
|
public GHDeploymentStatusBuilder autoInactive(boolean autoInactive) {
|
||||||
|
this.builder.with("auto_inactive", autoInactive);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description gh deployment status builder.
|
* Description gh deployment status builder.
|
||||||
*
|
*
|
||||||
* @param description
|
* @param description
|
||||||
* the description
|
* the description
|
||||||
|
*
|
||||||
* @return the gh deployment status builder
|
* @return the gh deployment status builder
|
||||||
*/
|
*/
|
||||||
public GHDeploymentStatusBuilder description(String description) {
|
public GHDeploymentStatusBuilder description(String description) {
|
||||||
@@ -46,13 +73,70 @@ public class GHDeploymentStatusBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name for the target deployment environment, which can be changed when setting a deploy status.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @param environment
|
||||||
|
* the environment name
|
||||||
|
*
|
||||||
|
* @return the gh deployment status builder
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.FLASH)
|
||||||
|
public GHDeploymentStatusBuilder environment(String environment) {
|
||||||
|
this.builder.with("environment", environment);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL for accessing the environment
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @param environmentUrl
|
||||||
|
* the environment url
|
||||||
|
*
|
||||||
|
* @return the gh deployment status builder
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public GHDeploymentStatusBuilder environmentUrl(String environmentUrl) {
|
||||||
|
this.builder.with("environment_url", environmentUrl);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full URL of the deployment's output.
|
||||||
|
* <p>
|
||||||
|
* This method replaces {@link #targetUrl(String) targetUrl}.
|
||||||
|
*
|
||||||
|
* @deprecated until preview feature has graduated to stable
|
||||||
|
*
|
||||||
|
* @param logUrl
|
||||||
|
* the deployment output url
|
||||||
|
*
|
||||||
|
* @return the gh deployment status builder
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Preview(Previews.ANT_MAN)
|
||||||
|
public GHDeploymentStatusBuilder logUrl(String logUrl) {
|
||||||
|
this.builder.with("log_url", logUrl);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target url gh deployment status builder.
|
* Target url gh deployment status builder.
|
||||||
*
|
*
|
||||||
|
* @deprecated Target url is deprecated in favor of {@link #logUrl(String) logUrl}
|
||||||
|
*
|
||||||
* @param targetUrl
|
* @param targetUrl
|
||||||
* the target url
|
* the target url
|
||||||
|
*
|
||||||
* @return the gh deployment status builder
|
* @return the gh deployment status builder
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public GHDeploymentStatusBuilder targetUrl(String targetUrl) {
|
public GHDeploymentStatusBuilder targetUrl(String targetUrl) {
|
||||||
this.builder.with("target_url", targetUrl);
|
this.builder.with("target_url", targetUrl);
|
||||||
return this;
|
return this;
|
||||||
@@ -62,11 +146,13 @@ public class GHDeploymentStatusBuilder {
|
|||||||
* Create gh deployment status.
|
* Create gh deployment status.
|
||||||
*
|
*
|
||||||
* @return the gh deployment status
|
* @return the gh deployment status
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHDeploymentStatus create() throws IOException {
|
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);
|
.wrap(repo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
230
src/main/java/org/kohsuke/github/GHDiscussion.java
Normal file
230
src/main/java/org/kohsuke/github/GHDiscussion.java
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.kohsuke.github.internal.Previews;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.annotation.CheckForNull;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A discussion in GitHub Team.
|
||||||
|
*
|
||||||
|
* @author Charles Moulliard
|
||||||
|
* @see <a href="https://developer.github.com/v3/teams/discussions">GitHub Team Discussions</a>
|
||||||
|
*/
|
||||||
|
public class GHDiscussion extends GHObject {
|
||||||
|
|
||||||
|
private GHTeam team;
|
||||||
|
private long number;
|
||||||
|
private String body, title, htmlUrl;
|
||||||
|
|
||||||
|
@JsonProperty(value = "private")
|
||||||
|
private boolean isPrivate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URL getHtmlUrl() throws IOException {
|
||||||
|
return GitHubClient.parseURL(htmlUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
GHDiscussion wrapUp(GHTeam team) {
|
||||||
|
this.team = team;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the team to which this discussion belongs.
|
||||||
|
*
|
||||||
|
* @return the team for this discussion
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public GHTeam getTeam() {
|
||||||
|
return team;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the title of the discussion.
|
||||||
|
*
|
||||||
|
* @return the title
|
||||||
|
*/
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of this discussion.
|
||||||
|
*
|
||||||
|
* @return the body
|
||||||
|
*/
|
||||||
|
public String getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of this discussion.
|
||||||
|
*
|
||||||
|
* @return the number
|
||||||
|
*/
|
||||||
|
public long getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id number of this discussion. GitHub discussions have "number" instead of "id". This is provided for
|
||||||
|
* convenience.
|
||||||
|
*
|
||||||
|
* @return the id number for this discussion
|
||||||
|
* @see #getNumber()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
return getNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the discussion is private to the team.
|
||||||
|
*
|
||||||
|
* @return {@code true} if discussion is private.
|
||||||
|
*/
|
||||||
|
public boolean isPrivate() {
|
||||||
|
return isPrivate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begins the creation of a new instance.
|
||||||
|
*
|
||||||
|
* Consumer must call {@link GHDiscussion.Creator#done()} to commit changes.
|
||||||
|
*
|
||||||
|
* @param team
|
||||||
|
* the team in which the discussion will be created.
|
||||||
|
* @return a {@link GHLabel.Creator}
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
static GHDiscussion.Creator create(GHTeam team) throws IOException {
|
||||||
|
return new GHDiscussion.Creator(team);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GHDiscussion read(GHTeam team, long discussionNumber) throws IOException {
|
||||||
|
return team.root.createRequest()
|
||||||
|
.setRawUrlPath(getRawUrlPath(team, discussionNumber))
|
||||||
|
.fetch(GHDiscussion.class)
|
||||||
|
.wrapUp(team);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PagedIterable<GHDiscussion> readAll(GHTeam team) throws IOException {
|
||||||
|
return team.root.createRequest()
|
||||||
|
.setRawUrlPath(getRawUrlPath(team, null))
|
||||||
|
.toIterable(GHDiscussion[].class, item -> item.wrapUp(team));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begins a batch update
|
||||||
|
*
|
||||||
|
* Consumer must call {@link GHDiscussion.Updater#done()} to commit changes.
|
||||||
|
*
|
||||||
|
* @return a {@link GHDiscussion.Updater}
|
||||||
|
*/
|
||||||
|
@Preview(Previews.SQUIRREL_GIRL)
|
||||||
|
@Deprecated
|
||||||
|
public GHDiscussion.Updater update() {
|
||||||
|
return new GHDiscussion.Updater(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begins a single property update.
|
||||||
|
*
|
||||||
|
* @return a {@link GHDiscussion.Setter}
|
||||||
|
*/
|
||||||
|
@Preview(Previews.SQUIRREL_GIRL)
|
||||||
|
@Deprecated
|
||||||
|
public GHDiscussion.Setter set() {
|
||||||
|
return new GHDiscussion.Setter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the discussion
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
public void delete() throws IOException {
|
||||||
|
team.root.createRequest().method("DELETE").setRawUrlPath(getRawUrlPath(team, number)).send();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getRawUrlPath(@Nonnull GHTeam team, @CheckForNull Long discussionNumber) {
|
||||||
|
return team.getUrl().toString() + "/discussions" + (discussionNumber == null ? "" : "/" + discussionNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GHLabelBuilder} that updates a single property per request
|
||||||
|
*
|
||||||
|
* {@link #done()} is called automatically after the property is set.
|
||||||
|
*/
|
||||||
|
public static class Setter extends GHDiscussionBuilder<GHDiscussion> {
|
||||||
|
private Setter(@Nonnull GHDiscussion base) {
|
||||||
|
super(GHDiscussion.class, base.team, base);
|
||||||
|
requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GHLabelBuilder} that allows multiple properties to be updated per request.
|
||||||
|
*
|
||||||
|
* Consumer must call {@link #done()} to commit changes.
|
||||||
|
*/
|
||||||
|
public static class Updater extends GHDiscussionBuilder<Updater> {
|
||||||
|
private Updater(@Nonnull GHDiscussion base) {
|
||||||
|
super(GHDiscussion.Updater.class, base.team, base);
|
||||||
|
requester.method("PATCH").setRawUrlPath(base.getUrl().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GHLabelBuilder} that creates a new {@link GHLabel}
|
||||||
|
*
|
||||||
|
* Consumer must call {@link #done()} to create the new instance.
|
||||||
|
*/
|
||||||
|
public static class Creator extends GHDiscussionBuilder<Creator> {
|
||||||
|
|
||||||
|
private Creator(@Nonnull GHTeam team) {
|
||||||
|
super(GHDiscussion.Creator.class, team, null);
|
||||||
|
requester.method("POST").setRawUrlPath(getRawUrlPath(team, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether this discussion is private to this team.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* privacy of this discussion
|
||||||
|
* @return either a continuing builder or an updated {@link GHDiscussion}
|
||||||
|
* @throws IOException
|
||||||
|
* if there is an I/O Exception
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public Creator private_(boolean value) throws IOException {
|
||||||
|
return with("private", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GHDiscussion that = (GHDiscussion) o;
|
||||||
|
return number == that.number && Objects.equals(getUrl(), that.getUrl()) && Objects.equals(team, that.team)
|
||||||
|
&& Objects.equals(body, that.body) && Objects.equals(title, that.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(team, number, body, title);
|
||||||
|
}
|
||||||
|
}
|
||||||
80
src/main/java/org/kohsuke/github/GHDiscussionBuilder.java
Normal file
80
src/main/java/org/kohsuke/github/GHDiscussionBuilder.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.annotation.CheckForNull;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for creating or updating a discussion.
|
||||||
|
*
|
||||||
|
* @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 GHDiscussionBuilder<S> extends AbstractBuilder<GHDiscussion, S> {
|
||||||
|
|
||||||
|
private final GHTeam team;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param intermediateReturnType
|
||||||
|
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If
|
||||||
|
* {@link S} the same as {@link GHDiscussion}, this builder will commit changes after each call to
|
||||||
|
* {@link #with(String, Object)}.
|
||||||
|
* @param team
|
||||||
|
* the GitHub team. Updates will be sent to the root of this team.
|
||||||
|
* @param baseInstance
|
||||||
|
* instance on which to base this builder. If {@code null} a new instance will be created.
|
||||||
|
*/
|
||||||
|
protected GHDiscussionBuilder(@Nonnull Class<S> intermediateReturnType,
|
||||||
|
@Nonnull GHTeam team,
|
||||||
|
@CheckForNull GHDiscussion baseInstance) {
|
||||||
|
super(GHDiscussion.class, intermediateReturnType, team.root, baseInstance);
|
||||||
|
|
||||||
|
this.team = team;
|
||||||
|
|
||||||
|
if (baseInstance != null) {
|
||||||
|
requester.with("title", baseInstance.getTitle());
|
||||||
|
requester.with("body", baseInstance.getBody());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for this discussion.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* title of discussion
|
||||||
|
* @return either a continuing builder or an updated {@link GHDiscussion}
|
||||||
|
* @throws IOException
|
||||||
|
* if there is an I/O Exception
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public S title(String value) throws IOException {
|
||||||
|
return with("title", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Body content for this discussion.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* body of discussion*
|
||||||
|
* @return either a continuing builder or an updated {@link GHDiscussion}
|
||||||
|
* @throws IOException
|
||||||
|
* if there is an I/O Exception
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public S body(String value) throws IOException {
|
||||||
|
return with("body", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public GHDiscussion done() throws IOException {
|
||||||
|
return super.done().wrapUp(team);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,50 +10,70 @@ import java.util.Locale;
|
|||||||
* @see <a href="https://developer.github.com/v3/activity/events/types/">Event type reference</a>
|
* @see <a href="https://developer.github.com/v3/activity/events/types/">Event type reference</a>
|
||||||
*/
|
*/
|
||||||
public enum GHEvent {
|
public enum GHEvent {
|
||||||
|
CHECK_RUN,
|
||||||
|
CHECK_SUITE,
|
||||||
|
CODE_SCANNING_ALERT,
|
||||||
COMMIT_COMMENT,
|
COMMIT_COMMENT,
|
||||||
|
CONTENT_REFERENCE,
|
||||||
CREATE,
|
CREATE,
|
||||||
DELETE,
|
DELETE,
|
||||||
|
DEPLOY_KEY,
|
||||||
DEPLOYMENT,
|
DEPLOYMENT,
|
||||||
DEPLOYMENT_STATUS,
|
DEPLOYMENT_STATUS,
|
||||||
|
DISCUSSION,
|
||||||
|
DISCUSSION_COMMENT,
|
||||||
DOWNLOAD,
|
DOWNLOAD,
|
||||||
FOLLOW,
|
FOLLOW,
|
||||||
FORK,
|
FORK,
|
||||||
FORK_APPLY,
|
FORK_APPLY,
|
||||||
|
GITHUB_APP_AUTHORIZATION,
|
||||||
GIST,
|
GIST,
|
||||||
GOLLUM,
|
GOLLUM,
|
||||||
INSTALLATION,
|
INSTALLATION,
|
||||||
INSTALLATION_REPOSITORIES,
|
INSTALLATION_REPOSITORIES,
|
||||||
INTEGRATION_INSTALLATION_REPOSITORIES,
|
INTEGRATION_INSTALLATION_REPOSITORIES,
|
||||||
CHECK_SUITE,
|
|
||||||
ISSUE_COMMENT,
|
ISSUE_COMMENT,
|
||||||
ISSUES,
|
ISSUES,
|
||||||
LABEL,
|
LABEL,
|
||||||
MARKETPLACE_PURCHASE,
|
MARKETPLACE_PURCHASE,
|
||||||
MEMBER,
|
MEMBER,
|
||||||
MEMBERSHIP,
|
MEMBERSHIP,
|
||||||
|
META,
|
||||||
MILESTONE,
|
MILESTONE,
|
||||||
ORGANIZATION,
|
ORGANIZATION,
|
||||||
ORG_BLOCK,
|
ORG_BLOCK,
|
||||||
|
PACKAGE,
|
||||||
PAGE_BUILD,
|
PAGE_BUILD,
|
||||||
PROJECT_CARD,
|
PROJECT_CARD,
|
||||||
PROJECT_COLUMN,
|
PROJECT_COLUMN,
|
||||||
PROJECT,
|
PROJECT,
|
||||||
|
PING,
|
||||||
PUBLIC,
|
PUBLIC,
|
||||||
PULL_REQUEST,
|
PULL_REQUEST,
|
||||||
PULL_REQUEST_REVIEW,
|
PULL_REQUEST_REVIEW,
|
||||||
PULL_REQUEST_REVIEW_COMMENT,
|
PULL_REQUEST_REVIEW_COMMENT,
|
||||||
PUSH,
|
PUSH,
|
||||||
|
REGISTRY_PACKAGE,
|
||||||
RELEASE,
|
RELEASE,
|
||||||
REPOSITORY, // only
|
REPOSITORY_DISPATCH, // only valid for org hooks
|
||||||
// valid
|
REPOSITORY,
|
||||||
// for
|
REPOSITORY_IMPORT,
|
||||||
// org
|
REPOSITORY_VULNERABILITY_ALERT,
|
||||||
// hooks
|
SCHEDULE,
|
||||||
|
SECURITY_ADVISORY,
|
||||||
|
STAR,
|
||||||
STATUS,
|
STATUS,
|
||||||
TEAM,
|
TEAM,
|
||||||
TEAM_ADD,
|
TEAM_ADD,
|
||||||
WATCH,
|
WATCH,
|
||||||
PING,
|
WORKFLOW_DISPATCH,
|
||||||
|
WORKFLOW_RUN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special event type that means we haven't found an enum value corresponding to the event.
|
||||||
|
*/
|
||||||
|
UNKNOWN,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special event type that means "every possible event"
|
* Special event type that means "every possible event"
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an event.
|
* Represents an event.
|
||||||
@@ -12,14 +12,22 @@ import java.util.Date;
|
|||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
||||||
public class GHEventInfo {
|
public class GHEventInfo extends GitHubInteractiveObject {
|
||||||
private GitHub root;
|
|
||||||
|
|
||||||
// we don't want to expose Jackson dependency to the user. This needs databinding
|
// we don't want to expose Jackson dependency to the user. This needs databinding
|
||||||
private ObjectNode payload;
|
private ObjectNode payload;
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String created_at;
|
private String created_at;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of GitHub Event API Event Type.
|
||||||
|
*
|
||||||
|
* This is not the same as the values used for hook methods such as
|
||||||
|
* {@link GHRepository#createHook(String, Map, Collection, boolean)}.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.github.com/en/developers/webhooks-and-events/github-event-types">GitHub event
|
||||||
|
* types</a>
|
||||||
|
*/
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
// these are all shallow objects
|
// these are all shallow objects
|
||||||
@@ -42,20 +50,45 @@ public class GHEventInfo {
|
|||||||
private String name; // owner/repo
|
private String name; // owner/repo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final Map<String, GHEvent> mapTypeStringToEvent = createEventMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map for GitHub Event API Event Type to GHEvent.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.github.com/en/developers/webhooks-and-events/github-event-types">GitHub event
|
||||||
|
* types</a>
|
||||||
|
*/
|
||||||
|
private static Map<String, GHEvent> createEventMap() {
|
||||||
|
HashMap<String, GHEvent> map = new HashMap<>();
|
||||||
|
map.put("CommitCommentEvent", GHEvent.COMMIT_COMMENT);
|
||||||
|
map.put("CreateEvent", GHEvent.CREATE);
|
||||||
|
map.put("DeleteEvent", GHEvent.DELETE);
|
||||||
|
map.put("ForkEvent", GHEvent.FORK);
|
||||||
|
map.put("GollumEvent", GHEvent.GOLLUM);
|
||||||
|
map.put("IssueCommentEvent", GHEvent.ISSUE_COMMENT);
|
||||||
|
map.put("IssuesEvent", GHEvent.ISSUES);
|
||||||
|
map.put("MemberEvent", GHEvent.MEMBER);
|
||||||
|
map.put("PublicEvent", GHEvent.PUBLIC);
|
||||||
|
map.put("PullRequestEvent", GHEvent.PULL_REQUEST);
|
||||||
|
map.put("PullRequestReviewEvent", GHEvent.PULL_REQUEST_REVIEW);
|
||||||
|
map.put("PullRequestReviewCommentEvent", GHEvent.PULL_REQUEST_REVIEW_COMMENT);
|
||||||
|
map.put("PushEvent", GHEvent.PUSH);
|
||||||
|
map.put("ReleaseEvent", GHEvent.RELEASE);
|
||||||
|
map.put("WatchEvent", GHEvent.WATCH);
|
||||||
|
return Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GHEvent transformTypeToGHEvent(String type) {
|
||||||
|
return mapTypeStringToEvent.getOrDefault(type, GHEvent.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets type.
|
* Gets type.
|
||||||
*
|
*
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
public GHEvent getType() {
|
public GHEvent getType() {
|
||||||
String t = type;
|
return transformTypeToGHEvent(type);
|
||||||
if (t.endsWith("Event"))
|
|
||||||
t = t.substring(0, t.length() - 5);
|
|
||||||
for (GHEvent e : GHEvent.values()) {
|
|
||||||
if (e.name().replace("_", "").equalsIgnoreCase(t))
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
return null; // unknown event type
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GHEventInfo wrapUp(GitHub root) {
|
GHEventInfo wrapUp(GitHub root) {
|
||||||
@@ -78,7 +111,7 @@ public class GHEventInfo {
|
|||||||
* @return the created at
|
* @return the created at
|
||||||
*/
|
*/
|
||||||
public Date getCreatedAt() {
|
public Date getCreatedAt() {
|
||||||
return GitHub.parseDate(created_at);
|
return GitHubClient.parseDate(created_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,7 +177,7 @@ public class GHEventInfo {
|
|||||||
* if payload cannot be parsed
|
* if payload cannot be parsed
|
||||||
*/
|
*/
|
||||||
public <T extends GHEventPayload> T getPayload(Class<T> type) throws IOException {
|
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);
|
v.wrapUp(root);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,11 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.CheckForNull;
|
import javax.annotation.CheckForNull;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
|
* 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.
|
* Instantiates a new Gh file not found exception.
|
||||||
*
|
*
|
||||||
* @param s
|
* @param message
|
||||||
* the s
|
* the message
|
||||||
*/
|
*/
|
||||||
public GHFileNotFoundException(String s) {
|
public GHFileNotFoundException(String message) {
|
||||||
super(s);
|
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;
|
return responseHeaderFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHFileNotFoundException withResponseHeaderFields(HttpURLConnection urlConnection) {
|
GHFileNotFoundException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
|
||||||
this.responseHeaderFields = urlConnection.getHeaderFields();
|
this.responseHeaderFields = headerFields;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
@@ -20,8 +21,8 @@ import java.util.Map.Entry;
|
|||||||
* @see <a href="https://developer.github.com/v3/gists/">documentation</a>
|
* @see <a href="https://developer.github.com/v3/gists/">documentation</a>
|
||||||
*/
|
*/
|
||||||
public class GHGist extends GHObject {
|
public class GHGist extends GHObject {
|
||||||
/* package almost final */ GHUser owner;
|
|
||||||
/* package almost final */ GitHub root;
|
final GHUser owner;
|
||||||
|
|
||||||
private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url;
|
private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url;
|
||||||
|
|
||||||
@@ -34,7 +35,43 @@ public class GHGist extends GHObject {
|
|||||||
|
|
||||||
private String comments_url;
|
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.
|
* Gets owner.
|
||||||
@@ -44,7 +81,7 @@ public class GHGist extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHUser getOwner() throws IOException {
|
public GHUser getOwner() throws IOException {
|
||||||
return root.intern(owner);
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,8 +120,13 @@ public class GHGist extends GHObject {
|
|||||||
return git_push_url;
|
return git_push_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the html url.
|
||||||
|
*
|
||||||
|
* @return the github html url
|
||||||
|
*/
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,31 +182,7 @@ public class GHGist extends GHObject {
|
|||||||
* @return the files
|
* @return the files
|
||||||
*/
|
*/
|
||||||
public Map<String, GHGistFile> getFiles() {
|
public Map<String, GHGistFile> getFiles() {
|
||||||
return Collections.unmodifiableMap(files);
|
return 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getApiTailUrl(String tail) {
|
String getApiTailUrl(String tail) {
|
||||||
@@ -182,7 +200,7 @@ public class GHGist extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void star() throws IOException {
|
public void star() throws IOException {
|
||||||
new Requester(root).method("PUT").to(getApiTailUrl("star"));
|
root.createRequest().method("PUT").withUrlPath(getApiTailUrl("star")).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,7 +210,7 @@ public class GHGist extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void unstar() throws IOException {
|
public void unstar() throws IOException {
|
||||||
new Requester(root).method("DELETE").to(getApiTailUrl("star"));
|
root.createRequest().method("DELETE").withUrlPath(getApiTailUrl("star")).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,7 +221,7 @@ public class GHGist extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public boolean isStarred() throws IOException {
|
public boolean isStarred() throws IOException {
|
||||||
return root.retrieve().asHttpStatusCode(getApiTailUrl("star")) / 100 == 2;
|
return root.createRequest().withUrlPath(getApiTailUrl("star")).fetchHttpStatusCode() / 100 == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +232,7 @@ public class GHGist extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHGist fork() throws IOException {
|
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 +241,7 @@ public class GHGist extends GHObject {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHGist> listForks() {
|
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 +251,7 @@ public class GHGist extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(root).method("DELETE").to("/gists/" + id);
|
root.createRequest().method("DELETE").withUrlPath("/gists/" + id).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,10 +280,4 @@ public class GHGist extends GHObject {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return id.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.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder pattern for creating a new Gist.
|
* Builder pattern for creating a new Gist.
|
||||||
*
|
*
|
||||||
@@ -11,7 +13,6 @@ import java.util.LinkedHashMap;
|
|||||||
* @see GitHub#createGist() GitHub#createGist()
|
* @see GitHub#createGist() GitHub#createGist()
|
||||||
*/
|
*/
|
||||||
public class GHGistBuilder {
|
public class GHGistBuilder {
|
||||||
private final GitHub root;
|
|
||||||
private final Requester req;
|
private final Requester req;
|
||||||
private final LinkedHashMap<String, Object> files = new LinkedHashMap<String, Object>();
|
private final LinkedHashMap<String, Object> files = new LinkedHashMap<String, Object>();
|
||||||
|
|
||||||
@@ -22,8 +23,7 @@ public class GHGistBuilder {
|
|||||||
* the root
|
* the root
|
||||||
*/
|
*/
|
||||||
public GHGistBuilder(GitHub root) {
|
public GHGistBuilder(GitHub root) {
|
||||||
this.root = root;
|
req = root.createRequest().method("POST");
|
||||||
req = new Requester(root);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +59,7 @@ public class GHGistBuilder {
|
|||||||
* the content
|
* the content
|
||||||
* @return Adds a new file.
|
* @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));
|
files.put(fileName, Collections.singletonMap("content", content));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -73,6 +73,6 @@ public class GHGistBuilder {
|
|||||||
*/
|
*/
|
||||||
public GHGist create() throws IOException {
|
public GHGist create() throws IOException {
|
||||||
req.with("files", files);
|
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;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder pattern for updating a Gist.
|
* Builder pattern for updating a Gist.
|
||||||
@@ -12,11 +15,11 @@ import java.util.LinkedHashMap;
|
|||||||
public class GHGistUpdater {
|
public class GHGistUpdater {
|
||||||
private final GHGist base;
|
private final GHGist base;
|
||||||
private final Requester builder;
|
private final Requester builder;
|
||||||
LinkedHashMap<String, Object> files;
|
LinkedHashMap<String, Map<String, String>> files;
|
||||||
|
|
||||||
GHGistUpdater(GHGist base) {
|
GHGistUpdater(GHGist base) {
|
||||||
this.base = base;
|
this.base = base;
|
||||||
this.builder = new Requester(base.root);
|
this.builder = base.root.createRequest();
|
||||||
|
|
||||||
files = new LinkedHashMap<>();
|
files = new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
@@ -32,16 +35,15 @@ public class GHGistUpdater {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* 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);
|
updateFile(fileName, content);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // This method does not work.
|
public GHGistUpdater deleteFile(@Nonnull String fileName) throws IOException {
|
||||||
// public GHGistUpdater deleteFile(String fileName) throws IOException {
|
files.put(fileName, null);
|
||||||
// files.put(fileName, Collections.singletonMap("filename", null));
|
return this;
|
||||||
// return this;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename file gh gist updater.
|
* Rename file gh gist updater.
|
||||||
@@ -54,8 +56,9 @@ public class GHGistUpdater {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHGistUpdater renameFile(String fileName, String newFileName) throws IOException {
|
public GHGistUpdater renameFile(@Nonnull String fileName, @Nonnull String newFileName) throws IOException {
|
||||||
files.put(fileName, Collections.singletonMap("filename", newFileName));
|
Map<String, String> file = files.computeIfAbsent(fileName, d -> new HashMap<>());
|
||||||
|
file.put("filename", newFileName);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +73,31 @@ public class GHGistUpdater {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHGistUpdater updateFile(String fileName, String content) throws IOException {
|
public GHGistUpdater updateFile(@Nonnull String fileName, @Nonnull String content) throws IOException {
|
||||||
files.put(fileName, Collections.singletonMap("content", content));
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +122,6 @@ public class GHGistUpdater {
|
|||||||
*/
|
*/
|
||||||
public GHGist update() throws IOException {
|
public GHGist update() throws IOException {
|
||||||
builder.with("files", files);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
import org.kohsuke.github.internal.EnumUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,10 +40,7 @@ public abstract class GHHook extends GHObject {
|
|||||||
public EnumSet<GHEvent> getEvents() {
|
public EnumSet<GHEvent> getEvents() {
|
||||||
EnumSet<GHEvent> s = EnumSet.noneOf(GHEvent.class);
|
EnumSet<GHEvent> s = EnumSet.noneOf(GHEvent.class);
|
||||||
for (String e : events) {
|
for (String e : events) {
|
||||||
if (e.equals("*"))
|
s.add(e.equals("*") ? GHEvent.ALL : EnumUtils.getEnumOrDefault(GHEvent.class, e, GHEvent.UNKNOWN));
|
||||||
s.add(GHEvent.ALL);
|
|
||||||
else
|
|
||||||
s.add(Enum.valueOf(GHEvent.class, e.toUpperCase(Locale.ENGLISH)));
|
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -74,7 +71,7 @@ public abstract class GHHook extends GHObject {
|
|||||||
* @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a>
|
* @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a>
|
||||||
*/
|
*/
|
||||||
public void ping() throws IOException {
|
public void ping() throws IOException {
|
||||||
new Requester(getRoot()).method("POST").to(getApiRoute() + "/pings");
|
getRoot().createRequest().method("POST").withUrlPath(getApiRoute() + "/pings").send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +81,7 @@ public abstract class GHHook extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(getRoot()).method("DELETE").to(getApiRoute());
|
getRoot().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ import java.util.Map;
|
|||||||
* functionality
|
* functionality
|
||||||
*/
|
*/
|
||||||
class GHHooks {
|
class GHHooks {
|
||||||
static abstract class Context {
|
static abstract class Context extends GitHubInteractiveObject {
|
||||||
private final GitHub root;
|
|
||||||
|
|
||||||
private Context(GitHub root) {
|
private Context(GitHub root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
@@ -28,8 +27,10 @@ class GHHooks {
|
|||||||
*/
|
*/
|
||||||
public List<GHHook> getHooks() throws IOException {
|
public List<GHHook> getHooks() throws IOException {
|
||||||
|
|
||||||
GHHook[] hookArray = root.retrieve().to(collection(), collectionClass()); // jdk/eclipse bug requires this
|
GHHook[] hookArray = root.createRequest().withUrlPath(collection()).fetch(collectionClass()); // jdk/eclipse
|
||||||
// to be on separate line
|
// bug
|
||||||
|
// requires this
|
||||||
|
// to be on separate line
|
||||||
List<GHHook> list = new ArrayList<GHHook>(Arrays.asList(hookArray));
|
List<GHHook> list = new ArrayList<GHHook>(Arrays.asList(hookArray));
|
||||||
for (GHHook h : list)
|
for (GHHook h : list)
|
||||||
wrap(h);
|
wrap(h);
|
||||||
@@ -46,7 +47,7 @@ class GHHooks {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHHook getHook(int id) throws IOException {
|
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);
|
return wrap(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,11 +75,14 @@ class GHHooks {
|
|||||||
ea.add(e.symbol());
|
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("active", active)
|
||||||
.with("config", config)
|
.with("config", config)
|
||||||
.with("events", ea)
|
.with("events", ea)
|
||||||
.to(collection(), clazz());
|
.withUrlPath(collection())
|
||||||
|
.fetch(clazz());
|
||||||
|
|
||||||
return wrap(hook);
|
return wrap(hook);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.CheckForNull;
|
import javax.annotation.CheckForNull;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
|
* Request/responce contains useful metadata. Custom exception allows store info for next diagnostics.
|
||||||
@@ -31,6 +31,20 @@ public class GHIOException extends IOException {
|
|||||||
super(message);
|
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.
|
* Gets response header fields.
|
||||||
*
|
*
|
||||||
@@ -41,8 +55,8 @@ public class GHIOException extends IOException {
|
|||||||
return responseHeaderFields;
|
return responseHeaderFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHIOException withResponseHeaderFields(HttpURLConnection urlConnection) {
|
GHIOException withResponseHeaderFields(@Nonnull Map<String, List<String>> headerFields) {
|
||||||
this.responseHeaderFields = urlConnection.getHeaderFields();
|
this.responseHeaderFields = headerFields;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import java.net.URL;
|
|||||||
"UUF_UNUSED_FIELD" },
|
"UUF_UNUSED_FIELD" },
|
||||||
justification = "JSON API")
|
justification = "JSON API")
|
||||||
public class GHInvitation extends GHObject {
|
public class GHInvitation extends GHObject {
|
||||||
/* package almost final */ GitHub root;
|
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private GHRepository repository;
|
private GHRepository repository;
|
||||||
@@ -36,7 +35,7 @@ public class GHInvitation extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void accept() throws IOException {
|
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 +45,11 @@ public class GHInvitation extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void decline() throws IOException {
|
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
|
@Override
|
||||||
public URL getHtmlUrl() {
|
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 com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -36,8 +37,9 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an issue on GitHub.
|
* Represents an issue on GitHub.
|
||||||
@@ -51,7 +53,6 @@ import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
|||||||
public class GHIssue extends GHObject implements Reactable {
|
public class GHIssue extends GHObject implements Reactable {
|
||||||
private static final String ASSIGNEES = "assignees";
|
private static final String ASSIGNEES = "assignees";
|
||||||
|
|
||||||
GitHub root;
|
|
||||||
GHRepository owner;
|
GHRepository owner;
|
||||||
|
|
||||||
// API v3
|
// API v3
|
||||||
@@ -63,8 +64,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
protected int comments;
|
protected int comments;
|
||||||
@SkipFromToString
|
@SkipFromToString
|
||||||
protected String body;
|
protected String body;
|
||||||
// for backward compatibility with < 1.63, this collection needs to hold instances of Label, not GHLabel
|
protected List<GHLabel> labels;
|
||||||
protected List<Label> labels;
|
|
||||||
protected GHUser user;
|
protected GHUser user;
|
||||||
protected String title, html_url;
|
protected String title, html_url;
|
||||||
protected GHIssue.PullRequest pull_request;
|
protected GHIssue.PullRequest pull_request;
|
||||||
@@ -72,14 +72,6 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
protected GHUser closed_by;
|
protected GHUser closed_by;
|
||||||
protected boolean locked;
|
protected boolean locked;
|
||||||
|
|
||||||
/**
|
|
||||||
* The type Label.
|
|
||||||
*
|
|
||||||
* @deprecated use {@link GHLabel}
|
|
||||||
*/
|
|
||||||
public static class Label extends GHLabel {
|
|
||||||
}
|
|
||||||
|
|
||||||
GHIssue wrap(GHRepository owner) {
|
GHIssue wrap(GHRepository owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
if (milestone != null)
|
if (milestone != null)
|
||||||
@@ -100,12 +92,6 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GHIssue[] wrap(GHIssue[] issues, GHRepository owner) {
|
|
||||||
for (GHIssue i : issues)
|
|
||||||
i.wrap(owner);
|
|
||||||
return issues;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository to which the issue belongs.
|
* Repository to which the issue belongs.
|
||||||
*
|
*
|
||||||
@@ -137,7 +123,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
|
* The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
|
||||||
*/
|
*/
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,14 +157,12 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* Gets labels.
|
* Gets labels.
|
||||||
*
|
*
|
||||||
* @return the labels
|
* @return the labels
|
||||||
* @throws IOException
|
|
||||||
* the io exception
|
|
||||||
*/
|
*/
|
||||||
public Collection<GHLabel> getLabels() throws IOException {
|
public Collection<GHLabel> getLabels() {
|
||||||
if (labels == null) {
|
if (labels == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return Collections.<GHLabel>unmodifiableList(labels);
|
return Collections.unmodifiableList(labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,16 +171,18 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* @return the closed at
|
* @return the closed at
|
||||||
*/
|
*/
|
||||||
public Date getClosedAt() {
|
public Date getClosedAt() {
|
||||||
return GitHub.parseDate(closed_at);
|
return GitHubClient.parseDate(closed_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets api url.
|
* Gets api url.
|
||||||
*
|
*
|
||||||
* @return the api url
|
* @return API URL of this object.
|
||||||
|
* @deprecated use {@link #getUrl()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public URL getApiURL() {
|
public URL getApiURL() {
|
||||||
return GitHub.parseURL(url);
|
return getUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +192,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void lock() throws IOException {
|
public void lock() throws IOException {
|
||||||
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
|
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -216,7 +202,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void unlock() throws IOException {
|
public void unlock() throws IOException {
|
||||||
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
|
root.createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,17 +216,27 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
*/
|
*/
|
||||||
@WithBridgeMethods(void.class)
|
@WithBridgeMethods(void.class)
|
||||||
public GHIssueComment comment(String message) throws IOException {
|
public GHIssueComment comment(String message) throws IOException {
|
||||||
GHIssueComment r = new Requester(root).with("body", message)
|
GHIssueComment r = root.createRequest()
|
||||||
.to(getIssuesApiRoute() + "/comments", GHIssueComment.class);
|
.method("POST")
|
||||||
|
.with("body", message)
|
||||||
|
.withUrlPath(getIssuesApiRoute() + "/comments")
|
||||||
|
.fetch(GHIssueComment.class);
|
||||||
return r.wrapUp(this);
|
return r.wrapUp(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void edit(String key, Object value) throws IOException {
|
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 {
|
private void editIssue(String key, Object value) throws IOException {
|
||||||
new Requester(root).with(key, value).method("PATCH").to(getIssuesApiRoute());
|
root.createRequest().withNullable(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -288,15 +284,19 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets milestone.
|
* Sets the milestone for this issue.
|
||||||
*
|
*
|
||||||
* @param milestone
|
* @param milestone
|
||||||
* the milestone
|
* The milestone to assign this issue to. Use null to remove the milestone for this issue.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* The io exception
|
||||||
*/
|
*/
|
||||||
public void setMilestone(GHMilestone milestone) throws IOException {
|
public void setMilestone(GHMilestone milestone) throws IOException {
|
||||||
edit("milestone", milestone.getNumber());
|
if (milestone == null) {
|
||||||
|
editIssue("milestone", null);
|
||||||
|
} else {
|
||||||
|
editIssue("milestone", milestone.getNumber());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -312,7 +312,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets labels.
|
* Sets labels on the target to a specific list.
|
||||||
*
|
*
|
||||||
* @param labels
|
* @param labels
|
||||||
* the labels
|
* the labels
|
||||||
@@ -326,100 +326,137 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
/**
|
/**
|
||||||
* Adds labels to the issue.
|
* Adds labels to the issue.
|
||||||
*
|
*
|
||||||
|
* Labels that are already present on the target are ignored.
|
||||||
|
*
|
||||||
|
* @return the complete list of labels including the new additions
|
||||||
* @param names
|
* @param names
|
||||||
* Names of the label
|
* Names of the label
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void addLabels(String... names) throws IOException {
|
@WithBridgeMethods(void.class)
|
||||||
_addLabels(Arrays.asList(names));
|
public List<GHLabel> addLabels(String... names) throws IOException {
|
||||||
|
return _addLabels(Arrays.asList(names));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add labels.
|
* Add labels.
|
||||||
*
|
*
|
||||||
|
* Labels that are already present on the target are ignored.
|
||||||
|
*
|
||||||
|
* @return the complete list of labels including the new additions
|
||||||
* @param labels
|
* @param labels
|
||||||
* the labels
|
* the labels
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void addLabels(GHLabel... labels) throws IOException {
|
@WithBridgeMethods(void.class)
|
||||||
addLabels(Arrays.asList(labels));
|
public List<GHLabel> addLabels(GHLabel... labels) throws IOException {
|
||||||
|
return addLabels(Arrays.asList(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add labels.
|
* Add labels.
|
||||||
*
|
*
|
||||||
|
* Labels that are already present on the target are ignored.
|
||||||
|
*
|
||||||
|
* @return the complete list of labels including the new additions
|
||||||
* @param labels
|
* @param labels
|
||||||
* the labels
|
* the labels
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void addLabels(Collection<GHLabel> labels) throws IOException {
|
@WithBridgeMethods(void.class)
|
||||||
_addLabels(GHLabel.toNames(labels));
|
public List<GHLabel> addLabels(Collection<GHLabel> labels) throws IOException {
|
||||||
|
return _addLabels(GHLabel.toNames(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _addLabels(Collection<String> names) throws IOException {
|
private List<GHLabel> _addLabels(Collection<String> names) throws IOException {
|
||||||
List<String> newLabels = new ArrayList<String>();
|
return Arrays.asList(root.createRequest()
|
||||||
|
.with("labels", names)
|
||||||
for (GHLabel label : getLabels()) {
|
.method("POST")
|
||||||
newLabels.add(label.getName());
|
.withUrlPath(getIssuesApiRoute() + "/labels")
|
||||||
}
|
.fetch(GHLabel[].class));
|
||||||
for (String name : names) {
|
|
||||||
if (!newLabels.contains(name)) {
|
|
||||||
newLabels.add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setLabels(newLabels.toArray(new String[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a given label by name from this issue.
|
* Remove a single label.
|
||||||
*
|
*
|
||||||
|
* Attempting to remove a label that is not present throws {@link GHFileNotFoundException}.
|
||||||
|
*
|
||||||
|
* @return the remaining list of labels
|
||||||
|
* @param name
|
||||||
|
* the name
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception, throws {@link GHFileNotFoundException} if label was not present.
|
||||||
|
*/
|
||||||
|
@WithBridgeMethods(void.class)
|
||||||
|
public List<GHLabel> removeLabel(String name) throws IOException {
|
||||||
|
return Arrays.asList(root.createRequest()
|
||||||
|
.method("DELETE")
|
||||||
|
.withUrlPath(getIssuesApiRoute() + "/labels", name)
|
||||||
|
.fetch(GHLabel[].class));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a collection of labels.
|
||||||
|
*
|
||||||
|
* Attempting to remove labels that are not present on the target are ignored.
|
||||||
|
*
|
||||||
|
* @return the remaining list of labels
|
||||||
* @param names
|
* @param names
|
||||||
* the names
|
* the names
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void removeLabels(String... names) throws IOException {
|
@WithBridgeMethods(void.class)
|
||||||
_removeLabels(Arrays.asList(names));
|
public List<GHLabel> removeLabels(String... names) throws IOException {
|
||||||
|
return _removeLabels(Arrays.asList(names));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove labels.
|
* Remove a collection of labels.
|
||||||
*
|
*
|
||||||
|
* Attempting to remove labels that are not present on the target are ignored.
|
||||||
|
*
|
||||||
|
* @return the remaining list of labels
|
||||||
* @param labels
|
* @param labels
|
||||||
* the labels
|
* the labels
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
* @see #removeLabels(String...) #removeLabels(String...)
|
* @see #removeLabels(String...) #removeLabels(String...)
|
||||||
*/
|
*/
|
||||||
public void removeLabels(GHLabel... labels) throws IOException {
|
@WithBridgeMethods(void.class)
|
||||||
removeLabels(Arrays.asList(labels));
|
public List<GHLabel> removeLabels(GHLabel... labels) throws IOException {
|
||||||
|
return removeLabels(Arrays.asList(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove labels.
|
* Remove a collection of labels.
|
||||||
*
|
*
|
||||||
|
* Attempting to remove labels that are not present on the target are ignored.
|
||||||
|
*
|
||||||
|
* @return the remaining list of labels
|
||||||
* @param labels
|
* @param labels
|
||||||
* the labels
|
* the labels
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void removeLabels(Collection<GHLabel> labels) throws IOException {
|
@WithBridgeMethods(void.class)
|
||||||
_removeLabels(GHLabel.toNames(labels));
|
public List<GHLabel> removeLabels(Collection<GHLabel> labels) throws IOException {
|
||||||
|
return _removeLabels(GHLabel.toNames(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _removeLabels(Collection<String> names) throws IOException {
|
private List<GHLabel> _removeLabels(Collection<String> names) throws IOException {
|
||||||
List<String> newLabels = new ArrayList<String>();
|
List<GHLabel> remainingLabels = Collections.emptyList();
|
||||||
|
for (String name : names) {
|
||||||
for (GHLabel l : getLabels()) {
|
try {
|
||||||
if (!names.contains(l.getName())) {
|
remainingLabels = removeLabel(name);
|
||||||
newLabels.add(l.getName());
|
} catch (GHFileNotFoundException e) {
|
||||||
|
// when trying to remove multiple labels, we ignore already removed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return remainingLabels;
|
||||||
setLabels(newLabels.toArray(new String[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -431,7 +468,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* @see #listComments() #listComments()
|
* @see #listComments() #listComments()
|
||||||
*/
|
*/
|
||||||
public List<GHIssueComment> getComments() throws IOException {
|
public List<GHIssueComment> getComments() throws IOException {
|
||||||
return listComments().asList();
|
return listComments().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -442,27 +479,30 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHIssueComment> listComments() throws IOException {
|
public PagedIterable<GHIssueComment> listComments() throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(getIssuesApiRoute() + "/comments",
|
.withUrlPath(getIssuesApiRoute() + "/comments")
|
||||||
GHIssueComment[].class,
|
.toIterable(GHIssueComment[].class, item -> item.wrapUp(this));
|
||||||
item -> item.wrapUp(GHIssue.this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview(SQUIRREL_GIRL)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHReaction createReaction(ReactionContent content) throws IOException {
|
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())
|
.with("content", content.getContent())
|
||||||
.to(getApiRoute() + "/reactions", GHReaction.class)
|
.withUrlPath(getApiRoute() + "/reactions")
|
||||||
|
.fetch(GHReaction.class)
|
||||||
.wrap(root);
|
.wrap(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview(SQUIRREL_GIRL)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PagedIterable<GHReaction> listReactions() {
|
public PagedIterable<GHReaction> listReactions() {
|
||||||
return owner.root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(SQUIRREL_GIRL)
|
.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 +526,11 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void addAssignees(Collection<GHUser> assignees) throws IOException {
|
public void addAssignees(Collection<GHUser> assignees) throws IOException {
|
||||||
root.retrieve()
|
root.createRequest()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.with(ASSIGNEES, getLogins(assignees))
|
.with(ASSIGNEES, getLogins(assignees))
|
||||||
.to(getIssuesApiRoute() + "/assignees", this);
|
.withUrlPath(getIssuesApiRoute() + "/assignees")
|
||||||
|
.fetchInto(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -513,7 +554,11 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void setAssignees(Collection<GHUser> assignees) throws IOException {
|
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 +582,12 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
|
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
|
||||||
root.retrieve()
|
root.createRequest()
|
||||||
.method("DELETE")
|
.method("DELETE")
|
||||||
.with(ASSIGNEES, getLogins(assignees))
|
.with(ASSIGNEES, getLogins(assignees))
|
||||||
.inBody()
|
.inBody()
|
||||||
.to(getIssuesApiRoute() + "/assignees", this);
|
.withUrlPath(getIssuesApiRoute() + "/assignees")
|
||||||
|
.fetchInto(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -559,6 +605,11 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* @return the issues api route
|
* @return the issues api route
|
||||||
*/
|
*/
|
||||||
protected String getIssuesApiRoute() {
|
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;
|
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +716,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* @return the diff url
|
* @return the diff url
|
||||||
*/
|
*/
|
||||||
public URL getDiffUrl() {
|
public URL getDiffUrl() {
|
||||||
return GitHub.parseURL(diff_url);
|
return GitHubClient.parseURL(diff_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -674,7 +725,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* @return the patch url
|
* @return the patch url
|
||||||
*/
|
*/
|
||||||
public URL getPatchUrl() {
|
public URL getPatchUrl() {
|
||||||
return GitHub.parseURL(patch_url);
|
return GitHubClient.parseURL(patch_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -683,7 +734,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,9 +754,8 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHIssueEvent> listEvents() throws IOException {
|
public PagedIterable<GHIssueEvent> listEvents() throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)),
|
.withUrlPath(owner.getApiTailUrl(String.format("/issues/%s/events", number)))
|
||||||
GHIssueEvent[].class,
|
.toIterable(GHIssueEvent[].class, item -> item.wrapUp(this));
|
||||||
item -> item.wrapUp(GHIssue.this));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class GHIssueBuilder {
|
|||||||
|
|
||||||
GHIssueBuilder(GHRepository repo, String title) {
|
GHIssueBuilder(GHRepository repo, String title) {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.builder = new Requester(repo.root);
|
this.builder = repo.root.createRequest().method("POST");
|
||||||
builder.with("title", title);
|
builder.with("title", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,8 @@ public class GHIssueBuilder {
|
|||||||
public GHIssue create() throws IOException {
|
public GHIssue create() throws IOException {
|
||||||
return builder.with("labels", labels)
|
return builder.with("labels", labels)
|
||||||
.with("assignees", assignees)
|
.with("assignees", assignees)
|
||||||
.to(repo.getApiTailUrl("issues"), GHIssue.class)
|
.withUrlPath(repo.getApiTailUrl("issues"))
|
||||||
|
.fetch(GHIssue.class)
|
||||||
.wrap(repo);
|
.wrap(repo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
49
src/main/java/org/kohsuke/github/GHIssueChanges.java
Normal file
49
src/main/java/org/kohsuke/github/GHIssueChanges.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper to define changed fields on issues action="edited"
|
||||||
|
*
|
||||||
|
* @see GHEventPayload.Issue
|
||||||
|
*/
|
||||||
|
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
|
||||||
|
public class GHIssueChanges {
|
||||||
|
|
||||||
|
private GHFrom title;
|
||||||
|
private GHFrom body;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old issue title.
|
||||||
|
*
|
||||||
|
* @return old issue title (or null if not changed)
|
||||||
|
*/
|
||||||
|
public GHFrom getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old issue body.
|
||||||
|
*
|
||||||
|
* @return old issue body (or null if not changed)
|
||||||
|
*/
|
||||||
|
public GHFrom getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for changed values.
|
||||||
|
*/
|
||||||
|
public static class GHFrom {
|
||||||
|
private String from;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Previous value that was changed.
|
||||||
|
*
|
||||||
|
* @return previous value
|
||||||
|
*/
|
||||||
|
public String getFrom() {
|
||||||
|
return from;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ package org.kohsuke.github;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.*;
|
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment to the issue
|
* Comment to the issue
|
||||||
@@ -87,7 +87,7 @@ public class GHIssueComment extends GHObject implements Reactable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getHtmlUrl() {
|
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
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void update(String body) throws IOException {
|
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;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,28 +123,32 @@ public class GHIssueComment extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(owner.root).method("DELETE").to(getApiRoute());
|
owner.root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview(SQUIRREL_GIRL)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHReaction createReaction(ReactionContent content) throws IOException {
|
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())
|
.with("content", content.getContent())
|
||||||
.to(getApiRoute() + "/reactions", GHReaction.class)
|
.withUrlPath(getApiRoute() + "/reactions")
|
||||||
|
.fetch(GHReaction.class)
|
||||||
.wrap(owner.root);
|
.wrap(owner.root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview(SQUIRREL_GIRL)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PagedIterable<GHReaction> listReactions() {
|
public PagedIterable<GHReaction> listReactions() {
|
||||||
return owner.root.retrieve()
|
return owner.root.createRequest()
|
||||||
.withPreview(SQUIRREL_GIRL)
|
.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() {
|
private String getApiRoute() {
|
||||||
return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()
|
return "/repos/" + owner.getRepository().getOwnerName() + "/" + owner.getRepository().getName()
|
||||||
+ "/issues/comments/" + id;
|
+ "/issues/comments/" + getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* The type GHIssueEvent.
|
* The type GHIssueEvent.
|
||||||
*
|
*
|
||||||
|
* @see <a href="https://developer.github.com/v3/issues/events/">Github documentation for issue events</a>
|
||||||
|
*
|
||||||
* @author Martin van Zijl
|
* @author Martin van Zijl
|
||||||
*/
|
*/
|
||||||
public class GHIssueEvent {
|
public class GHIssueEvent extends GitHubInteractiveObject {
|
||||||
private GitHub root;
|
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String node_id;
|
private String node_id;
|
||||||
private String url;
|
private String url;
|
||||||
@@ -18,6 +18,9 @@ public class GHIssueEvent {
|
|||||||
private String commit_id;
|
private String commit_id;
|
||||||
private String commit_url;
|
private String commit_url;
|
||||||
private String created_at;
|
private String created_at;
|
||||||
|
private GHMilestone milestone;
|
||||||
|
private GHLabel label;
|
||||||
|
private GHUser assignee;
|
||||||
|
|
||||||
private GHIssue issue;
|
private GHIssue issue;
|
||||||
|
|
||||||
@@ -90,7 +93,7 @@ public class GHIssueEvent {
|
|||||||
* @return the created at
|
* @return the created at
|
||||||
*/
|
*/
|
||||||
public Date getCreatedAt() {
|
public Date getCreatedAt() {
|
||||||
return GitHub.parseDate(created_at);
|
return GitHubClient.parseDate(created_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,6 +114,36 @@ public class GHIssueEvent {
|
|||||||
return issue;
|
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) {
|
GHIssueEvent wrapUp(GitHub root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -31,4 +31,4 @@ package org.kohsuke.github;
|
|||||||
*/
|
*/
|
||||||
public enum GHIssueState {
|
public enum GHIssueState {
|
||||||
OPEN, CLOSED, ALL
|
OPEN, CLOSED, ALL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
||||||
public class GHKey {
|
public class GHKey extends GitHubInteractiveObject {
|
||||||
/* package almost final */ GitHub root;
|
|
||||||
|
|
||||||
protected String url, key, title;
|
protected String url, key, title;
|
||||||
protected boolean verified;
|
protected boolean verified;
|
||||||
protected int id;
|
protected int id;
|
||||||
|
|||||||
@@ -1,29 +1,77 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.SYMMETRA;
|
import javax.annotation.CheckForNull;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHLabel.
|
* The type GHLabel.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
|
* @see <a href="https://developer.github.com/v3/issues/labels/">Labels</a>
|
||||||
* @see GHIssue#getLabels() GHIssue#getLabels()
|
* @see GHIssue#getLabels() GHIssue#getLabels()
|
||||||
* @see GHRepository#listLabels() GHRepository#listLabels()
|
* @see GHRepository#listLabels() GHRepository#listLabels()
|
||||||
*/
|
*/
|
||||||
public class GHLabel {
|
public class GHLabel extends GitHubInteractiveObject {
|
||||||
private String url, name, color, description;
|
|
||||||
private GHRepository repo;
|
private long id;
|
||||||
|
private String nodeId;
|
||||||
|
@JsonProperty("default")
|
||||||
|
private boolean default_;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private String url, name, color;
|
||||||
|
|
||||||
|
@CheckForNull
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
private GHLabel(@JacksonInject @Nonnull GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
url = "";
|
||||||
|
name = "";
|
||||||
|
color = "";
|
||||||
|
description = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
GitHub getApiRoot() {
|
||||||
|
return Objects.requireNonNull(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets id.
|
||||||
|
*
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets node id.
|
||||||
|
*
|
||||||
|
* @return the node id.
|
||||||
|
*/
|
||||||
|
public String getNodeId() {
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets url.
|
* Gets url.
|
||||||
*
|
*
|
||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@@ -33,6 +81,7 @@ public class GHLabel {
|
|||||||
*
|
*
|
||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -42,6 +91,7 @@ public class GHLabel {
|
|||||||
*
|
*
|
||||||
* @return the color
|
* @return the color
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public String getColor() {
|
public String getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
@@ -51,25 +101,18 @@ public class GHLabel {
|
|||||||
*
|
*
|
||||||
* @return the description
|
* @return the description
|
||||||
*/
|
*/
|
||||||
@Preview
|
@CheckForNull
|
||||||
@Deprecated
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHLabel wrapUp(GHRepository repo) {
|
|
||||||
this.repo = repo;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete.
|
* If the label is one of the default labels created by GitHub automatically.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @return true if the label is a default one
|
||||||
* the io exception
|
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public boolean isDefault() {
|
||||||
repo.root.retrieve().method("DELETE").to(url);
|
return default_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,15 +122,11 @@ public class GHLabel {
|
|||||||
* 6-letter hex color code, like "f29513"
|
* 6-letter hex color code, like "f29513"
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
|
* @deprecated use {@link #set()} or {@link #update()} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setColor(String newColor) throws IOException {
|
public void setColor(String newColor) throws IOException {
|
||||||
repo.root.retrieve()
|
set().color(newColor);
|
||||||
.method("PATCH")
|
|
||||||
.withPreview(SYMMETRA)
|
|
||||||
.with("name", name)
|
|
||||||
.with("color", newColor)
|
|
||||||
.with("description", description)
|
|
||||||
.to(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,27 +136,106 @@ public class GHLabel {
|
|||||||
* Description of label
|
* Description of label
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
|
* @deprecated use {@link #set()} or {@link #update()} instead
|
||||||
*/
|
*/
|
||||||
@Preview
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setDescription(String newDescription) throws IOException {
|
public void setDescription(String newDescription) throws IOException {
|
||||||
repo.root.retrieve()
|
set().description(newDescription);
|
||||||
.method("PATCH")
|
|
||||||
.withPreview(SYMMETRA)
|
|
||||||
.with("name", name)
|
|
||||||
.with("color", color)
|
|
||||||
.with("description", newDescription)
|
|
||||||
.to(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Collection<String> toNames(Collection<GHLabel> labels) {
|
static Collection<String> toNames(Collection<GHLabel> labels) {
|
||||||
List<String> r = new ArrayList<String>();
|
List<String> r = new ArrayList<>();
|
||||||
for (GHLabel l : labels) {
|
for (GHLabel l : labels) {
|
||||||
r.add(l.getName());
|
r.add(l.getName());
|
||||||
}
|
}
|
||||||
return r;
|
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
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@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}
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@Deprecated
|
||||||
|
public Updater update() {
|
||||||
|
return new Updater(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begins a single property update.
|
||||||
|
*
|
||||||
|
* @return a {@link Setter}
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@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
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
@@ -126,11 +244,54 @@ public class GHLabel {
|
|||||||
return false;
|
return false;
|
||||||
final GHLabel ghLabel = (GHLabel) o;
|
final GHLabel ghLabel = (GHLabel) o;
|
||||||
return Objects.equals(url, ghLabel.url) && Objects.equals(name, ghLabel.name)
|
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
|
@Override
|
||||||
public int hashCode() {
|
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.
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@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.
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@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.
|
||||||
|
*/
|
||||||
|
@BetaApi
|
||||||
|
@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
|
||||||
|
@BetaApi
|
||||||
|
@Deprecated
|
||||||
|
public S name(String value) throws IOException {
|
||||||
|
return with("name", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@BetaApi
|
||||||
|
@Deprecated
|
||||||
|
public S color(String value) throws IOException {
|
||||||
|
return with("color", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@BetaApi
|
||||||
|
@Deprecated
|
||||||
|
public S description(String value) throws IOException {
|
||||||
|
return with("description", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/main/java/org/kohsuke/github/GHLabelChanges.java
Normal file
49
src/main/java/org/kohsuke/github/GHLabelChanges.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper to define changed fields on label action="edited"
|
||||||
|
*
|
||||||
|
* @see GHEventPayload.Label
|
||||||
|
*/
|
||||||
|
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
|
||||||
|
public class GHLabelChanges {
|
||||||
|
|
||||||
|
private GHFrom name;
|
||||||
|
private GHFrom color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old label name.
|
||||||
|
*
|
||||||
|
* @return old label name (or null if not changed)
|
||||||
|
*/
|
||||||
|
public GHFrom getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old label color.
|
||||||
|
*
|
||||||
|
* @return old label color (or null if not changed)
|
||||||
|
*/
|
||||||
|
public GHFrom getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for changed values.
|
||||||
|
*/
|
||||||
|
public static class GHFrom {
|
||||||
|
private String from;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Previous value that was changed.
|
||||||
|
*
|
||||||
|
* @return previous value
|
||||||
|
*/
|
||||||
|
public String getFrom() {
|
||||||
|
return from;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,13 +24,13 @@
|
|||||||
|
|
||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The GitHub Preview API's license information
|
* The GitHub Preview API's license information
|
||||||
@@ -44,9 +44,6 @@ import java.util.List;
|
|||||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||||
justification = "JSON API")
|
justification = "JSON API")
|
||||||
public class GHLicense extends GHObject {
|
public class GHLicense extends GHObject {
|
||||||
@SuppressFBWarnings("IS2_INCONSISTENT_SYNC")
|
|
||||||
// root is set before the object is returned to the app
|
|
||||||
/* package almost final */ GitHub root;
|
|
||||||
|
|
||||||
// these fields are always present, even in the short form
|
// these fields are always present, even in the short form
|
||||||
protected String key, name;
|
protected String key, name;
|
||||||
@@ -78,14 +75,6 @@ public class GHLicense extends GHObject {
|
|||||||
return name;
|
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
|
* Featured licenses are bold in the new repository drop-down
|
||||||
*
|
*
|
||||||
@@ -100,7 +89,7 @@ public class GHLicense extends GHObject {
|
|||||||
|
|
||||||
public URL getHtmlUrl() throws IOException {
|
public URL getHtmlUrl() throws IOException {
|
||||||
populate();
|
populate();
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +188,14 @@ public class GHLicense extends GHObject {
|
|||||||
if (description != null)
|
if (description != null)
|
||||||
return; // already populated
|
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
|
@Override
|
||||||
@@ -210,12 +206,12 @@ public class GHLicense extends GHObject {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
GHLicense that = (GHLicense) o;
|
GHLicense that = (GHLicense) o;
|
||||||
return this.url.equals(that.url);
|
return Objects.equals(getUrl(), that.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return url.hashCode();
|
return Objects.hashCode(getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
GHLicense wrap(GitHub root) {
|
GHLicense wrap(GitHub root) {
|
||||||
|
|||||||
86
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
86
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
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 extends GitHubInteractiveObject {
|
||||||
|
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,70 @@
|
|||||||
|
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 extends GitHubInteractiveObject {
|
||||||
|
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,73 @@
|
|||||||
|
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 extends GitHubInteractiveObject {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
182
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
182
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
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 extends GitHubInteractiveObject {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
101
src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
Normal file
101
src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
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 extends GitHubInteractiveObject {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
112
src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
Normal file
112
src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
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 extends GitHubInteractiveObject {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,9 +10,7 @@ import java.util.Locale;
|
|||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
* @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships()
|
* @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships()
|
||||||
*/
|
*/
|
||||||
public class GHMembership /* extends GHObject --- but it doesn't have id, created_at, etc. */ {
|
public class GHMembership extends GitHubInteractiveObject {
|
||||||
GitHub root;
|
|
||||||
|
|
||||||
String url;
|
String url;
|
||||||
String state;
|
String state;
|
||||||
String role;
|
String role;
|
||||||
@@ -25,7 +23,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +70,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
|||||||
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
|
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
|
||||||
*/
|
*/
|
||||||
public void activate() throws IOException {
|
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) {
|
GHMembership wrap(GitHub root) {
|
||||||
@@ -84,11 +82,6 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wrap(GHMembership[] page, GitHub root) {
|
|
||||||
for (GHMembership m : page)
|
|
||||||
m.wrap(root);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Role of a user in an organization.
|
* Role of a user in an organization.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ public class GHMeta {
|
|||||||
private List<String> api;
|
private List<String> api;
|
||||||
private List<String> pages;
|
private List<String> pages;
|
||||||
private List<String> importer = new ArrayList<>();
|
private List<String> importer = new ArrayList<>();
|
||||||
|
private List<String> packages;
|
||||||
|
private List<String> actions;
|
||||||
|
private List<String> dependabot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is verifiable password authentication boolean.
|
* Is verifiable password authentication boolean.
|
||||||
@@ -86,4 +89,31 @@ public class GHMeta {
|
|||||||
public List<String> getImporter() {
|
public List<String> getImporter() {
|
||||||
return Collections.unmodifiableList(importer);
|
return Collections.unmodifiableList(importer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets package.
|
||||||
|
*
|
||||||
|
* @return the package
|
||||||
|
*/
|
||||||
|
public List<String> getPackages() {
|
||||||
|
return Collections.unmodifiableList(packages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets actions.
|
||||||
|
*
|
||||||
|
* @return the actions
|
||||||
|
*/
|
||||||
|
public List<String> getActions() {
|
||||||
|
return Collections.unmodifiableList(actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets dependabot.
|
||||||
|
*
|
||||||
|
* @return the dependabot
|
||||||
|
*/
|
||||||
|
public List<String> getDependabot() {
|
||||||
|
return Collections.unmodifiableList(dependabot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import java.util.Locale;
|
|||||||
* @author Yusuke Kokubo
|
* @author Yusuke Kokubo
|
||||||
*/
|
*/
|
||||||
public class GHMilestone extends GHObject {
|
public class GHMilestone extends GHObject {
|
||||||
GitHub root;
|
|
||||||
GHRepository owner;
|
GHRepository owner;
|
||||||
|
|
||||||
GHUser creator;
|
GHUser creator;
|
||||||
@@ -56,7 +55,7 @@ public class GHMilestone extends GHObject {
|
|||||||
public Date getDueOn() {
|
public Date getDueOn() {
|
||||||
if (due_on == null)
|
if (due_on == null)
|
||||||
return null;
|
return null;
|
||||||
return GitHub.parseDate(due_on);
|
return GitHubClient.parseDate(due_on);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +66,7 @@ public class GHMilestone extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public Date getClosedAt() throws IOException {
|
public Date getClosedAt() throws IOException {
|
||||||
return GitHub.parseDate(closed_at);
|
return GitHubClient.parseDate(closed_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +115,7 @@ public class GHMilestone extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,11 +154,11 @@ public class GHMilestone extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
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 {
|
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 +194,7 @@ public class GHMilestone extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void setDueOn(Date dueOn) throws IOException {
|
public void setDueOn(Date dueOn) throws IOException {
|
||||||
edit("due_on", GitHub.printDate(dueOn));
|
edit("due_on", GitHubClient.printDate(dueOn));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ package org.kohsuke.github;
|
|||||||
*/
|
*/
|
||||||
public enum GHMilestoneState {
|
public enum GHMilestoneState {
|
||||||
OPEN, CLOSED
|
OPEN, CLOSED
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -71,8 +70,7 @@ public class GHMyself extends GHUser {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public List<GHEmail> getEmails2() throws IOException {
|
public List<GHEmail> getEmails2() throws IOException {
|
||||||
GHEmail[] addresses = root.retrieve().to("/user/emails", GHEmail[].class);
|
return root.createRequest().withUrlPath("/user/emails").toIterable(GHEmail[].class, null).toList();
|
||||||
return Collections.unmodifiableList(Arrays.asList(addresses));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +84,7 @@ public class GHMyself extends GHUser {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public List<GHKey> getPublicKeys() throws IOException {
|
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
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
|
public List<GHVerifiedKey> getPublicVerifiedKeys() throws IOException {
|
||||||
return Collections.unmodifiableList(
|
return root.createRequest()
|
||||||
Arrays.asList(root.retrieve().to("/users/" + getLogin() + "/keys", GHVerifiedKey[].class)));
|
.withUrlPath("/users/" + getLogin() + "/keys")
|
||||||
|
.toIterable(GHVerifiedKey[].class, null)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +114,10 @@ public class GHMyself extends GHUser {
|
|||||||
public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException {
|
public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException {
|
||||||
GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>();
|
GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>();
|
||||||
Set<String> names = new HashSet<String>();
|
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
|
if (names.add(o.getLogin())) // in case of rumoured duplicates in the data
|
||||||
orgs.add(root.getOrganization(o.getLogin()));
|
orgs.add(root.getOrganization(o.getLogin()));
|
||||||
}
|
}
|
||||||
@@ -175,9 +178,10 @@ public class GHMyself extends GHUser {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHRepository> listRepositories(final int pageSize, final RepositoryListFilter repoType) {
|
public PagedIterable<GHRepository> listRepositories(final int pageSize, final RepositoryListFilter repoType) {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.with("type", repoType)
|
.with("type", repoType)
|
||||||
.asPagedIterable("/user/repos", GHRepository[].class, item -> item.wrap(root))
|
.withUrlPath("/user/repos")
|
||||||
|
.toIterable(GHRepository[].class, item -> item.wrap(root))
|
||||||
.withPageSize(pageSize);
|
.withPageSize(pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,6 +191,7 @@ public class GHMyself extends GHUser {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
* @deprecated Use {@link #listRepositories()}
|
* @deprecated Use {@link #listRepositories()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public PagedIterable<GHRepository> listAllRepositories() {
|
public PagedIterable<GHRepository> listAllRepositories() {
|
||||||
return listRepositories();
|
return listRepositories();
|
||||||
}
|
}
|
||||||
@@ -208,9 +213,10 @@ public class GHMyself extends GHUser {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHMembership> listOrgMemberships(final GHMembership.State state) {
|
public PagedIterable<GHMembership> listOrgMemberships(final GHMembership.State state) {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.with("state", state)
|
.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
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHMembership getMembership(GHOrganization o) throws IOException {
|
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 {
|
// public void addEmails(Collection<String> emails) throws IOException {
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ import java.util.NoSuchElementException;
|
|||||||
* @see GitHub#listNotifications() GitHub#listNotifications()
|
* @see GitHub#listNotifications() GitHub#listNotifications()
|
||||||
* @see GHRepository#listNotifications() GHRepository#listNotifications()
|
* @see GHRepository#listNotifications() GHRepository#listNotifications()
|
||||||
*/
|
*/
|
||||||
public class GHNotificationStream implements Iterable<GHThread> {
|
public class GHNotificationStream extends GitHubInteractiveObject implements Iterable<GHThread> {
|
||||||
private final GitHub root;
|
|
||||||
|
|
||||||
private Boolean all, participating;
|
private Boolean all, participating;
|
||||||
private String since;
|
private String since;
|
||||||
private String apiUrl;
|
private String apiUrl;
|
||||||
@@ -79,7 +77,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
|||||||
* @return the gh notification stream
|
* @return the gh notification stream
|
||||||
*/
|
*/
|
||||||
public GHNotificationStream since(Date dt) {
|
public GHNotificationStream since(Date dt) {
|
||||||
since = GitHub.printDate(dt);
|
since = GitHubClient.printDate(dt);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +99,7 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
|||||||
*/
|
*/
|
||||||
public Iterator<GHThread> iterator() {
|
public Iterator<GHThread> iterator() {
|
||||||
// capture the configuration setting here
|
// capture the configuration setting here
|
||||||
final Requester req = new Requester(root).method("GET")
|
final Requester req = root.createRequest()
|
||||||
.with("all", all)
|
.with("all", all)
|
||||||
.with("participating", participating)
|
.with("participating", participating)
|
||||||
.with("since", since);
|
.with("since", since);
|
||||||
@@ -180,7 +178,11 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
|||||||
|
|
||||||
req.setHeader("If-Modified-Since", lastModified);
|
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) {
|
if (threads == null) {
|
||||||
threads = EMPTY_ARRAY; // if unmodified, we get empty array
|
threads = EMPTY_ARRAY; // if unmodified, we get empty array
|
||||||
} else {
|
} else {
|
||||||
@@ -189,27 +191,21 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
|||||||
}
|
}
|
||||||
idx = threads.length - 1;
|
idx = threads.length - 1;
|
||||||
|
|
||||||
nextCheckTime = calcNextCheckTime();
|
nextCheckTime = calcNextCheckTime(response);
|
||||||
lastModified = req.getResponseHeader("Last-Modified");
|
lastModified = response.headerField("Last-Modified");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long calcNextCheckTime() {
|
private long calcNextCheckTime(GitHubResponse<GHThread[]> response) {
|
||||||
String v = req.getResponseHeader("X-Poll-Interval");
|
String v = response.headerField("X-Poll-Interval");
|
||||||
if (v == null)
|
if (v == null)
|
||||||
v = "60";
|
v = "60";
|
||||||
long seconds = Integer.parseInt(v);
|
long seconds = Integer.parseInt(v);
|
||||||
return System.currentTimeMillis() + seconds * 1000;
|
return System.currentTimeMillis() + seconds * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,10 +228,10 @@ public class GHNotificationStream implements Iterable<GHThread> {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void markAsRead(long timestamp) throws IOException {
|
public void markAsRead(long timestamp) throws IOException {
|
||||||
final Requester req = new Requester(root).method("PUT");
|
final Requester req = root.createRequest();
|
||||||
if (timestamp >= 0)
|
if (timestamp >= 0)
|
||||||
req.with("last_read_at", GitHub.printDate(new Date(timestamp)));
|
req.with("last_read_at", GitHubClient.printDate(new Date(timestamp)));
|
||||||
req.asHttpStatusCode(apiUrl);
|
req.withUrlPath(apiUrl).fetchHttpStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final GHThread[] EMPTY_ARRAY = new GHThread[0];
|
private static final GHThread[] EMPTY_ARRAY = new GHThread[0];
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||||
@@ -19,20 +20,35 @@ import javax.annotation.CheckForNull;
|
|||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||||
justification = "JSON API")
|
justification = "JSON API")
|
||||||
public abstract class GHObject {
|
public abstract class GHObject extends GitHubInteractiveObject {
|
||||||
/**
|
/**
|
||||||
* Capture response HTTP headers on the state object.
|
* Capture response HTTP headers on the state object.
|
||||||
*/
|
*/
|
||||||
protected Map<String, List<String>> responseHeaderFields;
|
protected transient Map<String, List<String>> responseHeaderFields;
|
||||||
|
|
||||||
protected String url;
|
private String url;
|
||||||
protected long id;
|
|
||||||
protected String created_at;
|
private long id;
|
||||||
protected String updated_at;
|
private String nodeId;
|
||||||
|
private String createdAt;
|
||||||
|
private String updatedAt;
|
||||||
|
|
||||||
GHObject() {
|
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.
|
* 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")
|
@WithBridgeMethods(value = String.class, adapterMethod = "createdAtStr")
|
||||||
public Date getCreatedAt() throws IOException {
|
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")
|
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
|
||||||
private Object createdAtStr(Date id, Class type) {
|
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")
|
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +112,18 @@ public abstract class GHObject {
|
|||||||
* on error
|
* on error
|
||||||
*/
|
*/
|
||||||
public Date getUpdatedAt() throws IOException {
|
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
|
@Override
|
||||||
String getApiRoute() {
|
String getApiRoute() {
|
||||||
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), id);
|
return String.format("/orgs/%s/hooks/%d", organization.getLogin(), getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.INERTIA;
|
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHOrganization.
|
* The type GHOrganization.
|
||||||
@@ -18,6 +18,9 @@ import static org.kohsuke.github.Previews.INERTIA;
|
|||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
public class GHOrganization extends GHPerson {
|
public class GHOrganization extends GHPerson {
|
||||||
|
|
||||||
|
private boolean has_organization_projects;
|
||||||
|
|
||||||
GHOrganization wrapUp(GitHub root) {
|
GHOrganization wrapUp(GitHub root) {
|
||||||
return (GHOrganization) super.wrapUp(root);
|
return (GHOrganization) super.wrapUp(root);
|
||||||
}
|
}
|
||||||
@@ -40,6 +43,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public GHRepository createRepository(String name,
|
public GHRepository createRepository(String name,
|
||||||
String description,
|
String description,
|
||||||
String homepage,
|
String homepage,
|
||||||
@@ -69,6 +73,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public GHRepository createRepository(String name,
|
public GHRepository createRepository(String name,
|
||||||
String description,
|
String description,
|
||||||
String homepage,
|
String homepage,
|
||||||
@@ -88,14 +93,14 @@ public class GHOrganization extends GHPerson {
|
|||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to
|
* You use the returned builder to set various properties, then call {@link GHCreateRepositoryBuilder#create()} to
|
||||||
* finally createa repository.
|
* finally create a repository.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* the name
|
* the name
|
||||||
* @return the gh create repository builder
|
* @return the gh create repository builder
|
||||||
*/
|
*/
|
||||||
public GHCreateRepositoryBuilder createRepository(String name) {
|
public GHCreateRepositoryBuilder createRepository(String name) {
|
||||||
return new GHCreateRepositoryBuilder(root, "/orgs/" + login + "/repos", name);
|
return new GHCreateRepositoryBuilder(name, root, "/orgs/" + login + "/repos");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,10 +126,43 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHTeam> listTeams() throws IOException {
|
public PagedIterable<GHTeam> listTeams() throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(String.format("/orgs/%s/teams", login),
|
.withUrlPath(String.format("/orgs/%s/teams", login))
|
||||||
GHTeam[].class,
|
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
|
||||||
item -> item.wrapUp(GHOrganization.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,13 +190,13 @@ public class GHOrganization extends GHPerson {
|
|||||||
* @return the team by slug
|
* @return the team by slug
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* 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 {
|
public GHTeam getTeamBySlug(String slug) throws IOException {
|
||||||
for (GHTeam t : listTeams()) {
|
return root.createRequest()
|
||||||
if (t.getSlug().equals(slug))
|
.withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))
|
||||||
return t;
|
.fetch(GHTeam.class)
|
||||||
}
|
.wrapUp(this);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,10 +221,11 @@ public class GHOrganization extends GHPerson {
|
|||||||
* "https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership">documentation</a>
|
* "https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership">documentation</a>
|
||||||
*/
|
*/
|
||||||
public void add(GHUser user, Role role) throws IOException {
|
public void add(GHUser user, Role role) throws IOException {
|
||||||
root.retrieve()
|
root.createRequest()
|
||||||
.method("PUT")
|
.method("PUT")
|
||||||
.with("role", role.name().toLowerCase())
|
.with("role", role.name().toLowerCase())
|
||||||
.to("/orgs/" + login + "/memberships/" + user.getLogin());
|
.withUrlPath("/orgs/" + login + "/memberships/" + user.getLogin())
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,7 +237,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
*/
|
*/
|
||||||
public boolean hasMember(GHUser user) {
|
public boolean hasMember(GHUser user) {
|
||||||
try {
|
try {
|
||||||
root.retrieve().to("/orgs/" + login + "/members/" + user.getLogin());
|
root.createRequest().withUrlPath("/orgs/" + login + "/members/" + user.getLogin()).send();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
return false;
|
return false;
|
||||||
@@ -215,7 +254,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void remove(GHUser user) throws IOException {
|
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 +266,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
*/
|
*/
|
||||||
public boolean hasPublicMember(GHUser user) {
|
public boolean hasPublicMember(GHUser user) {
|
||||||
try {
|
try {
|
||||||
root.retrieve().to("/orgs/" + login + "/public_members/" + user.getLogin());
|
root.createRequest().withUrlPath("/orgs/" + login + "/public_members/" + user.getLogin()).send();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
return false;
|
return false;
|
||||||
@@ -243,7 +282,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void publicize(GHUser u) throws IOException {
|
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 +294,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* @deprecated use {@link #listMembers()}
|
* @deprecated use {@link #listMembers()}
|
||||||
*/
|
*/
|
||||||
public List<GHUser> getMembers() throws IOException {
|
public List<GHUser> getMembers() throws IOException {
|
||||||
return listMembers().asList();
|
return listMembers().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -281,7 +320,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
|
private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
|
||||||
return listMembers(suffix, null);
|
return listMembers(suffix, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -294,15 +333,29 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHUser> listMembersWithFilter(String filter) throws IOException {
|
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);
|
* List members with specified role paged iterable.
|
||||||
return root.retrieve()
|
*
|
||||||
.asPagedIterable(String.format("/orgs/%s/%s%s", login, suffix, filterParams),
|
* @param role
|
||||||
GHUser[].class,
|
* the role
|
||||||
item -> item.wrapUp(root));
|
* @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 +367,36 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void conceal(GHUser u) throws IOException {
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are projects enabled for organization boolean.
|
||||||
|
*
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean areOrganizationProjectsEnabled() {
|
||||||
|
return has_organization_projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets organization projects enabled status boolean
|
||||||
|
*
|
||||||
|
* @param newStatus
|
||||||
|
* enable status
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
public void enableOrganizationProjects(boolean newStatus) throws IOException {
|
||||||
|
edit("has_organization_projects", newStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void edit(String key, Object value) throws IOException {
|
||||||
|
root.createRequest()
|
||||||
|
.withUrlPath(String.format("/orgs/%s", login))
|
||||||
|
.method("PATCH")
|
||||||
|
.with(key, value)
|
||||||
|
.fetchInto(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,10 +409,11 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
|
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(INERTIA)
|
.withPreview(INERTIA)
|
||||||
.with("state", status)
|
.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 +439,13 @@ public class GHOrganization extends GHPerson {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHProject createProject(String name, String body) throws IOException {
|
public GHProject createProject(String name, String body) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.withPreview(INERTIA)
|
.withPreview(INERTIA)
|
||||||
.with("name", name)
|
.with("name", name)
|
||||||
.with("body", body)
|
.with("body", body)
|
||||||
.to(String.format("/orgs/%s/projects", login), GHProject.class)
|
.withUrlPath(String.format("/orgs/%s/projects", login))
|
||||||
|
.fetch(GHProject.class)
|
||||||
.wrap(root);
|
.wrap(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +453,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* The enum Permission.
|
* The enum Permission.
|
||||||
*/
|
*/
|
||||||
public enum Permission {
|
public enum Permission {
|
||||||
ADMIN, PUSH, PULL
|
ADMIN, MAINTAIN, PUSH, TRIAGE, PULL
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -385,17 +469,17 @@ public class GHOrganization extends GHPerson {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
||||||
* {@link #createTeam(String, Collection)}
|
* {@link #createTeam(String)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
|
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>();
|
List<String> repo_names = new ArrayList<String>();
|
||||||
for (GHRepository r : repositories) {
|
for (GHRepository r : repositories) {
|
||||||
repo_names.add(login + "/" + r.getName());
|
repo_names.add(login + "/" + r.getName());
|
||||||
}
|
}
|
||||||
post.with("repo_names", repo_names);
|
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 +495,7 @@ public class GHOrganization extends GHPerson {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
|
||||||
* {@link #createTeam(String, GHRepository...)}
|
* {@link #createTeam(String)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException {
|
public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException {
|
||||||
@@ -428,15 +512,17 @@ public class GHOrganization extends GHPerson {
|
|||||||
* @return the gh team
|
* @return the gh team
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* 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 {
|
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>();
|
List<String> repo_names = new ArrayList<String>();
|
||||||
for (GHRepository r : repositories) {
|
for (GHRepository r : repositories) {
|
||||||
repo_names.add(login + "/" + r.getName());
|
repo_names.add(login + "/" + r.getName());
|
||||||
}
|
}
|
||||||
post.with("repo_names", repo_names);
|
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 +535,28 @@ public class GHOrganization extends GHPerson {
|
|||||||
* @return the gh team
|
* @return the gh team
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* 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 {
|
public GHTeam createTeam(String name, GHRepository... repositories) throws IOException {
|
||||||
return createTeam(name, Arrays.asList(repositories));
|
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.
|
* List up repositories that has some open pull requests.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -495,10 +598,9 @@ public class GHOrganization extends GHPerson {
|
|||||||
* Lists events performed by a user (this includes private events if the caller is authenticated.
|
* Lists events performed by a user (this includes private events if the caller is authenticated.
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHEventInfo> listEvents() throws IOException {
|
public PagedIterable<GHEventInfo> listEvents() throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(String.format("/orgs/%s/events", login),
|
.withUrlPath(String.format("/orgs/%s/events", login))
|
||||||
GHEventInfo[].class,
|
.toIterable(GHEventInfo[].class, item -> item.wrapUp(root));
|
||||||
item -> item.wrapUp(root));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -511,8 +613,9 @@ public class GHOrganization extends GHPerson {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
|
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable("/orgs/" + login + "/repos", GHRepository[].class, item -> item.wrap(root))
|
.withUrlPath("/orgs/" + login + "/repos")
|
||||||
|
.toIterable(GHRepository[].class, item -> item.wrap(root))
|
||||||
.withPageSize(pageSize);
|
.withPageSize(pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Permission for a user in a repository.
|
* Permission for a user in a repository.
|
||||||
*
|
*
|
||||||
* @see <a href="https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level">API</a>
|
* @see <a href="https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level">API</a>
|
||||||
*/
|
*/
|
||||||
class GHPermission {
|
class GHPermission {
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,15 +18,18 @@ import java.util.TreeMap;
|
|||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
public abstract class GHPerson extends GHObject {
|
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)
|
// 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)
|
// other fields (that only show up in full data)
|
||||||
protected String location, blog, email, name, company;
|
protected String location, blog, email, bio, name, company, type, twitter_username;
|
||||||
protected String html_url;
|
protected String html_url;
|
||||||
protected int followers, following, public_repos, public_gists;
|
protected int followers, following, public_repos, public_gists;
|
||||||
|
protected boolean site_admin, hireable;
|
||||||
|
|
||||||
|
// other fields (that only show up in full data) that require privileged scope
|
||||||
|
protected Integer total_private_repos;
|
||||||
|
|
||||||
GHPerson wrapUp(GitHub root) {
|
GHPerson wrapUp(GitHub root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
@@ -41,13 +45,16 @@ public abstract class GHPerson extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
protected synchronized void populate() throws IOException {
|
protected synchronized void populate() throws IOException {
|
||||||
if (created_at != null) {
|
if (super.getCreatedAt() != null) {
|
||||||
return; // already populated
|
return; // already populated
|
||||||
}
|
}
|
||||||
if (root == null || root.isOffline()) {
|
if (root == null || root.isOffline()) {
|
||||||
return; // cannot populate, will have to live with what we have
|
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 +95,9 @@ public abstract class GHPerson extends GHObject {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
|
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable("/users/" + login + "/repos", GHRepository[].class, item -> item.wrap(root))
|
.withUrlPath("/users/" + login + "/repos")
|
||||||
|
.toIterable(GHRepository[].class, item -> item.wrap(root))
|
||||||
.withPageSize(pageSize);
|
.withPageSize(pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,28 +118,27 @@ public abstract class GHPerson extends GHObject {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
|
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
|
||||||
return new Iterable<List<GHRepository>>() {
|
return () -> {
|
||||||
public Iterator<List<GHRepository>> iterator() {
|
final PagedIterator<GHRepository> pager;
|
||||||
final Iterator<GHRepository[]> pager = root.retrieve()
|
try {
|
||||||
.asIterator("/users/" + login + "/repos", GHRepository[].class, pageSize);
|
GitHubPageIterator<GHRepository[]> iterator = GitHubPageIterator.create(root.getClient(),
|
||||||
|
GHRepository[].class,
|
||||||
return new Iterator<List<GHRepository>>() {
|
root.createRequest().withUrlPath("users", login, "repos").build(),
|
||||||
public boolean hasNext() {
|
pageSize);
|
||||||
return pager.hasNext();
|
pager = new PagedIterator<>(iterator, item -> item.wrap(root));
|
||||||
}
|
} catch (MalformedURLException e) {
|
||||||
|
throw new GHException("Unable to build GitHub API URL", e);
|
||||||
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 new Iterator<List<GHRepository>>() {
|
||||||
|
public boolean hasNext() {
|
||||||
|
return pager.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GHRepository> next() {
|
||||||
|
return pager.nextPage();
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +153,7 @@ public abstract class GHPerson extends GHObject {
|
|||||||
*/
|
*/
|
||||||
public GHRepository getRepository(String name) throws IOException {
|
public GHRepository getRepository(String name) throws IOException {
|
||||||
try {
|
try {
|
||||||
return root.retrieve().to("/repos/" + login + '/' + name, GHRepository.class).wrap(root);
|
return GHRepository.read(root, login, name);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -167,22 +174,18 @@ public abstract class GHPerson extends GHObject {
|
|||||||
* @return the gravatar id
|
* @return the gravatar id
|
||||||
* @deprecated No longer available in the v3 API.
|
* @deprecated No longer available in the v3 API.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getGravatarId() {
|
public String getGravatarId() {
|
||||||
return gravatar_id;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' that indicates the
|
* Returns a string of the avatar image URL.
|
||||||
* avatar image URL.
|
|
||||||
*
|
*
|
||||||
* @return the avatar url
|
* @return the avatar url
|
||||||
*/
|
*/
|
||||||
public String getAvatarUrl() {
|
public String getAvatarUrl() {
|
||||||
if (avatar_url != null)
|
return avatar_url;
|
||||||
return avatar_url;
|
|
||||||
if (gravatar_id != null)
|
|
||||||
return "https://secure.gravatar.com/avatar/" + gravatar_id;
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,6 +233,18 @@ public abstract class GHPerson extends GHObject {
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Twitter Username of this user, like "GitHub"
|
||||||
|
*
|
||||||
|
* @return the Twitter username
|
||||||
|
* @throws IOException
|
||||||
|
* the io exception
|
||||||
|
*/
|
||||||
|
public String getTwitterUsername() throws IOException {
|
||||||
|
populate();
|
||||||
|
return twitter_username;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getCreatedAt() throws IOException {
|
public Date getCreatedAt() throws IOException {
|
||||||
populate();
|
populate();
|
||||||
return super.getCreatedAt();
|
return super.getCreatedAt();
|
||||||
@@ -254,7 +269,7 @@ public abstract class GHPerson extends GHObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,4 +331,40 @@ public abstract class GHPerson extends GHObject {
|
|||||||
populate();
|
populate();
|
||||||
return followers;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static org.kohsuke.github.Previews.INERTIA;
|
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A GitHub project.
|
* A GitHub project.
|
||||||
@@ -37,12 +37,10 @@ import static org.kohsuke.github.Previews.INERTIA;
|
|||||||
* @see <a href="https://developer.github.com/v3/projects/">Projects</a>
|
* @see <a href="https://developer.github.com/v3/projects/">Projects</a>
|
||||||
*/
|
*/
|
||||||
public class GHProject extends GHObject {
|
public class GHProject extends GHObject {
|
||||||
protected GitHub root;
|
|
||||||
protected GHObject owner;
|
protected GHObject owner;
|
||||||
|
|
||||||
private String owner_url;
|
private String owner_url;
|
||||||
private String html_url;
|
private String html_url;
|
||||||
private String node_id;
|
|
||||||
private String name;
|
private String name;
|
||||||
private String body;
|
private String body;
|
||||||
private int number;
|
private int number;
|
||||||
@@ -51,7 +49,7 @@ public class GHProject extends GHObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getHtmlUrl() throws IOException {
|
public URL getHtmlUrl() throws IOException {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,11 +72,15 @@ public class GHProject extends GHObject {
|
|||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
try {
|
try {
|
||||||
if (owner_url.contains("/orgs/")) {
|
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/")) {
|
} 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/")) {
|
} else if (owner_url.contains("/repos/")) {
|
||||||
owner = root.retrieve().to(getOwnerUrl().getPath(), GHRepository.class).wrap(root);
|
String[] pathElements = getOwnerUrl().getPath().split("/");
|
||||||
|
owner = GHRepository.read(root, pathElements[1], pathElements[2]);
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
@@ -93,16 +95,18 @@ public class GHProject extends GHObject {
|
|||||||
* @return the owner url
|
* @return the owner url
|
||||||
*/
|
*/
|
||||||
public URL getOwnerUrl() {
|
public URL getOwnerUrl() {
|
||||||
return GitHub.parseURL(owner_url);
|
return GitHubClient.parseURL(owner_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets node id.
|
* Gets node id.
|
||||||
*
|
*
|
||||||
|
* @deprecated Use {@link GHObject#getNodeId()}
|
||||||
* @return the node id
|
* @return the node id
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getNode_id() {
|
public String getNode_id() {
|
||||||
return node_id;
|
return getNodeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,7 +180,7 @@ public class GHProject extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void edit(String key, Object value) throws IOException {
|
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 +189,7 @@ public class GHProject extends GHObject {
|
|||||||
* @return the api route
|
* @return the api route
|
||||||
*/
|
*/
|
||||||
protected String getApiRoute() {
|
protected String getApiRoute() {
|
||||||
return "/projects/" + id;
|
return "/projects/" + getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -270,7 +274,7 @@ public class GHProject extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
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 +286,10 @@ public class GHProject extends GHObject {
|
|||||||
*/
|
*/
|
||||||
public PagedIterable<GHProjectColumn> listColumns() throws IOException {
|
public PagedIterable<GHProjectColumn> listColumns() throws IOException {
|
||||||
final GHProject project = this;
|
final GHProject project = this;
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(INERTIA)
|
.withPreview(INERTIA)
|
||||||
.asPagedIterable(String.format("/projects/%d/columns", id),
|
.withUrlPath(String.format("/projects/%d/columns", getId()))
|
||||||
GHProjectColumn[].class,
|
.toIterable(GHProjectColumn[].class, item -> item.wrap(project));
|
||||||
item -> item.wrap(project));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,11 +302,12 @@ public class GHProject extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHProjectColumn createColumn(String name) throws IOException {
|
public GHProjectColumn createColumn(String name) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.withPreview(INERTIA)
|
.withPreview(INERTIA)
|
||||||
.with("name", name)
|
.with("name", name)
|
||||||
.to(String.format("/projects/%d/columns", id), GHProjectColumn.class)
|
.withUrlPath(String.format("/projects/%d/columns", getId()))
|
||||||
|
.fetch(GHProjectColumn.class)
|
||||||
.wrap(this);
|
.wrap(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user