desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Create a fork of this repository.
:param str organization: (required), login for organization to create
the fork under
:returns: :class:`Repository <Repository>` if successful, else None'
| @requires_auth
def create_fork(self, organization=None):
| url = self._build_url(u'forks', base_url=self._api)
if organization:
resp = self._post(url, data={u'organization': organization})
else:
resp = self._post(url)
json = self._json(resp, 202)
return self._instance_or_null(Repository, json)
|
'Create a hook on this repository.
:param str name: (required), name of the hook
:param dict config: (required), key-value pairs which act as settings
for this hook
:param list events: (optional), events the hook is triggered for
:param bool active: (optional), whether the hook is actually
triggered
:returns: :class:`H... | @requires_auth
def create_hook(self, name, config, events=[u'push'], active=True):
| json = None
if (name and config and isinstance(config, dict)):
url = self._build_url(u'hooks', base_url=self._api)
data = {u'name': name, u'config': config, u'events': events, u'active': active}
json = self._json(self._post(url, data=data), 201)
return (Hook(json, self) if json else ... |
'Create an issue on this repository.
:param str title: (required), title of the issue
:param str body: (optional), body of the issue
:param str assignee: (optional), login of the user to assign the
issue to
:param int milestone: (optional), id number of the milestone to
attribute this issue to (e.g. ``m`` is a :class:`... | @requires_auth
def create_issue(self, title, body=None, assignee=None, milestone=None, labels=None, assignees=None):
| issue = {u'title': title, u'body': body, u'assignee': assignee, u'milestone': milestone, u'labels': labels, u'assignees': assignees}
self._remove_none(issue)
json = None
if issue:
url = self._build_url(u'issues', base_url=self._api)
json = self._json(self._post(url, data=issue), 201)
... |
'Create a deploy key.
:param str title: (required), title of key
:param str key: (required), key text
:param bool read_only: (optional), restrict key access to read-only,
default is False
:returns: :class:`~github3.users.Key` if successful, else None'
| @requires_auth
def create_key(self, title, key, read_only=False):
| json = None
if (title and key):
data = {u'title': title, u'key': key, u'read_only': read_only}
url = self._build_url(u'keys', base_url=self._api)
json = self._json(self._post(url, data=data), 201)
return self._instance_or_null(users.Key, json)
|
'Create a label for this repository.
:param str name: (required), name to give to the label
:param str color: (required), value of the color to assign to the
label, e.g., \'#fafafa\' or \'fafafa\' (the latter is what is sent)
:returns: :class:`Label <github3.issues.label.Label>` if successful,
else None'
| @requires_auth
def create_label(self, name, color):
| json = None
if (name and color):
data = {u'name': name, u'color': color.strip(u'#')}
url = self._build_url(u'labels', base_url=self._api)
json = self._json(self._post(url, data=data), 201)
return self._instance_or_null(Label, json)
|
'Create a milestone for this repository.
:param str title: (required), title of the milestone
:param str state: (optional), state of the milestone, accepted
values: (\'open\', \'closed\'), default: \'open\'
:param str description: (optional), description of the milestone
:param str due_on: (optional), ISO 8601 formatte... | @requires_auth
def create_milestone(self, title, state=None, description=None, due_on=None):
| url = self._build_url(u'milestones', base_url=self._api)
if (state not in (u'open', u'closed')):
state = None
data = {u'title': title, u'state': state, u'description': description, u'due_on': due_on}
self._remove_none(data)
json = None
if data:
json = self._json(self._post(url, d... |
'Create a pull request of ``head`` onto ``base`` branch in this repo.
:param str title: (required)
:param str base: (required), e.g., \'master\'
:param str head: (required), e.g., \'username:branch\'
:param str body: (optional), markdown formatted description
:returns: :class:`PullRequest <github3.pulls.PullRequest>` i... | @requires_auth
def create_pull(self, title, base, head, body=None):
| data = {u'title': title, u'body': body, u'base': base, u'head': head}
return self._create_pull(data)
|
'Create a pull request from issue #``issue``.
:param int issue: (required), issue number
:param str base: (required), e.g., \'master\'
:param str head: (required), e.g., \'username:branch\'
:returns: :class:`PullRequest <github3.pulls.PullRequest>` if
successful, else None'
| @requires_auth
def create_pull_from_issue(self, issue, base, head):
| if (int(issue) > 0):
data = {u'issue': issue, u'base': base, u'head': head}
return self._create_pull(data)
return None
|
'Create a reference in this repository.
:param str ref: (required), fully qualified name of the reference,
e.g. ``refs/heads/master``. If it doesn\'t start with ``refs`` and
contain at least two slashes, GitHub\'s API will reject it.
:param str sha: (required), SHA1 value to set the reference to
:returns: :class:`Refer... | @requires_auth
def create_ref(self, ref, sha):
| json = None
if (ref and ref.startswith(u'refs') and (ref.count(u'/') >= 2) and sha):
data = {u'ref': ref, u'sha': sha}
url = self._build_url(u'git', u'refs', base_url=self._api)
json = self._json(self._post(url, data=data), 201)
return self._instance_or_null(Reference, json)
|
'Create a release for this repository.
:param str tag_name: (required), name to give to the tag
:param str target_commitish: (optional), vague concept of a target,
either a SHA or a branch name.
:param str name: (optional), name of the release
:param str body: (optional), description of the release
:param bool draft: (... | @requires_auth
def create_release(self, tag_name, target_commitish=None, name=None, body=None, draft=False, prerelease=False):
| data = {u'tag_name': str(tag_name), u'target_commitish': target_commitish, u'name': name, u'body': body, u'draft': draft, u'prerelease': prerelease}
self._remove_none(data)
url = self._build_url(u'releases', base_url=self._api)
json = self._json(self._post(url, data=data, headers=Release.CUSTOM_HEADERS)... |
'Create a status object on a commit.
:param str sha: (required), SHA of the commit to create the status on
:param str state: (required), state of the test; only the following
are accepted: \'pending\', \'success\', \'error\', \'failure\'
:param str target_url: (optional), URL to associate with this status.
:param str d... | @requires_auth
def create_status(self, sha, state, target_url=None, description=None, context=u'default'):
| json = None
if (sha and state):
data = {u'state': state, u'target_url': target_url, u'description': description, u'context': context}
url = self._build_url(u'statuses', sha, base_url=self._api)
self._remove_none(data)
json = self._json(self._post(url, data=data), 201)
return ... |
'Create a tag in this repository.
By default, this method creates an annotated tag. If you wish to
create a lightweight tag instead, pass ``lightweight=True``.
If you are creating an annotated tag, this method makes **2 calls** to
the API:
1. Creates the tag object
2. Creates the reference for the tag
This behaviour is... | @requires_auth
def create_tag(self, tag, message, sha, obj_type, tagger, lightweight=False):
| if (lightweight and tag and sha):
return self.create_ref((u'refs/tags/' + tag), sha)
json = None
if (tag and message and sha and obj_type and (len(tagger) == 3)):
data = {u'tag': tag, u'message': message, u'object': sha, u'type': obj_type, u'tagger': tagger}
url = self._build_url(u'g... |
'Create a tree on this repository.
:param list tree: (required), specifies the tree structure.
Format: [{\'path\': \'path/file\', \'mode\':
\'filemode\', \'type\': \'blob or tree\', \'sha\': \'44bfc6d...\'}]
:param str base_tree: (optional), SHA1 of the tree you want
to update with new data
:returns: :class:`Tree <gith... | @requires_auth
def create_tree(self, tree, base_tree=None):
| json = None
if (tree and isinstance(tree, list)):
data = {u'tree': tree}
if base_tree:
data[u'base_tree'] = base_tree
url = self._build_url(u'git', u'trees', base_url=self._api)
json = self._json(self._post(url, data=data), 201)
return self._instance_or_null(Tree,... |
'Delete this repository.
:returns: bool -- True if successful, False otherwise'
| @requires_auth
def delete(self):
| return self._boolean(self._delete(self._api), 204, 404)
|
'Delete the key with the specified id from your deploy keys list.
:returns: bool -- True if successful, False otherwise'
| @requires_auth
def delete_key(self, key_id):
| if (int(key_id) <= 0):
return False
url = self._build_url(u'keys', str(key_id), base_url=self._api)
return self._boolean(self._delete(url), 204, 404)
|
'Delete the user\'s subscription to this repository.
:returns: bool'
| @requires_auth
def delete_subscription(self):
| url = self._build_url(u'subscription', base_url=self._api)
return self._boolean(self._delete(url), 204, 404)
|
'Retrieve the deployment identified by ``id``.
:param int id: (required), id for deployments.
:returns: :class:`~github3.repos.deployment.Deployment`'
| def deployment(self, id):
| json = None
if (int(id) > 0):
url = self._build_url(u'deployments', str(id), base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Deployment, json)
|
'Iterate over deployments for this repository.
:param int number: (optional), number of deployments to return.
Default: -1, returns all available deployments
:param str etag: (optional), ETag from a previous request for all
deployments
:returns: generator of
:class:`Deployment <github3.repos.deployment.Deployment>`\ s'... | def deployments(self, number=(-1), etag=None):
| url = self._build_url(u'deployments', base_url=self._api)
i = self._iter(int(number), url, Deployment, etag=etag)
return i
|
'Get the contents of each file in ``directory_path``.
If the path provided is actually a directory, you will receive a
list back of the form::
[(\'filename.md\', Contents(...)),
(\'github.py\', Contents(...)),
(\'fiz.py\', Contents(...))]
You can either then transform it into a dictionary::
contents = dict(repo.directo... | def directory_contents(self, directory_path, ref=None, return_as=list):
| url = self._build_url(u'contents', directory_path, base_url=self._api)
json = (self._json(self._get(url, params={u'ref': ref}), 200) or [])
return return_as(((j.get(u'name'), Contents(j, self)) for j in json))
|
'Edit this repository.
:param str name: (required), name of the repository
:param str description: (optional), If not ``None``, change the
description for this repository. API default: ``None`` - leave
value unchanged.
:param str homepage: (optional), If not ``None``, change the homepage
for this repository. API defaul... | @requires_auth
def edit(self, name, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, default_branch=None):
| edit = {u'name': name, u'description': description, u'homepage': homepage, u'private': private, u'has_issues': has_issues, u'has_wiki': has_wiki, u'has_downloads': has_downloads, u'default_branch': default_branch}
self._remove_none(edit)
json = None
if edit:
json = self._json(self._patch(self._a... |
'Iterate over events on this repository.
:param int number: (optional), number of events to return. Default: -1
returns all available events
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Event <github3.events.Event>`\ s'
| def events(self, number=(-1), etag=None):
| url = self._build_url(u'events', base_url=self._api)
return self._iter(int(number), url, Event, etag=etag)
|
'Get the contents of the file pointed to by ``path``.
:param str path: (required), path to file, e.g.
github3/repos/repo.py
:param str ref: (optional), the string name of a commit/branch/tag.
Default: master
:returns: the contents of the file requested
:rtype: :class:`~github3.repos.contents.Contents`'
| def file_contents(self, path, ref=None):
| url = self._build_url(u'contents', path, base_url=self._api)
json = self._json(self._get(url, params={u'ref': ref}), 200)
return self._instance_or_null(Contents, json)
|
'Iterate over forks of this repository.
:param str sort: (optional), accepted values:
(\'newest\', \'oldest\', \'watchers\'), API default: \'newest\'
:param int number: (optional), number of forks to return. Default: -1
returns all forks
:param str etag: (optional), ETag from a previous request to the same
endpoint
:re... | def forks(self, sort=u'', number=(-1), etag=None):
| url = self._build_url(u'forks', base_url=self._api)
params = {}
if (sort in (u'newest', u'oldest', u'watchers')):
params = {u'sort': sort}
return self._iter(int(number), url, Repository, params, etag)
|
'Get a single (git) commit.
:param str sha: (required), sha of the commit
:returns: :class:`Commit <github3.git.Commit>` if successful,
otherwise None'
| def git_commit(self, sha):
| json = {}
if sha:
url = self._build_url(u'git', u'commits', sha, base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Commit, json)
|
'Get a single hook.
:param int hook_id: (required), id of the hook
:returns: :class:`Hook <github3.repos.hook.Hook>` if successful,
otherwise None'
| @requires_auth
def hook(self, hook_id):
| json = None
if (int(hook_id) > 0):
url = self._build_url(u'hooks', str(hook_id), base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Hook, json)
|
'Iterate over hooks registered on this repository.
:param int number: (optional), number of hoks to return. Default: -1
returns all hooks
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Hook <github3.repos.hook.Hook>`\ s'
| @requires_auth
def hooks(self, number=(-1), etag=None):
| url = self._build_url(u'hooks', base_url=self._api)
return self._iter(int(number), url, Hook, etag=etag)
|
'Ignore notifications from this repository for the user.
.. versionadded:: 1.0
This replaces ``Repository#set_subscription``.
:returns: :class:`Subscription <github3.notifications.Subscription>`'
| @requires_auth
def ignore(self):
| url = self._build_url(u'subscription', base_url=self._api)
json = self._json(self._put(url, data=dumps({u'ignored': True})), 200)
return self._instance_or_null(Subscription, json)
|
'Retrieve imported issue specified by imported issue id.
:param int imported_issue_id: (required) id of imported issue
:returns: :class:`Imported Issue <github3.repos.
issue_import.ImportedIssue>`'
| @requires_auth
def imported_issue(self, imported_issue_id):
| url = self._build_url(u'import/issues', imported_issue_id, base_url=self._api)
data = self._get(url, headers=ImportedIssue.IMPORT_CUSTOM_HEADERS)
json = self._json(data, 200)
return self._instance_or_null(ImportedIssue, json)
|
'Retrieve the collection of imported issues via the API.
See also: https://gist.github.com/jonmagic/5282384165e0f86ef105
:param int number: (optional), number of imported issues to return.
Default: -1 returns all branches
:param since: (optional), Only imported issues after this date will
be returned. This can be a ``d... | @requires_auth
def imported_issues(self, number=(-1), since=None, etag=None):
| data = {u'since': timestamp_parameter(since)}
self._remove_none(data)
url = self._build_url(u'import/issues', base_url=self._api)
return self._iter(int(number), url, ImportedIssue, etag=etag, params=data, headers=ImportedIssue.IMPORT_CUSTOM_HEADERS)
|
'Import an issue into the repository.
See also: https://gist.github.com/jonmagic/5282384165e0f86ef105
:param string title: (required) Title of issue
:param string body: (required) Body of issue
:param timestamp created_at: (required) Creation timestamp
:param string assignee: (optional) Username to assign issue to
:par... | @requires_auth
def import_issue(self, title, body, created_at, assignee=None, milestone=None, closed=None, labels=None, comments=None):
| issue = {u'issue': {u'title': title, u'body': body, u'created_at': created_at, u'assignee': assignee, u'milestone': milestone, u'closed': closed, u'labels': labels}, u'comments': comments}
self._remove_none(issue)
self._remove_none(issue[u'issue'])
url = self._build_url(u'import/issues', base_url=self._... |
'Check if the user can be assigned an issue on this repository.
:param username: name of the user to check
:type username: str or :class:`User <github3.users.User>`
:returns: :class:`bool`'
| def is_assignee(self, username):
| if (not username):
return False
url = self._build_url(u'assignees', str(username), base_url=self._api)
return self._boolean(self._get(url), 204, 404)
|
'Check to see if ``username`` is a collaborator on this repository.
:param username: (required), login for the user
:type username: str or :class:`User <github3.users.User>`
:returns: bool -- True if successful, False otherwise'
| @requires_auth
def is_collaborator(self, username):
| if (not username):
return False
url = self._build_url(u'collaborators', str(username), base_url=self._api)
return self._boolean(self._get(url), 204, 404)
|
'Get the issue specified by ``number``.
:param int number: (required), number of the issue on this repository
:returns: :class:`Issue <github3.issues.issue.Issue>` if successful,
otherwise None'
| def issue(self, number):
| json = None
if (int(number) > 0):
url = self._build_url(u'issues', str(number), base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Issue, json)
|
'Iterate over issue events on this repository.
:param int number: (optional), number of events to return. Default: -1
returns all available events
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of
:class:`IssueEvent <github3.issues.event.IssueEvent>`\ s'
| def issue_events(self, number=(-1), etag=None):
| url = self._build_url(u'issues', u'events', base_url=self._api)
return self._iter(int(number), url, IssueEvent, etag=etag)
|
'Iterate over issues on this repo based upon parameters passed.
.. versionchanged:: 0.9.0
The ``state`` parameter now accepts \'all\' in addition to \'open\'
and \'closed\'.
:param int milestone: (optional), \'none\', or \'*\'
:param str state: (optional), accepted values: (\'all\', \'open\',
\'closed\')
:param str ass... | def issues(self, milestone=None, state=None, assignee=None, mentioned=None, labels=None, sort=None, direction=None, since=None, number=(-1), etag=None):
| url = self._build_url(u'issues', base_url=self._api)
params = repo_issue_params(milestone, state, assignee, mentioned, labels, sort, direction, since)
return self._iter(int(number), url, Issue, params, etag)
|
'Get the specified deploy key.
:param int id_num: (required), id of the key
:returns: :class:`~github3.users.Key` if successful, else None'
| @requires_auth
def key(self, id_num):
| json = None
if (int(id_num) > 0):
url = self._build_url(u'keys', str(id_num), base_url=self._api)
json = self._json(self._get(url), 200)
return (users.Key(json, self) if json else None)
|
'Iterate over deploy keys on this repository.
:param int number: (optional), number of keys to return. Default: -1
returns all available keys
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`~github3.users.Key`\ s'
| @requires_auth
def keys(self, number=(-1), etag=None):
| url = self._build_url(u'keys', base_url=self._api)
return self._iter(int(number), url, users.Key, etag=etag)
|
'Get the label specified by ``name``.
:param str name: (required), name of the label
:returns: :class:`Label <github3.issues.label.Label>` if successful,
else None'
| def label(self, name):
| json = None
if name:
url = self._build_url(u'labels', name, base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Label, json)
|
'Iterate over labels on this repository.
:param int number: (optional), number of labels to return. Default: -1
returns all available labels
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Label <github3.issues.label.Label>`\ s'
| def labels(self, number=(-1), etag=None):
| url = self._build_url(u'labels', base_url=self._api)
return self._iter(int(number), url, Label, etag=etag)
|
'Iterate over the programming languages used in the repository.
:param int number: (optional), number of languages to return. Default:
-1 returns all used languages
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of tuples'
| def languages(self, number=(-1), etag=None):
| url = self._build_url(u'languages', base_url=self._api)
return self._iter(int(number), url, tuple, etag=etag)
|
'Get the build information for the most recent Pages build.
:returns: :class:`PagesBuild <github3.repos.pages.PagesBuild>`'
| @requires_auth
def latest_pages_build(self):
| url = self._build_url(u'pages', u'builds', u'latest', base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(PagesBuild, json)
|
'Get the latest release.
Draft releases and prereleases are not returned by this endpoint.
:returns: :class:`Release <github3.repos.release.Release>`'
| def latest_release(self):
| url = self._build_url(u'releases', u'latest', base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Release, json)
|
'Get the contents of a license for the repo
:returns: :class:`License <github3.licenses.License>`'
| def license(self):
| url = self._build_url(u'license', base_url=self._api)
json = self._json(self._get(url, headers=License.CUSTOM_HEADERS), 200)
return self._instance_or_null(License, json)
|
'Mark all notifications in this repository as read.
:param str last_read: (optional), Describes the last point that
notifications were checked. Anything updated since this time will
not be updated. Default: Now. Expected in ISO 8601 format:
``YYYY-MM-DDTHH:MM:SSZ``. Example: "2012-10-09T23:39:01Z".
:returns: bool'
| @requires_auth
def mark_notifications(self, last_read=u''):
| url = self._build_url(u'notifications', base_url=self._api)
mark = {u'read': True}
if last_read:
mark[u'last_read_at'] = last_read
return self._boolean(self._put(url, data=dumps(mark)), 205, 404)
|
'Perform a merge from ``head`` into ``base``.
:param str base: (required), where you\'re merging into
:param str head: (required), where you\'re merging from
:param str message: (optional), message to be used for the commit
:returns: :class:`RepoCommit <github3.repos.commit.RepoCommit>`'
| @requires_auth
def merge(self, base, head, message=u''):
| url = self._build_url(u'merges', base_url=self._api)
data = {u'base': base, u'head': head}
if message:
data[u'commit_message'] = message
json = self._json(self._post(url, data=data), 201)
return self._instance_or_null(RepoCommit, json)
|
'Get the milestone indicated by ``number``.
:param int number: (required), unique id number of the milestone
:returns: :class:`Milestone <github3.issues.milestone.Milestone>`'
| def milestone(self, number):
| json = None
if (int(number) > 0):
url = self._build_url(u'milestones', str(number), base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Milestone, json)
|
'Iterate over the milestones on this repository.
:param str state: (optional), state of the milestones, accepted
values: (\'open\', \'closed\')
:param str sort: (optional), how to sort the milestones, accepted
values: (\'due_date\', \'completeness\')
:param str direction: (optional), direction to sort the milestones,
a... | def milestones(self, state=None, sort=None, direction=None, number=(-1), etag=None):
| url = self._build_url(u'milestones', base_url=self._api)
accepted = {u'state': (u'open', u'closed', u'all'), u'sort': (u'due_date', u'completeness'), u'direction': (u'asc', u'desc')}
params = {u'state': state, u'sort': sort, u'direction': direction}
for (k, v) in list(params.items()):
if (not (v... |
'Iterate over events on a network of repositories.
:param int number: (optional), number of events to return. Default: -1
returns all available events
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Event <github3.events.Event>`\ s'
| def network_events(self, number=(-1), etag=None):
| base = self._api.replace(u'repos', u'networks', 1)
url = self._build_url(u'events', base_url=base)
return self._iter(int(number), url, Event, etag)
|
'Iterate over the notifications for this repository.
:param bool all: (optional), show all notifications, including ones
marked as read
:param bool participating: (optional), show only the notifications the
user is participating in directly
:param since: (optional), filters out any notifications updated
before the give... | @requires_auth
def notifications(self, all=False, participating=False, since=None, number=(-1), etag=None):
| url = self._build_url(u'notifications', base_url=self._api)
params = {u'all': str(all).lower(), u'participating': str(participating).lower(), u'since': timestamp_parameter(since)}
self._remove_none(params)
return self._iter(int(number), url, Thread, params, etag)
|
'Get information about this repository\'s pages site.
:returns: :class:`PagesInfo <github3.repos.pages.PagesInfo>`'
| @requires_auth
def pages(self):
| url = self._build_url(u'pages', base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(PagesInfo, json)
|
'Iterate over pages builds of this repository.
:returns: generator of :class:`PagesBuild
<github3.repos.pages.PagesBuild>`'
| @requires_auth
def pages_builds(self, number=(-1), etag=None):
| url = self._build_url(u'pages', u'builds', base_url=self._api)
return self._iter(int(number), url, PagesBuild, etag=etag)
|
'Get the pull request indicated by ``number``.
:param int number: (required), number of the pull request.
:returns: :class:`PullRequest <github3.pulls.PullRequest>`'
| def pull_request(self, number):
| json = None
if (int(number) > 0):
url = self._build_url(u'pulls', str(number), base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(PullRequest, json)
|
'List pull requests on repository.
.. versionchanged:: 0.9.0
- The ``state`` parameter now accepts \'all\' in addition to \'open\'
and \'closed\'.
- The ``sort`` parameter was added.
- The ``direction`` parameter was added.
:param str state: (optional), accepted values: (\'all\', \'open\',
\'closed\')
:param str head: ... | def pull_requests(self, state=None, head=None, base=None, sort=u'created', direction=u'desc', number=(-1), etag=None):
| url = self._build_url(u'pulls', base_url=self._api)
params = {}
if state:
state = state.lower()
if (state in (u'all', u'open', u'closed')):
params[u'state'] = state
params.update(head=head, base=base, sort=sort, direction=direction)
self._remove_none(params)
return se... |
'Get the README for this repository.
:returns: :class:`Contents <github3.repos.contents.Contents>`'
| def readme(self):
| url = self._build_url(u'readme', base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Contents, json)
|
'Get a reference pointed to by ``ref``.
The most common will be branches and tags. For a branch, you must
specify \'heads/branchname\' and for a tag, \'tags/tagname\'. Essentially,
the system should return any reference you provide it in the namespace,
including notes and stashes (provided they exist on the server).
:p... | def ref(self, ref):
| json = None
if ref:
url = self._build_url(u'git', u'refs', ref, base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Reference, json)
|
'Iterate over references for this repository.
:param str subspace: (optional), e.g. \'tags\', \'stashes\', \'notes\'
:param int number: (optional), number of refs to return. Default: -1
returns all available refs
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :clas... | def refs(self, subspace=u'', number=(-1), etag=None):
| if subspace:
args = (u'git', u'refs', subspace)
else:
args = (u'git', u'refs')
url = self._build_url(base_url=self._api, *args)
return self._iter(int(number), url, Reference, etag=etag)
|
'Get a single release.
:param int id: (required), id of release
:returns: :class:`Release <github3.repos.release.Release>`'
| def release(self, id):
| json = None
if (int(id) > 0):
url = self._build_url(u'releases', str(id), base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Release, json)
|
'Get a release by tag name.
release_from_tag() returns a release with specified tag
while release() returns a release with specified release id
:param str tag_name: (required) name of tag
:returns: :class:`Release <github3.repos.release.Release>`'
| def release_from_tag(self, tag_name):
| url = self._build_url(u'releases', u'tags', tag_name, base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Release, json)
|
'Iterate over releases for this repository.
:param int number: (optional), number of refs to return. Default: -1
returns all available refs
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of
:class:`Release <github3.repos.release.Release>`\ s'
| def releases(self, number=(-1), etag=None):
| url = self._build_url(u'releases', base_url=self._api)
iterator = self._iter(int(number), url, Release, etag=etag)
iterator.headers.update(Release.CUSTOM_HEADERS)
return iterator
|
'Remove collaborator ``username`` from the repository.
:param username: (required), login name of the collaborator
:type username: str or :class:`User <github3.users.User>`
:returns: bool'
| @requires_auth
def remove_collaborator(self, username):
| if (not username):
return False
url = self._build_url(u'collaborators', str(username), base_url=self._api)
return self._boolean(self._delete(url), 204, 404)
|
'List users who have starred this repository.
:param int number: (optional), number of stargazers to return.
Default: -1 returns all subscribers available
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`~github3.users.ShortUser`\ s'
| def stargazers(self, number=(-1), etag=None):
| url = self._build_url(u'stargazers', base_url=self._api)
return self._iter(int(number), url, users.ShortUser, etag=etag)
|
'Iterate over the statuses for a specific SHA.
.. warning::
Deprecated in v1.0. Also deprecated upstream
https://developer.github.com/v3/repos/statuses/
:param str sha: SHA of the commit to list the statuses of
:param int number: (optional), return up to number statuses. Default:
-1 returns all available statuses.
:par... | def statuses(self, sha, number=(-1), etag=None):
| url = u''
if sha:
url = self._build_url(u'statuses', sha, base_url=self._api)
return self._iter(int(number), url, Status, etag=etag)
|
'Subscribe the user to this repository\'s notifications.
.. versionadded:: 1.0
This replaces ``Repository#set_subscription``
:param bool subscribed: (required), determines if notifications should
be received from this repository.
:param bool ignored: (required), determines if notifications should be
ignored from this r... | @requires_auth
def subscribe(self):
| url = self._build_url(u'subscription', base_url=self._api)
json = self._json(self._put(url, data=dumps({u'subcribed': True})), 200)
return self._instance_or_null(Subscription, json)
|
'Iterate over users subscribed to this repository.
:param int number: (optional), number of subscribers to return.
Default: -1 returns all subscribers available
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`~github3.users.ShortUser`'
| def subscribers(self, number=(-1), etag=None):
| url = self._build_url(u'subscribers', base_url=self._api)
return self._iter(int(number), url, users.ShortUser, etag=etag)
|
'Return subscription for this Repository.
:returns: :class:`Subscription <github3.notifications.Subscription>`'
| @requires_auth
def subscription(self):
| url = self._build_url(u'subscription', base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Subscription, json)
|
'Get an annotated tag.
http://learn.github.com/p/tagging.html
:param str sha: (required), sha of the object for this tag
:returns: :class:`Tag <github3.git.Tag>`'
| def tag(self, sha):
| json = None
if sha:
url = self._build_url(u'git', u'tags', sha, base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Tag, json)
|
'Iterate over tags on this repository.
:param int number: (optional), return up to at most number tags.
Default: -1 returns all available tags.
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`RepoTag <github3.repos.tag.RepoTag>`\ s'
| def tags(self, number=(-1), etag=None):
| url = self._build_url(u'tags', base_url=self._api)
return self._iter(int(number), url, RepoTag, etag=etag)
|
'Iterate over teams with access to this repository.
:param int number: (optional), return up to number Teams. Default: -1
returns all Teams.
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Team <github3.orgs.Team>`\ s'
| @requires_auth
def teams(self, number=(-1), etag=None):
| from ..orgs import Team
url = self._build_url(u'teams', base_url=self._api)
return self._iter(int(number), url, Team, etag=etag)
|
'Get a tree.
:param str sha: (required), sha of the object for this tree
:returns: :class:`Tree <github3.git.Tree>`'
| def tree(self, sha):
| json = None
if sha:
url = self._build_url(u'git', u'trees', sha, base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(Tree, json)
|
'Retrieve the total commit counts.
.. note:: All statistics methods may return a 202. If github3.py
receives a 202 in this case, it will return an emtpy dictionary.
You should give the API a moment to compose the data and then re
-request it via this method.
..versionadded:: 0.7
The dictionary returned has two entries:... | def weekly_commit_count(self):
| url = self._build_url(u'stats', u'participation', base_url=self._api)
resp = self._get(url)
if (resp and (resp.status_code == 202)):
return {}
json = self._json(resp, 200)
if (json and json.get(u'ETag')):
del json[u'ETag']
if (json and json.get(u'Last-Modified')):
del jso... |
'Check if SHA-1 is the same as remote branch
See: https://git.io/vaqIw
:param str differs_from: (optional), sha to compare against
:returns: string of the SHA or None'
| def latest_sha(self, differs_from=u''):
| headers = {u'Accept': u'application/vnd.github.chitauri-preview+sha', u'If-None-Match': u'"{0}"'.format(differs_from)}
base = self._api.split(u'/branches', 1)[0]
url = self._build_url(u'commits', self.name, base_url=base)
resp = self._get(url, headers=headers)
if self._boolean(resp, 200, 304):
... |
'Enable force push protection and configure status check enforcement.
See: http://git.io/v4Gvu
:param str enforcement: (optional), Specifies the enforcement level of
the status checks. Must be one of \'off\', \'non_admins\', or
\'everyone\'. Use `None` or omit to use the already associated value.
:param list status_che... | def protect(self, enforcement=None, status_checks=None):
| previous_values = self.protection[u'required_status_checks']
if (enforcement is None):
enforcement = previous_values[u'enforcement_level']
if (status_checks is None):
status_checks = previous_values[u'contexts']
edit = {u'protection': {u'enabled': True, u'required_status_checks': {u'enfo... |
'Disable force push protection on this branch.'
| def unprotect(self):
| edit = {u'protection': {u'enabled': False}}
json = self._json(self._patch(self._api, data=dumps(edit), headers=self.PREVIEW_HEADERS), 200)
self._update_attributes(json)
return True
|
'Create a new deployment status for this deployment.
:param str state: (required), The state of the status. Can be one of
``pending``, ``success``, ``error``, or ``failure``.
:param str target_url: The target URL to associate with this status.
This URL should contain output to keep the user updated while the
task is ru... | def create_status(self, state, target_url=None, description=None):
| json = None
if (state in (u'pending', u'success', u'error', u'failure')):
data = {u'state': state, u'target_url': target_url, u'description': description}
self._remove_none(data)
response = self._post(self.statuses_url, data=data)
json = self._json(response, 201)
return self.... |
'Iterate over the deployment statuses for this deployment.
:param int number: (optional), the number of statuses to return.
Default: -1, returns all statuses.
:param str etag: (optional), the ETag header value from the last time
you iterated over the statuses.
:returns: generator of :class:`DeploymentStatus`\ es'
| def statuses(self, number=(-1), etag=None):
| i = self._iter(int(number), self.statuses_url, DeploymentStatus, etag=etag)
return i
|
'Delete this file.
:param str message: (required), commit message to describe the removal
:param str branch: (optional), branch where the file exists.
Defaults to the default branch of the repository.
:param dict committer: (optional), if no information is given the
authenticated user\'s information will be used. You m... | @requires_auth
def delete(self, message, branch=None, committer=None, author=None):
| json = {}
if message:
data = {u'message': message, u'sha': self.sha, u'branch': branch, u'committer': validate_commmitter(committer), u'author': validate_commmitter(author)}
self._remove_none(data)
json = self._json(self._delete(self._api, data=dumps(data)), 200)
if (json and (u'... |
'Update this file.
:param str message: (required), commit message to describe the update
:param str content: (required), content to update the file with
:param str branch: (optional), branch where the file exists.
Defaults to the default branch of the repository.
:param dict committer: (optional), if no information is ... | @requires_auth
def update(self, message, content, branch=None, committer=None, author=None):
| if (content and (not isinstance(content, bytes))):
raise ValueError(u'content must be a bytes object')
json = None
if (message and content):
content = b64encode(content).decode(u'utf-8')
data = {u'message': message, u'content': content, u'branch': branch, u'sha': self.... |
'Retrieve the diff for this commit.
:returns: the diff as a bytes object
:rtype: bytes'
| def diff(self):
| resp = self._get(self._api, headers={u'Accept': u'application/vnd.github.diff'})
return (resp.content if self._boolean(resp, 200, 404) else '')
|
'Retrieve the patch formatted diff for this commit.
:returns: the patch as a bytes object
:rtype: bytes'
| def patch(self):
| resp = self._get(self._api, headers={u'Accept': u'application/vnd.github.patch'})
return (resp.content if self._boolean(resp, 200, 404) else '')
|
'Retrieve the combined status for this commit.
:returns: the combined status for this commit
:rtype: :class:`~github3.repos.status.CombinedStatus`'
| def status(self):
| url = self._build_url(u'status', base_url=self._api)
json = self._json(self._get(url), 200)
return self._instance_or_null(status.CombinedStatus, json)
|
'Retrieve the statuses for this commit.
:returns: the statuses for this commit
:rtype: :class:`~github3.repos.status.Status`'
| def statuses(self):
| url = self._build_url(u'statuses', base_url=self._api)
return self._iter((-1), url, status.Status)
|
'Iterate over comments for this commit.
:param int number: (optional), number of comments to return. Default:
-1 returns all comments
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of
:class:`RepoComment <github3.repos.comment.RepoComment>`\ s'
| def comments(self, number=(-1), etag=None):
| url = self._build_url(u'comments', base_url=self._api)
return self._iter(int(number), url, RepoComment, etag=etag)
|
'Retrieve the diff for this comparison.
:returns: the diff as a bytes object
:rtype: bytes'
| def diff(self):
| resp = self._get(self._api, headers={u'Accept': u'application/vnd.github.diff'})
return (resp.content if self._boolean(resp, 200, 404) else '')
|
'Retrieve the patch formatted diff for this commit.
:returns: the patch as a bytes object
:rtype: bytes'
| def patch(self):
| resp = self._get(self._api, headers={u'Accept': u'application/vnd.github.patch'})
return (resp.content if self._boolean(resp, 200, 404) else '')
|
'Delete this hook.
:returns: bool'
| @requires_auth
def delete(self):
| return self._boolean(self._delete(self._api), 204, 404)
|
'Edit this hook.
:param dict config: (optional), key-value pairs of settings for this
hook
:param list events: (optional), which events should this be triggered
for
:param list add_events: (optional), events to be added to the list of
events that this hook triggers for
:param list rm_events: (optional), events to be re... | @requires_auth
def edit(self, config={}, events=[], add_events=[], rm_events=[], active=True):
| data = {u'config': config, u'active': active}
if events:
data[u'events'] = events
if add_events:
data[u'add_events'] = add_events
if rm_events:
data[u'remove_events'] = rm_events
json = self._json(self._patch(self._api, data=dumps(data)), 200)
if json:
self._updat... |
'Ping this hook.
:returns: bool'
| @requires_auth
def ping(self):
| url = self._build_url(u'pings', base_url=self._api)
return self._boolean(self._post(url), 204, 404)
|
'Test this hook
:returns: bool'
| @requires_auth
def test(self):
| url = self._build_url(u'tests', base_url=self._api)
return self._boolean(self._post(url), 204, 404)
|
'Add ``username`` to this team.
:param str username: the username of the user you would like to add to
the team.
:returns: bool'
| @requires_auth
def add_member(self, username):
| warnings.warn(u'This is no longer supported by the GitHub API, see https://developer.github.com/changes/2014-09-23-one-more-week-before-the-add-team-member-api-breaking-change/', DeprecationWarning)
url = self._build_url(u'members', username, base_url=self._api)
return self._bo... |
'Add ``repository`` to this team.
:param str repository: (required), form: \'user/repo\'
:param str permission: (optional), (\'pull\', \'push\', \'admin\')
:returns: bool'
| @requires_auth
def add_repository(self, repository, permission=u''):
| data = {u'permission': permission}
url = self._build_url(u'repos', repository, base_url=self._api)
return self._boolean(self._put(url, data=dumps(data)), 204, 404)
|
'Delete this team.
:returns: bool'
| @requires_auth
def delete(self):
| return self._boolean(self._delete(self._api), 204, 404)
|
'Edit this team.
:param str name: (required)
:param str permission: (optional), (\'pull\', \'push\', \'admin\')
:returns: bool'
| @requires_auth
def edit(self, name, permission=u''):
| if name:
data = {u'name': name, u'permission': permission}
json = self._json(self._patch(self._api, data=dumps(data)), 200)
if json:
self._update_attributes(json)
return True
return False
|
'Check if this team has access to ``repository``.
:param str repository: (required), form: \'user/repo\'
:returns: bool'
| @requires_auth
def has_repository(self, repository):
| url = self._build_url(u'repos', repository, base_url=self._api)
return self._boolean(self._get(url), 204, 404)
|
'Invite the user to join this team.
This returns a dictionary like so::
{\'state\': \'pending\', \'url\': \'https://api.github.com/teams/...\'}
:param str username: (required), user to invite to join this team.
:returns: dictionary'
| @requires_auth
def invite(self, username):
| url = self._build_url(u'memberships', username, base_url=self._api)
return self._json(self._put(url), 200)
|
'Check if ``login`` is a member of this team.
:param str username: (required), username name of the user
:returns: bool'
| @requires_auth
def is_member(self, username):
| url = self._build_url(u'members', username, base_url=self._api)
return self._boolean(self._get(url), 204, 404)
|
'Iterate over the members of this team.
:param str role: (optional), filter members returned by their role
in the team. Can be one of: ``"member"``, ``"maintainer"``,
``"all"``. Default: ``"all"``.
:param int number: (optional), number of users to iterate over.
Default: -1 iterates over all values
:param str etag: (opt... | @requires_auth
def members(self, role=None, number=(-1), etag=None):
| headers = {}
params = {}
if (role in self.members_roles):
params[u'role'] = role
headers[u'Accept'] = u'application/vnd.github.ironman-preview+json'
url = self._build_url(u'members', base_url=self._api)
return self._iter(int(number), url, users.ShortUser, params=params, etag=etag, he... |
'Iterate over the repositories this team has access to.
:param int number: (optional), number of repos to iterate over.
Default: -1 iterates over all values
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Repository <github3.repos.Repository>`
objects'
| @requires_auth
def repositories(self, number=(-1), etag=None):
| headers = {u'Accept': u'application/vnd.github.ironman-preview+json'}
url = self._build_url(u'repos', base_url=self._api)
return self._iter(int(number), url, Repository, etag=etag, headers=headers)
|
'Retrieve the membership information for the user.
:param str username: (required), name of the user
:returns: dictionary'
| @requires_auth
def membership_for(self, username):
| url = self._build_url(u'memberships', username, base_url=self._api)
json = self._json(self._get(url), 200)
return (json or {})
|
'Remove ``username`` from this team.
:param str username: (required), username of the member to remove
:returns: bool'
| @requires_auth
def remove_member(self, username):
| warnings.warn(u'This is no longer supported by the GitHub API, see https://developer.github.com/changes/2014-09-23-one-more-week-before-the-add-team-member-api-breaking-change/', DeprecationWarning)
url = self._build_url(u'members', username, base_url=self._api)
return self._bo... |
'Revoke this user\'s team membership.
:param str username: (required), name of the team member
:returns: bool'
| @requires_auth
def revoke_membership(self, username):
| url = self._build_url(u'memberships', username, base_url=self._api)
return self._boolean(self._delete(url), 204, 404)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.