インタラクティブなマップレイヤレベルの通知を設定します
通知は基本的に、インタラクティブなマップ レイヤー で機能の変更に関する更新を受け取るデータストリーム です。
通知は、ストリーム レイヤー へのメッセージとして書き込まれます。 レイヤーにサブスクライブし、 HERE platform の任意のストリーム レイヤー からデータを消費するのと同じようにメッセージを消費することで、通知を受信します。 1 つのカタログに複数のサブスクリプションを作成できますが、サブスクリプションは常に 1 つのカタログに関連します。
通知メッセージの内容は、作成されるサブスクリプションのタイプによって異なります。 サポートされているサブスクリプションには、次の 3 つのタイプがあります。
サブスクリプションを作成しています
subscription
API を使用して各タイプのサブスクリプションを作成する手順については、次の各項で説明します。 作成するサブスクリプションのタイプにかかわらず、次の必須パラメータを指定する必要があります。
必須パラメータ :
-
<subscription name>
- サブスクリプションの名前。 -
<subscription type>
- サブスクリプションのタイプ。通知メッセージに含まれる詳細レベルも指定します。 指定できる値は perTransaction
、、perFeature
、および contentChange
です。 -
<source catalog HRN>
- 通知を受け取るレイヤーが含まれているカタログの HERE リソースネーム ( HERE リソースネーム )。 -
<source layer ID>
- 通知を受信するレイヤーの ID 。 -
<destination catalog HRN>
- 通知メッセージが書き込まれるストリーム レイヤー を含むカタログの HERE リソースネーム ( HERE リソースネーム )。 -
<destination layer ID>
- 通知メッセージが書き込まれるストリーム レイヤー の ID 。 このストリーム レイヤー はすでに存在している必要があります。 ストリーム レイヤー が作成されているか、またはこのレイヤーに対する読み取りおよび書き込み権限が必要です。 ストリーム レイヤー は、通知を受け取るレイヤーと同じカタログに含めることができます。 ストリーム レイヤー は複数のサブスクリプションで再利用できます。
オプションのパラメータ :
-
<subscription description>
- サブスクリプションの詳細な説明。
POST /config/v1/subscriptions HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
x-idempotency-key: <Unique value generated by client>
Authorization: Bearer <Authorization Token>
Content-Type: application/json
Cache-Control: no-cache
{
"subscriptionName": "<subscription name>",
"description": "<subscription description>",
"sourceCatalog": "<source catalog HRN>",
"sourceLayer": "<source layer ID>",
"destinationCatalog": "<destination catalog HRN>",
"destinationLayer": "<destination layer ID>",
"interactiveMapSubscription": {
"type": "<subscription name>"
}
}
例 :
POST /config/v1/subscriptions HTTP/1.1
{
"subscriptionName": "my-subscription",
"description": "string",
"sourceCatalog": "hrn:here:data::olp-here:my-source-catalog",
"sourceLayer": "source-layer",
"destinationCatalog": "hrn:here:data::olp-here:my-destination-catalog",
"destinationLayer": "destination-layer",
"interactiveMapSubscription": {
"type": "perFeature"
}
}
curl -X POST https://<Hostname for the subscription API>/config/v1/subscriptions \
-H 'x-idempotency-key: <Unique value generated by client> \
-H 'Authorization: Bearer <Authorization Token>' \
-H 'Content-Type: application/json' \
-H 'Cache-Control: no-cache' \
-d '{
"subscriptionName": "my-subscription",
"description": "string",
"sourceCatalog": "hrn:here:data::olp-here:my-source-catalog",
"sourceLayer": "source-layer",
"destinationCatalog": "hrn:here:data::olp-here:my-destination-catalog",
"destinationLayer": "destination-layer",
"interactiveMapSubscription": {
"type": "perFeature"
}
}'
すべてのサブスクリプションを一覧表示します
アプリ が読み取り権限を持っているすべてのサブスクリプションのリストを取得するには、次のリクエストを使用します。
GET /config/v1/subscriptions HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
例 :
GET /config/v1/subscriptions HTTP/1.1
curl -X GET https://<Hostname for the notification API from the API Lookup Service>/config/v1/subscriptions \
-H 'Authorization: Bearer <Authorization Token>' \
サブスクリプションの設定を取得します
サブスクリプションの詳細な設定を取得するに <subscriptionHrn>
は、読み取るを指定します。 は <subscriptionHrn>
、サブスクリプションの作成時、または サブスクリプションのリストから提供されました。
GET /config/v1/subscriptions/{subscriptionHrn} HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
例 :
GET /config/v1/subscriptions/{subscriptionHrn} HTTP/1.1
curl -X GET https://<Hostname for the notification API from the API Lookup Service>/config/v1/subscriptions/hrn:here:data-subscription::olp-here:my-subscription-7d93563980d94f1b \
-H 'Authorization: Bearer <Authorization Token>' \
サブスクリプションを削除しています
サブスクリプションを削除するに <subscriptionHrn>
は、削除するを指定します。 は <subscriptionHrn>
、サブスクリプションの作成時、または サブスクリプションのリストから提供されました。
DELETE /config/v1/subscriptions/{subscriptionHrn} HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
x-idempotency-key: <Unique value generated by client>
Authorization: Bearer <Authorization Token>
例 :
DELETE /config/v1/subscriptions/hrn:here:data-subscription::olp-here:my-subscription-7d93563980d94f1b HTTP/1.1
curl -X DELETE https://<Hostname for the notification API from the API Lookup Service>/config/v1/subscriptions/hrn:here:data-subscription::olp-here:my-subscription-7d93563980d94f1b \
-H 'Authorization: Bearer <Authorization Token>' \
subscription
API の使用方法の詳細については 、『 API リファレンス』を参照してください。
サブスクリプションのタイプ
フィーチャーごと
の type
値を使用してサブスクリプションが作成された場合 perFeature
、通知にはソースレイヤーで変更された特定の機能に関する基本情報が含まれます。 例 :
{
"type": "FeatureChange",
"operation": <"INSERT"|"DELETE"|"UPDATE">,
"catalogHrn": "hrn:here:data::realm:source-catalog",
"layerId": "source-iml",
"feature": {
"type": "Feature", ...
}
}
perTransaction
perTransaction
の type
値を使用してサブスクリプションが作成された場合 、ソースレイヤーですべての機能が 1 つのトランザクションとして変更された状態で、通知にFeatureCollection,
含まれます。 例 :
例 :
{
"type": "Changeset",
"version": 5,
"author": "abcXyz",
"catalogHrn": "hrn:here:data::realm:source-catalog",
"layerId": "source-iml",
"createdAt": 1668519747712,
"inserted": {
"type": "FeatureCollection",
"features": [...
]
},
"updated": {
"type": "FeatureCollection",
"features": [...
]
},
"deleted": {
"type": "FeatureCollection",
"features": [...
]
}
}
contentChange
の type
値を使用してサブスクリプションが作成された場合 contentChange
は、ソースレイヤーで何らかのフィーチャーが変更されたことを示す簡単な通知が送信されます。 例 :
例 :
{
"type": "ChangeNotification",
"catalogHrn": "hrn:here:data::realm:source-catalog",
"layerId": "source-iml",
"createdAt": 1668519747712
}
通知の受信中
通知メッセージはストリーム レイヤー に書き込まれるため、通知を受信するプロセスは、 HERE platform の任意のストリーム レイヤー からデータを読み取るプロセスと同じです。 ストリーム レイヤー から通知メッセージを読み取るには、次の 2 つの方法があります。
- データ クライアント ライブラリ を使用します。 データ クライアント ライブラリ を使用したストリーム レイヤー からのデータの読み取りの詳細について は、『 データ クライアント ライブラリ 開発者ガイド 』を参照してください。
stream
API を使用します。stream
API を使用したストリーム レイヤーからのデータの読み取りについての詳細は、データ API の API リファレンス を参照してください。``