民意调查

轮询资源包含有关特定数据请求的信息。创建轮询后,它将触发创建一个或多个任务以完成请求。
属性
名称 | 类型 | 描述 |
---|---|---|
id |
poll ID | Resource identifier. |
resource |
string, always poll |
Resource type specifier. |
organisation |
organisation ID | The organisation associated with this resource. |
key |
key ID | The key associated with this resource. |
user |
user ID | The user associated with this resource. |
source |
source ID | The source the poll is targeting. This can be a child source of the session's source. |
session |
session ID | The session the poll is using. |
subscription |
optional subscription ID | The associated subscription object ID, if applicable. |
tasks_pending |
list of task IDs | The tasks associated with the poll that are awaiting processing. |
tasks_processing |
list of task IDs | The tasks associated with the poll that are being processed. |
tasks_succeeded |
list of task IDs | The tasks associated with the poll that have succeeded. |
tasks_failed |
list of task IDs | The tasks associated with the poll that have failed. |
tasks_suspended |
list of task IDs | The tasks associated with the poll that are suspended. |
results |
list object containing result objects | List of result objects generated by the poll's tasks. |
errors |
list object containing error objects | List of error objects generated by the poll's tasks. |
state |
string | One of: pending , processing , completed . |
date_created |
datetime | When the resource was created. |
date_started |
optional datetime | When processing of the poll began. |
date_completed |
optional datetime | When processing of the poll finished. |
任务
轮询资源的最重要作用是反映其相关任务的进度,并允许最终用户在这些结果可用后立即开始从中获取结果。因此,轮询资源公开了与任务相关的属性,其中,根据任务的状态对相关任务进行了分类。
结果
轮询中运行的任务发布的任何结果都将显示在轮询的results
属性中。这样可以在调查完成之前消耗结果。
错误
在轮询中运行的任务引起的任何错误将显示在轮询的errors
属性中。
状态
轮询状态仅反映轮询是等待初始化( pending
),正在进行( processing
)还是所有任务已完成执行( completed
)。
除了通过其关联任务之外,轮询不会反映任何错误状态。
有效载荷
轮询有效负载指示应检索哪些类型的信息,数据类型和文件。轮询有效载荷属性架构如下所述。
名称 | 类型 | 描述 |
---|---|---|
info_types |
list of info_type objects |
Specifies which info types should be retrieved. Supports wildcard * . |
data_types |
list of data_type objects |
Specifies which data types should be retrieved. |
files |
list of file IDs. |
Specifies which files to retrieve. |
filters |
nested filters object |
Specifies which filters to apply to retrieved data. |
例如,用于检索iCloud帐户源上所有类型的信息的轮询有效载荷将是:
{ "info_types": ["*"] }
要从iCloud备份或重新孵化中继源中检索各种消息传递数据,但仅从特定日期开始:
{ "data_types": ["ios_messages.messages", "whatsapp.messages", "viber.messages"], "filters": { "since": "2019-09-15T22:04:12Z", "until": "2021-06-02T12:00:00Z" } }
要检索iCloud照片库结果中引用的图像的文件数据,请执行以下操作:
{ "files": ["icpl://xyz123", "icpl://abc321"] }
不同的属性也可以同时使用:
{ "info_types": ["*"], "data_types": ["ios_phone.calls"] }
Filters
Filters allow the client to reduce the amount of data returned to only that which is likely to be of interest. For example, you might filter a poll for SMS data to only the last month of data.
name | type | description |
---|---|---|
since |
optional datetime | Filter to only data that was created after this datetime. |
until |
optional datetime | Filter to only data that was created before this datetime. |
Filters in subscription poll payloads
When using subscriptions to generate regular polls, any filters set in the poll payload will only be used on the initial poll of the subscription. Thereafter, the API will do the following:
- Any value for
until
is ignored as to avoid simply re-polling the same interval repeatedly - If
until
was set, the next poll will fetch data from that point in time forward - If
until
was not set, the next poll will fetch data from the time of the initial poll forward (i.e. the API will poll progressively as normal)
创建POST /polls
针对特定会话创建针对数据的轮询。
仅当将会话的主要来源的子来源作为目标时,才应使用source
参数。例如,如果从rirelay.source
检索数据,则source
参数应为该源的ID。
名称 | 类型 | 描述 |
---|---|---|
key |
optional, key ID | Optionally override the key used for this poll. This is useful when letting users trial new functionality. |
source |
optional, source ID | Optionally target a child source of the session-linked source. |
session |
session ID | The session to be used to authenticate data retrieval. |
subscription |
subscription ID | The subscription to use to perform the poll. If this is provided, source and session can be omitted. |
payload |
nested poll payload | The poll payload used to specify poll |
使用cURL
curl https://ricloud-api.reincubate.com/polls \ -X POST \ -H 'Authorization: Token <your key_token>' \ -H 'Content-Type: application/json' \ -d '{ "session": "<session ID>", "payload": { "info_types": ["*"] } }'
使用ricloud-py
import ricloud poll_payload = { 'info_types': ['*'], } poll = ricloud.Poll.create( session='<session ID or ricloud.Session instance>', payload=poll_payload, )
样品回复
{ "id": "54554389-5f1a-4ccf-9bb8-024a031cf948", "resource": "poll", "organisation": 1, "key": 1, "user": 1, "source": 1, "session": "f5a7a7ef-ff21-47fe-9aa6-7ebd08123623", "subscription": null, "tasks_pending": [], "tasks_processing": [], "tasks_succeeded": [], "tasks_failed": [], "tasks_suspended": [], "results": { "data": [], "has_more": false, "total_count": 0, "url": "/polls/54554389-5f1a-4ccf-9bb8-024a031cf948/results" }, "errors": { "data": [], "has_more": false, "total_count": 0, "url": "/polls/54554389-5f1a-4ccf-9bb8-024a031cf948/errors" }, "state": "pending", "date_created": "2020-02-20T11:59:14.694337Z", "date_started": null, "date_completed": null }
检索GET /polls/{poll ID}
使用cURL
curl https://ricloud-api.reincubate.com/polls/<poll ID> \ -H 'Authorization: Token <your key_token>'
使用ricloud-py
import ricloud poll = ricloud.Poll.retrieve(<poll ID>)
列出GET /polls
名称 | 类型 | 描述 |
---|---|---|
key |
key ID | Filter by associated key. This is the key used by the user at the time. |
user |
user ID | Filter by associated user. |
source |
source ID | Filter by the target source. |
session |
session ID | Filter by the target session. |
subscription |
subscription ID | Filter by the associated subscription. |
state |
string | Filter by session state. |
date_created |
datetime filter | Filter by when the resource was created. |
date_started |
datetime filter | Filter by when the poll started. |
date_completed |
datetime filter | Filter by when the poll was finished. |
使用cURL
curl https://ricloud-api.reincubate.com/polls \ -H 'Authorization: Token <your key_token>'
使用ricloud-py
import ricloud polls = ricloud.Poll.list()
变更日志
2022-07-08
- Support for the
until
filter in poll payloads was added for SMS extraction. This complements thesince
filter to allow clients to specify an exact datetime range to retrieve data from.
2020-05-05
-
errors
属性已添加到轮询对象。这是一个嵌套列表对象,其中包含与轮询相关的错误对象。
2020-02-20
- Major :轮询对象的
results
属性现在是嵌套列表对象,而不是简单的列表属性。当民意调查发布大量结果时,可以对结果进行分页。
2019-10-16
- 将
subscription
属性添加到轮询对象,以指示轮询是否由订阅触发。
2019-06-01
- 轮询对象
payload
属性现在可以由多种操作类型组成。这意味着可以使用有效负载中的任何或所有info-types
,data-types
和files
来创建轮询。 - Major不建议使用poll对象的
type
属性,而建议使用可组合的poll有效负载。