Skip to content

Commit

Permalink
chore: enable explicit API mode for runtime/service components (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianbotsf authored Jul 22, 2022
1 parent 12ffcd0 commit fb5701b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .changes/5c7e4dc6-7bf9-421b-a6d9-01007eacf6be.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "5c7e4dc6-7bf9-421b-a6d9-01007eacf6be",
"type": "misc",
"description": "Enable [Explicit API mode](https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md)",
"issues": [
"awslabs/smithy-kotlin#216"
]
}
3 changes: 1 addition & 2 deletions aws-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ subprojects {
}

kotlin {
// TODO - refactor this to error `explicitApi()`
explicitApiWarning()
explicitApi()

sourceSets {
all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,10 @@ class PresignerGenerator : KotlinIntegration {
writer
.addImport(KotlinTypes.Time.Duration)
.withBlock(
"suspend fun $requestTypeName.presign(config: $serviceClientTypeName.Config, duration: #T): HttpRequest {",
"public suspend fun #L.presign(config: #L.Config, duration: #T): HttpRequest {",
"}\n",
requestTypeName,
serviceClientTypeName,
KotlinTypes.Time.Duration
) {
withBlock("val presignConfig = $presignConfigTypeName {", "}") {
Expand All @@ -341,8 +343,9 @@ class PresignerGenerator : KotlinIntegration {
writer
.addImport(KotlinTypes.Time.Duration)
.withBlock(
"suspend fun $requestTypeName.presign(presignConfig: ServicePresignConfig, duration: #T): HttpRequest {",
"public suspend fun #L.presign(presignConfig: ServicePresignConfig, duration: #T): HttpRequest {",
"}\n",
requestTypeName,
KotlinTypes.Time.Duration
) {
write("return createPresignedRequest(presignConfig, $requestConfigFnName(this, duration))")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PresignerGeneratorTest {
* @param duration the amount of time from signing for which the request is valid, with seconds granularity.
* @return The [HttpRequest] that can be invoked within the specified time window.
*/
suspend fun GetFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest {
public suspend fun GetFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest {
return createPresignedRequest(presignConfig, getFooPresignConfig(this, duration))
}
Expand All @@ -126,7 +126,7 @@ class PresignerGeneratorTest {
* @param duration the amount of time from signing for which the request is valid, with seconds granularity.
* @return The [HttpRequest] that can be invoked within the specified time window.
*/
suspend fun GetFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest {
public suspend fun GetFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest {
val presignConfig = TestPresignConfig {
credentialsProvider = config.credentialsProvider
endpointProvider = config.endpointResolver.asSigningEndpointProvider()
Expand Down Expand Up @@ -155,7 +155,7 @@ class PresignerGeneratorTest {
* @param duration the amount of time from signing for which the request is valid, with seconds granularity.
* @return The [HttpRequest] that can be invoked within the specified time window.
*/
suspend fun PostFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest {
public suspend fun PostFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest {
return createPresignedRequest(presignConfig, postFooPresignConfig(this, duration))
}
Expand All @@ -165,7 +165,7 @@ class PresignerGeneratorTest {
* @param duration the amount of time from signing for which the request is valid, with seconds granularity.
* @return The [HttpRequest] that can be invoked within the specified time window.
*/
suspend fun PostFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest {
public suspend fun PostFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest {
val presignConfig = TestPresignConfig {
credentialsProvider = config.credentialsProvider
endpointProvider = config.endpointResolver.asSigningEndpointProvider()
Expand Down Expand Up @@ -194,7 +194,7 @@ class PresignerGeneratorTest {
* @param duration the amount of time from signing for which the request is valid, with seconds granularity.
* @return The [HttpRequest] that can be invoked within the specified time window.
*/
suspend fun PutFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest {
public suspend fun PutFooRequest.presign(presignConfig: ServicePresignConfig, duration: Duration): HttpRequest {
return createPresignedRequest(presignConfig, putFooPresignConfig(this, duration))
}
Expand All @@ -204,7 +204,7 @@ class PresignerGeneratorTest {
* @param duration the amount of time from signing for which the request is valid, with seconds granularity.
* @return The [HttpRequest] that can be invoked within the specified time window.
*/
suspend fun PutFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest {
public suspend fun PutFooRequest.presign(config: TestClient.Config, duration: Duration): HttpRequest {
val presignConfig = TestPresignConfig {
credentialsProvider = config.credentialsProvider
endpointProvider = config.endpointResolver.asSigningEndpointProvider()
Expand Down
2 changes: 2 additions & 0 deletions services/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ subprojects {
}

kotlin {
explicitApi()

sourceSets {
all {
val srcDir = if (name.endsWith("Main")) "src" else "test"
Expand Down

0 comments on commit fb5701b

Please sign in to comment.