curl --request PUT \
--url https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"default": {
"projection": {
"scalar_operators": [
"<string>"
],
"aggregate_operators": [
"<string>"
],
"external_operators": [
"<string>"
]
},
"group_by": {
"scalar_operators": [
"<string>"
]
},
"join": {
"scalar_operators": [
"<string>"
]
}
},
"usage_rules": [
{
"attribute": "<string>",
"field": "<string>"
}
],
"join_required_rule": {
"match": [
{
"keys": [
{
"form": "raw",
"attribute": "<string>",
"field": "<string>"
}
]
}
]
}
}
'import requests
url = "https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy"
payload = {
"default": {
"projection": {
"scalar_operators": ["<string>"],
"aggregate_operators": ["<string>"],
"external_operators": ["<string>"]
},
"group_by": { "scalar_operators": ["<string>"] },
"join": { "scalar_operators": ["<string>"] }
},
"usage_rules": [
{
"attribute": "<string>",
"field": "<string>"
}
],
"join_required_rule": { "match": [{ "keys": [
{
"form": "raw",
"attribute": "<string>",
"field": "<string>"
}
] }] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
default: {
projection: {
scalar_operators: ['<string>'],
aggregate_operators: ['<string>'],
external_operators: ['<string>']
},
group_by: {scalar_operators: ['<string>']},
join: {scalar_operators: ['<string>']}
},
usage_rules: [{attribute: '<string>', field: '<string>'}],
join_required_rule: {match: [{keys: [{form: 'raw', attribute: '<string>', field: '<string>'}]}]}
})
};
fetch('https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'default' => [
'projection' => [
'scalar_operators' => [
'<string>'
],
'aggregate_operators' => [
'<string>'
],
'external_operators' => [
'<string>'
]
],
'group_by' => [
'scalar_operators' => [
'<string>'
]
],
'join' => [
'scalar_operators' => [
'<string>'
]
]
],
'usage_rules' => [
[
'attribute' => '<string>',
'field' => '<string>'
]
],
'join_required_rule' => [
'match' => [
[
'keys' => [
[
'form' => 'raw',
'attribute' => '<string>',
'field' => '<string>'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy"
payload := strings.NewReader("{\n \"default\": {\n \"projection\": {\n \"scalar_operators\": [\n \"<string>\"\n ],\n \"aggregate_operators\": [\n \"<string>\"\n ],\n \"external_operators\": [\n \"<string>\"\n ]\n },\n \"group_by\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n },\n \"join\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n }\n },\n \"usage_rules\": [\n {\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ],\n \"join_required_rule\": {\n \"match\": [\n {\n \"keys\": [\n {\n \"form\": \"raw\",\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"default\": {\n \"projection\": {\n \"scalar_operators\": [\n \"<string>\"\n ],\n \"aggregate_operators\": [\n \"<string>\"\n ],\n \"external_operators\": [\n \"<string>\"\n ]\n },\n \"group_by\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n },\n \"join\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n }\n },\n \"usage_rules\": [\n {\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ],\n \"join_required_rule\": {\n \"match\": [\n {\n \"keys\": [\n {\n \"form\": \"raw\",\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"default\": {\n \"projection\": {\n \"scalar_operators\": [\n \"<string>\"\n ],\n \"aggregate_operators\": [\n \"<string>\"\n ],\n \"external_operators\": [\n \"<string>\"\n ]\n },\n \"group_by\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n },\n \"join\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n }\n },\n \"usage_rules\": [\n {\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ],\n \"join_required_rule\": {\n \"match\": [\n {\n \"keys\": [\n {\n \"form\": \"raw\",\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"default": {
"projection": {
"mode": "allow",
"scalar_operators": [
"<string>"
],
"aggregate_operators": [
"<string>"
],
"external_operators": [
"<string>"
]
},
"group_by": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
},
"join": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
}
},
"usage_rules": [
{
"attribute": "<string>",
"field": "<string>",
"projection": {
"mode": "allow",
"scalar_operators": [
"<string>"
],
"aggregate_operators": [
"<string>"
],
"external_operators": [
"<string>"
]
},
"group_by": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
},
"join": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
}
}
],
"join_required_rule": {
"match": [
{
"keys": [
{
"form": "raw",
"attribute": "<string>",
"field": "<string>"
}
]
}
]
}
}{
"error": "invalid_request",
"error_description": "invalid query policy: default.projection.aggregate_operators: UPPER is not an aggregate function"
}"<string>"Set the query policy of an Access Rule
Attach a query policy to an access rule, replacing the current one if there is one. Only the owning company can set the policy.
curl --request PUT \
--url https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"default": {
"projection": {
"scalar_operators": [
"<string>"
],
"aggregate_operators": [
"<string>"
],
"external_operators": [
"<string>"
]
},
"group_by": {
"scalar_operators": [
"<string>"
]
},
"join": {
"scalar_operators": [
"<string>"
]
}
},
"usage_rules": [
{
"attribute": "<string>",
"field": "<string>"
}
],
"join_required_rule": {
"match": [
{
"keys": [
{
"form": "raw",
"attribute": "<string>",
"field": "<string>"
}
]
}
]
}
}
'import requests
url = "https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy"
payload = {
"default": {
"projection": {
"scalar_operators": ["<string>"],
"aggregate_operators": ["<string>"],
"external_operators": ["<string>"]
},
"group_by": { "scalar_operators": ["<string>"] },
"join": { "scalar_operators": ["<string>"] }
},
"usage_rules": [
{
"attribute": "<string>",
"field": "<string>"
}
],
"join_required_rule": { "match": [{ "keys": [
{
"form": "raw",
"attribute": "<string>",
"field": "<string>"
}
] }] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
default: {
projection: {
scalar_operators: ['<string>'],
aggregate_operators: ['<string>'],
external_operators: ['<string>']
},
group_by: {scalar_operators: ['<string>']},
join: {scalar_operators: ['<string>']}
},
usage_rules: [{attribute: '<string>', field: '<string>'}],
join_required_rule: {match: [{keys: [{form: 'raw', attribute: '<string>', field: '<string>'}]}]}
})
};
fetch('https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'default' => [
'projection' => [
'scalar_operators' => [
'<string>'
],
'aggregate_operators' => [
'<string>'
],
'external_operators' => [
'<string>'
]
],
'group_by' => [
'scalar_operators' => [
'<string>'
]
],
'join' => [
'scalar_operators' => [
'<string>'
]
]
],
'usage_rules' => [
[
'attribute' => '<string>',
'field' => '<string>'
]
],
'join_required_rule' => [
'match' => [
[
'keys' => [
[
'form' => 'raw',
'attribute' => '<string>',
'field' => '<string>'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy"
payload := strings.NewReader("{\n \"default\": {\n \"projection\": {\n \"scalar_operators\": [\n \"<string>\"\n ],\n \"aggregate_operators\": [\n \"<string>\"\n ],\n \"external_operators\": [\n \"<string>\"\n ]\n },\n \"group_by\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n },\n \"join\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n }\n },\n \"usage_rules\": [\n {\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ],\n \"join_required_rule\": {\n \"match\": [\n {\n \"keys\": [\n {\n \"form\": \"raw\",\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"default\": {\n \"projection\": {\n \"scalar_operators\": [\n \"<string>\"\n ],\n \"aggregate_operators\": [\n \"<string>\"\n ],\n \"external_operators\": [\n \"<string>\"\n ]\n },\n \"group_by\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n },\n \"join\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n }\n },\n \"usage_rules\": [\n {\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ],\n \"join_required_rule\": {\n \"match\": [\n {\n \"keys\": [\n {\n \"form\": \"raw\",\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/access-rules/{access_rule_id}/query-policy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"default\": {\n \"projection\": {\n \"scalar_operators\": [\n \"<string>\"\n ],\n \"aggregate_operators\": [\n \"<string>\"\n ],\n \"external_operators\": [\n \"<string>\"\n ]\n },\n \"group_by\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n },\n \"join\": {\n \"scalar_operators\": [\n \"<string>\"\n ]\n }\n },\n \"usage_rules\": [\n {\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ],\n \"join_required_rule\": {\n \"match\": [\n {\n \"keys\": [\n {\n \"form\": \"raw\",\n \"attribute\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"default": {
"projection": {
"mode": "allow",
"scalar_operators": [
"<string>"
],
"aggregate_operators": [
"<string>"
],
"external_operators": [
"<string>"
]
},
"group_by": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
},
"join": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
}
},
"usage_rules": [
{
"attribute": "<string>",
"field": "<string>",
"projection": {
"mode": "allow",
"scalar_operators": [
"<string>"
],
"aggregate_operators": [
"<string>"
],
"external_operators": [
"<string>"
]
},
"group_by": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
},
"join": {
"mode": "allow",
"scalar_operators": [
"<string>"
]
}
}
],
"join_required_rule": {
"match": [
{
"keys": [
{
"form": "raw",
"attribute": "<string>",
"field": "<string>"
}
]
}
]
}
}{
"error": "invalid_request",
"error_description": "invalid query policy: default.projection.aggregate_operators: UPPER is not an aggregate function"
}"<string>"Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Access rule identifier.
Body
Limits how a querying company may use the attributes and fields this access rule selects. An attribute is a
Rosetta Stone attribute that the access rule selects from _rosetta_stone. A field is any other column of the
access rule, such as a dataset column it selects directly. A query that breaks the policy reads no rows from the
access rule.
Rules for every attribute and field that no usage_rules entry names. A usage left out is denied.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Requires every query to inner join this access rule to a dataset the querying company owns, matching on the keys
of one match entry.
Show child attributes
Show child attributes
Response
OK. The stored policy.
Limits how a querying company may use the attributes and fields this access rule selects. An attribute is a
Rosetta Stone attribute that the access rule selects from _rosetta_stone. A field is any other column of the
access rule, such as a dataset column it selects directly. A query that breaks the policy reads no rows from the
access rule.
Rules for every attribute and field that no usage_rules entry names. A usage left out is denied.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Requires every query to inner join this access rule to a dataset the querying company owns, matching on the keys
of one match entry.
Show child attributes
Show child attributes
Was this page helpful?

