Add support for projects (#854)

Initial solution for [PyGithub support for projects](https://github.com/PyGithub/PyGithub/issues/606) (#606). Adds comprehensive project querying API.

Currently does not support for modifying projects, columns or cards. (I only need this interface for reporting purposes. Of course once I'm done others are more than welcome to add additional features!)

API that was integrated:
https://developer.github.com/v3/projects
https://developer.github.com/v3/projects/columns
https://developer.github.com/v3/projects/cards

Note that the Github project API is in preview mode - it requires a special header in order for requests to be processed, and the API is subject to change without notice.

## Summary
- new classes: Project, ProjectColumn, ProjectCard
- add Organization.get_projects method
- add Repository.get_projects method
- add MainClass.get_project method
- add test cases to exercise all new classes and methods and verify attributes are as expected; replay data is included, recorded (mostly) from my fork of PyGithub
- updated add_attribute script to:
  - use makeXXXAttribute API
  - be able to add to the end of the current set of properties
  - handle both Completable and NonCompletable class types correctly

## Checklist
Not to be merged until these are done:

- [x] remaining Project properties
- [x] remaining ProjectColumn properties
- [x] remaining ProjectCard properties
- [x] support for archived_state parameter when getting cards: all,archived, or not_archived
- [x] get issue from card, not just pull request ("get_content" method?)
- [x] centralize header management for "preview" access to projects API
- [x] add test for retrieving organization projects
- [x] add test for getting issue / pull request content from card
This commit is contained in:
Yossarian King
2018-09-11 13:05:16 +08:00
committed by Wan Liuyang
parent 6c5451d6ba
commit faca4ce1c0
20 changed files with 990 additions and 26 deletions
+20
View File
@@ -102,6 +102,7 @@ import github.PullRequest
import github.RepositoryKey
import github.NamedUser
import github.Milestone
import github.Project
import github.Comparison
import github.CommitComment
import github.GitCommit
@@ -1458,6 +1459,25 @@ class Repository(github.GithubObject.CompletableGithubObject):
]
return github.ContentFile.ContentFile(self._requester, headers, data, completed=True)
def get_projects(self, state=github.GithubObject.NotSet):
"""
:calls: `GET /repos/:owner/:repo/projects <https://developer.github.com/v3/projects/#list-repository-projects>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Project.Project`
:param state: string
"""
url_parameters = dict()
if state is not github.GithubObject.NotSet:
url_parameters["state"] = state
return github.PaginatedList.PaginatedList(
github.Project.Project,
self._requester,
self.url + "/projects",
url_parameters,
{"Accept": Consts.mediaTypeProjectsPreview}
)
def create_file(self, path, message, content,
branch=github.GithubObject.NotSet,
committer=github.GithubObject.NotSet,