mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-14 15:50:05 +00:00
Compare commits
291 Commits
github-api
...
github-api
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cda7607e1c | ||
|
|
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 | ||
|
|
b7af635a9a | ||
|
|
dc33e28452 | ||
|
|
9da4781759 | ||
|
|
0c6959cb4a | ||
|
|
ff3136df70 | ||
|
|
326c627221 | ||
|
|
075f382a8f | ||
|
|
dabb8fe49e | ||
|
|
90489e4392 | ||
|
|
ad45a74f87 | ||
|
|
60c045a713 | ||
|
|
f6c75e1f99 | ||
|
|
dd9245f6f2 | ||
|
|
7310a70743 | ||
|
|
82276837ac | ||
|
|
bd68252b44 | ||
|
|
6b1258e33a | ||
|
|
0400032923 | ||
|
|
d9563322f1 | ||
|
|
ab965969dd | ||
|
|
2f32e034d8 | ||
|
|
1cf7931f43 | ||
|
|
edc697dd73 | ||
|
|
54a059ff68 | ||
|
|
289282e235 | ||
|
|
825c36c15e | ||
|
|
1234c2e99e | ||
|
|
b8fae1308d | ||
|
|
dddcf624e6 | ||
|
|
b33fe9f7fe | ||
|
|
5a799400a9 | ||
|
|
76919a819f | ||
|
|
9c30f846b2 | ||
|
|
9230f51988 | ||
|
|
712035dc9a | ||
|
|
32e5c5b4ad | ||
|
|
134a6fab7e | ||
|
|
82e27cb962 | ||
|
|
8bcad7b3f9 | ||
|
|
d767575f76 | ||
|
|
7214c7d393 | ||
|
|
205e5ab03d | ||
|
|
6576beae76 | ||
|
|
001f8f1f50 | ||
|
|
3b694a87ef | ||
|
|
84dd06d769 | ||
|
|
c5cb16abfb | ||
|
|
79fb34324d | ||
|
|
303aef3548 | ||
|
|
fd278f8c32 | ||
|
|
53041a4117 | ||
|
|
9b3fe3b13a | ||
|
|
5c6c5081e9 | ||
|
|
e087ea0ac7 | ||
|
|
71c44dc805 | ||
|
|
c5c8596664 | ||
|
|
92a86f4d1c | ||
|
|
8098b68b8e | ||
|
|
7356001723 | ||
|
|
aba60587ab | ||
|
|
936a6a04fb | ||
|
|
9675126298 | ||
|
|
6a5886ea1c | ||
|
|
648c6a5a8f | ||
|
|
14b7bf4753 | ||
|
|
0e310fa96a | ||
|
|
0f6c282c80 | ||
|
|
ed3cd0c9c8 | ||
|
|
398f029f6d | ||
|
|
ad9c2b917b | ||
|
|
d0d65182c0 | ||
|
|
4c3a0d329b | ||
|
|
7c495c2177 | ||
|
|
2f86a9e534 | ||
|
|
12c3a0b1fa | ||
|
|
14f3660f55 | ||
|
|
5a8b032d74 | ||
|
|
57c4613b1f | ||
|
|
e008021a42 | ||
|
|
7e600c43ed | ||
|
|
963478e206 | ||
|
|
0f32783488 | ||
|
|
756d470715 | ||
|
|
2c47b7535b | ||
|
|
4cc90b4929 | ||
|
|
32754ffcf5 | ||
|
|
64aae75680 | ||
|
|
69d2160a0d | ||
|
|
99e326539e | ||
|
|
1dde975cfe | ||
|
|
58c069ec5c | ||
|
|
7916600a7b | ||
|
|
3e4f160c5d | ||
|
|
aeb5e5f681 | ||
|
|
1c2e491845 | ||
|
|
eb4000f26b | ||
|
|
74dd887c79 | ||
|
|
764599a7d9 | ||
|
|
ad683fee89 | ||
|
|
85a53fc68f | ||
|
|
3bf8baee85 | ||
|
|
8792213594 | ||
|
|
d9ebc9455c | ||
|
|
9ab8bdfe4a | ||
|
|
418ea9a19e | ||
|
|
20f04febf2 | ||
|
|
a65783201e | ||
|
|
a5f04d44a4 | ||
|
|
cbe1022f20 | ||
|
|
90301ae9ee | ||
|
|
4f38ab3640 | ||
|
|
fca179abab | ||
|
|
e426237c35 | ||
|
|
3dae361d7b | ||
|
|
967831388e | ||
|
|
f9794f20d4 | ||
|
|
f98efd6af0 | ||
|
|
69bf0641f8 | ||
|
|
5791843d16 | ||
|
|
58d0a20074 | ||
|
|
5884c7b3ba | ||
|
|
dd1da268a2 | ||
|
|
473f3954c7 | ||
|
|
5aad5406a2 | ||
|
|
98b606287d | ||
|
|
9792fc0daa | ||
|
|
a9bb9302bc | ||
|
|
30c70bc8d4 | ||
|
|
0df48c37ac | ||
|
|
ec31e94e7a | ||
|
|
ea631d0e88 | ||
|
|
66a180346e | ||
|
|
63ee878789 | ||
|
|
3479e4f2fd | ||
|
|
54f4152f89 | ||
|
|
06334bf272 | ||
|
|
839f096f39 | ||
|
|
f3b2fdc4fc | ||
|
|
16d34f3268 | ||
|
|
61e8dd09d6 | ||
|
|
90d7fea7aa | ||
|
|
b9c8bf07ea | ||
|
|
a3ba07d45f | ||
|
|
5a6a29cbb5 | ||
|
|
72aedbb76c | ||
|
|
e7e3be6ea7 | ||
|
|
62e1b9eb01 | ||
|
|
3fff92dc35 | ||
|
|
352d77719e | ||
|
|
ff397dfa4d | ||
|
|
34d64c0dff | ||
|
|
b5fdc2f956 | ||
|
|
38602965db | ||
|
|
df1ea62883 | ||
|
|
afaff52888 | ||
|
|
5b7829c288 | ||
|
|
2462eb2c79 | ||
|
|
edc26b0a55 | ||
|
|
cc94e8b0ca | ||
|
|
80f3a6e507 | ||
|
|
5709be7ff7 | ||
|
|
46fce8cf4b | ||
|
|
e84049367e | ||
|
|
f213ead595 | ||
|
|
ba540b0725 | ||
|
|
eb55691c89 | ||
|
|
dd508e7dea | ||
|
|
66357866c5 | ||
|
|
6e3728b458 | ||
|
|
31d4eef4b1 | ||
|
|
f58f32a7a8 | ||
|
|
28d8fb686a | ||
|
|
4c7fc2ef47 | ||
|
|
a3f99978c2 | ||
|
|
136b55d310 | ||
|
|
617e90259b | ||
|
|
959eb46162 | ||
|
|
998bda9de7 | ||
|
|
37a2018fe3 | ||
|
|
2c80e07c9d | ||
|
|
a115f34766 | ||
|
|
cd66c1e7c3 | ||
|
|
4f9975dc6d | ||
|
|
9da487d962 | ||
|
|
c7123b016b | ||
|
|
efb13ddaf0 | ||
|
|
3539b73c08 | ||
|
|
2c084ef4d5 | ||
|
|
754e66f4dd | ||
|
|
41b698f0a8 | ||
|
|
de78da4fa6 | ||
|
|
3d241d6fa1 | ||
|
|
1d983a0090 | ||
|
|
78fb860305 | ||
|
|
c699a84f42 | ||
|
|
d8a178d93d | ||
|
|
ada4243548 | ||
|
|
fa2e3aad6c | ||
|
|
0cf457a46f | ||
|
|
bb7b98d448 | ||
|
|
e8d90848f2 | ||
|
|
7c791451ba | ||
|
|
16d8c2b221 | ||
|
|
dceecbef0a | ||
|
|
3cbddf1de9 | ||
|
|
650340fcb3 | ||
|
|
ce5b893224 | ||
|
|
7869afa4ff | ||
|
|
9085606082 | ||
|
|
1e3f646814 | ||
|
|
933f0cb4b8 | ||
|
|
7497761fcc | ||
|
|
12b3d4ec7a | ||
|
|
8fd5ed57c4 | ||
|
|
7bc301bc70 | ||
|
|
30321d3a0e | ||
|
|
511a0ae503 | ||
|
|
1057636666 | ||
|
|
564b1d2a98 | ||
|
|
20cd0e2de2 | ||
|
|
6bc617c488 | ||
|
|
049db83423 | ||
|
|
52dd90e85d | ||
|
|
305267d07f | ||
|
|
20369aa1b5 | ||
|
|
40f05e4dbb | ||
|
|
a23d19f208 | ||
|
|
cb1d1e8ed7 | ||
|
|
4f67f32719 | ||
|
|
a80b5b6abc | ||
|
|
0be3d88872 | ||
|
|
48bb996350 | ||
|
|
ee2dde4cd1 | ||
|
|
c10a31c933 | ||
|
|
d6a846f58d | ||
|
|
945873231d | ||
|
|
5dc494978e | ||
|
|
c870ec10c0 | ||
|
|
2085b8fd14 | ||
|
|
e065b6435c | ||
|
|
da5331ceb0 | ||
|
|
8f81982de4 | ||
|
|
499b46ecf3 | ||
|
|
a7d232e15f | ||
|
|
8fdb394ec5 | ||
|
|
7a1da64bf2 | ||
|
|
95ae155fc0 | ||
|
|
d1507f2666 | ||
|
|
7e4f98d328 | ||
|
|
f9a956905e | ||
|
|
e7d95f9da6 | ||
|
|
bc8f0aa223 | ||
|
|
6f2ae94e12 | ||
|
|
8f787e9976 | ||
|
|
321d8240a2 | ||
|
|
0f9482864c | ||
|
|
60700d59fe | ||
|
|
3296cef02d | ||
|
|
1b55b5fa3c | ||
|
|
b2701f5ba4 | ||
|
|
5d9a4b42a6 |
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -7,4 +7,4 @@ We love getting PRs, but we hate asking people for the same basic changes every
|
|||||||
- [ ] Push your changes to a branch other than `master`. Create your PR from that branch.
|
- [ ] Push your changes to a branch other than `master`. 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. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.
|
||||||
|
|||||||
66
.github/workflows/maven-build.yml
vendored
66
.github/workflows/maven-build.yml
vendored
@@ -1,22 +1,72 @@
|
|||||||
name: Java CI Build and Test
|
name: CI
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
name: build-only (Java ${{ matrix.java }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [ '1.8.0', '11.0.x', '13.0.x' ]
|
java: [ 11 ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
- name: Cached .m2
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.m2/repository
|
||||||
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven-
|
||||||
|
- name: Maven Install (skipTests)
|
||||||
|
run: mvn -B install -DskipTests -D enable-ci --file pom.xml
|
||||||
|
site:
|
||||||
|
name: site (Java ${{ matrix.java }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
java: [ 11 ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.m2/repository
|
||||||
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven-
|
||||||
|
- name: Maven Site
|
||||||
|
run: mvn -B site -D enable-ci --file pom.xml
|
||||||
|
test:
|
||||||
|
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
|
||||||
|
runs-on: ${{ matrix.os }}-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ ubuntu, windows ]
|
||||||
|
java: [ 8, 11, 13 ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
- name: Maven Download all dependencies
|
- uses: actions/cache@v1
|
||||||
run: mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
|
with:
|
||||||
- name: Maven Build
|
path: ~/.m2/repository
|
||||||
run: mvn -B install site -P ci --file pom.xml
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven-
|
||||||
|
- name: Maven Install without Code Coverage
|
||||||
|
if: matrix.os == 'windows'
|
||||||
|
run: mvn -B install --file pom.xml
|
||||||
|
- name: Maven Install with Code Coverage
|
||||||
|
if: matrix.os != 'windows'
|
||||||
|
run: mvn -B install -D enable-ci --file pom.xml
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -7,3 +7,7 @@ target
|
|||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
.factorypath
|
||||||
|
.vscode/settings.json
|
||||||
|
|||||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,6 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [github-api-1.100](https://github.com/github-api/github-api/tree/github-api-1.100) (2019-11-27)
|
## [github-api-1.101](https://github.com/github-api/github-api/tree/github-api-1.101) (2019-11-27)
|
||||||
|
|
||||||
|
[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.100...github-api-1.101)
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- Fixed `ClassNotFoundException` when creating `okhttp3.OkHttpConnector` with `Cache` @alecharp [\#627](https://github.com/github-api/github-api/issues/627)
|
||||||
|
|
||||||
|
## [github-api-1.100](https://github.com/github-api/github-api/tree/github-api-1.100) (2019-11-26)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.99...github-api-1.100)
|
[Full Changelog](https://github.com/github-api/github-api/compare/github-api-1.99...github-api-1.100)
|
||||||
|
|
||||||
|
|||||||
372
pom.xml
372
pom.xml
@@ -1,14 +1,8 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<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.101</version>
|
<version>1.107</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>
|
||||||
@@ -17,10 +11,20 @@
|
|||||||
<connection>scm:git:git@github.com/github-api/${project.artifactId}.git</connection>
|
<connection>scm:git:git@github.com/github-api/${project.artifactId}.git</connection>
|
||||||
<developerConnection>scm:git:ssh://git@github.com/github-api/${project.artifactId}.git</developerConnection>
|
<developerConnection>scm:git:ssh://git@github.com/github-api/${project.artifactId}.git</developerConnection>
|
||||||
<url>https://${project.artifactId}.kohsuke.org/</url>
|
<url>https://${project.artifactId}.kohsuke.org/</url>
|
||||||
<tag>github-api-1.101</tag>
|
<tag>github-api-1.107</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/github-api/${project.artifactId}.git</url>
|
||||||
@@ -30,17 +34,16 @@
|
|||||||
<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>3.1.12.2</spotbugs-maven-plugin.version>
|
||||||
<spotbugs.version>3.1.12</spotbugs.version>
|
<spotbugs.version>4.0.0</spotbugs.version>
|
||||||
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
|
<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.0</okhttp3.version>
|
||||||
<okio.version>2.4.1</okio.version>
|
<okio.version>2.4.3</okio.version>
|
||||||
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
|
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
|
||||||
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
|
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
|
||||||
<jacoco.coverage.target.class>.80</jacoco.coverage.target.class>
|
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
|
||||||
<jacoco.coverage.target.method>0.20</jacoco.coverage.target.method>
|
<jacoco.coverage.target.bundle.method>0.556</jacoco.coverage.target.bundle.method>
|
||||||
<jacoco.coverage.target.line>0.50</jacoco.coverage.target.line>
|
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
|
||||||
<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>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -57,6 +60,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,11 +79,136 @@
|
|||||||
</testResources>
|
</testResources>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- adds jacoco coverage -->
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<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.5</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<!-- attached to Maven test phase -->
|
||||||
|
<execution>
|
||||||
|
<id>report</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>check</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<element>BUNDLE</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>METHOD</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>${jacoco.coverage.target.bundle.method}</minimum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
<rule>
|
||||||
|
<!--We end up with chatty logs, but it shows us which particular classes -->
|
||||||
|
<!--are lacking in coverage. If this is too much, just remove the -->
|
||||||
|
<!--<element>CLASS</element> tag below. -->
|
||||||
|
<element>CLASS</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>METHOD</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>${jacoco.coverage.target.class.method}</minimum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
<excludes>
|
||||||
|
<!-- Code implemented externally -->
|
||||||
|
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.**</exclude>
|
||||||
|
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
|
||||||
|
|
||||||
|
<!-- Sample only -->
|
||||||
|
<exclude>org.kohsuke.github.example.*</exclude>
|
||||||
|
|
||||||
|
<!-- No methods -->
|
||||||
|
<exclude>org.kohsuke.github.DeleteToken</exclude>
|
||||||
|
<exclude>org.kohsuke.github.Previews</exclude>
|
||||||
|
|
||||||
|
<!-- Deprecated -->
|
||||||
|
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
|
||||||
|
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPerson.1</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPerson.1.1</exclude>
|
||||||
|
|
||||||
|
<!-- These fail coverage on windows because tests are disabled -->
|
||||||
|
<exclude>org.kohsuke.github.GHAsset</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHReleaseBuilder</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHRelease</exclude>
|
||||||
|
|
||||||
|
<!-- TODO: These still need test coverage -->
|
||||||
|
<exclude>org.kohsuke.github.GitHubClient.GHApiInfo</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCommentAuthorAssociation</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCommitBuilder.UserInfo</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCommitState</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCompare.Commit</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCompare.InnerCommit</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCompare.Status</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCompare.Tree</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCompare.User</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHCompare</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHDeployKey</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHDeploymentStatusBuilder</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHDirection</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHEmail</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHEventPayload.Ping</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHEventPayload.Release</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHException</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHHook</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHHooks.OrgContext</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHInvitation</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHMilestoneState</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHOrgHook</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHProject.ProjectStateFilter</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Authorship</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Commit</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.CommitPointer</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Tree</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestCommitDetail</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestFileDetail</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHPullRequestQueryBuilder.Sort</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHReleaseUpdater</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHRepository.ForkSort</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHRequestedAction</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHStargazer</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHTagObject</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
|
||||||
|
<exclude>org.kohsuke.github.GitHubBuilder.1</exclude>
|
||||||
|
</excludes>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -81,6 +217,18 @@
|
|||||||
<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>
|
||||||
@@ -102,6 +250,10 @@
|
|||||||
<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>
|
||||||
@@ -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>
|
||||||
|
|
||||||
@@ -245,11 +386,6 @@
|
|||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.9</version>
|
<version>3.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>commons-codec</groupId>
|
|
||||||
<artifactId>commons-codec</artifactId>
|
|
||||||
<version>1.13</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
<artifactId>hamcrest</artifactId>
|
<artifactId>hamcrest</artifactId>
|
||||||
@@ -272,18 +408,18 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.13</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.10.2</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.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.infradna.tool</groupId>
|
<groupId>com.infradna.tool</groupId>
|
||||||
@@ -291,6 +427,27 @@
|
|||||||
<version>1.18</version>
|
<version>1.18</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.259</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,7 +457,7 @@
|
|||||||
<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.6.1.202002131546-r</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -338,19 +495,19 @@
|
|||||||
<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.2.4</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.26.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -374,119 +531,50 @@
|
|||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>ci</id>
|
<id>ci-non-windows</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>enable-ci</name>
|
||||||
|
</property>
|
||||||
|
<os>
|
||||||
|
<family>!windows</family>
|
||||||
|
</os>
|
||||||
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
|
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
|
||||||
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
|
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
|
||||||
</build>
|
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>jacoco</id>
|
<id>ci-all</id>
|
||||||
<activation>
|
<activation>
|
||||||
<property>
|
<property>
|
||||||
<name>enable-jacoco</name>
|
<name>enable-ci</name>
|
||||||
</property>
|
</property>
|
||||||
</activation>
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
|
||||||
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<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>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>prepare-agent</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<!-- attached to Maven test phase -->
|
|
||||||
<execution>
|
|
||||||
<id>report</id>
|
|
||||||
<phase>test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>report</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>check</id>
|
|
||||||
<phase>install</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<rules>
|
|
||||||
<rule>
|
|
||||||
<!--We end up with chatty logs, but it shows us which particular classes -->
|
|
||||||
<!--are lacking in coverage. If this is too much, just remove the -->
|
|
||||||
<!--<element>CLASS</element> tag below. -->
|
|
||||||
<element>CLASS</element>
|
|
||||||
<limits>
|
|
||||||
<!-- These limits can be overridden, in the form of `0.50` for -->
|
|
||||||
<!-- 50%, as necessary. Using a property just puts it in one spot. -->
|
|
||||||
<!--
|
|
||||||
<limit>
|
|
||||||
<counter>LINE</counter>
|
|
||||||
<value>COVEREDRATIO</value>
|
|
||||||
<minimum>${jacoco.coverage.target.lines}</minimum>
|
|
||||||
</limit>
|
|
||||||
-->
|
|
||||||
<!--
|
|
||||||
<limit>
|
|
||||||
<counter>BRANCH</counter>
|
|
||||||
<value>COVEREDRATIO</value>
|
|
||||||
<minimum>${jacoco.coverage.target.other}</minimum>
|
|
||||||
</limit>
|
|
||||||
-->
|
|
||||||
<!--
|
|
||||||
<limit>
|
|
||||||
<counter>INSTRUCTION</counter>
|
|
||||||
<value>COVEREDRATIO</value>
|
|
||||||
<minimum>${jacoco.coverage.target.other}</minimum>
|
|
||||||
</limit>
|
|
||||||
-->
|
|
||||||
<!--
|
|
||||||
<limit>
|
|
||||||
<counter>COMPLEXITY</counter>
|
|
||||||
<value>COVEREDRATIO</value>
|
|
||||||
<minimum>${jacoco.coverage.target.other}</minimum>
|
|
||||||
</limit>
|
|
||||||
-->
|
|
||||||
<limit>
|
|
||||||
<counter>METHOD</counter>
|
|
||||||
<value>COVEREDRATIO</value>
|
|
||||||
<minimum>${jacoco.coverage.target.method}</minimum>
|
|
||||||
</limit>
|
|
||||||
<!-- <limit>-->
|
|
||||||
<!-- <counter>CLASS</counter>-->
|
|
||||||
<!-- <value>COVEREDRATIO</value>-->
|
|
||||||
<!-- <minimum>${jacoco.coverage.target.class}</minimum>-->
|
|
||||||
<!-- </limit>-->
|
|
||||||
</limits>
|
|
||||||
<excludes>
|
|
||||||
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory.**</exclude>
|
|
||||||
<exclude>org.kohsuke.github.extras.okhttp3.ObsoleteUrlFactory</exclude>
|
|
||||||
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
|
|
||||||
<!--<exclude>io.jenkins.plugins.todeclarative.converter.api.*</exclude>-->
|
|
||||||
</excludes>
|
|
||||||
</rule>
|
|
||||||
</rules>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>release</id>
|
<id>release</id>
|
||||||
|
<properties>
|
||||||
|
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
|
||||||
|
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
|
||||||
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<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 +594,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>
|
||||||
@@ -540,4 +647,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>
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.net.HttpURLConnection;
|
|||||||
/**
|
/**
|
||||||
* Pluggable strategy to determine what to do when the API abuse limit is hit.
|
* Pluggable strategy to determine what to do when the API abuse limit is hit.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler)
|
* @see GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler) GitHubBuilder#withAbuseLimitHandler(AbuseLimitHandler)
|
||||||
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">documentation</a>
|
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">documentation</a>
|
||||||
* @see RateLimitHandler
|
* @see RateLimitHandler
|
||||||
@@ -29,6 +28,9 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ package org.kohsuke.github;
|
|||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kohsuke Kawaguchi
|
*/
|
||||||
*/
|
|
||||||
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD",
|
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD",
|
||||||
justification = "Being constructed by JSON deserialization")
|
justification = "Being constructed by JSON deserialization")
|
||||||
class DeleteToken {
|
class DeleteToken {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import java.util.Locale;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This was added during preview API period but it has changed since then.
|
* This was added during preview API period but it has changed since then.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public enum EnforcementLevel {
|
public enum EnforcementLevel {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import static org.kohsuke.github.Previews.MACHINE_MAN;
|
|||||||
/**
|
/**
|
||||||
* A Github App.
|
* A Github App.
|
||||||
*
|
*
|
||||||
* @author Paulo Miguel Almeida
|
|
||||||
* @see GitHub#getApp() GitHub#getApp()
|
* @see GitHub#getApp() GitHub#getApp()
|
||||||
*/
|
*/
|
||||||
public class GHApp extends GHObject {
|
public class GHApp extends GHObject {
|
||||||
@@ -140,7 +139,7 @@ public class GHApp extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(htmlUrl);
|
return GitHubClient.parseURL(htmlUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,9 +177,10 @@ public class GHApp extends GHObject {
|
|||||||
@Preview
|
@Preview
|
||||||
@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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,9 +198,10 @@ public class GHApp extends GHObject {
|
|||||||
@Preview
|
@Preview
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,9 +221,10 @@ public class GHApp extends GHObject {
|
|||||||
@Preview
|
@Preview
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,9 +246,10 @@ public class GHApp extends GHObject {
|
|||||||
@Preview
|
@Preview
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,9 +268,10 @@ public class GHApp extends GHObject {
|
|||||||
@Preview
|
@Preview
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import static org.kohsuke.github.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
|
|
||||||
* @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 {
|
||||||
private final GitHub root;
|
private final GitHub root;
|
||||||
@@ -20,11 +20,17 @@ public class GHAppCreateTokenBuilder {
|
|||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@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);
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Deprecated
|
||||||
|
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
|
||||||
|
this(root, apiUrlTail);
|
||||||
|
permissions(permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +49,25 @@ public class GHAppCreateTokenBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the permissions granted to the access token. The permissions object includes the permission names and their
|
||||||
|
* access type.
|
||||||
|
*
|
||||||
|
* @param permissions
|
||||||
|
* Map containing the permission names and types.
|
||||||
|
* @return a GHAppCreateTokenBuilder
|
||||||
|
*/
|
||||||
|
@Preview
|
||||||
|
@Deprecated
|
||||||
|
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
|
||||||
|
Map<String, String> retMap = new HashMap<>();
|
||||||
|
for (Map.Entry<String, GHPermissionType> entry : permissions.entrySet()) {
|
||||||
|
retMap.put(entry.getKey(), GitHubRequest.transformEnum(entry.getValue()));
|
||||||
|
}
|
||||||
|
builder.with("permissions", retMap);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an app token with all the parameters.
|
* Creates an app token with all the parameters.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -57,16 +82,9 @@ public class GHAppCreateTokenBuilder {
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import static org.kohsuke.github.Previews.GAMBIT;
|
|||||||
/**
|
/**
|
||||||
* A Github App Installation.
|
* A Github App Installation.
|
||||||
*
|
*
|
||||||
* @author Paulo Miguel Almeida
|
|
||||||
* @see GHApp#listInstallations() GHApp#listInstallations()
|
* @see GHApp#listInstallations() GHApp#listInstallations()
|
||||||
* @see GHApp#getInstallationById(long) GHApp#getInstallationById(long)
|
* @see GHApp#getInstallationById(long) GHApp#getInstallationById(long)
|
||||||
* @see GHApp#getInstallationByOrganization(String) GHApp#getInstallationByOrganization(String)
|
* @see GHApp#getInstallationByOrganization(String) GHApp#getInstallationByOrganization(String)
|
||||||
@@ -42,7 +41,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -271,7 +270,11 @@ public class GHAppInstallation extends GHObject {
|
|||||||
@Preview
|
@Preview
|
||||||
@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", id))
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -283,11 +286,27 @@ 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
|
@Preview
|
||||||
@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", id), permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a builder that creates a new App Installation Token.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
|
||||||
|
* finally create an access token.
|
||||||
|
*
|
||||||
|
* @return a GHAppCreateTokenBuilder instance
|
||||||
|
*/
|
||||||
|
@Preview
|
||||||
|
@Deprecated
|
||||||
|
public GHAppCreateTokenBuilder createToken() {
|
||||||
|
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* A Github App Installation Token.
|
* A Github App Installation Token.
|
||||||
*
|
*
|
||||||
* @author Paulo Miguel Almeida
|
|
||||||
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
|
||||||
*/
|
*/
|
||||||
public class GHAppInstallationToken {
|
public class GHAppInstallationToken {
|
||||||
@@ -127,7 +126,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")
|
||||||
|
|||||||
@@ -135,7 +135,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,7 +145,7 @@ 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() {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Generated OAuth token
|
* Generated OAuth token
|
||||||
*
|
*
|
||||||
* @author janinko
|
|
||||||
* @see GitHub#createToken(Collection, String, String) GitHub#createToken(Collection, String, String)
|
* @see GitHub#createToken(Collection, String, String) GitHub#createToken(Collection, String, String)
|
||||||
* @see <a href="http://developer.github.com/v3/oauth/#create-a-new-authorization">API documentation</a>
|
* @see <a href="http://developer.github.com/v3/oauth/#create-a-new-authorization">API documentation</a>
|
||||||
*/
|
*/
|
||||||
@@ -96,7 +95,7 @@ public class GHAuthorization extends GHObject {
|
|||||||
* @return the app url
|
* @return the app url
|
||||||
*/
|
*/
|
||||||
public URL getAppUrl() {
|
public URL getAppUrl() {
|
||||||
return GitHub.parseURL(app.url);
|
return GitHubClient.parseURL(app.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,7 +114,7 @@ public class GHAuthorization extends GHObject {
|
|||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(value = "NM_CONFUSING", justification = "It's a part of the library API, cannot be changed")
|
@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 GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,7 +140,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,16 +1,13 @@
|
|||||||
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.
|
||||||
*
|
*
|
||||||
* @author Kanstantsin Shautsou
|
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
* @see GHTreeEntry#asBlob() GHTreeEntry#asBlob()
|
* @see GHTreeEntry#asBlob() GHTreeEntry#asBlob()
|
||||||
* @see GHRepository#getBlob(String) GHRepository#getBlob(String)
|
* @see GHRepository#getBlob(String) GHRepository#getBlob(String)
|
||||||
@@ -26,7 +23,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 +70,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,8 @@ 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.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A branch in a repository.
|
* A branch in a repository.
|
||||||
*
|
|
||||||
* @author Yusuke Kokubo
|
|
||||||
*/
|
*/
|
||||||
@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",
|
||||||
@@ -92,7 +88,7 @@ public class GHBranch {
|
|||||||
@Preview
|
@Preview
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public URL getProtectionUrl() {
|
public URL getProtectionUrl() {
|
||||||
return GitHub.parseURL(protection_url);
|
return GitHubClient.parseURL(protection_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +99,7 @@ public class GHBranch {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHBranchProtection getProtection() throws IOException {
|
public GHBranchProtection getProtection() throws IOException {
|
||||||
return root.retrieve().to(protection_url, GHBranchProtection.class).wrap(this);
|
return root.createRequest().withUrlPath(protection_url).fetch(GHBranchProtection.class).wrap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +118,7 @@ public class GHBranch {
|
|||||||
* if disabling protection fails
|
* 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").withUrlPath(protection_url).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class GHBranchProtection {
|
|||||||
@Preview
|
@Preview
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +56,7 @@ public class GHBranchProtection {
|
|||||||
@Preview
|
@Preview
|
||||||
@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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +87,7 @@ public class GHBranchProtection {
|
|||||||
@Preview
|
@Preview
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
82
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
82
src/main/java/org/kohsuke/github/GHCheckRun.java
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a check run.
|
||||||
|
*
|
||||||
|
* @see <a href="https://developer.github.com/v3/checks/runs/">documentation</a>
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
||||||
|
justification = "JSON API")
|
||||||
|
public class GHCheckRun extends GHObject {
|
||||||
|
GHRepository owner;
|
||||||
|
GitHub root;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
private String conclusion;
|
||||||
|
private String name;
|
||||||
|
private String headSha;
|
||||||
|
private GHPullRequest[] pullRequests;
|
||||||
|
|
||||||
|
GHCheckRun wrap(GHRepository owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
this.root = owner.root;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHCheckRun wrap(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
if (owner != null) {
|
||||||
|
owner.wrap(root);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHPullRequest[] wrap() {
|
||||||
|
return pullRequests;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConclusion() {
|
||||||
|
return conclusion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the HEAD SHA.
|
||||||
|
*
|
||||||
|
* @return sha for the HEAD commit
|
||||||
|
*/
|
||||||
|
public String getHeadSha() {
|
||||||
|
return headSha;
|
||||||
|
}
|
||||||
|
|
||||||
|
GHPullRequest[] getPullRequests() throws IOException {
|
||||||
|
if (pullRequests != null && pullRequests.length != 0) {
|
||||||
|
for (GHPullRequest singlePull : pullRequests) {
|
||||||
|
singlePull.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pullRequests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This object has no HTML URL.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public URL getHtmlUrl() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,8 +2,6 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* How is an user associated with a repository?
|
* How is an user associated with a repository?
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public enum GHCommentAuthorAssociation {
|
public enum GHCommentAuthorAssociation {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A commit in a repository.
|
* A commit in a repository.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHRepository#getCommit(String) GHRepository#getCommit(String)
|
* @see GHRepository#getCommit(String) GHRepository#getCommit(String)
|
||||||
* @see GHCommitComment#getCommit() GHCommitComment#getCommit()
|
* @see GHCommitComment#getCommit() GHCommitComment#getCommit()
|
||||||
*/
|
*/
|
||||||
@@ -61,7 +60,7 @@ public class GHCommit {
|
|||||||
* @return the authored date
|
* @return the authored date
|
||||||
*/
|
*/
|
||||||
public Date getAuthoredDate() {
|
public Date getAuthoredDate() {
|
||||||
return GitHub.parseDate(author.date);
|
return GitHubClient.parseDate(author.date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +79,7 @@ public class GHCommit {
|
|||||||
* @return the commit date
|
* @return the commit date
|
||||||
*/
|
*/
|
||||||
public Date getCommitDate() {
|
public Date getCommitDate() {
|
||||||
return GitHub.parseDate(committer.date);
|
return GitHubClient.parseDate(committer.date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,7 +200,7 @@ public class GHCommit {
|
|||||||
* resolves to the actual content of the file.
|
* 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 +211,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 +325,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -441,11 +440,10 @@ public class GHCommit {
|
|||||||
* @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 +464,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,7 +519,7 @@ public class GHCommit {
|
|||||||
*/
|
*/
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,6 +118,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import static org.kohsuke.github.Previews.*;
|
|||||||
/**
|
/**
|
||||||
* A comment attached to a commit (or a specific line in a specific file of a commit.)
|
* A comment attached to a commit (or a specific line in a specific file of a commit.)
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHRepository#listCommitComments() GHRepository#listCommitComments()
|
* @see GHRepository#listCommitComments() GHRepository#listCommitComments()
|
||||||
* @see GHCommit#listComments() GHCommit#listComments()
|
* @see GHCommit#listComments() GHCommit#listComments()
|
||||||
* @see GHCommit#createComment(String, String, Integer, Integer) GHCommit#createComment(String, String, Integer,
|
* @see GHCommit#createComment(String, String, Integer, Integer) GHCommit#createComment(String, String, Integer,
|
||||||
@@ -41,7 +40,7 @@ public class GHCommitComment extends GHObject implements Reactable {
|
|||||||
* show this commit comment in a browser.
|
* 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 +112,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
|
||||||
@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
|
||||||
@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,7 +148,7 @@ 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() {
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies a commit in {@link GHPullRequest}.
|
* Identifies a commit in {@link GHPullRequest}.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public class GHCommitPointer {
|
public class GHCommitPointer {
|
||||||
private String ref, sha, label;
|
private String ref, sha, label;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import java.util.Date;
|
|||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHRepository#queryCommits() GHRepository#queryCommits()
|
* @see GHRepository#queryCommits() GHRepository#queryCommits()
|
||||||
*/
|
*/
|
||||||
public class GHCommitQueryBuilder {
|
public class GHCommitQueryBuilder {
|
||||||
@@ -24,7 +23,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 +82,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 +105,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 +126,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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Search commits.
|
* Search commits.
|
||||||
*
|
*
|
||||||
* @author Marc de Verdelhan
|
|
||||||
* @see GitHub#searchCommits() GitHub#searchCommits()
|
* @see GitHub#searchCommits() GitHub#searchCommits()
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview
|
||||||
@@ -259,7 +258,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];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package org.kohsuke.github;
|
|||||||
/**
|
/**
|
||||||
* Represents the state of commit
|
* Represents the state of commit
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHCommitStatus
|
* @see GHCommitStatus
|
||||||
*/
|
*/
|
||||||
public enum GHCommitState {
|
public enum GHCommitState {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.net.URL;
|
|||||||
/**
|
/**
|
||||||
* Represents a status of a commit.
|
* Represents a status of a commit.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHRepository#getLastCommitStatus(String) GHRepository#getLastCommitStatus(String)
|
* @see GHRepository#getLastCommitStatus(String) GHRepository#getLastCommitStatus(String)
|
||||||
* @see GHCommit#getLastStatus() GHCommit#getLastStatus()
|
* @see GHCommit#getLastStatus() GHCommit#getLastStatus()
|
||||||
* @see GHRepository#createCommitStatus(String, GHCommitState, String, String) GHRepository#createCommitStatus(String,
|
* @see GHRepository#createCommitStatus(String, GHCommitState, String, String) GHRepository#createCommitStatus(String,
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import java.net.URL;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The model user for comparing 2 commits in the GitHub API.
|
* The model user for comparing 2 commits in the GitHub API.
|
||||||
*
|
|
||||||
* @author Michael Clarke
|
|
||||||
*/
|
*/
|
||||||
public class GHCompare {
|
public class GHCompare {
|
||||||
|
|
||||||
@@ -27,7 +25,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 +34,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 +43,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 +52,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 +61,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,18 +1,16 @@
|
|||||||
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.
|
||||||
*
|
*
|
||||||
* @author Alexandre COLLIGNON
|
|
||||||
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
|
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "UnusedDeclaration" })
|
@SuppressWarnings({ "UnusedDeclaration" })
|
||||||
@@ -114,7 +112,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 +173,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 +222,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 +236,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 +303,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 +317,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 +352,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 +363,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;
|
||||||
@@ -405,6 +410,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.
|
||||||
@@ -11,7 +10,6 @@ import java.io.UnsupportedEncodingException;
|
|||||||
* <p>
|
* <p>
|
||||||
* Call various methods to build up parameters, then call {@link #commit()} to make the change effective.
|
* Call various methods to build up parameters, then call {@link #commit()} to make the change effective.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHRepository#createContent() GHRepository#createContent()
|
* @see GHRepository#createContent() GHRepository#createContent()
|
||||||
*/
|
*/
|
||||||
public final class GHContentBuilder {
|
public final class GHContentBuilder {
|
||||||
@@ -21,7 +19,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 +48,7 @@ public final class GHContentBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used when updating (but not creating a new content) to specify Thetblob SHA of the file being replaced.
|
* Used when updating (but not creating a new content) to specify the blob SHA of the file being replaced.
|
||||||
*
|
*
|
||||||
* @param sha
|
* @param sha
|
||||||
* the sha
|
* the sha
|
||||||
@@ -69,7 +67,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 +79,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 +102,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);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package org.kohsuke.github;
|
|||||||
/**
|
/**
|
||||||
* Search code for {@link GHContent}.
|
* Search code for {@link GHContent}.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GitHub#searchContent() GitHub#searchContent()
|
* @see GitHub#searchContent() GitHub#searchContent()
|
||||||
*/
|
*/
|
||||||
public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {
|
public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package org.kohsuke.github;
|
|||||||
/**
|
/**
|
||||||
* {@link GHContent} with license information.
|
* {@link GHContent} with license information.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see <a href="https://developer.github.com/v3/licenses/#get-a-repositorys-license">documentation</a>
|
* @see <a href="https://developer.github.com/v3/licenses/#get-a-repositorys-license">documentation</a>
|
||||||
* @see GHRepository#getLicense()
|
* @see GHRepository#getLicense()
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import java.net.URL;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a repository
|
* Creates a repository
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public class GHCreateRepositoryBuilder {
|
public class GHCreateRepositoryBuilder {
|
||||||
private final GitHub root;
|
private final GitHub root;
|
||||||
@@ -16,7 +14,7 @@ public class GHCreateRepositoryBuilder {
|
|||||||
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
|
GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.apiUrlTail = apiUrlTail;
|
this.apiUrlTail = apiUrlTail;
|
||||||
this.builder = new Requester(root);
|
this.builder = root.createRequest();
|
||||||
this.builder.with("name", name);
|
this.builder.with("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +194,7 @@ public class GHCreateRepositoryBuilder {
|
|||||||
* if repsitory cannot be created
|
* if repsitory cannot be created
|
||||||
*/
|
*/
|
||||||
public GHRepository create() throws IOException {
|
public GHRepository create() throws IOException {
|
||||||
return builder.method("POST").to(apiUrlTail, GHRepository.class).wrap(root);
|
return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHRepository.class).wrap(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ public class GHDeployKey {
|
|||||||
* the io exception
|
* 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,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 +47,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,7 +131,9 @@ 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)
|
||||||
|
.toIterable(GHDeploymentStatus[].class, item -> item.wrap(owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ 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().method("POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,6 +127,6 @@ public class GHDeploymentBuilder {
|
|||||||
* 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class GHDeploymentStatus extends GHObject {
|
|||||||
* @return the target url
|
* @return the target url
|
||||||
*/
|
*/
|
||||||
public URL getTargetUrl() {
|
public URL getTargetUrl() {
|
||||||
return GitHub.parseURL(target_url);
|
return GitHubClient.parseURL(target_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +46,7 @@ public class GHDeploymentStatus extends GHObject {
|
|||||||
* @return the deployment url
|
* @return the deployment url
|
||||||
*/
|
*/
|
||||||
public URL getDeploymentUrl() {
|
public URL getDeploymentUrl() {
|
||||||
return GitHub.parseURL(deployment_url);
|
return GitHubClient.parseURL(deployment_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +55,7 @@ public class GHDeploymentStatus extends GHObject {
|
|||||||
* @return the repository url
|
* @return the repository url
|
||||||
*/
|
*/
|
||||||
public URL getRepositoryUrl() {
|
public URL getRepositoryUrl() {
|
||||||
return GitHub.parseURL(repository_url);
|
return GitHubClient.parseURL(repository_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ 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().method("POST");
|
||||||
this.builder.with("state", state);
|
this.builder.with("state", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,8 @@ public class GHDeploymentStatusBuilder {
|
|||||||
* 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort direction
|
* Sort direction
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public enum GHDirection {
|
public enum GHDirection {
|
||||||
ASC, DESC
|
ASC, DESC
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an email of GitHub.
|
* Represents an email of GitHub.
|
||||||
*
|
|
||||||
* @author Kelly Campbell
|
|
||||||
*/
|
*/
|
||||||
@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",
|
||||||
|
|||||||
@@ -5,55 +5,62 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* Hook event type.
|
* Hook event type.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHEventInfo
|
* @see GHEventInfo
|
||||||
* @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,
|
||||||
COMMIT_COMMENT,
|
COMMIT_COMMENT,
|
||||||
|
CONTENT_REFERENCE,
|
||||||
CREATE,
|
CREATE,
|
||||||
DELETE,
|
DELETE,
|
||||||
|
DEPLOY_KEY,
|
||||||
DEPLOYMENT,
|
DEPLOYMENT,
|
||||||
DEPLOYMENT_STATUS,
|
DEPLOYMENT_STATUS,
|
||||||
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,
|
||||||
RELEASE,
|
RELEASE,
|
||||||
REPOSITORY, // only
|
REPOSITORY_DISPATCH, // only valid for org hooks
|
||||||
// valid
|
REPOSITORY,
|
||||||
// for
|
REPOSITORY_IMPORT,
|
||||||
// org
|
REPOSITORY_VULNERABILITY_ALERT,
|
||||||
// hooks
|
SECURITY_ADVISORY,
|
||||||
|
STAR,
|
||||||
STATUS,
|
STATUS,
|
||||||
TEAM,
|
TEAM,
|
||||||
TEAM_ADD,
|
TEAM_ADD,
|
||||||
WATCH,
|
WATCH,
|
||||||
PING,
|
|
||||||
/**
|
/**
|
||||||
* Special event type that means "every possible event"
|
* Special event type that means "every possible event"
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import java.util.Date;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an event.
|
* Represents an event.
|
||||||
*
|
|
||||||
* @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 {
|
||||||
@@ -78,7 +76,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 +142,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.MAPPER.readValue(payload.traverse(), type);
|
||||||
v.wrapUp(root);
|
v.wrapUp(root);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,109 @@ public abstract class GHEventPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List of events that still need to be added:
|
||||||
|
// CheckRunEvent CheckSuiteEvent ContentReferenceEvent
|
||||||
|
// DeployKeyEvent DownloadEvent FollowEvent ForkApplyEvent GitHubAppAuthorizationEvent GistEvent GollumEvent
|
||||||
|
// InstallationEvent InstallationRepositoriesEvent IssuesEvent LabelEvent MarketplacePurchaseEvent MemberEvent
|
||||||
|
// MembershipEvent MetaEvent MilestoneEvent OrganizationEvent OrgBlockEvent PackageEvent PageBuildEvent
|
||||||
|
// ProjectCardEvent ProjectColumnEvent ProjectEvent RepositoryDispatchEvent RepositoryImportEvent
|
||||||
|
// RepositoryVulnerabilityAlertEvent SecurityAdvisoryEvent StarEvent StatusEvent TeamEvent TeamAddEvent WatchEvent
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A check run event has been created, rerequested, completed, or has a requested_action.
|
||||||
|
*
|
||||||
|
* @see <a href="https://developer.github.com/v3/activity/events/types/#checkrunevent">authoritative source</a>
|
||||||
|
*/
|
||||||
|
@SuppressFBWarnings(
|
||||||
|
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
|
||||||
|
justification = "JSON API")
|
||||||
|
public static class CheckRun extends GHEventPayload {
|
||||||
|
private String action;
|
||||||
|
private int number;
|
||||||
|
private GHCheckRun checkRun;
|
||||||
|
private GHRequestedAction requestedAction;
|
||||||
|
private GHRepository repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets action.
|
||||||
|
*
|
||||||
|
* @return the action
|
||||||
|
*/
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets number.
|
||||||
|
*
|
||||||
|
* @return the number
|
||||||
|
*/
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Check Run object
|
||||||
|
*
|
||||||
|
* @param currentCheckRun
|
||||||
|
* the check run object
|
||||||
|
*/
|
||||||
|
public void setCheckRun(GHCheckRun currentCheckRun) {
|
||||||
|
this.checkRun = currentCheckRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Check Run object
|
||||||
|
*
|
||||||
|
* @return the current checkRun object
|
||||||
|
*/
|
||||||
|
public GHCheckRun getCheckRun() {
|
||||||
|
return checkRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Requested Action object
|
||||||
|
*
|
||||||
|
* @param currentRequestedAction
|
||||||
|
* the current action
|
||||||
|
*/
|
||||||
|
public void setCheckRun(GHRequestedAction currentRequestedAction) {
|
||||||
|
this.requestedAction = currentRequestedAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Requested Action object
|
||||||
|
*
|
||||||
|
* @return the requested action
|
||||||
|
*/
|
||||||
|
public GHRequestedAction getRequestedAction() {
|
||||||
|
return requestedAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets repository.
|
||||||
|
*
|
||||||
|
* @return the repository
|
||||||
|
*/
|
||||||
|
public GHRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void wrapUp(GitHub root) {
|
||||||
|
super.wrapUp(root);
|
||||||
|
if (checkRun == null)
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Expected check_run payload, but got something else. Maybe we've got another type of event?");
|
||||||
|
if (repository != null) {
|
||||||
|
repository.wrap(root);
|
||||||
|
checkRun.wrap(repository);
|
||||||
|
} else {
|
||||||
|
checkRun.wrap(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pull request status has changed.
|
* A pull request status has changed.
|
||||||
*
|
*
|
||||||
@@ -1325,6 +1428,107 @@ public abstract class GHEventPayload {
|
|||||||
organization.wrapUp(root);
|
organization.wrapUp(root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A git commit status was changed.
|
||||||
|
*
|
||||||
|
* @see <a href="https://developer.github.com/v3/activity/events/types/#statusevent">authoritative source</a>
|
||||||
|
*/
|
||||||
|
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "Constructed by JSON deserialization")
|
||||||
|
public static class Status extends GHEventPayload {
|
||||||
|
private String context;
|
||||||
|
private String description;
|
||||||
|
private GHCommitState state;
|
||||||
|
private GHCommit commit;
|
||||||
|
private GHRepository repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the status content.
|
||||||
|
*
|
||||||
|
* @return status content
|
||||||
|
*/
|
||||||
|
public String getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the status description.
|
||||||
|
*
|
||||||
|
* @return status description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the status state.
|
||||||
|
*
|
||||||
|
* @return status state
|
||||||
|
*/
|
||||||
|
public GHCommitState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the status stage.
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* status state
|
||||||
|
*/
|
||||||
|
public void setState(GHCommitState state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the commit associated with the status event.
|
||||||
|
*
|
||||||
|
* @return commit
|
||||||
|
*/
|
||||||
|
public GHCommit getCommit() {
|
||||||
|
return commit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the commit associated with the status event.
|
||||||
|
*
|
||||||
|
* @param commit
|
||||||
|
* commit
|
||||||
|
*/
|
||||||
|
public void setCommit(GHCommit commit) {
|
||||||
|
this.commit = commit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the repository associated with the status event.
|
||||||
|
*
|
||||||
|
* @return repository
|
||||||
|
*/
|
||||||
|
public GHRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the repository associated with the status event.
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
* repository
|
||||||
|
*/
|
||||||
|
public void setRepository(GHRepository repository) {
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void wrapUp(GitHub root) {
|
||||||
|
super.wrapUp(root);
|
||||||
|
if (state == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Expected status payload, but got something else. Maybe we've got another type of event?");
|
||||||
|
}
|
||||||
|
if (repository != null) {
|
||||||
|
repository.wrap(root);
|
||||||
|
commit.wrapUp(repository);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHException.
|
* The type GHException.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public class GHException extends RuntimeException {
|
public class GHException extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
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.
|
||||||
*
|
|
||||||
* @author Kanstantsin Shautsou
|
|
||||||
*/
|
*/
|
||||||
public class GHFileNotFoundException extends FileNotFoundException {
|
public class GHFileNotFoundException extends FileNotFoundException {
|
||||||
protected Map<String, List<String>> responseHeaderFields;
|
protected Map<String, List<String>> responseHeaderFields;
|
||||||
@@ -24,11 +22,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 +52,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import java.util.Map.Entry;
|
|||||||
/**
|
/**
|
||||||
* Gist
|
* Gist
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHUser#listGists() GHUser#listGists()
|
* @see GHUser#listGists() GHUser#listGists()
|
||||||
* @see GitHub#getGist(String) GitHub#getGist(String)
|
* @see GitHub#getGist(String) GitHub#getGist(String)
|
||||||
* @see GitHub#createGist() GitHub#createGist()
|
* @see GitHub#createGist() GitHub#createGist()
|
||||||
@@ -84,7 +83,7 @@ public class GHGist extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,7 +181,7 @@ public class GHGist extends GHObject {
|
|||||||
* the io exception
|
* 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 +191,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 +202,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 +213,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).wrapUp(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +222,9 @@ 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, item -> item.wrapUp(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,7 +234,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.LinkedHashMap;
|
|||||||
/**
|
/**
|
||||||
* Builder pattern for creating a new Gist.
|
* Builder pattern for creating a new Gist.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GitHub#createGist() GitHub#createGist()
|
* @see GitHub#createGist() GitHub#createGist()
|
||||||
*/
|
*/
|
||||||
public class GHGistBuilder {
|
public class GHGistBuilder {
|
||||||
@@ -23,7 +22,7 @@ public class GHGistBuilder {
|
|||||||
*/
|
*/
|
||||||
public GHGistBuilder(GitHub root) {
|
public GHGistBuilder(GitHub root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
req = new Requester(root);
|
req = root.createRequest().method("POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,6 +72,6 @@ public class GHGistBuilder {
|
|||||||
*/
|
*/
|
||||||
public GHGist create() throws IOException {
|
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).wrapUp(root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package org.kohsuke.github;
|
|||||||
/**
|
/**
|
||||||
* A file inside {@link GHGist}
|
* A file inside {@link GHGist}
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHGist#getFile(String) GHGist#getFile(String)
|
* @see GHGist#getFile(String) GHGist#getFile(String)
|
||||||
* @see GHGist#getFiles() GHGist#getFiles()
|
* @see GHGist#getFiles() GHGist#getFiles()
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import java.util.LinkedHashMap;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder pattern for updating a Gist.
|
* Builder pattern for updating a Gist.
|
||||||
*
|
|
||||||
* @author Martin van Zijl
|
|
||||||
*/
|
*/
|
||||||
public class GHGistUpdater {
|
public class GHGistUpdater {
|
||||||
private final GHGist base;
|
private final GHGist base;
|
||||||
@@ -16,7 +14,7 @@ public class GHGistUpdater {
|
|||||||
|
|
||||||
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<>();
|
||||||
}
|
}
|
||||||
@@ -96,6 +94,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).wrap(base.owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHHook.
|
* The type GHHook.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
@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")
|
||||||
@@ -74,7 +72,7 @@ public abstract class GHHook extends GHObject {
|
|||||||
* @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a>
|
* @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 +82,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,8 +28,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 +48,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 +76,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,16 +1,14 @@
|
|||||||
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.
|
||||||
*
|
|
||||||
* @author Kanstantsin Shautsou
|
|
||||||
*/
|
*/
|
||||||
public class GHIOException extends IOException {
|
public class GHIOException extends IOException {
|
||||||
protected Map<String, List<String>> responseHeaderFields;
|
protected Map<String, List<String>> responseHeaderFields;
|
||||||
@@ -31,6 +29,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 +53,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,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 +46,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;
|
||||||
@@ -42,7 +43,6 @@ import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
|||||||
/**
|
/**
|
||||||
* Represents an issue on GitHub.
|
* Represents an issue on GitHub.
|
||||||
*
|
*
|
||||||
* @author Eric Maupin
|
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
* @see GHRepository#getIssue(int) GHRepository#getIssue(int)
|
* @see GHRepository#getIssue(int) GHRepository#getIssue(int)
|
||||||
* @see GitHub#searchIssues() GitHub#searchIssues()
|
* @see GitHub#searchIssues() GitHub#searchIssues()
|
||||||
@@ -137,7 +137,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* The HTML page of this issue, like https://github.com/jenkinsci/jenkins/issues/100
|
* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,7 +187,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,7 +196,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* @return the api url
|
* @return the api url
|
||||||
*/
|
*/
|
||||||
public URL getApiURL() {
|
public URL getApiURL() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +206,7 @@ public class GHIssue extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* 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 +216,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 +230,20 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
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().with(key, value).method("PATCH").withUrlPath(getIssuesApiRoute()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -442,27 +445,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
|
||||||
@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
|
||||||
@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 +492,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 +520,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 +548,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 +571,10 @@ 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.
|
||||||
|
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
|
||||||
|
}
|
||||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
|
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +681,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 +690,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 +699,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 +719,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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHIssueBuilder.
|
* The type GHIssueBuilder.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public class GHIssueBuilder {
|
public class GHIssueBuilder {
|
||||||
private final GHRepository repo;
|
private final GHRepository repo;
|
||||||
@@ -17,7 +15,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 +93,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import static org.kohsuke.github.Previews.*;
|
|||||||
/**
|
/**
|
||||||
* Comment to the issue
|
* Comment to the issue
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHIssue#comment(String) GHIssue#comment(String)
|
* @see GHIssue#comment(String) GHIssue#comment(String)
|
||||||
* @see GHIssue#listComments() GHIssue#listComments()
|
* @see GHIssue#listComments() GHIssue#listComments()
|
||||||
*/
|
*/
|
||||||
@@ -87,7 +86,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 +107,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,24 +122,28 @@ 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
|
||||||
@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
|
||||||
@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() {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import java.util.Date;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHIssueEvent.
|
* The type GHIssueEvent.
|
||||||
*
|
|
||||||
* @author Martin van Zijl
|
|
||||||
*/
|
*/
|
||||||
public class GHIssueEvent {
|
public class GHIssueEvent {
|
||||||
private GitHub root;
|
private GitHub root;
|
||||||
@@ -90,7 +88,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package org.kohsuke.github;
|
|||||||
/**
|
/**
|
||||||
* Search issues.
|
* Search issues.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GitHub#searchIssues() GitHub#searchIssues()
|
* @see GitHub#searchIssues() GitHub#searchIssues()
|
||||||
*/
|
*/
|
||||||
public class GHIssueSearchBuilder extends GHSearchBuilder<GHIssue> {
|
public class GHIssueSearchBuilder extends GHSearchBuilder<GHIssue> {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SSH public key.
|
* SSH public key.
|
||||||
*
|
|
||||||
* @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 {
|
||||||
|
|||||||
@@ -6,12 +6,9 @@ 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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHLabel.
|
* The type GHLabel.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHIssue#getLabels() GHIssue#getLabels()
|
* @see GHIssue#getLabels() GHIssue#getLabels()
|
||||||
* @see GHRepository#listLabels() GHRepository#listLabels()
|
* @see GHRepository#listLabels() GHRepository#listLabels()
|
||||||
*/
|
*/
|
||||||
@@ -51,8 +48,6 @@ public class GHLabel {
|
|||||||
*
|
*
|
||||||
* @return the description
|
* @return the description
|
||||||
*/
|
*/
|
||||||
@Preview
|
|
||||||
@Deprecated
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
@@ -69,7 +64,7 @@ public class GHLabel {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
repo.root.retrieve().method("DELETE").to(url);
|
repo.root.createRequest().method("DELETE").setRawUrlPath(url).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,13 +76,13 @@ public class GHLabel {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void setColor(String newColor) throws IOException {
|
public void setColor(String newColor) throws IOException {
|
||||||
repo.root.retrieve()
|
repo.root.createRequest()
|
||||||
.method("PATCH")
|
.method("PATCH")
|
||||||
.withPreview(SYMMETRA)
|
|
||||||
.with("name", name)
|
.with("name", name)
|
||||||
.with("color", newColor)
|
.with("color", newColor)
|
||||||
.with("description", description)
|
.with("description", description)
|
||||||
.to(url);
|
.setRawUrlPath(url)
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,16 +93,14 @@ public class GHLabel {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
@Preview
|
|
||||||
@Deprecated
|
|
||||||
public void setDescription(String newDescription) throws IOException {
|
public void setDescription(String newDescription) throws IOException {
|
||||||
repo.root.retrieve()
|
repo.root.createRequest()
|
||||||
.method("PATCH")
|
.method("PATCH")
|
||||||
.withPreview(SYMMETRA)
|
|
||||||
.with("name", name)
|
.with("name", name)
|
||||||
.with("color", color)
|
.with("color", color)
|
||||||
.with("description", newDescription)
|
.with("description", newDescription)
|
||||||
.to(url);
|
.setRawUrlPath(url)
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Collection<String> toNames(Collection<GHLabel> labels) {
|
static Collection<String> toNames(Collection<GHLabel> labels) {
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* The GitHub Preview API's license information
|
* The GitHub Preview API's license information
|
||||||
*
|
*
|
||||||
* @author Duncan Dickinson
|
|
||||||
* @see GitHub#getLicense(String) GitHub#getLicense(String)
|
* @see GitHub#getLicense(String) GitHub#getLicense(String)
|
||||||
* @see GHRepository#getLicense() GHRepository#getLicense()
|
* @see GHRepository#getLicense() GHRepository#getLicense()
|
||||||
* @see <a href="https://developer.github.com/v3/licenses/">https://developer.github.com/v3/licenses/</a>
|
* @see <a href="https://developer.github.com/v3/licenses/">https://developer.github.com/v3/licenses/</a>
|
||||||
@@ -83,7 +82,7 @@ public class GHLicense extends GHObject {
|
|||||||
*/
|
*/
|
||||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +99,7 @@ public class GHLicense extends GHObject {
|
|||||||
|
|
||||||
public URL getHtmlUrl() throws IOException {
|
public URL getHtmlUrl() throws IOException {
|
||||||
populate();
|
populate();
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +198,7 @@ public class GHLicense extends GHObject {
|
|||||||
if (description != null)
|
if (description != null)
|
||||||
return; // already populated
|
return; // already populated
|
||||||
|
|
||||||
root.retrieve().to(url, this);
|
root.createRequest().withUrlPath(url).fetchInto(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
87
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
87
src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for Github Marketplace Account.
|
||||||
|
*
|
||||||
|
* @see GitHub#getMyMarketplacePurchases()
|
||||||
|
* @see GHMarketplaceListAccountBuilder#createRequest()
|
||||||
|
*/
|
||||||
|
public class GHMarketplaceAccount {
|
||||||
|
|
||||||
|
protected GitHub root;
|
||||||
|
private String url;
|
||||||
|
private long id;
|
||||||
|
private String login;
|
||||||
|
private String email;
|
||||||
|
private String organizationBillingEmail;
|
||||||
|
private GHMarketplaceAccountType type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap up gh marketplace account.
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
* the root
|
||||||
|
* @return an instance of the GHMarketplaceAccount class
|
||||||
|
*/
|
||||||
|
GHMarketplaceAccount wrapUp(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets url.
|
||||||
|
*
|
||||||
|
* @return the url
|
||||||
|
*/
|
||||||
|
public URL getUrl() {
|
||||||
|
return GitHubClient.parseURL(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets id.
|
||||||
|
*
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets login.
|
||||||
|
*
|
||||||
|
* @return the login
|
||||||
|
*/
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets email.
|
||||||
|
*
|
||||||
|
* @return the email
|
||||||
|
*/
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets organization billing email.
|
||||||
|
*
|
||||||
|
* @return the organization billing email
|
||||||
|
*/
|
||||||
|
public String getOrganizationBillingEmail() {
|
||||||
|
return organizationBillingEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets type.
|
||||||
|
*
|
||||||
|
* @return the type
|
||||||
|
*/
|
||||||
|
public GHMarketplaceAccountType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Github Marketplace Account Plan.
|
||||||
|
*
|
||||||
|
* @see GHMarketplaceListAccountBuilder#createRequest()
|
||||||
|
*/
|
||||||
|
public class GHMarketplaceAccountPlan extends GHMarketplaceAccount {
|
||||||
|
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private GHMarketplacePendingChange marketplacePendingChange;
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private GHMarketplacePurchase marketplacePurchase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap up gh marketplace account.
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
* the root
|
||||||
|
* @return an instance of the GHMarketplaceAccount class
|
||||||
|
*/
|
||||||
|
GHMarketplaceAccountPlan wrapUp(GitHub root) {
|
||||||
|
super.wrapUp(root);
|
||||||
|
if (this.marketplacePendingChange != null)
|
||||||
|
this.marketplacePendingChange.wrapUp(this.root);
|
||||||
|
|
||||||
|
if (this.marketplacePurchase != null)
|
||||||
|
this.marketplacePurchase.wrapUp(this.root);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets marketplace pending change.
|
||||||
|
*
|
||||||
|
* @return the marketplace pending change
|
||||||
|
*/
|
||||||
|
public GHMarketplacePendingChange getMarketplacePendingChange() {
|
||||||
|
return marketplacePendingChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets marketplace purchase.
|
||||||
|
*
|
||||||
|
* @return the marketplace purchase
|
||||||
|
*/
|
||||||
|
public GHMarketplacePurchase getMarketplacePurchase() {
|
||||||
|
return marketplacePurchase;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GitHub Marketplace Account type.
|
||||||
|
*
|
||||||
|
* @see GHMarketplaceAccount
|
||||||
|
*/
|
||||||
|
public enum GHMarketplaceAccountType {
|
||||||
|
ORGANIZATION, USER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns GitHub's internal representation of this event.
|
||||||
|
*/
|
||||||
|
String symbol() {
|
||||||
|
return StringUtils.capitalize(name().toLowerCase(Locale.ENGLISH));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns any accounts associated with a plan, including free plans
|
||||||
|
*
|
||||||
|
* @see GHMarketplacePlan#listAccounts()
|
||||||
|
*/
|
||||||
|
public class GHMarketplaceListAccountBuilder {
|
||||||
|
private final GitHub root;
|
||||||
|
private final Requester builder;
|
||||||
|
private final long planId;
|
||||||
|
|
||||||
|
GHMarketplaceListAccountBuilder(GitHub root, long planId) {
|
||||||
|
this.root = root;
|
||||||
|
this.builder = root.createRequest();
|
||||||
|
this.planId = planId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts the GitHub accounts by the date they were created or last updated. Can be one of created or updated.
|
||||||
|
* <p>
|
||||||
|
* If omitted, the default sorting strategy will be "CREATED"
|
||||||
|
*
|
||||||
|
* @param sort
|
||||||
|
* the sort strategy
|
||||||
|
* @return a GHMarketplaceListAccountBuilder
|
||||||
|
*/
|
||||||
|
public GHMarketplaceListAccountBuilder sort(Sort sort) {
|
||||||
|
this.builder.with("sort", sort);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Orders the GitHub accounts results, Can be one of asc or desc. Ignored without the sort parameter.
|
||||||
|
*
|
||||||
|
* @param direction
|
||||||
|
* the order strategy
|
||||||
|
* @return a GHMarketplaceListAccountBuilder
|
||||||
|
*/
|
||||||
|
public GHMarketplaceListAccountBuilder direction(GHDirection direction) {
|
||||||
|
this.builder.with("direction", direction);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum Sort.
|
||||||
|
*/
|
||||||
|
public enum Sort {
|
||||||
|
CREATED, UPDATED
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List any accounts associated with the plan specified on construction with all the order/sort parameters set.
|
||||||
|
* <p>
|
||||||
|
* GitHub Apps must use a JWT to access this endpoint.
|
||||||
|
* <p>
|
||||||
|
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
|
||||||
|
*
|
||||||
|
* @return a paged iterable instance of GHMarketplaceAccountPlan
|
||||||
|
* @throws IOException
|
||||||
|
* on error
|
||||||
|
*/
|
||||||
|
public PagedIterable<GHMarketplaceAccountPlan> createRequest() throws IOException {
|
||||||
|
return builder.withUrlPath(String.format("/marketplace_listing/plans/%d/accounts", this.planId))
|
||||||
|
.toIterable(GHMarketplaceAccountPlan[].class, item -> item.wrapUp(root));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Github Marketplace purchase pending change.
|
||||||
|
*
|
||||||
|
* @see GHMarketplaceListAccountBuilder#createRequest()
|
||||||
|
*/
|
||||||
|
public class GHMarketplacePendingChange {
|
||||||
|
private GitHub root;
|
||||||
|
private long id;
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private Long unitCount;
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private GHMarketplacePlan plan;
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private String effectiveDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap up gh marketplace pending change.
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
* the root
|
||||||
|
* @return an instance of the GHMarketplacePendingChange class
|
||||||
|
*/
|
||||||
|
GHMarketplacePendingChange wrapUp(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
if (plan != null) { // sanity check
|
||||||
|
this.plan.wrapUp(this.root);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets id.
|
||||||
|
*
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets unit count.
|
||||||
|
*
|
||||||
|
* @return the unit count
|
||||||
|
*/
|
||||||
|
public Long getUnitCount() {
|
||||||
|
return unitCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets plan.
|
||||||
|
*
|
||||||
|
* @return the plan
|
||||||
|
*/
|
||||||
|
public GHMarketplacePlan getPlan() {
|
||||||
|
return plan;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets effective date.
|
||||||
|
*
|
||||||
|
* @return the effective date
|
||||||
|
*/
|
||||||
|
public Date getEffectiveDate() {
|
||||||
|
return GitHubClient.parseDate(effectiveDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
183
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
183
src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Github Marketplace plan.
|
||||||
|
*
|
||||||
|
* @see GitHub#listMarketplacePlans()
|
||||||
|
*/
|
||||||
|
public class GHMarketplacePlan {
|
||||||
|
|
||||||
|
private GitHub root;
|
||||||
|
private String url;
|
||||||
|
private String accountsUrl;
|
||||||
|
private long id;
|
||||||
|
private long number;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private long monthlyPriceInCents;
|
||||||
|
private long yearlyPriceInCents;
|
||||||
|
private GHMarketplacePriceModel priceModel;
|
||||||
|
@JsonProperty("has_free_trial")
|
||||||
|
private boolean freeTrial; // JavaBeans Spec 1.01 section 8.3.2 forces us to have is<propertyName>
|
||||||
|
private String unitName;
|
||||||
|
private String state;
|
||||||
|
private List<String> bullets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap up gh marketplace plan.
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
* the root
|
||||||
|
* @return an instance of the GHMarketplacePlan class
|
||||||
|
*/
|
||||||
|
GHMarketplacePlan wrapUp(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets url.
|
||||||
|
*
|
||||||
|
* @return the url
|
||||||
|
*/
|
||||||
|
public URL getUrl() {
|
||||||
|
return GitHubClient.parseURL(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets accounts url.
|
||||||
|
*
|
||||||
|
* @return the accounts url
|
||||||
|
*/
|
||||||
|
public String getAccountsUrl() {
|
||||||
|
return accountsUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets id.
|
||||||
|
*
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets number.
|
||||||
|
*
|
||||||
|
* @return the number
|
||||||
|
*/
|
||||||
|
public long getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets name.
|
||||||
|
*
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets description.
|
||||||
|
*
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets monthly price in cents.
|
||||||
|
*
|
||||||
|
* @return the monthly price in cents
|
||||||
|
*/
|
||||||
|
public long getMonthlyPriceInCents() {
|
||||||
|
return monthlyPriceInCents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets yearly price in cents.
|
||||||
|
*
|
||||||
|
* @return the yearly price in cents
|
||||||
|
*/
|
||||||
|
public long getYearlyPriceInCents() {
|
||||||
|
return yearlyPriceInCents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets price model.
|
||||||
|
*
|
||||||
|
* @return the price model
|
||||||
|
*/
|
||||||
|
public GHMarketplacePriceModel getPriceModel() {
|
||||||
|
return priceModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is free trial boolean.
|
||||||
|
*
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean isFreeTrial() {
|
||||||
|
return freeTrial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets unit name.
|
||||||
|
*
|
||||||
|
* @return the unit name
|
||||||
|
*/
|
||||||
|
public String getUnitName() {
|
||||||
|
return unitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets state.
|
||||||
|
*
|
||||||
|
* @return the state
|
||||||
|
*/
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets bullets.
|
||||||
|
*
|
||||||
|
* @return the bullets
|
||||||
|
*/
|
||||||
|
public List<String> getBullets() {
|
||||||
|
return bullets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a builder that list any accounts associated with a plan, including free plans. For per-seat pricing, you
|
||||||
|
* see the list of accounts that have purchased the plan, including the number of seats purchased. When someone
|
||||||
|
* submits a plan change that won't be processed until the end of their billing cycle, you will also see the
|
||||||
|
* upcoming pending change.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* You use the returned builder to set various properties, then call
|
||||||
|
* {@link GHMarketplaceListAccountBuilder#createRequest()} to finally list the accounts related to this plan.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* GitHub Apps must use a JWT to access this endpoint.
|
||||||
|
* <p>
|
||||||
|
* OAuth Apps must use basic authentication with their client ID and client secret to access this endpoint.
|
||||||
|
*
|
||||||
|
* @return a GHMarketplaceListAccountBuilder instance
|
||||||
|
* @see <a href=
|
||||||
|
* "https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan">List
|
||||||
|
* all GitHub accounts (user or organization) on a specific plan</a>
|
||||||
|
*/
|
||||||
|
public GHMarketplaceListAccountBuilder listAccounts() {
|
||||||
|
return new GHMarketplaceListAccountBuilder(root, this.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GitHub Marketplace plan pricing model.
|
||||||
|
*
|
||||||
|
* @see GHMarketplacePlan
|
||||||
|
*/
|
||||||
|
public enum GHMarketplacePriceModel {
|
||||||
|
FREE("free"), PER_UNIT("per-unit"), FLAT_RATE("flat-rate");
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
private final String internalName;
|
||||||
|
|
||||||
|
GHMarketplacePriceModel(String internalName) {
|
||||||
|
this.internalName = internalName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns GitHub's internal representation of this event.
|
||||||
|
*
|
||||||
|
* @return a string containing GitHub's internal representation of this event.
|
||||||
|
*/
|
||||||
|
public String symbol() {
|
||||||
|
return internalName;
|
||||||
|
}
|
||||||
|
}
|
||||||
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.
|
||||||
|
*
|
||||||
|
* @see GHMarketplaceListAccountBuilder#createRequest() GHMarketplaceListAccountBuilder#createRequest()
|
||||||
|
*/
|
||||||
|
public class GHMarketplacePurchase {
|
||||||
|
|
||||||
|
private GitHub root;
|
||||||
|
private String billingCycle;
|
||||||
|
private String nextBillingDate;
|
||||||
|
private boolean onFreeTrial;
|
||||||
|
private String freeTrialEndsOn;
|
||||||
|
private Long unitCount;
|
||||||
|
private String updatedAt;
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private GHMarketplacePlan plan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap up gh marketplace purchase.
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
* the root
|
||||||
|
* @return an instance of the GHMarketplacePurchase class
|
||||||
|
*/
|
||||||
|
GHMarketplacePurchase wrapUp(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
if (plan != null) { // sanity check
|
||||||
|
this.plan.wrapUp(this.root);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets billing cycle.
|
||||||
|
*
|
||||||
|
* @return the billing cycle
|
||||||
|
*/
|
||||||
|
public String getBillingCycle() {
|
||||||
|
return billingCycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets next billing date.
|
||||||
|
*
|
||||||
|
* @return the next billing date
|
||||||
|
*/
|
||||||
|
public Date getNextBillingDate() {
|
||||||
|
return GitHubClient.parseDate(nextBillingDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is on free trial boolean.
|
||||||
|
*
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean isOnFreeTrial() {
|
||||||
|
return onFreeTrial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets free trial ends on.
|
||||||
|
*
|
||||||
|
* @return the free trial ends on
|
||||||
|
*/
|
||||||
|
public Date getFreeTrialEndsOn() {
|
||||||
|
return GitHubClient.parseDate(freeTrialEndsOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets unit count.
|
||||||
|
*
|
||||||
|
* @return the unit count
|
||||||
|
*/
|
||||||
|
public Long getUnitCount() {
|
||||||
|
return unitCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets updated at.
|
||||||
|
*
|
||||||
|
* @return the updated at
|
||||||
|
*/
|
||||||
|
public Date getUpdatedAt() {
|
||||||
|
return GitHubClient.parseDate(updatedAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets plan.
|
||||||
|
*
|
||||||
|
* @return the plan
|
||||||
|
*/
|
||||||
|
public GHMarketplacePlan getPlan() {
|
||||||
|
return plan;
|
||||||
|
}
|
||||||
|
}
|
||||||
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
|
||||||
|
*
|
||||||
|
* @see GitHub#getMyMarketplacePurchases()
|
||||||
|
*/
|
||||||
|
public class GHMarketplaceUserPurchase {
|
||||||
|
protected GitHub root;
|
||||||
|
private String billingCycle;
|
||||||
|
private String nextBillingDate;
|
||||||
|
private boolean onFreeTrial;
|
||||||
|
private String freeTrialEndsOn;
|
||||||
|
private Long unitCount;
|
||||||
|
private String updatedAt;
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private GHMarketplaceAccount account;
|
||||||
|
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
|
||||||
|
private GHMarketplacePlan plan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap up GHMarketplaceUserPurchase.
|
||||||
|
*
|
||||||
|
* @param root
|
||||||
|
* the root
|
||||||
|
* @return an instance of the GHMarketplaceUserPurchase class
|
||||||
|
*/
|
||||||
|
GHMarketplaceUserPurchase wrapUp(GitHub root) {
|
||||||
|
this.root = root;
|
||||||
|
if (this.account != null)
|
||||||
|
this.account.wrapUp(this.root);
|
||||||
|
if (this.plan != null)
|
||||||
|
this.plan.wrapUp(this.root);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets billing cycle.
|
||||||
|
*
|
||||||
|
* @return the billing cycle
|
||||||
|
*/
|
||||||
|
public String getBillingCycle() {
|
||||||
|
return billingCycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets next billing date.
|
||||||
|
*
|
||||||
|
* @return the next billing date
|
||||||
|
*/
|
||||||
|
public Date getNextBillingDate() {
|
||||||
|
return GitHubClient.parseDate(nextBillingDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is on free trial boolean.
|
||||||
|
*
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean isOnFreeTrial() {
|
||||||
|
return onFreeTrial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets free trial ends on.
|
||||||
|
*
|
||||||
|
* @return the free trial ends on
|
||||||
|
*/
|
||||||
|
public Date getFreeTrialEndsOn() {
|
||||||
|
return GitHubClient.parseDate(freeTrialEndsOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets unit count.
|
||||||
|
*
|
||||||
|
* @return the unit count
|
||||||
|
*/
|
||||||
|
public Long getUnitCount() {
|
||||||
|
return unitCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets updated at.
|
||||||
|
*
|
||||||
|
* @return the updated at
|
||||||
|
*/
|
||||||
|
public Date getUpdatedAt() {
|
||||||
|
return GitHubClient.parseDate(updatedAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets account.
|
||||||
|
*
|
||||||
|
* @return the account
|
||||||
|
*/
|
||||||
|
public GHMarketplaceAccount getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets plan.
|
||||||
|
*
|
||||||
|
* @return the plan
|
||||||
|
*/
|
||||||
|
public GHMarketplacePlan getPlan() {
|
||||||
|
return plan;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,6 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* Represents a membership of a user in an organization.
|
* Represents a membership of a user in an organization.
|
||||||
*
|
*
|
||||||
* @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 GHObject --- but it doesn't have id, created_at, etc. */ {
|
||||||
@@ -25,7 +24,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +71,7 @@ public class GHMembership /* extends GHObject --- but it doesn't have id, create
|
|||||||
* @see GHMyself#getMembership(GHOrganization) GHMyself#getMembership(GHOrganization)
|
* @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) {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Class that wraps the list of GitHub's IP addresses.
|
* Class that wraps the list of GitHub's IP addresses.
|
||||||
*
|
*
|
||||||
* @author Paulo Miguel Almeida
|
|
||||||
* @see GitHub#getMeta() GitHub#getMeta()
|
* @see GitHub#getMeta() GitHub#getMeta()
|
||||||
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
|
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import java.util.Locale;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHMilestone.
|
* The type GHMilestone.
|
||||||
*
|
|
||||||
* @author Yusuke Kokubo
|
|
||||||
*/
|
*/
|
||||||
public class GHMilestone extends GHObject {
|
public class GHMilestone extends GHObject {
|
||||||
GitHub root;
|
GitHub root;
|
||||||
@@ -56,7 +54,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 +65,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 +114,7 @@ public class GHMilestone extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,11 +153,11 @@ public class GHMilestone extends GHObject {
|
|||||||
* the io exception
|
* 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 +193,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The enum GHMilestoneState.
|
* The enum GHMilestoneState.
|
||||||
*
|
|
||||||
* @author Yusuke Kokubo
|
|
||||||
*/
|
*/
|
||||||
public enum GHMilestoneState {
|
public enum GHMilestoneState {
|
||||||
OPEN, CLOSED
|
OPEN, CLOSED
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the account that's logging into GitHub.
|
* Represents the account that's logging into GitHub.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public class GHMyself extends GHUser {
|
public class GHMyself extends GHUser {
|
||||||
|
|
||||||
@@ -71,7 +69,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);
|
GHEmail[] addresses = root.createRequest().withUrlPath("/user/emails").fetchArray(GHEmail[].class);
|
||||||
return Collections.unmodifiableList(Arrays.asList(addresses));
|
return Collections.unmodifiableList(Arrays.asList(addresses));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +84,8 @@ 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 Collections.unmodifiableList(
|
||||||
|
Arrays.asList(root.createRequest().withUrlPath("/user/keys").fetchArray(GHKey[].class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +99,8 @@ 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 Collections.unmodifiableList(Arrays.asList(
|
||||||
Arrays.asList(root.retrieve().to("/users/" + getLogin() + "/keys", GHVerifiedKey[].class)));
|
root.createRequest().withUrlPath("/users/" + getLogin() + "/keys").fetchArray(GHVerifiedKey[].class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +113,7 @@ 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").fetchArray(GHOrganization[].class)) {
|
||||||
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 +174,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,9 +208,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 +224,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 {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import java.util.NoSuchElementException;
|
|||||||
* In the non-blocking mode, the iterator will only report the set of notifications initially retrieved from GitHub,
|
* In the non-blocking mode, the iterator will only report the set of notifications initially retrieved from GitHub,
|
||||||
* then quit. This is useful for a batch application to process the current set of notifications.
|
* then quit. This is useful for a batch application to process the current set of notifications.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GitHub#listNotifications() GitHub#listNotifications()
|
* @see GitHub#listNotifications() GitHub#listNotifications()
|
||||||
* @see GHRepository#listNotifications() GHRepository#listNotifications()
|
* @see GHRepository#listNotifications() GHRepository#listNotifications()
|
||||||
*/
|
*/
|
||||||
@@ -79,7 +78,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 +100,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 +179,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(requester.client, 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,18 +192,16 @@ 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);
|
||||||
@@ -232,10 +233,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];
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This exception is thrown when GitHub is requesting an OTP from the user
|
* This exception is thrown when GitHub is requesting an OTP from the user
|
||||||
*
|
|
||||||
* @author Kevin Harrington mad.hephaestus@gmail.com
|
|
||||||
*/
|
*/
|
||||||
public class GHOTPRequiredException extends GHIOException {
|
public class GHOTPRequiredException extends GHIOException {
|
||||||
// ...
|
// ...
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ 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(created_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
|
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getCreatedAt")
|
||||||
@@ -75,7 +75,7 @@ public abstract class GHObject {
|
|||||||
*/
|
*/
|
||||||
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
@WithBridgeMethods(value = String.class, adapterMethod = "urlToString")
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +96,7 @@ 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(updated_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import static org.kohsuke.github.Previews.INERTIA;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHOrganization.
|
* The type GHOrganization.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public class GHOrganization extends GHPerson {
|
public class GHOrganization extends GHPerson {
|
||||||
GHOrganization wrapUp(GitHub root) {
|
GHOrganization wrapUp(GitHub root) {
|
||||||
@@ -88,7 +86,7 @@ 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
|
||||||
@@ -121,10 +119,9 @@ 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,10 +180,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 +196,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 +213,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 +225,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 +241,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,10 +297,9 @@ public class GHOrganization extends GHPerson {
|
|||||||
|
|
||||||
private PagedIterable<GHUser> listMembers(final String suffix, final String filter) throws IOException {
|
private PagedIterable<GHUser> listMembers(final String suffix, final String filter) throws IOException {
|
||||||
String filterParams = (filter == null) ? "" : ("?filter=" + filter);
|
String filterParams = (filter == null) ? "" : ("?filter=" + filter);
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(String.format("/orgs/%s/%s%s", login, suffix, filterParams),
|
.withUrlPath(String.format("/orgs/%s/%s%s", login, suffix, filterParams))
|
||||||
GHUser[].class,
|
.toIterable(GHUser[].class, item -> item.wrapUp(root));
|
||||||
item -> item.wrapUp(root));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -314,7 +311,7 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,10 +324,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 +354,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,17 +384,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 +410,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 +427,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 +450,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 +513,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 +528,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package org.kohsuke.github;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The enum GHPermissionType.
|
* The enum GHPermissionType.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public enum GHPermissionType {
|
public enum GHPermissionType {
|
||||||
ADMIN, WRITE, READ, NONE
|
ADMIN, WRITE, READ, NONE
|
||||||
|
|||||||
@@ -9,12 +9,11 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common part of {@link GHUser} and {@link GHOrganization}.
|
* Common part of {@link GHUser} and {@link GHOrganization}.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public abstract class GHPerson extends GHObject {
|
public abstract class GHPerson extends GHObject {
|
||||||
/* package almost final */ GitHub root;
|
/* package almost final */ GitHub root;
|
||||||
@@ -23,9 +22,13 @@ public abstract class GHPerson extends GHObject {
|
|||||||
protected String login, avatar_url, gravatar_id;
|
protected String login, avatar_url, gravatar_id;
|
||||||
|
|
||||||
// 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, name, company, type;
|
||||||
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;
|
||||||
|
|
||||||
|
// 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;
|
||||||
@@ -47,7 +50,7 @@ public abstract class GHPerson extends GHObject {
|
|||||||
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);
|
root.createRequest().withUrlPath(url).fetchInto(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,8 +91,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +116,9 @@ public abstract class GHPerson extends GHObject {
|
|||||||
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
|
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
|
||||||
return new Iterable<List<GHRepository>>() {
|
return new Iterable<List<GHRepository>>() {
|
||||||
public Iterator<List<GHRepository>> iterator() {
|
public Iterator<List<GHRepository>> iterator() {
|
||||||
final Iterator<GHRepository[]> pager = root.retrieve()
|
final Iterator<GHRepository[]> pager = GitHubPageIterator.create(root.getClient(),
|
||||||
.asIterator("/users/" + login + "/repos", GHRepository[].class, pageSize);
|
GHRepository[].class,
|
||||||
|
root.createRequest().withUrlPath("users", login, "repos").withPageSize(pageSize));
|
||||||
|
|
||||||
return new Iterator<List<GHRepository>>() {
|
return new Iterator<List<GHRepository>>() {
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@@ -146,7 +151,10 @@ 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 root.createRequest()
|
||||||
|
.withUrlPath("/repos/" + login + '/' + name)
|
||||||
|
.fetch(GHRepository.class)
|
||||||
|
.wrap(root);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -254,7 +262,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 +324,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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.HashSet;
|
|||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* the type parameter
|
* the type parameter
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public class GHPersonSet<T extends GHPerson> extends HashSet<T> {
|
public class GHPersonSet<T extends GHPerson> extends HashSet<T> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import static org.kohsuke.github.Previews.INERTIA;
|
|||||||
/**
|
/**
|
||||||
* A GitHub project.
|
* A GitHub project.
|
||||||
*
|
*
|
||||||
* @author Martin van Zijl
|
|
||||||
* @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 {
|
||||||
@@ -51,7 +50,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 +73,17 @@ 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);
|
owner = root.createRequest()
|
||||||
|
.withUrlPath(getOwnerUrl().getPath())
|
||||||
|
.fetch(GHRepository.class)
|
||||||
|
.wrap(root);
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
@@ -93,7 +98,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,7 +181,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -270,7 +275,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 +287,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", id))
|
||||||
GHProjectColumn[].class,
|
.toIterable(GHProjectColumn[].class, item -> item.wrap(project));
|
||||||
item -> item.wrap(project));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,11 +303,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", id))
|
||||||
|
.fetch(GHProjectColumn.class)
|
||||||
.wrap(this);
|
.wrap(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,6 @@ import static org.kohsuke.github.Previews.INERTIA;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHProjectCard.
|
* The type GHProjectCard.
|
||||||
*
|
|
||||||
* @author Gunnar Skjold
|
|
||||||
*/
|
*/
|
||||||
public class GHProjectCard extends GHObject {
|
public class GHProjectCard extends GHObject {
|
||||||
private GitHub root;
|
private GitHub root;
|
||||||
@@ -72,7 +70,7 @@ public class GHProjectCard extends GHObject {
|
|||||||
public GHProject getProject() throws IOException {
|
public GHProject getProject() throws IOException {
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
try {
|
try {
|
||||||
project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root);
|
project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -90,7 +88,10 @@ public class GHProjectCard extends GHObject {
|
|||||||
public GHProjectColumn getColumn() throws IOException {
|
public GHProjectColumn getColumn() throws IOException {
|
||||||
if (column == null) {
|
if (column == null) {
|
||||||
try {
|
try {
|
||||||
column = root.retrieve().to(getColumnUrl().getPath(), GHProjectColumn.class).wrap(root);
|
column = root.createRequest()
|
||||||
|
.withUrlPath(getColumnUrl().getPath())
|
||||||
|
.fetch(GHProjectColumn.class)
|
||||||
|
.wrap(root);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -110,9 +111,12 @@ public class GHProjectCard extends GHObject {
|
|||||||
return null;
|
return null;
|
||||||
try {
|
try {
|
||||||
if (content_url.contains("/pulls")) {
|
if (content_url.contains("/pulls")) {
|
||||||
return root.retrieve().to(getContentUrl().getPath(), GHPullRequest.class).wrap(root);
|
return root.createRequest()
|
||||||
|
.withUrlPath(getContentUrl().getPath())
|
||||||
|
.fetch(GHPullRequest.class)
|
||||||
|
.wrap(root);
|
||||||
} else {
|
} else {
|
||||||
return root.retrieve().to(getContentUrl().getPath(), GHIssue.class).wrap(root);
|
return root.createRequest().withUrlPath(getContentUrl().getPath()).fetch(GHIssue.class).wrap(root);
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
@@ -143,7 +147,7 @@ public class GHProjectCard extends GHObject {
|
|||||||
* @return the content url
|
* @return the content url
|
||||||
*/
|
*/
|
||||||
public URL getContentUrl() {
|
public URL getContentUrl() {
|
||||||
return GitHub.parseURL(content_url);
|
return GitHubClient.parseURL(content_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,7 +156,7 @@ public class GHProjectCard extends GHObject {
|
|||||||
* @return the project url
|
* @return the project url
|
||||||
*/
|
*/
|
||||||
public URL getProjectUrl() {
|
public URL getProjectUrl() {
|
||||||
return GitHub.parseURL(project_url);
|
return GitHubClient.parseURL(project_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,7 +165,7 @@ public class GHProjectCard extends GHObject {
|
|||||||
* @return the column url
|
* @return the column url
|
||||||
*/
|
*/
|
||||||
public URL getColumnUrl() {
|
public URL getColumnUrl() {
|
||||||
return GitHub.parseURL(column_url);
|
return GitHubClient.parseURL(column_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,7 +202,7 @@ public class GHProjectCard extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void edit(String key, Object value) throws IOException {
|
private void edit(String key, Object value) throws IOException {
|
||||||
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
|
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,6 +221,6 @@ public class GHProjectCard extends GHObject {
|
|||||||
* the io exception
|
* 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import static org.kohsuke.github.Previews.INERTIA;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The type GHProjectColumn.
|
* The type GHProjectColumn.
|
||||||
*
|
|
||||||
* @author Gunnar Skjold
|
|
||||||
*/
|
*/
|
||||||
public class GHProjectColumn extends GHObject {
|
public class GHProjectColumn extends GHObject {
|
||||||
protected GitHub root;
|
protected GitHub root;
|
||||||
@@ -67,7 +65,7 @@ public class GHProjectColumn extends GHObject {
|
|||||||
public GHProject getProject() throws IOException {
|
public GHProject getProject() throws IOException {
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
try {
|
try {
|
||||||
project = root.retrieve().to(getProjectUrl().getPath(), GHProject.class).wrap(root);
|
project = root.createRequest().withUrlPath(getProjectUrl().getPath()).fetch(GHProject.class).wrap(root);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -90,7 +88,7 @@ public class GHProjectColumn extends GHObject {
|
|||||||
* @return the project url
|
* @return the project url
|
||||||
*/
|
*/
|
||||||
public URL getProjectUrl() {
|
public URL getProjectUrl() {
|
||||||
return GitHub.parseURL(project_url);
|
return GitHubClient.parseURL(project_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +104,7 @@ public class GHProjectColumn extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void edit(String key, Object value) throws IOException {
|
private void edit(String key, Object value) throws IOException {
|
||||||
new Requester(root).withPreview(INERTIA).with(key, value).method("PATCH").to(getApiRoute());
|
root.createRequest().method("PATCH").withPreview(INERTIA).with(key, value).withUrlPath(getApiRoute()).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,7 +123,7 @@ public class GHProjectColumn extends GHObject {
|
|||||||
* the io exception
|
* 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,11 +135,10 @@ public class GHProjectColumn extends GHObject {
|
|||||||
*/
|
*/
|
||||||
public PagedIterable<GHProjectCard> listCards() throws IOException {
|
public PagedIterable<GHProjectCard> listCards() throws IOException {
|
||||||
final GHProjectColumn column = this;
|
final GHProjectColumn column = this;
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.withPreview(INERTIA)
|
.withPreview(INERTIA)
|
||||||
.asPagedIterable(String.format("/projects/columns/%d/cards", id),
|
.withUrlPath(String.format("/projects/columns/%d/cards", id))
|
||||||
GHProjectCard[].class,
|
.toIterable(GHProjectCard[].class, item -> item.wrap(column));
|
||||||
item -> item.wrap(column));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -154,11 +151,12 @@ public class GHProjectColumn extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHProjectCard createCard(String note) throws IOException {
|
public GHProjectCard createCard(String note) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.withPreview(INERTIA)
|
.withPreview(INERTIA)
|
||||||
.with("note", note)
|
.with("note", note)
|
||||||
.to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class)
|
.withUrlPath(String.format("/projects/columns/%d/cards", id))
|
||||||
|
.fetch(GHProjectCard.class)
|
||||||
.wrap(this);
|
.wrap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,12 +170,13 @@ public class GHProjectColumn extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHProjectCard createCard(GHIssue issue) throws IOException {
|
public GHProjectCard createCard(GHIssue issue) throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.withPreview(INERTIA)
|
.withPreview(INERTIA)
|
||||||
.with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")
|
.with("content_type", issue instanceof GHPullRequest ? "PullRequest" : "Issue")
|
||||||
.with("content_id", issue.getId())
|
.with("content_id", issue.getId())
|
||||||
.to(String.format("/projects/columns/%d/cards", id), GHProjectCard.class)
|
.withUrlPath(String.format("/projects/columns/%d/cards", id))
|
||||||
|
.fetch(GHProjectCard.class)
|
||||||
.wrap(this);
|
.wrap(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.kohsuke.github;
|
package org.kohsuke.github;
|
||||||
|
|
||||||
|
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.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -39,7 +41,6 @@ import static org.kohsuke.github.Previews.SHADOW_CAT;
|
|||||||
/**
|
/**
|
||||||
* A pull request.
|
* A pull request.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHRepository#getPullRequest(int) GHRepository#getPullRequest(int)
|
* @see GHRepository#getPullRequest(int) GHRepository#getPullRequest(int)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "UnusedDeclaration" })
|
@SuppressWarnings({ "UnusedDeclaration" })
|
||||||
@@ -99,6 +100,10 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getApiRoute() {
|
protected String getApiRoute() {
|
||||||
|
if (owner == null) {
|
||||||
|
// Issues returned from search to do not have an owner. Attempt to use url.
|
||||||
|
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
|
||||||
|
}
|
||||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
|
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +113,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* @return the patch url
|
* @return the patch url
|
||||||
*/
|
*/
|
||||||
public URL getPatchUrl() {
|
public URL getPatchUrl() {
|
||||||
return GitHub.parseURL(patch_url);
|
return GitHubClient.parseURL(patch_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +122,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* @return the issue url
|
* @return the issue url
|
||||||
*/
|
*/
|
||||||
public URL getIssueUrl() {
|
public URL getIssueUrl() {
|
||||||
return GitHub.parseURL(issue_url);
|
return GitHubClient.parseURL(issue_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,7 +161,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* @return the diff url
|
* @return the diff url
|
||||||
*/
|
*/
|
||||||
public URL getDiffUrl() {
|
public URL getDiffUrl() {
|
||||||
return GitHub.parseURL(diff_url);
|
return GitHubClient.parseURL(diff_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,7 +170,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* @return the merged at
|
* @return the merged at
|
||||||
*/
|
*/
|
||||||
public Date getMergedAt() {
|
public Date getMergedAt() {
|
||||||
return GitHub.parseDate(merged_at);
|
return GitHubClient.parseDate(merged_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -384,7 +389,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
if (root.isOffline()) {
|
if (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().withPreview(SHADOW_CAT).to(url, this).wrapUp(owner);
|
root.createRequest().withPreview(SHADOW_CAT).withUrlPath(url).fetchInto(this).wrapUp(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,8 +398,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHPullRequestFileDetail> listFiles() {
|
public PagedIterable<GHPullRequestFileDetail> listFiles() {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(String.format("%s/files", getApiRoute()), GHPullRequestFileDetail[].class, null);
|
.withUrlPath(String.format("%s/files", getApiRoute()))
|
||||||
|
.toIterable(GHPullRequestFileDetail[].class, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -403,10 +409,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHPullRequestReview> listReviews() {
|
public PagedIterable<GHPullRequestReview> listReviews() {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(String.format("%s/reviews", getApiRoute()),
|
.withUrlPath(String.format("%s/reviews", getApiRoute()))
|
||||||
GHPullRequestReview[].class,
|
.toIterable(GHPullRequestReview[].class, item -> item.wrapUp(this));
|
||||||
item -> item.wrapUp(GHPullRequest.this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -417,10 +422,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
|
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(getApiRoute() + COMMENTS_ACTION,
|
.withUrlPath(getApiRoute() + COMMENTS_ACTION)
|
||||||
GHPullRequestReviewComment[].class,
|
.toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(this));
|
||||||
item -> item.wrapUp(GHPullRequest.this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -429,10 +433,9 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* @return the paged iterable
|
* @return the paged iterable
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHPullRequestCommitDetail> listCommits() {
|
public PagedIterable<GHPullRequestCommitDetail> listCommits() {
|
||||||
return root.retrieve()
|
return root.createRequest()
|
||||||
.asPagedIterable(String.format("%s/commits", getApiRoute()),
|
.withUrlPath(String.format("%s/commits", getApiRoute()))
|
||||||
GHPullRequestCommitDetail[].class,
|
.toIterable(GHPullRequestCommitDetail[].class, item -> item.wrapUp(this));
|
||||||
item -> item.wrapUp(GHPullRequest.this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -505,12 +508,14 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
*/
|
*/
|
||||||
public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position)
|
public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return new Requester(root).method("POST")
|
return root.createRequest()
|
||||||
|
.method("POST")
|
||||||
.with("body", body)
|
.with("body", body)
|
||||||
.with("commit_id", sha)
|
.with("commit_id", sha)
|
||||||
.with("path", path)
|
.with("path", path)
|
||||||
.with("position", position)
|
.with("position", position)
|
||||||
.to(getApiRoute() + COMMENTS_ACTION, GHPullRequestReviewComment.class)
|
.withUrlPath(getApiRoute() + COMMENTS_ACTION)
|
||||||
|
.fetch(GHPullRequestReviewComment.class)
|
||||||
.wrapUp(this);
|
.wrapUp(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,9 +528,11 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void requestReviewers(List<GHUser> reviewers) throws IOException {
|
public void requestReviewers(List<GHUser> reviewers) throws IOException {
|
||||||
new Requester(root).method("POST")
|
root.createRequest()
|
||||||
|
.method("POST")
|
||||||
.with("reviewers", getLogins(reviewers))
|
.with("reviewers", getLogins(reviewers))
|
||||||
.to(getApiRoute() + REQUEST_REVIEWERS);
|
.withUrlPath(getApiRoute() + REQUEST_REVIEWERS)
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -541,7 +548,11 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
for (GHTeam team : teams) {
|
for (GHTeam team : teams) {
|
||||||
teamReviewers.add(team.getSlug());
|
teamReviewers.add(team.getSlug());
|
||||||
}
|
}
|
||||||
new Requester(root).method("POST").with("team_reviewers", teamReviewers).to(getApiRoute() + REQUEST_REVIEWERS);
|
root.createRequest()
|
||||||
|
.method("POST")
|
||||||
|
.with("team_reviewers", teamReviewers)
|
||||||
|
.withUrlPath(getApiRoute() + REQUEST_REVIEWERS)
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -589,11 +600,13 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void merge(String msg, String sha, MergeMethod method) throws IOException {
|
public void merge(String msg, String sha, MergeMethod method) throws IOException {
|
||||||
new Requester(root).method("PUT")
|
root.createRequest()
|
||||||
|
.method("PUT")
|
||||||
.with("commit_message", msg)
|
.with("commit_message", msg)
|
||||||
.with("sha", sha)
|
.with("sha", sha)
|
||||||
.with("merge_method", method)
|
.with("merge_method", method)
|
||||||
.to(getApiRoute() + "/merge");
|
.withUrlPath(getApiRoute() + "/merge")
|
||||||
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -605,7 +618,7 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
|||||||
|
|
||||||
private void fetchIssue() throws IOException {
|
private void fetchIssue() throws IOException {
|
||||||
if (!fetchedIssueDetails) {
|
if (!fetchedIssueDetails) {
|
||||||
new Requester(root).method("GET").to(getIssuesApiRoute(), this);
|
root.createRequest().withUrlPath(getIssuesApiRoute()).fetchInto(this);
|
||||||
fetchedIssueDetails = true;
|
fetchedIssueDetails = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import java.net.URL;
|
|||||||
/**
|
/**
|
||||||
* Commit detail inside a {@link GHPullRequest}.
|
* Commit detail inside a {@link GHPullRequest}.
|
||||||
*
|
*
|
||||||
* @author Luca Milanesio
|
|
||||||
* @see GHPullRequest#listCommits() GHPullRequest#listCommits()
|
* @see GHPullRequest#listCommits() GHPullRequest#listCommits()
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(
|
@SuppressFBWarnings(
|
||||||
@@ -75,7 +74,7 @@ public class GHPullRequestCommitDetail {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +124,7 @@ public class GHPullRequestCommitDetail {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,7 +160,7 @@ public class GHPullRequestCommitDetail {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,7 +169,7 @@ public class GHPullRequestCommitDetail {
|
|||||||
* @return the html url
|
* @return the html url
|
||||||
*/
|
*/
|
||||||
public URL getHtml_url() {
|
public URL getHtml_url() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +213,7 @@ public class GHPullRequestCommitDetail {
|
|||||||
* @return the api url
|
* @return the api url
|
||||||
*/
|
*/
|
||||||
public URL getApiUrl() {
|
public URL getApiUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +222,7 @@ public class GHPullRequestCommitDetail {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,7 +231,7 @@ public class GHPullRequestCommitDetail {
|
|||||||
* @return the comments url
|
* @return the comments url
|
||||||
*/
|
*/
|
||||||
public URL getCommentsUrl() {
|
public URL getCommentsUrl() {
|
||||||
return GitHub.parseURL(comments_url);
|
return GitHubClient.parseURL(comments_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import java.net.URL;
|
|||||||
/**
|
/**
|
||||||
* File detail inside a {@link GHPullRequest}.
|
* File detail inside a {@link GHPullRequest}.
|
||||||
*
|
*
|
||||||
* @author Julien Henry
|
|
||||||
* @see GHPullRequest#listFiles() GHPullRequest#listFiles()
|
* @see GHPullRequest#listFiles() GHPullRequest#listFiles()
|
||||||
*/
|
*/
|
||||||
public class GHPullRequestFileDetail {
|
public class GHPullRequestFileDetail {
|
||||||
@@ -105,7 +104,7 @@ public class GHPullRequestFileDetail {
|
|||||||
* @return the blob url
|
* @return the blob url
|
||||||
*/
|
*/
|
||||||
public URL getBlobUrl() {
|
public URL getBlobUrl() {
|
||||||
return GitHub.parseURL(blob_url);
|
return GitHubClient.parseURL(blob_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +113,7 @@ public class GHPullRequestFileDetail {
|
|||||||
* @return the raw url
|
* @return the raw url
|
||||||
*/
|
*/
|
||||||
public URL getRawUrl() {
|
public URL getRawUrl() {
|
||||||
return GitHub.parseURL(raw_url);
|
return GitHubClient.parseURL(raw_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,7 +122,7 @@ public class GHPullRequestFileDetail {
|
|||||||
* @return the contents url
|
* @return the contents url
|
||||||
*/
|
*/
|
||||||
public URL getContentsUrl() {
|
public URL getContentsUrl() {
|
||||||
return GitHub.parseURL(contents_url);
|
return GitHubClient.parseURL(contents_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import static org.kohsuke.github.Previews.SHADOW_CAT;
|
|||||||
/**
|
/**
|
||||||
* Lists up pull requests with some filtering and sorting.
|
* Lists up pull requests with some filtering and sorting.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHRepository#queryPullRequests() GHRepository#queryPullRequests()
|
* @see GHRepository#queryPullRequests() GHRepository#queryPullRequests()
|
||||||
*/
|
*/
|
||||||
public class GHPullRequestQueryBuilder extends GHQueryBuilder<GHPullRequest> {
|
public class GHPullRequestQueryBuilder extends GHQueryBuilder<GHPullRequest> {
|
||||||
@@ -89,6 +88,7 @@ public class GHPullRequestQueryBuilder extends GHQueryBuilder<GHPullRequest> {
|
|||||||
@Override
|
@Override
|
||||||
public PagedIterable<GHPullRequest> list() {
|
public PagedIterable<GHPullRequest> list() {
|
||||||
return req.withPreview(SHADOW_CAT)
|
return req.withPreview(SHADOW_CAT)
|
||||||
.asPagedIterable(repo.getApiTailUrl("pulls"), GHPullRequest[].class, item -> item.wrapUp(repo));
|
.withUrlPath(repo.getApiTailUrl("pulls"))
|
||||||
|
.toIterable(GHPullRequest[].class, item -> item.wrapUp(repo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class GHPullRequestReview extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public Date getSubmittedAt() throws IOException {
|
public Date getSubmittedAt() throws IOException {
|
||||||
return GitHub.parseDate(submitted_at);
|
return GitHubClient.parseDate(submitted_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,10 +160,12 @@ public class GHPullRequestReview extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void submit(String body, GHPullRequestReviewEvent event) throws IOException {
|
public void submit(String body, GHPullRequestReviewEvent event) throws IOException {
|
||||||
new Requester(owner.root).method("POST")
|
owner.root.createRequest()
|
||||||
|
.method("POST")
|
||||||
.with("body", body)
|
.with("body", body)
|
||||||
.with("event", event.action())
|
.with("event", event.action())
|
||||||
.to(getApiRoute() + "/events", this);
|
.withUrlPath(getApiRoute() + "/events")
|
||||||
|
.fetchInto(this);
|
||||||
this.body = body;
|
this.body = body;
|
||||||
this.state = event.toState();
|
this.state = event.toState();
|
||||||
}
|
}
|
||||||
@@ -175,7 +177,7 @@ public class GHPullRequestReview extends GHObject {
|
|||||||
* 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,7 +189,11 @@ public class GHPullRequestReview extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void dismiss(String message) throws IOException {
|
public void dismiss(String message) throws IOException {
|
||||||
new Requester(owner.root).method("PUT").with("message", message).to(getApiRoute() + "/dismissals");
|
owner.root.createRequest()
|
||||||
|
.method("PUT")
|
||||||
|
.with("message", message)
|
||||||
|
.withUrlPath(getApiRoute() + "/dismissals")
|
||||||
|
.send();
|
||||||
state = GHPullRequestReviewState.DISMISSED;
|
state = GHPullRequestReviewState.DISMISSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,9 +205,8 @@ public class GHPullRequestReview extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
|
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException {
|
||||||
return owner.root.retrieve()
|
return owner.root.createRequest()
|
||||||
.asPagedIterable(getApiRoute() + "/comments",
|
.withUrlPath(getApiRoute() + "/comments")
|
||||||
GHPullRequestReviewComment[].class,
|
.toIterable(GHPullRequestReviewComment[].class, item -> item.wrapUp(owner));
|
||||||
item -> item.wrapUp(owner));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Builds up a creation of new {@link GHPullRequestReview}.
|
* Builds up a creation of new {@link GHPullRequestReview}.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see GHPullRequest#createReview() GHPullRequest#createReview()
|
* @see GHPullRequest#createReview() GHPullRequest#createReview()
|
||||||
*/
|
*/
|
||||||
public class GHPullRequestReviewBuilder {
|
public class GHPullRequestReviewBuilder {
|
||||||
@@ -17,7 +16,7 @@ public class GHPullRequestReviewBuilder {
|
|||||||
|
|
||||||
GHPullRequestReviewBuilder(GHPullRequest pr) {
|
GHPullRequestReviewBuilder(GHPullRequest pr) {
|
||||||
this.pr = pr;
|
this.pr = pr;
|
||||||
this.builder = new Requester(pr.root);
|
this.builder = pr.root.createRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public GHPullRequestReview createReview(@Nullable String commitId, String body, GHPullRequestReviewEvent event,
|
// public GHPullRequestReview createReview(@Nullable String commitId, String body, GHPullRequestReviewEvent event,
|
||||||
@@ -91,7 +90,8 @@ public class GHPullRequestReviewBuilder {
|
|||||||
public GHPullRequestReview create() throws IOException {
|
public GHPullRequestReview create() throws IOException {
|
||||||
return builder.method("POST")
|
return builder.method("POST")
|
||||||
.with("comments", comments)
|
.with("comments", comments)
|
||||||
.to(pr.getApiRoute() + "/reviews", GHPullRequestReview.class)
|
.withUrlPath(pr.getApiRoute() + "/reviews")
|
||||||
|
.fetch(GHPullRequestReview.class)
|
||||||
.wrapUp(pr);
|
.wrapUp(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import static org.kohsuke.github.Previews.*;
|
|||||||
/**
|
/**
|
||||||
* Review comment to the pull request
|
* Review comment to the pull request
|
||||||
*
|
*
|
||||||
* @author Julien Henry
|
|
||||||
* @see GHPullRequest#listReviewComments() GHPullRequest#listReviewComments()
|
* @see GHPullRequest#listReviewComments() GHPullRequest#listReviewComments()
|
||||||
* @see GHPullRequest#createReviewComment(String, String, String, int) GHPullRequest#createReviewComment(String, String,
|
* @see GHPullRequest#createReviewComment(String, String, String, int) GHPullRequest#createReviewComment(String, String,
|
||||||
* String, int)
|
* String, int)
|
||||||
@@ -163,7 +162,7 @@ public class GHPullRequestReviewComment 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).method("PATCH").with("body", body).to(getApiRoute(), this);
|
owner.root.createRequest().method("PATCH").with("body", body).withUrlPath(getApiRoute()).fetchInto(this);
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +173,7 @@ public class GHPullRequestReviewComment 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,27 +186,33 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHPullRequestReviewComment reply(String body) throws IOException {
|
public GHPullRequestReviewComment reply(String body) throws IOException {
|
||||||
return new Requester(owner.root).method("POST")
|
return owner.root.createRequest()
|
||||||
|
.method("POST")
|
||||||
.with("body", body)
|
.with("body", body)
|
||||||
.with("in_reply_to", getId())
|
.with("in_reply_to", getId())
|
||||||
.to(getApiRoute() + "/comments", GHPullRequestReviewComment.class)
|
.withUrlPath(getApiRoute() + "/comments")
|
||||||
|
.fetch(GHPullRequestReviewComment.class)
|
||||||
.wrapUp(owner);
|
.wrapUp(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@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
|
||||||
@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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package org.kohsuke.github;
|
|||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* the type parameter
|
* the type parameter
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
public abstract class GHQueryBuilder<T> {
|
public abstract class GHQueryBuilder<T> {
|
||||||
protected final GitHub root;
|
protected final GitHub root;
|
||||||
@@ -13,7 +12,7 @@ public abstract class GHQueryBuilder<T> {
|
|||||||
|
|
||||||
GHQueryBuilder(GitHub root) {
|
GHQueryBuilder(GitHub root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.req = root.retrieve();
|
this.req = root.createRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,14 +12,13 @@ import java.util.Date;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.annotation.CheckForNull;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import static java.util.logging.Level.FINEST;
|
import static java.util.logging.Level.FINEST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rate limit.
|
* Rate limit.
|
||||||
*
|
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
|
||||||
public class GHRateLimit {
|
public class GHRateLimit {
|
||||||
@@ -41,7 +40,10 @@ public class GHRateLimit {
|
|||||||
public int limit;
|
public int limit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time at which the current rate limit window resets in UTC epoch seconds. NOTE: that means to
|
* The time at which the current rate limit window resets in UTC epoch seconds. WARNING: this field was implemented
|
||||||
|
* using {@link Date#Date(long)} which expects UTC epoch milliseconds, so this Date instance is meaningless as a
|
||||||
|
* date. To use this field in any meaningful way, it must be converted to a long using {@link Date#getTime()}
|
||||||
|
* multiplied by 1000.
|
||||||
*
|
*
|
||||||
* @deprecated This value should never have been made public. Use {@link #getResetDate()}
|
* @deprecated This value should never have been made public. Use {@link #getResetDate()}
|
||||||
*/
|
*/
|
||||||
@@ -60,6 +62,7 @@ public class GHRateLimit {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private final Record integrationManifest;
|
private final Record integrationManifest;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
static GHRateLimit Unknown() {
|
static GHRateLimit Unknown() {
|
||||||
return new GHRateLimit(new UnknownLimitRecord(),
|
return new GHRateLimit(new UnknownLimitRecord(),
|
||||||
new UnknownLimitRecord(),
|
new UnknownLimitRecord(),
|
||||||
@@ -67,6 +70,7 @@ public class GHRateLimit {
|
|||||||
new UnknownLimitRecord());
|
new UnknownLimitRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
static GHRateLimit fromHeaderRecord(Record header) {
|
static GHRateLimit fromHeaderRecord(Record header) {
|
||||||
return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord());
|
return new GHRateLimit(header, new UnknownLimitRecord(), new UnknownLimitRecord(), new UnknownLimitRecord());
|
||||||
}
|
}
|
||||||
@@ -76,6 +80,12 @@ public class GHRateLimit {
|
|||||||
@Nonnull @JsonProperty("search") Record search,
|
@Nonnull @JsonProperty("search") Record search,
|
||||||
@Nonnull @JsonProperty("graphql") Record graphql,
|
@Nonnull @JsonProperty("graphql") Record graphql,
|
||||||
@Nonnull @JsonProperty("integration_manifest") Record integrationManifest) {
|
@Nonnull @JsonProperty("integration_manifest") Record integrationManifest) {
|
||||||
|
// The Nonnull annotation is ignored by Jackson, we have to check manually
|
||||||
|
Objects.requireNonNull(core);
|
||||||
|
Objects.requireNonNull(search);
|
||||||
|
Objects.requireNonNull(graphql);
|
||||||
|
Objects.requireNonNull(integrationManifest);
|
||||||
|
|
||||||
this.core = core;
|
this.core = core;
|
||||||
this.search = search;
|
this.search = search;
|
||||||
this.graphql = graphql;
|
this.graphql = graphql;
|
||||||
@@ -84,6 +94,7 @@ public class GHRateLimit {
|
|||||||
// Deprecated fields
|
// Deprecated fields
|
||||||
this.remaining = core.getRemaining();
|
this.remaining = core.getRemaining();
|
||||||
this.limit = core.getLimit();
|
this.limit = core.getLimit();
|
||||||
|
// This is wrong but is how this was implemented. Kept for backward compat.
|
||||||
this.reset = new Date(core.getResetEpochSeconds());
|
this.reset = new Date(core.getResetEpochSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +217,28 @@ public class GHRateLimit {
|
|||||||
return Objects.hash(getCore(), getSearch(), getGraphQL(), getIntegrationManifest());
|
return Objects.hash(getCore(), getSearch(), getGraphQL(), getIntegrationManifest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the appropriate {@link Record} for a particular url path.
|
||||||
|
*
|
||||||
|
* @param urlPath
|
||||||
|
* the url path of the request
|
||||||
|
* @return the {@link Record} for a url path.
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
Record getRecordForUrlPath(@Nonnull String urlPath) {
|
||||||
|
if (urlPath.equals("/rate_limit")) {
|
||||||
|
return new UnknownLimitRecord();
|
||||||
|
} else if (urlPath.startsWith("/search")) {
|
||||||
|
return getSearch();
|
||||||
|
} else if (urlPath.startsWith("/graphql")) {
|
||||||
|
return getGraphQL();
|
||||||
|
} else if (urlPath.startsWith("/app-manifests")) {
|
||||||
|
return getIntegrationManifest();
|
||||||
|
} else {
|
||||||
|
return getCore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A limit record used as a placeholder when the the actual limit is not known.
|
* A limit record used as a placeholder when the the actual limit is not known.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -244,6 +277,8 @@ public class GHRateLimit {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The time at which the current rate limit window resets in UTC epoch seconds.
|
* The time at which the current rate limit window resets in UTC epoch seconds.
|
||||||
|
*
|
||||||
|
* This is the raw value returned by the server.
|
||||||
*/
|
*/
|
||||||
private final long resetEpochSeconds;
|
private final long resetEpochSeconds;
|
||||||
|
|
||||||
@@ -253,8 +288,12 @@ public class GHRateLimit {
|
|||||||
private final long createdAtEpochSeconds = System.currentTimeMillis() / 1000;
|
private final long createdAtEpochSeconds = System.currentTimeMillis() / 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The calculated time at which the rate limit will reset. Recalculated if {@link #recalculateResetDate} is
|
* The time at which the rate limit will reset. This value is calculated based on
|
||||||
* called.
|
* {@link #getResetEpochSeconds()} by calling {@link #recalculateResetDate}. If the clock on the local machine
|
||||||
|
* not synchronized with the server clock, this time value will be adjusted to match the local machine's clock.
|
||||||
|
* <p>
|
||||||
|
* Recalculated by calling {@link #recalculateResetDate}.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private Date resetDate;
|
private Date resetDate;
|
||||||
@@ -270,9 +309,9 @@ public class GHRateLimit {
|
|||||||
* the reset epoch seconds
|
* the reset epoch seconds
|
||||||
*/
|
*/
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public Record(@JsonProperty("limit") int limit,
|
public Record(@JsonProperty(value = "limit", required = true) int limit,
|
||||||
@JsonProperty("remaining") int remaining,
|
@JsonProperty(value = "remaining", required = true) int remaining,
|
||||||
@JsonProperty("reset") long resetEpochSeconds) {
|
@JsonProperty(value = "reset", required = true) long resetEpochSeconds) {
|
||||||
this(limit, remaining, resetEpochSeconds, null);
|
this(limit, remaining, resetEpochSeconds, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +328,7 @@ public class GHRateLimit {
|
|||||||
* the updated at
|
* the updated at
|
||||||
*/
|
*/
|
||||||
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "Deprecated")
|
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "Deprecated")
|
||||||
public Record(int limit, int remaining, long resetEpochSeconds, String updatedAt) {
|
public Record(int limit, int remaining, long resetEpochSeconds, @CheckForNull String updatedAt) {
|
||||||
this.limit = limit;
|
this.limit = limit;
|
||||||
this.remaining = remaining;
|
this.remaining = remaining;
|
||||||
this.resetEpochSeconds = resetEpochSeconds;
|
this.resetEpochSeconds = resetEpochSeconds;
|
||||||
@@ -297,14 +336,33 @@ public class GHRateLimit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recalculates the reset date using the server response date to calculate a time duration and then add that to
|
* Recalculates the {@link #resetDate} relative to the local machine clock.
|
||||||
* the local created time for this record.
|
* <p>
|
||||||
|
* {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetDate()} to make decisions about
|
||||||
|
* how long to wait for until for the rate limit to reset. That means that {@link #getResetDate()} needs to be
|
||||||
|
* accurate to the local machine.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* When we say that the clock on two machines is "synchronized", we mean that the UTC time returned from
|
||||||
|
* {@link System#currentTimeMillis()} on each machine is basically the same. For the purposes of rate limits an
|
||||||
|
* differences of up to a second can be ignored.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* When the clock on the local machine is synchronized to the same time as the clock on the GitHub server (via a
|
||||||
|
* time service for example), the {@link #resetDate} generated directly from {@link #resetEpochSeconds} will be
|
||||||
|
* accurate for the local machine as well.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* When the clock on the local machine is not synchronized with the server, the {@link #resetDate} must be
|
||||||
|
* recalculated relative to the local machine clock. This is done by taking the number of seconds between the
|
||||||
|
* response "Date" header and {@link #resetEpochSeconds} and then adding that to this record's
|
||||||
|
* {@link #createdAtEpochSeconds}.
|
||||||
*
|
*
|
||||||
* @param updatedAt
|
* @param updatedAt
|
||||||
* a string date in RFC 1123
|
* a string date in RFC 1123
|
||||||
* @return reset date based on the passed date
|
* @return reset date based on the passed date
|
||||||
*/
|
*/
|
||||||
Date recalculateResetDate(String updatedAt) {
|
Date recalculateResetDate(@CheckForNull String updatedAt) {
|
||||||
long updatedAtEpochSeconds = createdAtEpochSeconds;
|
long updatedAtEpochSeconds = createdAtEpochSeconds;
|
||||||
if (!StringUtils.isBlank(updatedAt)) {
|
if (!StringUtils.isBlank(updatedAt)) {
|
||||||
try {
|
try {
|
||||||
@@ -319,7 +377,7 @@ public class GHRateLimit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This may seem odd but it results in an accurate or slightly pessimistic reset date
|
// This may seem odd but it results in an accurate or slightly pessimistic reset date
|
||||||
// based on system time rather than on the system being in sync with the server
|
// based on system time rather than assuming the system time synchronized with the server
|
||||||
long calculatedSecondsUntilReset = resetEpochSeconds - updatedAtEpochSeconds;
|
long calculatedSecondsUntilReset = resetEpochSeconds - updatedAtEpochSeconds;
|
||||||
return resetDate = new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
|
return resetDate = new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000);
|
||||||
}
|
}
|
||||||
@@ -345,14 +403,19 @@ public class GHRateLimit {
|
|||||||
/**
|
/**
|
||||||
* Gets the time in epoch seconds when the rate limit will reset.
|
* Gets the time in epoch seconds when the rate limit will reset.
|
||||||
*
|
*
|
||||||
* @return a long
|
* This is the raw value returned by the server. This value is not adjusted if local machine time is not
|
||||||
|
* synchronized with server time. If attempting to check when the rate limit will reset, use
|
||||||
|
* {@link #getResetDate()} or implement a {@link RateLimitChecker} instead.
|
||||||
|
*
|
||||||
|
* @return a long representing the time in epoch seconds when the rate limit will reset
|
||||||
|
* @see #getResetDate() #getResetDate()
|
||||||
*/
|
*/
|
||||||
public long getResetEpochSeconds() {
|
public long getResetEpochSeconds() {
|
||||||
return resetEpochSeconds;
|
return resetEpochSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the rate limit reset date indicated by this instance is in the
|
* Whether the rate limit reset date indicated by this instance is expired
|
||||||
*
|
*
|
||||||
* @return true if the rate limit reset date has passed. Otherwise false.
|
* @return true if the rate limit reset date has passed. Otherwise false.
|
||||||
*/
|
*/
|
||||||
@@ -361,7 +424,10 @@ public class GHRateLimit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date at which the rate limit will reset.
|
* Returns the date at which the rate limit will reset, adjusted to local machine time if the local machine's
|
||||||
|
* clock not synchronized with to the same clock as the GitHub server.
|
||||||
|
*
|
||||||
|
* If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead.
|
||||||
*
|
*
|
||||||
* @return the calculated date at which the rate limit has or will reset.
|
* @return the calculated date at which the rate limit has or will reset.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import static org.kohsuke.github.Previews.*;
|
|||||||
/**
|
/**
|
||||||
* Reaction to issue, comment, PR, and so on.
|
* Reaction to issue, comment, PR, and so on.
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
|
||||||
* @see Reactable
|
* @see Reactable
|
||||||
*/
|
*/
|
||||||
@Preview
|
@Preview
|
||||||
@@ -58,6 +57,6 @@ public class GHReaction extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(root).method("DELETE").withPreview(SQUIRREL_GIRL).to("/reactions/" + id);
|
root.createRequest().method("DELETE").withPreview(SQUIRREL_GIRL).withUrlPath("/reactions/" + id).send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import java.net.URL;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides information on a Git ref from GitHub.
|
* Provides information on a Git ref from GitHub.
|
||||||
*
|
|
||||||
* @author Michael Clarke
|
|
||||||
*/
|
*/
|
||||||
public class GHRef {
|
public class GHRef {
|
||||||
/* package almost final */ GitHub root;
|
/* package almost final */ GitHub root;
|
||||||
@@ -31,7 +29,7 @@ public class GHRef {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +64,13 @@ public class GHRef {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void updateTo(String sha, Boolean force) throws IOException {
|
public void updateTo(String sha, Boolean force) throws IOException {
|
||||||
new Requester(root).with("sha", sha).with("force", force).method("PATCH").to(url, GHRef.class).wrap(root);
|
root.createRequest()
|
||||||
|
.method("PATCH")
|
||||||
|
.with("sha", sha)
|
||||||
|
.with("force", force)
|
||||||
|
.withUrlPath(url)
|
||||||
|
.fetch(GHRef.class)
|
||||||
|
.wrap(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +80,7 @@ public class GHRef {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(root).method("DELETE").to(url);
|
root.createRequest().method("DELETE").withUrlPath(url).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
GHRef wrap(GitHub root) {
|
GHRef wrap(GitHub root) {
|
||||||
@@ -125,7 +129,7 @@ public class GHRef {
|
|||||||
* @return the url
|
* @return the url
|
||||||
*/
|
*/
|
||||||
public URL getUrl() {
|
public URL getUrl() {
|
||||||
return GitHub.parseURL(url);
|
return GitHubClient.parseURL(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class GHRelease extends GHObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public URL getHtmlUrl() {
|
public URL getHtmlUrl() {
|
||||||
return GitHub.parseURL(html_url);
|
return GitHubClient.parseURL(html_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,12 +240,12 @@ public class GHRelease extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHAsset uploadAsset(String filename, InputStream stream, String contentType) throws IOException {
|
public GHAsset uploadAsset(String filename, InputStream stream, String contentType) throws IOException {
|
||||||
Requester builder = new Requester(owner.root);
|
Requester builder = owner.root.createRequest().method("POST");
|
||||||
String url = getUploadUrl();
|
String url = getUploadUrl();
|
||||||
// strip the helpful garbage from the url
|
// strip the helpful garbage from the url
|
||||||
url = url.substring(0, url.indexOf('{'));
|
url = url.substring(0, url.indexOf('{'));
|
||||||
url += "?name=" + URLEncoder.encode(filename, "UTF-8");
|
url += "?name=" + URLEncoder.encode(filename, "UTF-8");
|
||||||
return builder.contentType(contentType).with(stream).to(url, GHAsset.class).wrap(this);
|
return builder.contentType(contentType).with(stream).withUrlPath(url).fetch(GHAsset.class).wrap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,9 +256,9 @@ public class GHRelease extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public List<GHAsset> getAssets() throws IOException {
|
public List<GHAsset> getAssets() throws IOException {
|
||||||
Requester builder = new Requester(owner.root);
|
Requester builder = owner.root.createRequest();
|
||||||
|
|
||||||
GHAsset[] assets = builder.method("GET").to(getApiTailUrl("assets"), GHAsset[].class);
|
GHAsset[] assets = builder.withUrlPath(getApiTailUrl("assets")).fetchArray(GHAsset[].class);
|
||||||
return Arrays.asList(GHAsset.wrap(assets, this));
|
return Arrays.asList(GHAsset.wrap(assets, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ public class GHRelease extends GHObject {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public void delete() throws IOException {
|
public void delete() throws IOException {
|
||||||
new Requester(root).method("DELETE").to(owner.getApiTailUrl("releases/" + id));
|
root.createRequest().method("DELETE").withUrlPath(owner.getApiTailUrl("releases/" + id)).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class GHReleaseBuilder {
|
|||||||
*/
|
*/
|
||||||
public GHReleaseBuilder(GHRepository ghRepository, String tag) {
|
public GHReleaseBuilder(GHRepository ghRepository, String tag) {
|
||||||
this.repo = ghRepository;
|
this.repo = ghRepository;
|
||||||
this.builder = new Requester(repo.root);
|
this.builder = repo.root.createRequest().method("POST");
|
||||||
builder.with("tag_name", tag);
|
builder.with("tag_name", tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +95,6 @@ public class GHReleaseBuilder {
|
|||||||
* the io exception
|
* the io exception
|
||||||
*/
|
*/
|
||||||
public GHRelease create() throws IOException {
|
public GHRelease create() throws IOException {
|
||||||
return builder.to(repo.getApiTailUrl("releases"), GHRelease.class).wrap(repo);
|
return builder.withUrlPath(repo.getApiTailUrl("releases")).fetch(GHRelease.class).wrap(repo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user