generated from JetBrains/intellij-platform-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
96 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/kotlin/com/dsoftware/ghmanager/api/GhApiRequestExecutor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.dsoftware.ghmanager.api | ||
|
||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.progress.ProcessCanceledException | ||
import com.intellij.openapi.progress.ProgressIndicator | ||
import com.intellij.util.io.HttpSecurityUtil | ||
import org.jetbrains.plugins.github.api.GHRequestExecutorBreaker | ||
import org.jetbrains.plugins.github.api.GithubApiRequest | ||
import org.jetbrains.plugins.github.api.GithubApiRequestExecutor | ||
import org.jetbrains.plugins.github.util.GithubSettings | ||
import java.io.IOException | ||
|
||
/** | ||
* Executes API requests taking care of authentication, headers, proxies, timeouts, etc. | ||
*/ | ||
class GhApiRequestExecutor( | ||
githubSettings: GithubSettings, | ||
private val token: String, | ||
private val useProxy: Boolean, | ||
) : GithubApiRequestExecutor.Base(githubSettings) { | ||
|
||
@Throws(IOException::class, ProcessCanceledException::class) | ||
override fun <T> execute(indicator: ProgressIndicator, request: GithubApiRequest<T>): T { | ||
check(!service<GHRequestExecutorBreaker>().isRequestsShouldFail) { | ||
"Request failure was triggered by user action. This a pretty long description of this failure that should resemble some long error which can go out of bounds." | ||
} | ||
|
||
indicator.checkCanceled() | ||
return createRequestBuilder(request) | ||
.tuner { connection -> | ||
request.additionalHeaders.forEach(connection::addRequestProperty) | ||
if (request.url.contains(connection.url.host)) { | ||
connection.addRequestProperty(HttpSecurityUtil.AUTHORIZATION_HEADER_NAME, "Bearer ${token}") | ||
} | ||
} | ||
.useProxy(useProxy) | ||
.execute(request, indicator) | ||
} | ||
|
||
|
||
companion object { | ||
fun create(token: String): GhApiRequestExecutor = | ||
GhApiRequestExecutor(GithubSettings.getInstance(), token, true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 23 additions & 26 deletions
49
src/main/kotlin/com/dsoftware/ghmanager/data/providers/DataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/dsoftware/ghmanager/data/providers/JobsDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/dsoftware/ghmanager/data/providers/LogDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters