clarify.selectItems
Require access to Clarify namespace
For an integration to access this method, it must have been granted access to the Clarify namespace.
A resource select method for the items resource.
Method parameters
Parameter | Properties | Description |
---|---|---|
query Resource query | default={} | Resource query to select items. |
include array(string(enum)) | default=[] | Relationships to include. Allow inclusion of "item" . |
groupIncludedByType bool | default=false | Alter result format to group included resources by type. |
Result
The result contains a JSON:API compatible resource selection result if groupIncludedByType
was set to false
.
type: object
Field | Description |
---|---|
meta Selection meta | Selection meta data. |
data array(Item select) | Resource selection. |
included array(resource),map(string => array(resource)) | Side-loaded resources from relationships. |
Limits
Query:
query.limit
:- default is
20
. - maximum is
1000
.
- default is
Example
- cURL
- Python
- Go
The curl example uses Basic Auth for simplicity.
# BASIC_AUTH_USERNAME=<Username from Basic Auth credentials>
# BASIC_AUTH_PASSWORD=<Password from Basic Auth credentials>
# INTEGRATION_ID=${BASIC_AUTH_USERNAME}
curl -u ${BASIC_AUTH_USERNAME}:${BASIC_AUTH_PASSWORD} \
--request POST \
--url 'https://api.clarify.io/v1/rpc' \
--header 'content-type: application/json' \
--header 'X-API-Version: 1.1beta2' \
--data \
'
{
"jsonrpc": "2.0",
"method": "clarify.selectItems",
"id": 10,
"params": {
"integration": "'${INTEGRATION_ID}'",
"query": {
"filter": {
"annotations.docs-clarify-io/example/name": "publish_signals"
},
"limit": 10
}
}
}
'
from pyclarify import Client, query
client = Client("./clarify-credentials.json")
filter = query.Filter(fields={
"annotations.clarify/clarify-go/example/name": query.Equal(value="publish_signals")
})
response = client.select_items(filter=filter, limit=10)
items = response.result.data
package main
import (
"context"
"encoding/json"
"os"
clarify "github.com/clarify/clarify-go"
"github.com/clarify/clarify-go/query"
)
func main() {
// To select item data or meta-data, you must enable access to the "clarify"
// namespace in clarify.
creds, err := clarify.CredentialsFromFile("clarify-credentials.json")
if err != nil {
panic(err)
}
ctx := context.Background()
client := creds.Client(ctx)
result, err := client.SelectItems().Filter(query.Comparisons{
"annotations.clarify/clarify-go/example/name": query.Equal("publish_signals"),
}).Limit(10).Do(ctx)
if err != nil {
panic(err)
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(result)
}