计划端点
示例API调用
现在您了解了要使用哪些标头,就可以开始调用Query Service API了。 以下部分介绍了您可以使用Query Service API进行的各种API调用。 每个调用包括常规API格式、显示所需标头的示例请求以及示例响应。
检索计划查询的列表
您可以通过向/schedules
端点发出GET请求来检索贵组织的所有计划查询列表。
API格式
GET /schedules
GET /schedules?{QUERY_PARAMETERS}
{QUERY_PARAMETERS}
&
)分隔。 下面列出了可用的参数。查询参数
以下是列出计划查询的可用查询参数列表。 所有这些参数都是可选的。 在不使用参数的情况下调用此端点将检索对您的组织可用的所有计划查询。
orderby
created
和updated
。 例如,orderby=created
将按创建的结果以升序排序。 在创建之前(orderby=-created
)添加-
将按创建的顺序降序对项进行排序。limit
start
个ISO时间戳允许在日期和时间使用不同级别的粒度。 基本ISO时间戳采用
2020-09-07
格式,表示日期2020年9月7日。 一个更复杂的示例将编写为2022-11-05T08:15:30-05:00
,对应于2022年11月5日美国东部标准时间上午8:15:30。 可以为时区提供UTC偏移量,时区由后缀“Z”(2020-01-01T01:01:01Z
)表示。 如果未提供时区,则默认设置为0。property
created
、templateId
和userId
。 支持的运算符列表为>
(大于)、<
(小于)和==
(等于)。 例如,userId==6ebd9c2d-494d-425a-aa91-24033f3abeec
将返回用户ID为指定的所有计划查询。请求
以下请求检索为您的组织创建的最新计划查询。
curl -X GET https://platform.adobe.io/data/foundation/query/schedules?limit=1
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
响应
成功的响应返回HTTP状态200,其中包含指定组织的已计划查询列表。 以下响应返回为您的组织创建的最新计划查询。
{
"schedules": [
{
"state": "ENABLED",
"query": {
"dbName": "prod:all",
"sql": "SELECT * FROM accounts;",
"name": "Sample Scheduled Query",
"description": "A sample of a scheduled query."
},
"updatedUserId": "{USER_ID}",
"version": 2,
"id": "e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"updated": "1578523458919",
"schedule": {
"schedule": "30 * * * *",
"startDate": "2020-01-08T12:30:00.000Z",
"maxActiveRuns": 1
},
"userId": "{USER_ID}",
"created": "1578523458919",
"_links": {
"enable": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "PATCH",
"body": "{ \"op\": \"enable\" }"
},
"runs": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm/runs",
"method": "GET"
},
"self": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "GET"
},
"delete": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "DELETE"
},
"disable": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "PATCH",
"body": "{ \"op\": \"disable\" }"
},
"trigger": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm/runs",
"method": "POST"
}
}
}
],
"_page": {
"orderby": "+created",
"start": "2020-01-08T22:44:18.919Z",
"count": 1
},
"_links": {},
"version": 2
}
创建新的计划查询
您可以通过向/schedules
端点发出POST请求来创建新的计划查询。 在API中创建计划查询时,您还可以在查询编辑器中看到它。 有关UI中计划查询的更多信息,请阅读查询编辑器文档。
API格式
POST /schedules
请求
curl -X POST https://platform.adobe.io/data/foundation/query/schedules
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
-d '
{
"query": {
"dbName": "prod:all",
"sql": "SELECT * FROM accounts;",
"name": "Sample Scheduled Query",
"description": "A sample of a scheduled query."
},
"schedule": {
"schedule": "30 * * * *",
"startDate": "2020-01-08T12:30:00.000Z"
}
}
'
query.dbName
query.sql
query.name
schedule.schedule
查询的cron计划。 有关cron计划的详细信息,请阅读cron表达式格式文档。 在此示例中,“30 * * * *”表示查询将每小时在30分钟标记处运行。
或者,您可以使用以下简写表达式:
@once
:查询只运行一次。@hourly
:查询每小时在一小时的开头运行一次。 这相当于cron表达式0 * * * *
。@daily
:查询每天午夜运行一次。 这相当于cron表达式0 0 * * *
。@weekly
:查询每周运行一次,于星期日、午夜运行。 这相当于cron表达式0 0 * * 0
。@monthly
:查询每月运行一次,在每月的第一天午夜运行。 这相当于cron表达式0 0 1 * *
。@yearly
:查询每年运行一次,于1月1日午夜。 这相当于cron表达式1 0 0 1 1 *
。
schedule.startDate
响应
成功的响应返回HTTP状态202(已接受)以及新创建的计划查询的详细信息。 计划查询激活完成后,state
将从REGISTERING
更改为ENABLED
。
{
"state": "REGISTERING",
"query": {
"dbName": "prod:all",
"sql": "SELECT * FROM accounts;",
"name": "Sample Scheduled Query",
"description": "A sample of a scheduled query."
},
"updatedUserId": "{USER_ID}",
"version": 2,
"id": "e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"schedule": {
"schedule": "30 * * * *",
"startDate": "2020-01-08T12:30:00.000Z",
"maxActiveRuns": 1
},
"userId": "{USER_ID}",
"_links": {
"enable": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "PATCH",
"body": "{ \"op\": \"enable\" }"
},
"runs": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm/runs",
"method": "GET"
},
"self": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "GET"
},
"delete": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "DELETE"
},
"disable": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "PATCH",
"body": "{ \"op\": \"disable\" }"
},
"trigger": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm/runs",
"method": "POST"
}
}
}
_links.delete
的值删除您创建的计划查询。指定计划查询的请求详细信息
您可以通过向/schedules
端点发出GET请求并在请求路径中提供其ID来检索特定计划查询的信息。
API格式
GET /schedules/{SCHEDULE_ID}
{SCHEDULE_ID}
id
值。请求
curl -X GET https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
响应
成功的响应返回HTTP状态200,其中包含指定计划查询的详细信息。
{
"state": "ENABLED",
"query": {
"dbName": "prod:all",
"sql": "SELECT * FROM accounts;",
"name": "Sample Scheduled Query",
"description": "A sample of a scheduled query."
},
"updatedUserId": "{USER_ID}",
"version": 2,
"id": "e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"updated": "1578523458919",
"schedule": {
"schedule": "30 * * * *",
"startDate": "2020-01-08T12:30:00.000Z",
"maxActiveRuns": 1
},
"userId": "{USER_ID}",
"created": "1578523458919",
"_links": {
"enable": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "PATCH",
"body": "{ \"op\": \"enable\" }"
},
"runs": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm/runs",
"method": "GET"
},
"self": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "GET"
},
"delete": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "DELETE"
},
"disable": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm",
"method": "PATCH",
"body": "{ \"op\": \"disable\" }"
},
"trigger": {
"href": "https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm/runs",
"method": "POST"
}
}
}
_links.delete
的值删除您创建的计划查询。更新指定计划查询的详细信息
您可以通过向/schedules
端点发出PATCH请求并在请求路径中提供其ID来更新指定计划查询的详细信息。
PATCH请求支持两个不同的路径: /state
和/schedule/schedule
。
更新计划的查询状态
通过将path
属性设置为/state
并将value
属性设置为enable
或disable
,可以更新所选计划查询的状态。
API格式
PATCH /schedules/{SCHEDULE_ID}
{SCHEDULE_ID}
id
值。请求
此API请求对其有效负载使用JSON修补程序语法。 有关JSON修补程序如何工作的更多信息,请阅读API基础知识文档。
curl -X PATCH https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
-d '{
"body": [
{
"op": "replace",
"path": "/state",
"value": "disable"
}
]
}'
op
replace
。path
path
的值设置为/state
。value
/state
的更新值。 此值可设置为enable
或disable
以启用或禁用计划的查询。响应
成功的响应返回HTTP状态202(已接受),并显示以下消息。
{
"message": "Request to patch accepted",
"statusCode": 202
}
更新计划的查询计划
通过在请求正文中将path
属性设置为/schedule/schedule
,可以更新计划查询的cron计划。 有关cron计划的详细信息,请阅读cron表达式格式文档。
API格式
PATCH /schedules/{SCHEDULE_ID}
{SCHEDULE_ID}
id
值。请求
此API请求对其有效负载使用JSON修补程序语法。 有关JSON修补程序如何工作的更多信息,请阅读API基础知识文档。
curl -X PATCH https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
-d '{
"body": [
{
"op": "replace",
"path": "/schedule/schedule",
"value": "45 * * * *"
}
]
}'
op
replace
。path
path
的值设置为/schedule/schedule
。value
/schedule
的更新值。 该值需要采用cron计划的形式。 因此,在此示例中,计划查询将每小时以45分钟标记运行。响应
成功的响应返回HTTP状态202(已接受),并显示以下消息。
{
"message": "Request to patch accepted",
"statusCode": 202
}
删除指定的计划查询
您可以通过向/schedules
端点发出DELETE请求并在请求路径中提供要删除的计划查询的ID来删除指定的计划查询。
API格式
DELETE /schedules/{SCHEDULE_ID}
{SCHEDULE_ID}
id
值。请求
curl -X DELETE https://platform.adobe.io/data/foundation/query/schedules/e95186d65a28abf00a495d82_28e74200-e3de-11e9-8f5d-7f27416c5f0d_sample_scheduled_query7omob151bm_birvwm
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
响应
成功的响应返回HTTP状态202(已接受),并显示以下消息。
{
"message": "Schedule deleted successfully",
"statusCode": 202
}