1717from github3.models import GitHubCore
1818from github3.orgs import Organization
1919from github3.repos import Repository
20- from github3.search import (CodeSearchResult, RepositorySearchResult ,
21- UserSearchResult)
20+ from github3.search import (CodeSearchResult, IssueSearchResult ,
21+ RepositorySearchResult, UserSearchResult)
2222from github3.structs import SearchIterator
2323from github3.users import User, Key
2424from github3.notifications import Thread
@@ -1018,7 +1018,7 @@ def search_code(self, query, sort=None, order=None, per_page=None,
10181018 options: ``asc``, ``desc``; default: ``desc``
10191019 :param int per_page: (optional)
10201020 :param bool text_match: (optional), if True, return matching search
1021- terms. See http://git.io/4ct1eQ for more information
1021+ terms. See http://git.io/iRmJxg for more information
10221022 :param int number: (optional), number of repositories to return.
10231023 Default: -1, returns all available repositories
10241024 :param str etag: (optional), previous ETag header value
@@ -1043,6 +1043,71 @@ def search_code(self, query, sort=None, order=None, per_page=None,
10431043 return SearchIterator(number, url, CodeSearchResult, self, params,
10441044 etag, headers)
10451045
1046+ def search_issues(self, query, sort=None, order=None, per_page=None,
1047+ text_match=False, number=-1, etag=None):
1048+ """Find issues by state and keyword
1049+
1050+ The query can contain any combination of the following supported
1051+ qualifers:
1052+
1053+ - ``type`` With this qualifier you can restrict the search to issues
1054+ or pull request only.
1055+ - ``in`` Qualifies which fields are searched. With this qualifier you
1056+ can restrict the search to just the title, body, comments, or any
1057+ combination of these.
1058+ - ``author`` Finds issues created by a certain user.
1059+ - ``assignee`` Finds issues that are assigned to a certain user.
1060+ - ``mentions`` Finds issues that mention a certain user.
1061+ - ``commenter`` Finds issues that a certain user commented on.
1062+ - ``involves`` Finds issues that were either created by a certain user,
1063+ assigned to that user, mention that user, or were commented on by
1064+ that user.
1065+ - ``state`` Filter issues based on whether they’re open or closed.
1066+ - ``labels`` Filters issues based on their labels.
1067+ - ``language`` Searches for issues within repositories that match a
1068+ certain language.
1069+ - ``created`` or ``updated`` Filters issues based on times of creation,
1070+ or when they were last updated.
1071+ - ``comments`` Filters issues based on the quantity of comments.
1072+ - ``user`` or ``repo`` Limits searches to a specific user or
1073+ repository.
1074+
1075+ For more information about these qualifiers, see: http://git.io/d1oELA
1076+
1077+ :param str query: (required), a valid query as described above, e.g.,
1078+ ``windows label:bug``
1079+ :param str sort: (optional), how the results should be sorted;
1080+ options: ``created``, ``comments``, ``updated``;
1081+ default: best match
1082+ :param str order: (optional), the direction of the sorted results,
1083+ options: ``asc``, ``desc``; default: ``desc``
1084+ :param int per_page: (optional)
1085+ :param bool text_match: (optional), if True, return matching search
1086+ terms. See http://git.io/QLQuSQ for more information
1087+ :param int number: (optional), number of issues to return.
1088+ Default: -1, returns all available issues
1089+ :param str etag: (optional), previous ETag header value
1090+ :return: generator of :class:`IssueSearchResult
1091+ <github3.search.IssueSearchResult>`
1092+ """
1093+ params = {'q': query}
1094+ headers = {}
1095+
1096+ if sort in ('comments', 'created', 'updated'):
1097+ params['sort'] = sort
1098+
1099+ if order in ('asc', 'desc'):
1100+ params['order'] = order
1101+
1102+ if text_match:
1103+ headers = {
1104+ 'Accept': 'application/vnd.github.v3.full.text-match+json'
1105+ }
1106+
1107+ url = self._build_url('search', 'issues')
1108+ return SearchIterator(number, url, IssueSearchResult, self, params,
1109+ etag, headers)
1110+
10461111 def search_repositories(self, query, sort=None, order=None,
10471112 per_page=None, text_match=False, number=-1,
10481113 etag=None):
0 commit comments