mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Source Import API (#673)
* add import source * add import header * create/get source import for repo, SourceImport class * Corrected use_lfs, not considered completed with creation * vcs creds optional * SourceImport test, removed unneeded attributes * create/get source import tests for repo * Encoding and copyright comment * styling fixes * Update SourceImport.py * Update SourceImport.py * Update SourceImport.py
This commit is contained in:
@@ -107,6 +107,7 @@ import github.Download
|
||||
import github.Permissions
|
||||
import github.Event
|
||||
import github.Legacy
|
||||
import github.SourceImport
|
||||
import github.StatsContributor
|
||||
import github.StatsCommitActivity
|
||||
import github.StatsCodeFrequency
|
||||
@@ -1092,6 +1093,41 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.PullRequest.PullRequest(self._requester, headers, data, completed=True)
|
||||
|
||||
def create_source_import(self, vcs, vcs_url, vcs_username=github.GithubObject.NotSet, vcs_password=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `PUT /repos/:owner/:repo/import https://developer.github.com/v3/migration/source_imports/#start-an-import`_
|
||||
:param vcs: string
|
||||
:param vcs_url: string
|
||||
:param vcs_username: string
|
||||
:param vcs_password: string
|
||||
:rtype: :class:`github.SourceImport.SourceImport`
|
||||
"""
|
||||
assert isinstance(vcs, (str, unicode)), vcs
|
||||
assert isinstance(vcs_url, (str, unicode)), vcs_url
|
||||
assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, (str, unicode)), vcs_username
|
||||
assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, (str, unicode)), vcs_password
|
||||
put_parameters = {
|
||||
"vcs": vcs,
|
||||
"vcs_url": vcs_url
|
||||
}
|
||||
|
||||
if vcs_username is not github.GithubObject.NotSet:
|
||||
put_parameters["vcs_username"] = vcs_username
|
||||
|
||||
if vcs_password is not github.GithubObject.NotSet:
|
||||
put_parameters["vcs_password"] = vcs_password
|
||||
|
||||
import_header = {"Accept": "application/vnd.github.barred-rock-preview"}
|
||||
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/import",
|
||||
headers=import_header,
|
||||
input=put_parameters
|
||||
)
|
||||
|
||||
return github.SourceImport.SourceImport(self._requester, headers, data, completed=False)
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
:calls: `DELETE /repos/:owner/:repo <http://developer.github.com/v3/repos>`_
|
||||
@@ -2040,6 +2076,22 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.ContentFile.ContentFile(self._requester, headers, data, completed=True)
|
||||
|
||||
def get_source_import(self):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/import https://developer.github.com/v3/migration/source_imports/#get-import-progress`_
|
||||
:rtype: :class:`github.SourceImport.SourceImport`
|
||||
"""
|
||||
import_header = {"Accept": "application/vnd.github.barred-rock-preview"}
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/import",
|
||||
headers=import_header,
|
||||
)
|
||||
if not data:
|
||||
return None
|
||||
else:
|
||||
return github.SourceImport.SourceImport(self._requester, headers, data, completed=True)
|
||||
|
||||
def get_stargazers(self):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/stargazers <http://developer.github.com/v3/activity/starring>`_
|
||||
|
||||
Reference in New Issue
Block a user