Skip to content

Commit

Permalink
add Kotlin lintered files
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon committed Jun 11, 2024
1 parent 0948d7f commit b107589
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 388 deletions.
4 changes: 2 additions & 2 deletions kotlin/services/xray/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ repositories {
}
apply(plugin = "org.jlleitschuh.gradle.ktlint")
dependencies {
implementation("aws.sdk.kotlin:xray:1.0.30")
implementation("aws.sdk.kotlin:secretsmanager:1.0.30")
implementation("aws.sdk.kotlin:xray: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
105 changes: 52 additions & 53 deletions kotlin/services/xray/src/main/kotlin/com/kotlin/xray/CreateGroup.kt
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.xray

// snippet-start:[xray.kotlin_create_group.import]
import aws.sdk.kotlin.services.xray.XRayClient
import aws.sdk.kotlin.services.xray.model.CreateGroupRequest
import kotlin.system.exitProcess
// snippet-end:[xray.kotlin_create_group.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:
<groupName>
Where:
groupName - The name of the group to create
"""

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

val groupName = args[0]
createNewGroup(groupName)
}

// snippet-start:[xray.kotlin_create_group.main]
suspend fun createNewGroup(groupNameVal: String?) {

val groupRequest = CreateGroupRequest {
filterExpression = "fault = true AND http.url CONTAINS \"example/game\" AND responsetime >= 5"
groupName = groupNameVal
}

XRayClient { region = "us-east-1" }.use { xRayClient ->
val groupResponse = xRayClient.createGroup(groupRequest)
println("The Group ARN is " + (groupResponse.group?.groupArn))
}
}
// snippet-end:[xray.kotlin_create_group.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.xray

// snippet-start:[xray.kotlin_create_group.import]
import aws.sdk.kotlin.services.xray.XRayClient
import aws.sdk.kotlin.services.xray.model.CreateGroupRequest
import kotlin.system.exitProcess
// snippet-end:[xray.kotlin_create_group.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:
<groupName>
Where:
groupName - The name of the group to create
"""

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

val groupName = args[0]
createNewGroup(groupName)
}

// snippet-start:[xray.kotlin_create_group.main]
suspend fun createNewGroup(groupNameVal: String?) {
val groupRequest =
CreateGroupRequest {
filterExpression = "fault = true AND http.url CONTAINS \"example/game\" AND responsetime >= 5"
groupName = groupNameVal
}

XRayClient { region = "us-east-1" }.use { xRayClient ->
val groupResponse = xRayClient.createGroup(groupRequest)
println("The Group ARN is " + (groupResponse.group?.groupArn))
}
}
// snippet-end:[xray.kotlin_create_group.main]
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.xray

// snippet-start:[xray.kotlin_create_rule.import]
import aws.sdk.kotlin.services.xray.XRayClient
import aws.sdk.kotlin.services.xray.model.CreateSamplingRuleRequest
import aws.sdk.kotlin.services.xray.model.CreateSamplingRuleResponse
import aws.sdk.kotlin.services.xray.model.SamplingRule
import kotlin.system.exitProcess
// snippet-end:[xray.kotlin_create_rule.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:
<ruleName>
Where:
ruleName - The name of the rule.
"""

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

val ruleName = args[0]
createRule(ruleName)
}

// snippet-start:[xray.kotlin_create_rule.main]
suspend fun createRule(ruleNameVal: String?) {

val rule = SamplingRule {
ruleName = ruleNameVal
priority = 1
httpMethod = "*"
serviceType = "*"
serviceName = "*"
urlPath = "*"
version = 1
host = "*"
resourceArn = "*"
}

val ruleRequest = CreateSamplingRuleRequest {
samplingRule = rule
}

XRayClient { region = "us-east-1" }.use { xRayClient ->
val ruleResponse: CreateSamplingRuleResponse = xRayClient.createSamplingRule(ruleRequest)
println("The ARN of the new rule is ${ruleResponse.samplingRuleRecord?.samplingRule?.ruleArn}")
}
}
// snippet-end:[xray.kotlin_create_rule.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.xray

// snippet-start:[xray.kotlin_create_rule.import]
import aws.sdk.kotlin.services.xray.XRayClient
import aws.sdk.kotlin.services.xray.model.CreateSamplingRuleRequest
import aws.sdk.kotlin.services.xray.model.CreateSamplingRuleResponse
import aws.sdk.kotlin.services.xray.model.SamplingRule
import kotlin.system.exitProcess
// snippet-end:[xray.kotlin_create_rule.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:
<ruleName>
Where:
ruleName - The name of the rule.
"""

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

val ruleName = args[0]
createRule(ruleName)
}

// snippet-start:[xray.kotlin_create_rule.main]
suspend fun createRule(ruleNameVal: String?) {
val rule =
SamplingRule {
ruleName = ruleNameVal
priority = 1
httpMethod = "*"
serviceType = "*"
serviceName = "*"
urlPath = "*"
version = 1
host = "*"
resourceArn = "*"
}

val ruleRequest =
CreateSamplingRuleRequest {
samplingRule = rule
}

XRayClient { region = "us-east-1" }.use { xRayClient ->
val ruleResponse: CreateSamplingRuleResponse = xRayClient.createSamplingRule(ruleRequest)
println("The ARN of the new rule is ${ruleResponse.samplingRuleRecord?.samplingRule?.ruleArn}")
}
}
// snippet-end:[xray.kotlin_create_rule.main]
103 changes: 51 additions & 52 deletions kotlin/services/xray/src/main/kotlin/com/kotlin/xray/DeleteGroup.kt
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.xray

// snippet-start:[xray.kotlin_delete_group.import]
import aws.sdk.kotlin.services.xray.XRayClient
import aws.sdk.kotlin.services.xray.model.DeleteGroupRequest
import kotlin.system.exitProcess
// snippet-end:[xray.kotlin_delete_group.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:
<groupName>
Where:
groupName - The name of the group.
"""

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

val groupName = args[0]
deleteSpecificGroup(groupName)
}

// snippet-start:[xray.kotlin_delete_group.main]
suspend fun deleteSpecificGroup(groupNameVal: String) {

val groupRequest = DeleteGroupRequest {
groupName = groupNameVal
}

XRayClient { region = "us-east-1" }.use { xRayClient ->
xRayClient.deleteGroup(groupRequest)
println("$groupNameVal was deleted!")
}
}
// snippet-end:[xray.kotlin_delete_group.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.xray

// snippet-start:[xray.kotlin_delete_group.import]
import aws.sdk.kotlin.services.xray.XRayClient
import aws.sdk.kotlin.services.xray.model.DeleteGroupRequest
import kotlin.system.exitProcess
// snippet-end:[xray.kotlin_delete_group.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:
<groupName>
Where:
groupName - The name of the group.
"""

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

val groupName = args[0]
deleteSpecificGroup(groupName)
}

// snippet-start:[xray.kotlin_delete_group.main]
suspend fun deleteSpecificGroup(groupNameVal: String) {
val groupRequest =
DeleteGroupRequest {
groupName = groupNameVal
}

XRayClient { region = "us-east-1" }.use { xRayClient ->
xRayClient.deleteGroup(groupRequest)
println("$groupNameVal was deleted!")
}
}
// snippet-end:[xray.kotlin_delete_group.main]
Loading

0 comments on commit b107589

Please sign in to comment.