Class SearchAPI
java.lang.Object
edu.sustech.search.engine.github.API.RestAPI
edu.sustech.search.engine.github.API.SearchAPI
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Each time a successful response is received from the server, theparse
method will be invoked to parse the raw response body (inString
) into a POJO. -
Field Summary
Fields inherited from class edu.sustech.search.engine.github.API.RestAPI
TIME_OUT_DURATION
-
Method Summary
Modifier and TypeMethodDescriptionstatic SearchAPI
registerAPI
(String... OAuthTokens) Register a new SearchAPI based on OAuthTokens providedstatic SearchAPI
registerAPI
(List<String> OAuthTokens) Register a new SearchAPI based on OAuthTokens providedsearch
(SearchRequest request) searchCode
(CodeSearchRequest request1, int count) This method is a type-restricted implementation of the methodsearchType
.searchCode
(CodeSearchRequest request1, int count, long timeIntervalMillis) This method is a type-restricted implementation of the methodsearchType
.searchCommit
(CommitSearchRequest request1, int count) This method is a type-restricted implementation of the methodsearchType
.searchCommit
(CommitSearchRequest request1, int count, long timeIntervalMillis) This method is a type-restricted implementation of the methodsearchType
.searchIPR
(IPRSearchRequest request1, int count) Search Issues and Pull-requests.searchIPR
(IPRSearchRequest request1, int count, long timeIntervalMillis) Search Issues and Pull-requests.searchLabel
(LabelSearchRequest request1, int count) This method is a type-restricted implementation of the methodsearchType
.searchLabel
(LabelSearchRequest request1, int count, long timeIntervalMillis) This method is a type-restricted implementation of the methodsearchType
.searchLoop
(SearchRequest request, int targetPageCount, long timeIntervalMillis) searchLoopFetching
(SearchRequest request1, SearchAPI.AppendableResultParser p, int count, long timeIntervalMillis) This method uses while loop to request for search results.searchLoopFetching
(SearchRequest request1, AppendableResult origin, SearchAPI.AppendableResultParser p, int count, long timeIntervalMillis) This method uses while loop to request for search results.searchRaw
(SearchRequest request) searchRepo
(RepoSearchRequest request1, int count) This method is a type-restricted implementation of the methodsearchType
.searchRepo
(RepoSearchRequest request1, int count, long timeIntervalMillis) This method is a type-restricted implementation of the methodsearchType
.<T> T
searchResult
(SearchRequest request, Class<T> clazz) Automatically cast request result to the desired form.searchTopic
(TopicSearchRequest request1, int count) This method is a type-restricted implementation of the methodsearchType
.searchTopic
(TopicSearchRequest request1, int count, long timeIntervalMillis) This method is a type-restricted implementation of the methodsearchType
.<T extends AppendableResult>
TsearchType
(SearchRequest request1, Class<T> targetClazz, int count, long timeIntervalMillis) This method uses while loop to request for search results.searchUser
(UserSearchRequest request1, int count) This method is a type-restricted implementation of the methodsearchType
.searchUser
(UserSearchRequest request1, int count, long timeIntervalMillis) This method is a type-restricted implementation of the methodsearchType
.void
setProvidingTextMatch
(boolean enabled) If set totrue
, the search result will provide text-match metadata.Methods inherited from class edu.sustech.search.engine.github.API.RestAPI
addToken, convert, getHttpResponse, getHttpResponse, getHttpResponseLoopFetching, getHttpResponseLoopFetching, getHttpResponseLoopFetching, getHttpResponseLoopFetching, getHttpResponseRaw, getHttpResponseRaw, getHttpResponseRawLoopFetching, getHttpResponseRawLoopFetching, getHttpResponseRawLoopFetching, getHttpResponseRawLoopFetching, getNextToken, getRateLimit, getTokenCursor, parseEndPageCount, printRateLimit, setSuppressRateError, setSuppressResponseError, setTokenCursor
-
Method Details
-
searchIPR
public IPRResult searchIPR(IPRSearchRequest request1, int count) throws IOException, InterruptedException Search Issues and Pull-requests. This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-- Returns:
- Throws:
IOException
InterruptedException
-
searchIPR
public IPRResult searchIPR(IPRSearchRequest request1, int count, long timeIntervalMillis) throws IOException, InterruptedException Search Issues and Pull-requests. This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-timeIntervalMillis
-- Returns:
- Throws:
IOException
InterruptedException
-
searchCommit
public CommitResult searchCommit(CommitSearchRequest request1, int count) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-- Returns:
- Throws:
IOException
InterruptedException
-
searchCommit
public CommitResult searchCommit(CommitSearchRequest request1, int count, long timeIntervalMillis) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-timeIntervalMillis
-- Returns:
- Throws:
IOException
InterruptedException
-
searchLabel
public LabelResult searchLabel(LabelSearchRequest request1, int count) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-- Returns:
- Throws:
IOException
InterruptedException
-
searchLabel
public LabelResult searchLabel(LabelSearchRequest request1, int count, long timeIntervalMillis) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-timeIntervalMillis
-- Returns:
- Throws:
IOException
InterruptedException
-
searchTopic
public TopicResult searchTopic(TopicSearchRequest request1, int count) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-- Returns:
- Throws:
IOException
InterruptedException
-
searchTopic
public TopicResult searchTopic(TopicSearchRequest request1, int count, long timeIntervalMillis) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-timeIntervalMillis
-- Returns:
- Throws:
IOException
InterruptedException
-
searchUser
public UserResult searchUser(UserSearchRequest request1, int count) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-- Returns:
- Throws:
IOException
InterruptedException
-
searchUser
public UserResult searchUser(UserSearchRequest request1, int count, long timeIntervalMillis) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-timeIntervalMillis
-- Returns:
- Throws:
IOException
InterruptedException
-
searchCode
public CodeResult searchCode(CodeSearchRequest request1, int count) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-- Returns:
- Throws:
IOException
InterruptedException
-
searchCode
public CodeResult searchCode(CodeSearchRequest request1, int count, long timeIntervalMillis) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-timeIntervalMillis
-- Returns:
- Throws:
IOException
InterruptedException
-
searchRepo
public RepositoryResult searchRepo(RepoSearchRequest request1, int count) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-- Returns:
- Throws:
IOException
InterruptedException
-
searchRepo
public RepositoryResult searchRepo(RepoSearchRequest request1, int count, long timeIntervalMillis) throws IOException, InterruptedException This method is a type-restricted implementation of the methodsearchType
. For detailed documentation, seesearchType
- Parameters:
request1
-count
-timeIntervalMillis
-- Returns:
- Throws:
IOException
InterruptedException
-
searchType
public <T extends AppendableResult> T searchType(SearchRequest request1, Class<T> targetClazz, int count, long timeIntervalMillis) throws IOException, InterruptedException This method uses while loop to request for search results. Please notice that the GitHub REST API may severely restrict your ability to query the result.
If too often the secondary rate limit is encountered, please increase thetimeIntervalMillis
(a typical recommendation might be15000
), and run this method in another thread.
If multiple OAuthTokens are used, then the time interval between each request can be noticeably reduced.- Type Parameters:
T
- Result type- Parameters:
request1
- Request (will create another copy)targetClazz
- Target class for object mappercount
- Target item count. Note that the actual items retrieved might be moretimeIntervalMillis
- Preferred time interval between requests- Returns:
- CodeResult
- Throws:
InterruptedException
- Typically when time interval is interruptedIOException
- Typically when connection between this API and the server fails to establish or accidentally closed.
-
searchLoopFetching
public AppendableResult searchLoopFetching(SearchRequest request1, SearchAPI.AppendableResultParser p, int count, long timeIntervalMillis) throws InterruptedException, IOException This method uses while loop to request for search results. Please notice that the GitHub REST API may severely restrict your ability to query the result.
If too often the secondary rate limit is encountered, please increase thetimeIntervalMillis
(a typical recommendation might be15000
), and run this method in another thread.
If multiple OAuthTokens are used, then the time interval between each request can be noticeably reduced.- Parameters:
request1
- Request (will create another copy)p
- A functional interface used to parse the resultcount
- Target item count. Note that the actual items retrieved might be moretimeIntervalMillis
- Preferred time interval between requests- Returns:
- Results gathered through loop fetching
- Throws:
InterruptedException
- Typically when time interval is interruptedIOException
- Typically when connection between this API and the server fails to establish or accidentally closed.
-
searchLoopFetching
public AppendableResult searchLoopFetching(SearchRequest request1, AppendableResult origin, SearchAPI.AppendableResultParser p, int count, long timeIntervalMillis) throws InterruptedException, IOException This method uses while loop to request for search results. Please notice that the GitHub REST API may severely restrict your ability to query the result.
If too often the secondary rate limit is encountered, please increase thetimeIntervalMillis
(a typical recommendation might be15000
), and run this method in another thread.
If multiple OAuthTokens are used, then the time interval between each request can be noticeably reduced.- Parameters:
request1
- Request (will create another copy)origin
- The origin result that waits to be appended on. Ifnull
, then a new empty origin will be created.p
- A functional interface used to parse the resultcount
- Target item count. Note that the actual items retrieved might be moretimeIntervalMillis
- Preferred time interval between requests- Returns:
- Throws:
InterruptedException
IOException
-
searchResult
public <T> T searchResult(SearchRequest request, Class<T> clazz) throws IOException, InterruptedException Automatically cast request result to the desired form.- Type Parameters:
T
- Target type- Parameters:
request
- Requestclazz
- Target type class instance- Returns:
- Object result
- Throws:
IOException
InterruptedException
-
searchRaw
- Throws:
IOException
InterruptedException
-
searchLoop
public List<HttpResponse<String>> searchLoop(SearchRequest request, int targetPageCount, long timeIntervalMillis) throws IOException, InterruptedException - Parameters:
request
- Request (will create another copy)targetPageCount
- Target page count.timeIntervalMillis
- Preferred time interval between requests- Returns:
- Request result
- Throws:
IOException
InterruptedException
-
search
- Parameters:
request
- Request (will create another copy)- Returns:
- Request result
- Throws:
IOException
InterruptedException
-
setProvidingTextMatch
public void setProvidingTextMatch(boolean enabled) If set totrue
, the search result will provide text-match metadata.- Parameters:
enabled
- Whether the search result shall enable text-match providing.
-
registerAPI
Register a new SearchAPI based on OAuthTokens provided- Parameters:
OAuthTokens
- Array of OAuthTokens- Returns:
-
registerAPI
Register a new SearchAPI based on OAuthTokens provided- Parameters:
OAuthTokens
- List of OAuthTokens- Returns:
-