-
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
14 changed files
with
1,055 additions
and
1,005 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
174 changes: 88 additions & 86 deletions
174
kotlin/services/pinpoint/src/main/kotlin/com/kotlin/pinpoint/AddExampleEndpoint.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,86 +1,88 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.kotlin.pinpoint | ||
|
||
// snippet-start:[pinpoint.kotlin.add_endpoint.import] | ||
import aws.sdk.kotlin.services.pinpoint.PinpointClient | ||
import aws.sdk.kotlin.services.pinpoint.model.ChannelType | ||
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchItem | ||
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchRequest | ||
import aws.sdk.kotlin.services.pinpoint.model.EndpointUser | ||
import aws.sdk.kotlin.services.pinpoint.model.UpdateEndpointsBatchRequest | ||
import kotlin.system.exitProcess | ||
// snippet-end:[pinpoint.kotlin.add_endpoint.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: | ||
<appId> | ||
Where: | ||
appId - The Amazon Pinpoint project/application ID to use. | ||
""" | ||
|
||
if (args.size != 1) { | ||
println(usage) | ||
exitProcess(0) | ||
} | ||
|
||
val appId = args[0] | ||
updateEndpointsViaBatch(appId) | ||
} | ||
|
||
// snippet-start:[pinpoint.kotlin.add_endpoint.main] | ||
suspend fun updateEndpointsViaBatch(applicationIdVal: String?) { | ||
|
||
val myNames = mutableListOf<String>() | ||
myNames.add("Richard") | ||
myNames.add("Roe") | ||
|
||
val myMapRichard = mutableMapOf<String, List<String>>() | ||
myMapRichard.put("name", myNames) | ||
|
||
val richardRoe = EndpointUser { | ||
userId = "example_user_1" | ||
userAttributes = myMapRichard | ||
} | ||
|
||
// Create an EndpointBatchItem object for Richard Roe. | ||
val richardRoesEmailEndpoint = EndpointBatchItem { | ||
channelType = ChannelType.Email | ||
address = "[email protected]" | ||
id = "example_endpoint_1" | ||
attributes = myMapRichard | ||
user = richardRoe | ||
} | ||
|
||
val richardList: MutableList<EndpointBatchItem> = ArrayList() | ||
richardList.add(richardRoesEmailEndpoint) | ||
|
||
// Adds multiple endpoint definitions to a single request object. | ||
val endpointList = EndpointBatchRequest { | ||
item = richardList | ||
} | ||
|
||
// Updates the endpoints with Amazon Pinpoint. | ||
PinpointClient { region = "us-west-2" }.use { pinpoint -> | ||
val result = pinpoint.updateEndpointsBatch( | ||
UpdateEndpointsBatchRequest { | ||
applicationId = applicationIdVal | ||
endpointBatchRequest = endpointList | ||
} | ||
) | ||
println("Update endpoint result ${result.messageBody?.message}") | ||
} | ||
} | ||
// snippet-end:[pinpoint.kotlin.add_endpoint.main] | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.kotlin.pinpoint | ||
|
||
// snippet-start:[pinpoint.kotlin.add_endpoint.import] | ||
import aws.sdk.kotlin.services.pinpoint.PinpointClient | ||
import aws.sdk.kotlin.services.pinpoint.model.ChannelType | ||
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchItem | ||
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchRequest | ||
import aws.sdk.kotlin.services.pinpoint.model.EndpointUser | ||
import aws.sdk.kotlin.services.pinpoint.model.UpdateEndpointsBatchRequest | ||
import kotlin.system.exitProcess | ||
// snippet-end:[pinpoint.kotlin.add_endpoint.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: | ||
<appId> | ||
Where: | ||
appId - The Amazon Pinpoint project/application ID to use. | ||
""" | ||
|
||
if (args.size != 1) { | ||
println(usage) | ||
exitProcess(0) | ||
} | ||
|
||
val appId = args[0] | ||
updateEndpointsViaBatch(appId) | ||
} | ||
|
||
// snippet-start:[pinpoint.kotlin.add_endpoint.main] | ||
suspend fun updateEndpointsViaBatch(applicationIdVal: String?) { | ||
val myNames = mutableListOf<String>() | ||
myNames.add("Richard") | ||
myNames.add("Roe") | ||
|
||
val myMapRichard = mutableMapOf<String, List<String>>() | ||
myMapRichard.put("name", myNames) | ||
|
||
val richardRoe = | ||
EndpointUser { | ||
userId = "example_user_1" | ||
userAttributes = myMapRichard | ||
} | ||
|
||
// Create an EndpointBatchItem object for Richard Roe. | ||
val richardRoesEmailEndpoint = | ||
EndpointBatchItem { | ||
channelType = ChannelType.Email | ||
address = "[email protected]" | ||
id = "example_endpoint_1" | ||
attributes = myMapRichard | ||
user = richardRoe | ||
} | ||
|
||
val richardList: MutableList<EndpointBatchItem> = ArrayList() | ||
richardList.add(richardRoesEmailEndpoint) | ||
|
||
// Adds multiple endpoint definitions to a single request object. | ||
val endpointList = | ||
EndpointBatchRequest { | ||
item = richardList | ||
} | ||
|
||
// Updates the endpoints with Amazon Pinpoint. | ||
PinpointClient { region = "us-west-2" }.use { pinpoint -> | ||
val result = | ||
pinpoint.updateEndpointsBatch( | ||
UpdateEndpointsBatchRequest { | ||
applicationId = applicationIdVal | ||
endpointBatchRequest = endpointList | ||
}, | ||
) | ||
println("Update endpoint result ${result.messageBody?.message}") | ||
} | ||
} | ||
// snippet-end:[pinpoint.kotlin.add_endpoint.main] |
112 changes: 56 additions & 56 deletions
112
kotlin/services/pinpoint/src/main/kotlin/com/kotlin/pinpoint/CreateApp.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,56 +1,56 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.kotlin.pinpoint | ||
|
||
// snippet-start:[pinpoint.kotlin.createapp.import] | ||
import aws.sdk.kotlin.services.pinpoint.PinpointClient | ||
import aws.sdk.kotlin.services.pinpoint.model.CreateAppRequest | ||
import aws.sdk.kotlin.services.pinpoint.model.CreateApplicationRequest | ||
import kotlin.system.exitProcess | ||
// snippet-end:[pinpoint.kotlin.createapp.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: <appName> | ||
Where: | ||
appName - The name of the application to create. | ||
""" | ||
|
||
if (args.size != 1) { | ||
println(usage) | ||
exitProcess(0) | ||
} | ||
|
||
val appName = args[0] | ||
val appId = createApplication(appName) | ||
println("The app Id is: $appId") | ||
} | ||
|
||
// snippet-start:[pinpoint.kotlin.createapp.main] | ||
suspend fun createApplication(applicationName: String?): String? { | ||
|
||
val createApplicationRequestOb = CreateApplicationRequest { | ||
name = applicationName | ||
} | ||
|
||
PinpointClient { region = "us-west-2" }.use { pinpoint -> | ||
val result = pinpoint.createApp( | ||
CreateAppRequest { | ||
createApplicationRequest = createApplicationRequestOb | ||
} | ||
) | ||
return result.applicationResponse?.id | ||
} | ||
} | ||
// snippet-end:[pinpoint.kotlin.createapp.main] | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.kotlin.pinpoint | ||
|
||
// snippet-start:[pinpoint.kotlin.createapp.import] | ||
import aws.sdk.kotlin.services.pinpoint.PinpointClient | ||
import aws.sdk.kotlin.services.pinpoint.model.CreateAppRequest | ||
import aws.sdk.kotlin.services.pinpoint.model.CreateApplicationRequest | ||
import kotlin.system.exitProcess | ||
// snippet-end:[pinpoint.kotlin.createapp.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: <appName> | ||
Where: | ||
appName - The name of the application to create. | ||
""" | ||
|
||
if (args.size != 1) { | ||
println(usage) | ||
exitProcess(0) | ||
} | ||
|
||
val appName = args[0] | ||
val appId = createApplication(appName) | ||
println("The app Id is: $appId") | ||
} | ||
|
||
// snippet-start:[pinpoint.kotlin.createapp.main] | ||
suspend fun createApplication(applicationName: String?): String? { | ||
val createApplicationRequestOb = | ||
CreateApplicationRequest { | ||
name = applicationName | ||
} | ||
|
||
PinpointClient { region = "us-west-2" }.use { pinpoint -> | ||
val result = | ||
pinpoint.createApp( | ||
CreateAppRequest { | ||
createApplicationRequest = createApplicationRequestOb | ||
}, | ||
) | ||
return result.applicationResponse?.id | ||
} | ||
} | ||
// snippet-end:[pinpoint.kotlin.createapp.main] |
Oops, something went wrong.