Merge branch 'master' into issue_330_statistics

This commit is contained in:
Liam Newman
2019-10-04 21:12:35 -07:00
committed by GitHub
224 changed files with 10049 additions and 428 deletions

View File

@@ -1659,6 +1659,44 @@ public class GHRepository extends GHObject {
return new GHRepositoryStatistics(this);
}
/**
* Create a project for this repository.
*/
public GHProject createProject(String name, String body) throws IOException {
return root.retrieve().method("POST")
.withPreview(INERTIA)
.with("name", name)
.with("body", body)
.to(getApiTailUrl("projects"), GHProject.class).wrap(this);
}
/**
* Returns the projects for this repository.
* @param status The status filter (all, open or closed).
*/
public PagedIterable<GHProject> listProjects(final GHProject.ProjectStateFilter status) throws IOException {
return new PagedIterable<GHProject>() {
public PagedIterator<GHProject> _iterator(int pageSize) {
return new PagedIterator<GHProject>(root.retrieve().withPreview(INERTIA)
.with("state", status)
.asIterator(getApiTailUrl("projects"), GHProject[].class, pageSize)) {
@Override
protected void wrapUp(GHProject[] page) {
for (GHProject c : page)
c.wrap(GHRepository.this);
}
};
}
};
}
/**
* Returns open projects for this repository.
*/
public PagedIterable<GHProject> listProjects() throws IOException {
return listProjects(GHProject.ProjectStateFilter.OPEN);
}
/**
* Render a Markdown document.
*