-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kotlin add lintered files and update Kotlin SDK version to 1.2.28 (#6527
- Loading branch information
Showing
268 changed files
with
17,787 additions
and
16,847 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
101 changes: 50 additions & 51 deletions
101
kotlin/services/appsync/src/main/kotlin/com/example/appsync/CreateApiKey.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 |
---|---|---|
@@ -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] |
147 changes: 76 additions & 71 deletions
147
kotlin/services/appsync/src/main/kotlin/com/example/appsync/CreateDataSource.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 |
---|---|---|
@@ -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] |
108 changes: 55 additions & 53 deletions
108
kotlin/services/appsync/src/main/kotlin/com/example/appsync/DeleteApiKey.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 |
---|---|---|
@@ -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] |
Oops, something went wrong.