Amazon Pinpoint アプリケーションを作成する - AWS SDK コードサンプル

Doc AWS SDK Examples リポジトリには、他にも SDK の例があります。 AWS GitHub

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

Amazon Pinpoint アプリケーションを作成する

次のコード例は、アプリケーションを作成する方法を示しています。

CLI
AWS CLI

例 1: アプリケーションを作成するには

次の create-app 例では、新しいアプリケーション (プロジェクト) を作成します。

aws pinpoint create-app \ --create-application-request Name=ExampleCorp

出力:

{ "ApplicationResponse": { "Arn": "arn:aws:mobiletargeting:us-west-2:AIDACKCEVSQ6C2EXAMPLE:apps/810c7aab86d42fb2b56c8c966example", "Id": "810c7aab86d42fb2b56c8c966example", "Name": "ExampleCorp", "tags": {} } }

例 2: タグが付けられたアプリケーションを作成するには

次の create-app 例では、新しいアプリケーション (プロジェクト) を作成し、タグ (キーと値) をアプリケーションに関連付けます。

aws pinpoint create-app \ --create-application-request Name=ExampleCorp,tags={"Stack"="Test"}

出力:

{ "ApplicationResponse": { "Arn": "arn:aws:mobiletargeting:us-west-2:AIDACKCEVSQ6C2EXAMPLE:apps/810c7aab86d42fb2b56c8c966example", "Id": "810c7aab86d42fb2b56c8c966example", "Name": "ExampleCorp", "tags": { "Stack": "Test" } } }
  • API の詳細については、「 コマンドリファレンスCreateApp」の「」を参照してください。 AWS CLI

Java
SDK for Java 2.x
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.pinpoint.PinpointClient; import software.amazon.awssdk.services.pinpoint.model.CreateAppRequest; import software.amazon.awssdk.services.pinpoint.model.CreateAppResponse; import software.amazon.awssdk.services.pinpoint.model.CreateApplicationRequest; import software.amazon.awssdk.services.pinpoint.model.PinpointException; /** * Before running this Java V2 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-java/latest/developer-guide/get-started.html */ public class CreateApp { public static void main(String[] args) { final String usage = """ Usage: <appName> Where: appName - The name of the application to create. """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String appName = args[0]; System.out.println("Creating an application with name: " + appName); PinpointClient pinpoint = PinpointClient.builder() .region(Region.US_EAST_1) .build(); String appID = createApplication(pinpoint, appName); System.out.println("App ID is: " + appID); pinpoint.close(); } public static String createApplication(PinpointClient pinpoint, String appName) { try { CreateApplicationRequest appRequest = CreateApplicationRequest.builder() .name(appName) .build(); CreateAppRequest request = CreateAppRequest.builder() .createApplicationRequest(appRequest) .build(); CreateAppResponse result = pinpoint.createApp(request); return result.applicationResponse().id(); } catch (PinpointException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return ""; } }
  • API の詳細については、「 API リファレンスCreateApp」の「」を参照してください。 AWS SDK for Java 2.x

Kotlin
SDK for Kotlin
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

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 } }
  • API の詳細については、CreateAppAWS「 SDK for Kotlin API リファレンス」の「」を参照してください。