I have a yaml file that looks like that - see below. Question:
- Is it possible to use pystardog to automate changes to the saved queries? It doesn’t have to push deltas - when I change my model ttl and data ttl - I need to delete saved queries and recreate them.
- Is there a sample code that can be used for this?
queries:
- name: "executive_dashboard"
description: "Executive dashboard showing key GRC metrics: risks, controls, compliance, and gaps"
database: "OpenControls"
tags:
- "Voicebox Query Prompt"
voicebox_enabled: true
reasoning_enabled: false
private: false
variations:
- "Show me the executive dashboard"
- "What's our overall GRC status?"
- "Give me a summary of our security posture"
- "Show me key risk and control metrics"
- "What's our compliance status?"
sparql: |
PREFIX ocm: <http://www.w3.org/2019/05/ocm#>
PREFIX ocm3: <http://www.w3.org/2019/05/ocm-instance#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?metric ?value
WHERE {
{
# Total Risks
SELECT ("Total Risks" AS ?metric) (COUNT(?risk) AS ?value)
WHERE { ?risk a ocm:Risk }
}
UNION
{
# Critical Risks
SELECT ("Critical Risks" AS ?metric) (COUNT(?risk) AS ?value)
WHERE {
?risk a ocm:Risk ;
ocm:riskLevel "Critical" .
}
}
UNION
{
# Total Controls
SELECT ("Total Controls" AS ?metric) (COUNT(?control) AS ?value)
WHERE { ?control a ocm:OpenControlsCapability }
}
UNION
{
# Average Control Effectiveness
SELECT ("Avg Control Effectiveness" AS ?metric) (AVG(?score) AS ?value)
WHERE {
?control a ocm:OpenControlsCapability ;
ocm:effectivenessScore ?score .
}
}
UNION
{
# Total Gaps
SELECT ("Total Gaps" AS ?metric) (COUNT(?gap) AS ?value)
WHERE { ?gap a ocm:Issue }
}
UNION
{
# Critical Gaps
SELECT ("Critical Gaps" AS ?metric) (COUNT(?gap) AS ?value)
WHERE {
?gap a ocm:Issue ;
ocm:priority "Critical" .
}
}
UNION
{
# Total NIST Controls
SELECT ("NIST Controls" AS ?metric) (COUNT(?nist) AS ?value)
WHERE {
?nist a ocm:RegulatoryObjective ;
ocm:framework "NIST" .
}
}
UNION
{
# Implemented NIST Controls
SELECT ("Implemented NIST" AS ?metric) (COUNT(DISTINCT ?nist) AS ?value)
WHERE {
?nist a ocm:RegulatoryObjective ;
ocm:framework "NIST" .
?control ocm:implements ?nist .
}
}
}
ORDER BY ?metric