-
Notifications
You must be signed in to change notification settings - Fork 501
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
16 changed files
with
280 additions
and
8 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
1 change: 1 addition & 0 deletions
1
modules/core/.jvm/a/store/refresh_error/v1/github/xuwei-k/nobox/refresh_error.json
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 @@ | ||
null |
1 change: 1 addition & 0 deletions
1
...core/.jvm/a/store/refresh_error/v1/github/xuwei-k/scala-steward-test-1/refresh_error.json
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 @@ | ||
null |
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
21 changes: 21 additions & 0 deletions
21
modules/core/src/main/scala/org/scalasteward/core/vcs/github/GitHubApp.scala
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,21 @@ | ||
/* | ||
* Copyright 2018-2020 Scala Steward contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.scalasteward.core.vcs.github | ||
|
||
import better.files.File | ||
|
||
case class GitHubApp(id: Long, keyFile: File) |
74 changes: 74 additions & 0 deletions
74
modules/core/src/main/scala/org/scalasteward/core/vcs/github/GitHubAppApiAlg.scala
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,74 @@ | ||
/* | ||
* Copyright 2018-2020 Scala Steward contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.scalasteward.core.vcs.github | ||
|
||
import cats.Applicative | ||
import org.http4s.{Header, Uri} | ||
import org.scalasteward.core.util.HttpJsonClient | ||
|
||
class GitHubAppApiAlg[F[_]: Applicative]( | ||
gitHubApiHost: Uri | ||
)(implicit | ||
client: HttpJsonClient[F] | ||
) { | ||
|
||
private[this] val acceptHeader = | ||
Header("Accept", "application/vnd.github.v3+json") | ||
|
||
private[this] def addHeaders(jwt: String): client.ModReq = | ||
req => | ||
Applicative[F].point( | ||
req.putHeaders( | ||
Header("Authorization", s"Bearer $jwt"), | ||
acceptHeader | ||
) | ||
) | ||
|
||
/** [[https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-installations-for-the-authenticated-app]] | ||
* | ||
* TODO pagination use `page` query param | ||
*/ | ||
def installations(jwt: String): F[List[InstallationOut]] = | ||
client.get( | ||
(gitHubApiHost / "app" / "installations").withQueryParam("per_page", 100), | ||
addHeaders(jwt) | ||
) | ||
|
||
/** [[https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#create-an-installation-access-token-for-an-app]] */ | ||
def accessToken(jwt: String, installationId: Long): F[TokenOut] = | ||
client.post( | ||
gitHubApiHost / "app" / "installations" / installationId.toString / "access_tokens", | ||
addHeaders(jwt) | ||
) | ||
|
||
/** [[https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-repositories-accessible-to-the-app-installation]] | ||
* | ||
* TODO pagination use `page` query param | ||
*/ | ||
def repositories(token: String): F[RepositoriesOut] = | ||
client | ||
.get( | ||
(gitHubApiHost / "installation" / "repositories").withQueryParam("per_page", 100), | ||
req => | ||
Applicative[F].point( | ||
req.putHeaders( | ||
Header("Authorization", s"token ${token}"), | ||
acceptHeader | ||
) | ||
) | ||
) | ||
} |
25 changes: 25 additions & 0 deletions
25
modules/core/src/main/scala/org/scalasteward/core/vcs/github/InstallationOut.scala
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,25 @@ | ||
/* | ||
* Copyright 2018-2020 Scala Steward contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.scalasteward.core.vcs.github | ||
|
||
import io.circe.Decoder | ||
import io.circe.generic.semiauto.deriveDecoder | ||
|
||
case class InstallationOut(id: Long) | ||
object InstallationOut { | ||
implicit val installationDecoder: Decoder[InstallationOut] = deriveDecoder | ||
} |
30 changes: 30 additions & 0 deletions
30
modules/core/src/main/scala/org/scalasteward/core/vcs/github/RepositoriesOut.scala
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,30 @@ | ||
/* | ||
* Copyright 2018-2020 Scala Steward contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.scalasteward.core.vcs.github | ||
|
||
import io.circe.Decoder | ||
import io.circe.generic.semiauto.deriveDecoder | ||
|
||
case class RepositoriesOut(repositories: List[Repository]) | ||
object RepositoriesOut { | ||
implicit val repositoriesDecoder: Decoder[RepositoriesOut] = deriveDecoder | ||
} | ||
|
||
case class Repository(full_name: String) | ||
object Repository { | ||
implicit val repositoryDecoder: Decoder[Repository] = deriveDecoder | ||
} |
25 changes: 25 additions & 0 deletions
25
modules/core/src/main/scala/org/scalasteward/core/vcs/github/TokenOut.scala
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,25 @@ | ||
/* | ||
* Copyright 2018-2020 Scala Steward contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.scalasteward.core.vcs.github | ||
|
||
import io.circe.Decoder | ||
import io.circe.generic.semiauto.deriveDecoder | ||
|
||
case class TokenOut(token: String) | ||
object TokenOut { | ||
implicit val tokenDecoder: Decoder[TokenOut] = deriveDecoder | ||
} |
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
Oops, something went wrong.