-
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.
- Loading branch information
Showing
10 changed files
with
507 additions
and
388 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
105 changes: 52 additions & 53 deletions
105
kotlin/services/xray/src/main/kotlin/com/kotlin/xray/CreateGroup.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,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] |
132 changes: 66 additions & 66 deletions
132
kotlin/services/xray/src/main/kotlin/com/kotlin/xray/CreateSamplingRule.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,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
103
kotlin/services/xray/src/main/kotlin/com/kotlin/xray/DeleteGroup.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,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] |
Oops, something went wrong.