使用流程服務API更新資料流程
本教學課程涵蓋更新資料流的步驟,包括其基本資訊、排程和使用Flow Service API的對應集。
快速入門
本教學課程要求您具備有效的流量ID。 如果您沒有有效的流量ID,請從來源概觀中選取您選擇的聯結器,並依照在嘗試本教學課程之前概述的步驟進行。
本教學課程也要求您實際瞭解下列Adobe Experience Platform元件:
使用平台API
如需如何成功呼叫Platform API的詳細資訊,請參閱Platform API快速入門的指南。
查詢資料流詳細資料
更新資料流的第一步是使用流量ID擷取資料流詳細資料。 您可以透過向/flows
端點發出GET要求來檢視現有資料流的目前詳細資料。
API格式
GET /flows/{FLOW_ID}
{FLOW_ID}
id
值。要求
以下請求會擷取有關您的流程ID的更新資訊。
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/flows/2edc08ac-4df5-4fe6-936f-81a19ce92f5c' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
回應
成功的回應會傳回資料流的目前詳細資料,包括其版本、排程和唯一識別碼(id
)。
{
"items": [
{
"id": "2edc08ac-4df5-4fe6-936f-81a19ce92f5c",
"createdAt": 1612310475905,
"updatedAt": 1614122324830,
"createdBy": "{CREATED_BY}",
"updatedBy": "{UPDATED_BY}",
"createdClient": "{CREATED_CLIENT}",
"updatedClient": "{UPDATED_CLIENT}",
"sandboxId": "{SANDBOX_ID}",
"sandboxName": "{SANDBOX_NAME}",
"imsOrgId": "{ORG_ID}",
"name": "Database dataflow using BigQuery",
"description": "collecting test1.Mytable from Google BigQuery",
"flowSpec": {
"id": "14518937-270c-4525-bdec-c2ba7cce3860",
"version": "1.0"
},
"state": "enabled",
"version": "\"5400d99c-0000-0200-0000-60358d540000\"",
"etag": "\"5400d99c-0000-0200-0000-60358d540000\"",
"sourceConnectionIds": [
"b7581b59-c603-4df1-a689-d23d7ac440f3"
],
"targetConnectionIds": [
"320f119a-5ac1-4ab1-88ea-eb19e674ea2e"
],
"inheritedAttributes": {
"sourceConnections": [
{
"id": "b7581b59-c603-4df1-a689-d23d7ac440f3",
"connectionSpec": {
"id": "3c9b37f8-13a6-43d8-bad3-b863b941fedd",
"version": "1.0"
},
"baseConnection": {
"id": "6990abad-977d-41b9-a85d-17ea8cf1c0e4",
"connectionSpec": {
"id": "3c9b37f8-13a6-43d8-bad3-b863b941fedd",
"version": "1.0"
}
}
}
],
"targetConnections": [
{
"id": "320f119a-5ac1-4ab1-88ea-eb19e674ea2e",
"connectionSpec": {
"id": "c604ff05-7f1a-43c0-8e18-33bf874cb11c",
"version": "1.0"
}
}
]
},
"scheduleParams": {
"startTime": "1612310466",
"frequency": "week",
"interval": "15",
"backfill": "true"
},
"transformations": [
{
"name": "Copy",
"params": {
"deltaColumn": {
"name": "Datefield",
"dateFormat": "YYYY-MM-DD",
"timezone": "UTC"
}
}
},
{
"name": "Mapping",
"params": {
"mappingId": "0b090130b58b4819afc78b6dc98b484d",
"mappingVersion": "0"
}
}
],
"runs": "/flows/2edc08ac-4df5-4fe6-936f-81a19ce92f5c/runs",
"lastOperation": {
"started": 1614122316652,
"updated": 1614122324830,
"percentCompleted": 100.0,
"status": {
"value": "completed",
"errors": []
},
"ops": [
{
"op": "replace",
"path": "/scheduleParams/frequency",
"value": "week"
}
],
"operation": "update"
},
"lastRunDetails": {
"id": "a10cc80b-fbea-4c6b-873e-d7fd32f4d12d",
"state": "success",
"startedAtUTC": 1613079975512,
"completedAtUTC": 1613080027511
}
}
]
}
更新資料流
若要更新資料流的執行排程、名稱和說明,請對Flow Service API執行PATCH要求,同時提供您的資料流ID、版本以及您要使用的新排程。
If-Match
標頭。 此標頭的值是您要更新之連線的唯一版本。 每次成功更新資料流時,etag值都會更新。API格式
PATCH /flows/{FLOW_ID}
要求
下列請求會更新您的流程執行排程,以及資料流的名稱和說明。
curl -X PATCH \
'https://platform.adobe.io/data/foundation/flowservice/flows/2edc08ac-4df5-4fe6-936f-81a19ce92f5c' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
-H 'If-Match: "1a0037e4-0000-0200-0000-602e06f60000"' \
-d '[
{
"op": "replace",
"path": "/scheduleParams/frequency",
"value": "day"
},
{
"op": "replace",
"path": "/name",
"value": "Database Dataflow Feb2021"
},
{
"op": "replace",
"path": "/description",
"value": "Database dataflow for testing update API"
}
]'
op
add
、replace
和remove
。path
value
回應
成功的回應會傳回您的流程ID和更新的etag。 您可以透過向Flow Service API發出GET請求來驗證更新,同時提供您的流量ID。
{
"id": "2edc08ac-4df5-4fe6-936f-81a19ce92f5c",
"etag": "\"50014cc8-0000-0200-0000-6036eb720000\""
}
更新對應
您可以對Flow Service API發出PATCH要求並為您的mappingId
和mappingVersion
提供更新的值,以更新現有資料流的對應集。
API格式
PATCH /flows/{FLOW_ID}
要求
以下請求會更新資料流的對應集。
curl -X PATCH \
'https://platform.adobe.io/data/foundation/flowservice/flows/2edc08ac-4df5-4fe6-936f-81a19ce92f5c' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
-H 'If-Match: "50014cc8-0000-0200-0000-6036eb720000"' \
-d '[
{
"op": "replace",
"path": "/transformations/0",
"value": {
"name": "Mapping",
"params": {
"mappingId": "c5f22f04e09f44498e528901546a83b1",
"mappingVersion": 2
}
}
}
]'
op
add
、replace
和remove
。path
transformations
。value.name
value.params.mappingId
value.params.mappingVersion
回應
成功的回應會傳回您的流程ID和更新的etag。 您可以透過向Flow Service API發出GET請求來驗證更新,同時提供您的流量ID。
{
"id": "2edc08ac-4df5-4fe6-936f-81a19ce92f5c",
"etag": "\"2c000802-0000-0200-0000-613976440000\""
}
後續步驟
依照本教學課程,您已使用Flow Service API更新資料流的基本資訊、排程和對映集。 如需使用來源聯結器的詳細資訊,請參閱來源概觀。