Skip to content

Commit

Permalink
Kotlin add lintered files and remove Android app (#6561)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Jason Quesenberry <[email protected]>
  • Loading branch information
scmacdon and beqqrry-aws authored Jun 18, 2024
1 parent 64433f5 commit 3232280
Show file tree
Hide file tree
Showing 277 changed files with 3,519 additions and 4,421 deletions.
16 changes: 15 additions & 1 deletion .github/linters/ktlint_config
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.{kt,kts}]
ktlint_code_style = ktlint_official
indent_size = 4
ij_kotlin_packages_to_use_import_on_demand = unset
ij_kotlin_name_count_to_use_star_import = 999
ij_kotlin_name_count_to_use_star_import_for_members = 999
ktlint_code_style=intellij_idea
ktlint_standard_no-consecutive-comments = disabled

[*.{yml,yaml}]
indent_size = 2
2 changes: 1 addition & 1 deletion kotlin/services/apigateway/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
implementation("com.google.code.gson:gson:2.10")
}
tasks.withType<KotlinCompile>() {
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
tasks.test {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.create_deployment.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.CreateDeploymentRequest
import kotlin.system.exitProcess
// snippet-end:[apigateway.kotlin.create_deployment.import]

suspend fun main(args:Array<String>) {

val usage = """
Usage:
<restApiId> <stageName>
Where:
restApiId - The string identifier of the associated RestApi. (for example, xxxx99ewyg).
stageName - The name of the stage.
"""

if (args.size != 2) {
println(usage)
exitProcess(0)
}

val restApiId = args[0]
val stageName = args[1]
createNewDeployment(restApiId, stageName)
}

// snippet-start:[apigateway.kotlin.create_deployment.main]
suspend fun createNewDeployment(restApiIdVal: String?, stageNameVal: String?): String? {

val request = CreateDeploymentRequest {
restApiId = restApiIdVal
description = "Created using the AWS API Gateway Kotlin API"
stageName = stageNameVal
}

ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
val response = apiGateway.createDeployment(request)
println("The id of the deployment is " + response.id)
return response.id
}
}
// snippet-end:[apigateway.kotlin.create_deployment.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.create_deployment.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.CreateDeploymentRequest
import kotlin.system.exitProcess
// snippet-end:[apigateway.kotlin.create_deployment.import]

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<restApiId> <stageName>
Where:
restApiId - The string identifier of the associated RestApi. (for example, xxxx99ewyg).
stageName - The name of the stage.
"""

if (args.size != 2) {
println(usage)
exitProcess(0)
}

val restApiId = args[0]
val stageName = args[1]
createNewDeployment(restApiId, stageName)
}

// snippet-start:[apigateway.kotlin.create_deployment.main]
suspend fun createNewDeployment(restApiIdVal: String?, stageNameVal: String?): String? {
val request = CreateDeploymentRequest {
restApiId = restApiIdVal
description = "Created using the AWS API Gateway Kotlin API"
stageName = stageNameVal
}

ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
val response = apiGateway.createDeployment(request)
println("The id of the deployment is " + response.id)
return response.id
}
}
// snippet-end:[apigateway.kotlin.create_deployment.main]
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.create_api.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.CreateRestApiRequest
import kotlin.system.exitProcess
// snippet-end:[apigateway.kotlin.create_api.import]

suspend fun main(args:Array<String>) {

val usage = """
Usage:
<restApiId>
Where:
restApiId - The string identifier of an existing RestApi. (for example, xxxx99ewyg).
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val restApiId = args[0]
createAPI(restApiId)
}

// snippet-start:[apigateway.kotlin.create_api.main]
suspend fun createAPI(restApiName: String?): String? {

val request = CreateRestApiRequest {
description = "Created using the Gateway Kotlin API"
name = restApiName
}

ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
val response = apiGateway.createRestApi(request)
println("The id of the new api is ${response.id}")
return response.id
}
}
// snippet-end:[apigateway.kotlin.create_api.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.create_api.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.CreateRestApiRequest
import kotlin.system.exitProcess
// snippet-end:[apigateway.kotlin.create_api.import]

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<restApiId>
Where:
restApiId - The string identifier of an existing RestApi. (for example, xxxx99ewyg).
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val restApiId = args[0]
createAPI(restApiId)
}

// snippet-start:[apigateway.kotlin.create_api.main]
suspend fun createAPI(restApiName: String?): String? {
val request = CreateRestApiRequest {
description = "Created using the Gateway Kotlin API"
name = restApiName
}

ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
val response = apiGateway.createRestApi(request)
println("The id of the new api is ${response.id}")
return response.id
}
}
// snippet-end:[apigateway.kotlin.create_api.main]
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.delete_api.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.DeleteRestApiRequest
import kotlin.system.exitProcess
// snippet-end:[apigateway.kotlin.delete_api.import]


suspend fun main(args:Array<String>) {

val usage = """
Usage:
<restApiId>
Where:
restApiId - The string identifier of an existing RestApi. (for example, xxxx99ewyg).
"""

if (args.size != 1) {
println(usage)
exitProcess(1)
}

val restApiId = args[0]
deleteAPI(restApiId)
}

// snippet-start:[apigateway.kotlin.delete_api.main]
suspend fun deleteAPI(restApiIdVal: String?) {

val request = DeleteRestApiRequest {
restApiId = restApiIdVal
}

ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
apiGateway.deleteRestApi(request)
println("The API was successfully deleted")
}
}
// snippet-end:[apigateway.kotlin.delete_api.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.delete_api.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.DeleteRestApiRequest
import kotlin.system.exitProcess
// snippet-end:[apigateway.kotlin.delete_api.import]

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<restApiId>
Where:
restApiId - The string identifier of an existing RestApi. (for example, xxxx99ewyg).
"""

if (args.size != 1) {
println(usage)
exitProcess(1)
}

val restApiId = args[0]
deleteAPI(restApiId)
}

// snippet-start:[apigateway.kotlin.delete_api.main]
suspend fun deleteAPI(restApiIdVal: String?) {
val request = DeleteRestApiRequest {
restApiId = restApiIdVal
}

ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
apiGateway.deleteRestApi(request)
println("The API was successfully deleted")
}
}
// snippet-end:[apigateway.kotlin.delete_api.main]
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.get_apikeys.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.GetApiKeysRequest
// snippet-end:[apigateway.kotlin.get_apikeys.import]

suspend fun main() {
getKeys()
}

// snippet-start:[apigateway.kotlin.get_apikeys.main]
suspend fun getKeys() {

ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
val response = apiGateway.getApiKeys(GetApiKeysRequest { })
response.items?.forEach { key ->
println("Key is $key")
}
}
}
// snippet-end:[apigateway.kotlin.get_apikeys.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.gateway

// snippet-start:[apigateway.kotlin.get_apikeys.import]
import aws.sdk.kotlin.services.apigateway.ApiGatewayClient
import aws.sdk.kotlin.services.apigateway.model.GetApiKeysRequest
// snippet-end:[apigateway.kotlin.get_apikeys.import]

suspend fun main() {
getKeys()
}

// snippet-start:[apigateway.kotlin.get_apikeys.main]
suspend fun getKeys() {
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
val response = apiGateway.getApiKeys(GetApiKeysRequest { })
response.items?.forEach { key ->
println("Key is $key")
}
}
}
// snippet-end:[apigateway.kotlin.get_apikeys.main]
Loading

0 comments on commit 3232280

Please sign in to comment.