バージョン管理されたレイヤーレベルの通知を設定します
レイヤーレベルの通知を使用すると、特定のレイヤーで変更が発生したときに通知を受け取ることができます。 次のような通知を受け取る変更を選択できます。
- レイヤー内のすべての変更
- 地理的領域の変更
- 特定のパーティションへの変更
通知は基本的にデータストリームです。 通知はストリーム レイヤーにメッセージとして書き込まれ、レイヤーにサブスクライブすることで通知を受信します。また、 HERE platform 内の任意のストリーム レイヤーからデータを消費する場合と同様に、メッセージを使用します。 1 つのカタログに複数のサブスクリプションを作成できますが、サブスクリプションは常に 1 つのカタログに関連します。 カタログ内のいくつかのバージョン管理されたレイヤー、またはそのすべてのレイヤーにサブスクライブできます。 サブスクリプション領域と通知タイプを、サブスクライブしているすべてのレイヤーで同一または異なるように設定することもできます。
サブスクリプションを作成するときに、通知を受け取る変更を指定できます。 各タイプのサブスクリプションを作成する手順については、次の各項で説明します。 notification
API を使用してサブスクリプションを作成します。 作成するサブスクリプションのタイプに関係なく、次のパラメータを指定する必要があります。
<Source Catalog HRN>
API パスの一部は、通知を受け取るレイヤーを含むカタログの HERE リソースネーム ( HERE リソースネーム )です。 layerIds
このパラメータは、通知を受信するレイヤーの ID です。 少なくとも 1 つのレイヤーを指定する必要があります。 notificationCatalogHRN
このパラメータは、通知メッセージが書き込まれるストリーム レイヤーを含むカタログの HERE リソースネーム ( HERE リソースネーム )です。 notificationStreamLayerID
このパラメータは、通知メッセージが書き込まれるストリーム レイヤーの ID です。 このストリーム レイヤーはすでに存在している必要があります。 ストリーム レイヤーが作成されているか、またはこのレイヤーに対する読み取りおよび書き込み権限が必要です。 ストリーム レイヤーは、通知を受け取るレイヤーと同じカタログに含めることができます。 ストリーム レイヤーは複数のサブスクリプションで再利用できます。 subecriptionResultType
このフィールドでは、通知メッセージに含まれる詳細レベルを指定します。 使用できる値は SHORT
、、 LIST
、または FULL
です。 指定しない場合 subscriptionResultType
は、のデフォルト値 FULL
が使用されます。
レイヤー全体の通知をサブスクライブしています
レイヤーに対する変更の通知を受け取る場合は、レイヤー内のすべてのパーティションの通知をサブスクライブします。 すべてのパーティションの通知を有効にするには、リクエストの本文でsubscriptionType
フィールドにall
を指定します。
POST /notification/v2/catalogs/<Source Catalog HRN>/subscriptions HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Content-Type: application/json
Cache-Control: no-cache
{
"attributes": [
{
"layerIds": [
"<Layer to subscribe to>"
],
"subscriptionArea": {
"subscriptionType": "all"
},
"subscriptionResultType": "<Level of detail to include in the notifications - SHORT, LIST, or FULL>"
}
],
"notificationCatalogHRN": "<The HRN of the catalog that will contain the notification stream>",
"notificationStreamLayerId": "<The stream layer ID to contain the notification stream>"
}
例 :
POST /notification/v2/catalogs/<Catalog HRN>/subscriptions HTTP/1.1
{
"attributes": [
{
"layerIds": [
"baseline_load"
],
"subscriptionArea": {
"subscriptionType": "all"
},
"subscriptionResultType": "FULL"
}
],
"notificationCatalogHRN": "<Catalog HRN>",
"notificationStreamLayerId": "notifications-stream"
}
curl -X POST https://<Hostname for the notification API from the API Lookup Service>/notification/v2/catalogs/<Catalog HRN>/subscriptions \
-H 'Authorization: Bearer <Authorization Token>' \
-H 'Content-Type: application/json' \
-H 'Cache-Control: no-cache' \
-d '{
"attributes": [
{
"layerIds": [
"baseline_load"
],
"subscriptionArea": {
"subscriptionType": "all"
},
"subscriptionResultType": "FULL"
}
],
"notificationCatalogHRN": "<Catalog HRN>",
"notificationStreamLayerId": "notifications-stream"
}'
地理的領域の通知にサブスクライブしています
レイヤー内の地理的領域に対する通知を有効にするには、リクエストの本文で次のパラメーターを使用して、関心のある地理的領域を指定します。
指定した地理的領域に属するパーティションに変更があると、通知がトリガーされます。 内部的には地理的領域が HERE Tile パーティションに変換されるため、精度は特定のパーティションの通知を有効にするのと似ています。
POST /notification/v2/catalogs/<Source Catalog HRN>/subscriptions HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Content-Type: application/json
Cache-Control: no-cache
{
"attributes": [
{
"layerIds": [
"<Layer to subscribe to>"
],
"subscriptionArea": {
"subscriptionType": "wkt",
"wkt": "<Well-Known Text (WKT) Geometry Object>"
},
"subscriptionResultType": "<Level of detail to include in the notifications - SHORT, LIST, or FULL>"
}
],
"notificationCatalogHRN": "<The HRN of the catalog that will contain the notification stream>",
"notificationStreamLayerId": "<The stream layer ID to contain the notification stream>"
}
例 :
POST /notification/v2/catalogs/<Catalog HRN>/subscriptions HTTP/1.1
{
"attributes": [
{
"layerIds": [
"my-layer"
],
"subscriptionArea": {
"subscriptionType": "wkt",
"wkt": "POLYGON((-130.80754564763947 53.5992823604481,-59.08879564763947 53.5992823604481,-59.08879564763947 22.68538434109208,-130.80754564763947 22.68538434109208,-130.80754564763947 53.5992823604481))"
},
"subscriptionResultType": "SHORT"
}
],
"notificationCatalogHRN": "<Catalog HRN>",
"notificationStreamLayerId": "notifications-stream"
}
curl -X POST https://<Hostname for the notification API from the API Lookup Service>/notification/v2/catalogs/<Catalog HRN>/subscriptions \
-H 'Authorization: Bearer <Authorization Token>' \
-H 'Content-Type: application/json' \
-H 'Cache-Control: no-cache' \
-d '{
"attributes": [
{
"layerIds": [
"my-layer"
],
"subscriptionArea": {
"subscriptionType": "wkt",
"wkt": "POLYGON((-130.80754564763947 53.5992823604481,-59.08879564763947 53.5992823604481,-59.08879564763947 22.68538434109208,-130.80754564763947 22.68538434109208,-130.80754564763947 53.5992823604481))"
},
"subscriptionResultType": "SHORT"
}
],
"notificationCatalogHRN": "<Catalog HRN>",
"notificationStreamLayerId": "notifications-stream"
}'
notification
API の使用方法の詳細については 、『 API リファレンス』を参照してください。
特定のパーティションの通知をサブスクライブしています
特定のパーティションの通知にサブスクライブすると、すべての子パーティション(タイル)を含む、指定したパーティションへの変更によって通知がトリガーされます。 特定のパーティションの通知を有効にするには、リクエストの本文でsubscriptionType
フィールドにpartitions
を指定し、partitions
フィールドにパーティション ID のリストを指定します。
POST /notification/v2/catalogs/<Source Catalog HRN>/subscriptions HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Content-Type: application/json
Cache-Control: no-cache
{
"attributes": [
{
"layerIds": [
"<Layer to subscribe to>"
],
"subscriptionArea": {
"subscriptionType": "partitions",
"partitions": [<List of partition IDs to subscribe to>]
},
"subscriptionResultType": "<Level of detail to include in the notifications - SHORT, LIST, or FULL>"
}
],
"notificationCatalogHRN": "<The HRN of the catalog that will contain the notification stream>",
"notificationStreamLayerId": "<The stream layer ID to contain the notification stream>"
}
例 :
POST /notification/v2/catalogs/<Catalog HRN>/subscriptions HTTP/1.1
{
"attributes": [
{
"layerIds": [
"baseline_load"
],
"subscriptionArea": {
"subscriptionType": "partitions",
"partitions": ["67", "70", "73", "76"]
},
"subscriptionResultType": "FULL"
}
],
"notificationCatalogHRN": "<Catalog HRN>",
"notificationStreamLayerId": "notifications-stream"
}
curl -X POST https://<Hostname for the notification API from the API Lookup Service>/notification/v2/catalogs/<Catalog HRN>/subscriptions \
-H 'Authorization: Bearer <Authorization Token>' \
-H 'Content-Type: application/json' \
-H 'Cache-Control: no-cache' \
-d '{
"attributes": [
{
"layerIds": [
"baseline_load"
],
"subscriptionArea": {
"subscriptionType": "partitions",
"partitions": ["67", "70", "73", "76"]
},
"subscriptionResultType": "FULL"
}
],
"notificationCatalogHRN": "<Catalog HRN>",
"notificationStreamLayerId": "notifications-stream"
}'
notification
API の使用方法の詳細については 、『 API リファレンス』を参照してください。
通知の内容
通知メッセージの内容は、サブスクリプションが SHORT
、、 LIST
、 FULL
またはのいずれを返すように設定されているかによって異なります。
簡単な通知
サブスクリプションが subscriptionResultType
の値で作成された場合 SHORT
、通知には新しいカタログバージョンに関する基本情報が含まれます。 例 :
{
"catalogHRN":"<Catalog HRN>",
"catalogVersion":250836,
"layerId":"my-layer",
"timestamp": 1529947152971,
"subscriptionResultType": "SHORT"
}
一覧表の通知
サブスクリプションが subscriptionResultType
の値で作成された場合 LIST
、通知には変更されたパーティション ID のリストが含まれ、サブスクリプションが有効になります。
注
このリストには、サブスクライブされているパーティションのみが含まれています。 新しいカタログバージョンに、通知が有効になっていないパーティションへの変更が含まれている場合、これらのパーティションはリストに含まれません。
例 :
{
"partitions": [
"75767",
"75743",
"75765",
"75741",
"75773",
"78473",
"78472",
"78475",
"78497",
"78474",
"78496",
"78499",
"78498",
"78505",
"78504"
],
"catalogHRN":"<Catalog HRN>",
"layerId":"my-layer",
"catalogVersion": 19448,
"timestamp": 1529697829081,
"subscriptionResultType": "LIST"
}
完全な通知
サブスクリプションが subscriptionResultType
の値で作成された場合 FULL
、新しいカタログバージョンで変更された各パーティションのメタデータが通知に含まれます。
注
このリストには、サブスクライブされているパーティションのみが含まれています。 新しいカタログバージョンに、通知が有効になっていないパーティションへの変更が含まれている場合、これらのパーティションはリストに含まれません。
例 :
{
"catalogHRN":"<Catalog HRN>",
"catalogVersion":250836,
"layerId":"my-layer",
"partitions": [
{
"version": 250836,
"partition": "309967227",
"layer": "my-layer",
"dataHandle": "30111521-919d-4e45-8e48-3b6eea0a66b7",
"checksum":"a19946acbc6323bca24797e6892d53d510c2f88a",
"deleted": false
}
],
"timestamp": 1529944456598,
"subscriptionResultType": "FULL"
}
通知の受信中
通知メッセージはストリーム レイヤーに書き込まれるため、通知の受信プロセスは、 HERE platform 内の任意のストリーム レイヤーからデータを読み取るプロセスと同じです。 ストリーム レイヤーから通知メッセージを読み取るには、次の 2 つの方法があります。
通知を無効にしてい
通知を無効にするには、通知を含むカタログとレイヤーを指定してサブスクリプションを削除します。
注
変更によって通知がトリガーされたカタログではなく、通知ストリームが含まれているカタログおよびレイヤーを指定してください。
ターゲットカタログに関連付けられているすべてのサブスクリプションを削除するには、次の手順に従います
DELETE /notification/v2/catalogs/<HRN of the Target Catalog>/layers/<Layer ID of Notification Stream> HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Content-Type: application/json
Cache-Control: no-cache
{
"deleteAll": true
}
特定のサブスクリプションを削除するには、削除するサブスクリプション ID を指定します。 サブスクリプションの作成時にサブスクリプション ID が提供されました。 notification
API を使用して、サブスクリプション ID のリストを取得できます。 詳細については 、『 API リファレンス』を参照してください。
DELETE /notification/v2/catalogs/<HRN of the Target Catalog>/layers/<Layer ID of the Notification Stream> HTTP/1.1
Host: <Hostname for the notification API from the API Lookup Service>
Authorization: Bearer <Authorization Token>
Content-Type: application/json
Cache-Control: no-cache
{
"deleteAll": false,
"subscriptionIds" : ["<List of subscription IDs to delete>"]
}