Skip to content

Commit

Permalink
Kotlin add lintered files and update Kotlin SDK version to 1.2.28 (#6527
Browse files Browse the repository at this point in the history
)
  • Loading branch information
scmacdon authored Jun 10, 2024
1 parent 2a2fec3 commit 2d8381f
Show file tree
Hide file tree
Showing 268 changed files with 17,787 additions and 16,847 deletions.
8 changes: 4 additions & 4 deletions kotlin/services/appsync/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ repositories {
}
apply(plugin = "org.jlleitschuh.gradle.ktlint")
dependencies {
implementation("aws.sdk.kotlin:appsync:1.0.30")
implementation("aws.sdk.kotlin:sts:1.0.30")
implementation("aws.sdk.kotlin:s3:1.0.30")
implementation("aws.sdk.kotlin:secretsmanager:1.0.30")
implementation("aws.sdk.kotlin:appsync:1.2.28")
implementation("aws.sdk.kotlin:sts:1.2.28")
implementation("aws.sdk.kotlin:s3:1.2.28")
implementation("aws.sdk.kotlin:secretsmanager:1.2.28")
implementation("aws.smithy.kotlin:http-client-engine-okhttp:0.30.0")
implementation("aws.smithy.kotlin:http-client-engine-crt:0.30.0")
implementation("com.google.code.gson:gson:2.10")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.example.appsync

// snippet-start:[appsync.kotlin.create_key.import]
import aws.sdk.kotlin.services.appsync.AppSyncClient
import aws.sdk.kotlin.services.appsync.model.CreateApiKeyRequest
import kotlin.system.exitProcess
// snippet-end:[appsync.kotlin.create_key.import]

/**
* Before running this Kotlin code example, set up your development environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/
suspend fun main(args: Array<String>) {

val usage = """
Usage:
<apiId>
Where:
apiId - The Id of the API. (You can get this value from the AWS Management Console.)
"""

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

val apiId = args[0]
val key = createKey(apiId)
println("The Id of the new Key is $key")
}

// snippet-start:[appsync.kotlin.create_key.main]
suspend fun createKey(apiIdVal: String): String? {

val apiKeyRequest = CreateApiKeyRequest {
apiId = apiIdVal
description = "Created using the AWS SDK for Kotlin"
}

AppSyncClient { region = "us-east-1" }.use { appClient ->
val response = appClient.createApiKey(apiKeyRequest)
return response.apiKey?.id
}
}
// snippet-end:[appsync.kotlin.create_key.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.example.appsync

// snippet-start:[appsync.kotlin.create_key.import]
import aws.sdk.kotlin.services.appsync.AppSyncClient
import aws.sdk.kotlin.services.appsync.model.CreateApiKeyRequest
import kotlin.system.exitProcess
// snippet-end:[appsync.kotlin.create_key.import]

/**
* Before running this Kotlin code example, set up your development environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/
suspend fun main(args: Array<String>) {
val usage = """
Usage:
<apiId>
Where:
apiId - The Id of the API. (You can get this value from the AWS Management Console.)
"""

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

val apiId = args[0]
val key = createKey(apiId)
println("The Id of the new Key is $key")
}

// snippet-start:[appsync.kotlin.create_key.main]
suspend fun createKey(apiIdVal: String): String? {
val apiKeyRequest =
CreateApiKeyRequest {
apiId = apiIdVal
description = "Created using the AWS SDK for Kotlin"
}

AppSyncClient { region = "us-east-1" }.use { appClient ->
val response = appClient.createApiKey(apiKeyRequest)
return response.apiKey?.id
}
}
// snippet-end:[appsync.kotlin.create_key.main]
Original file line number Diff line number Diff line change
@@ -1,71 +1,76 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.example.appsync

// snippet-start:[appsync.kotlin.create_ds.import]
import aws.sdk.kotlin.services.appsync.AppSyncClient
import aws.sdk.kotlin.services.appsync.model.CreateDataSourceRequest
import aws.sdk.kotlin.services.appsync.model.DataSourceType
import aws.sdk.kotlin.services.appsync.model.DynamodbDataSourceConfig
import kotlin.system.exitProcess
// snippet-end:[appsync.kotlin.create_ds.import]

/**
* Before running this Kotlin code example, set up your development environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

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

val usage = """
Usage:
<apiId> <dsName> <dsRole> <tableName>
Where:
apiId - The Id of the API. (You can get this value from the AWS Management Console.)
dsName - The name of the data source.
dsRole - The AWS Identity and Access Management (IAM) service role for the data source.
tableName - The name of the Amazon DynamoDB table used as the data source.
"""

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

val apiId = args[0]
val dsName = args[1]
val dsRole = args[2]
val tableName = args[3]
val dsARN = createDS(dsName, dsRole, apiId, tableName)
println("The ARN of the data source is $dsARN")
}

// snippet-start:[appsync.kotlin.create_ds.main]
suspend fun createDS(dsName: String, dsRole: String, apiVal: String, tableNameVal: String): String? {

val config = DynamodbDataSourceConfig {
awsRegion = "us-east-1"
tableName = tableNameVal
versioned = true
}

val request = CreateDataSourceRequest {
description = "Created using the AWS SDK for Kotlin"
apiId = apiVal
name = dsName
serviceRoleArn = dsRole
dynamodbConfig = config
type = DataSourceType.AmazonDynamodb
}

AppSyncClient { region = "us-east-1" }.use { appClient ->
val response = appClient.createDataSource(request)
return response.dataSource?.dataSourceArn
}
}
// snippet-end:[appsync.kotlin.create_ds.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.example.appsync

// snippet-start:[appsync.kotlin.create_ds.import]
import aws.sdk.kotlin.services.appsync.AppSyncClient
import aws.sdk.kotlin.services.appsync.model.CreateDataSourceRequest
import aws.sdk.kotlin.services.appsync.model.DataSourceType
import aws.sdk.kotlin.services.appsync.model.DynamodbDataSourceConfig
import kotlin.system.exitProcess
// snippet-end:[appsync.kotlin.create_ds.import]

/**
* Before running this Kotlin code example, set up your development environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<apiId> <dsName> <dsRole> <tableName>
Where:
apiId - The Id of the API. (You can get this value from the AWS Management Console.)
dsName - The name of the data source.
dsRole - The AWS Identity and Access Management (IAM) service role for the data source.
tableName - The name of the Amazon DynamoDB table used as the data source.
"""

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

val apiId = args[0]
val dsName = args[1]
val dsRole = args[2]
val tableName = args[3]
val dsARN = createDS(dsName, dsRole, apiId, tableName)
println("The ARN of the data source is $dsARN")
}

// snippet-start:[appsync.kotlin.create_ds.main]
suspend fun createDS(
dsName: String,
dsRole: String,
apiVal: String,
tableNameVal: String
): String? {
val config =
DynamodbDataSourceConfig {
awsRegion = "us-east-1"
tableName = tableNameVal
versioned = true
}

val request =
CreateDataSourceRequest {
description = "Created using the AWS SDK for Kotlin"
apiId = apiVal
name = dsName
serviceRoleArn = dsRole
dynamodbConfig = config
type = DataSourceType.AmazonDynamodb
}

AppSyncClient { region = "us-east-1" }.use { appClient ->
val response = appClient.createDataSource(request)
return response.dataSource?.dataSourceArn
}
}
// snippet-end:[appsync.kotlin.create_ds.main]
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.example.appsync

// snippet-start:[appsync.kotlin.del_key.import]
import aws.sdk.kotlin.services.appsync.AppSyncClient
import aws.sdk.kotlin.services.appsync.model.DeleteApiKeyRequest
import kotlin.system.exitProcess
// snippet-end:[appsync.kotlin.del_key.import]

/**
* Before running this Kotlin code example, set up your development environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

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

val usage = """
Usage:
<apiId> <keyId>
Where:
apiId - The Id of the API. (You can get this value from the AWS Management Console.)
keyId - The Id of the key to delete.
"""

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

val apiId = args[0]
val keyId = args[1]
deleteKey(keyId, apiId)
}

// snippet-start:[appsync.kotlin.del_key.main]
suspend fun deleteKey(keyIdVal: String?, apiIdVal: String?) {

val apiKeyRequest = DeleteApiKeyRequest {
apiId = apiIdVal
id = keyIdVal
}

AppSyncClient { region = "us-east-1" }.use { appClient ->
appClient.deleteApiKey(apiKeyRequest)
println("$keyIdVal key was deleted.")
}
}
// snippet-end:[appsync.kotlin.del_key.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.example.appsync

// snippet-start:[appsync.kotlin.del_key.import]
import aws.sdk.kotlin.services.appsync.AppSyncClient
import aws.sdk.kotlin.services.appsync.model.DeleteApiKeyRequest
import kotlin.system.exitProcess
// snippet-end:[appsync.kotlin.del_key.import]

/**
* Before running this Kotlin code example, set up your development environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<apiId> <keyId>
Where:
apiId - The Id of the API. (You can get this value from the AWS Management Console.)
keyId - The Id of the key to delete.
"""

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

val apiId = args[0]
val keyId = args[1]
deleteKey(keyId, apiId)
}

// snippet-start:[appsync.kotlin.del_key.main]
suspend fun deleteKey(
keyIdVal: String?,
apiIdVal: String?
) {
val apiKeyRequest =
DeleteApiKeyRequest {
apiId = apiIdVal
id = keyIdVal
}

AppSyncClient { region = "us-east-1" }.use { appClient ->
appClient.deleteApiKey(apiKeyRequest)
println("$keyIdVal key was deleted.")
}
}
// snippet-end:[appsync.kotlin.del_key.main]
Loading

0 comments on commit 2d8381f

Please sign in to comment.