The Open Data Model api is available at %base_url%/opendatamodel where %base_url% is the base Data Hub API url (api.opinum.com for Opinum SAAS Data Hub).
Here is the way to use some of the API samples (/sample/{sampleKind}) using the API
- Store the schema
Schema:
type Query {
VariableGroups : [VARIABLE_GROUP]
SourceGroups : [SOURCE_GROUP]
}
type VARIABLE_GROUP {
Key: String
Type: String
AllVariables: [DataHubVariable] @traverse_relation(Type: GROUP_MEMBER Depth: 5)
GroupVariables: [DataHubVariable] @direct_relation(Type: GROUP_MEMBER)
SubGroups: [VARIABLE_GROUP] @direct_relation(Type: GROUP_OF)
}
type SOURCE_GROUP {
Key: String
Type: String
AllSources: [DataHubSource] @traverse_relation(Depth: 5)
GroupSources: [DataHubSource] @direct_relation(Type: GROUP_MEMBER)
SubGroups: [SOURCE_GROUP] @direct_relation(Type: GROUP_OF)
}
PUT the schema as the default one through /storage/schema/default
- Create nodes and relations
Mutation:
mutation {
CreateNodesAndRelations(
Nodes: [
{
KeyProperty: ""Key"",
KeyValue: ""Custom variables1"",
NodeType: ""VARIABLE_GROUP"" ,
Properties : [ {Name : ""Type"",Value: ""Custom1""}]}
],
Relations: [
{
SourceNode : {
KeyProperty: ""Key"",
KeyValue: ""Custom variables1"",
NodeType: ""VARIABLE_GROUP""},
DestinationNodes: {
NodeSelector : ""PARENT(DataHubSource,Id) = 10 AND Name LIKE 'test'"",
NodeType: ""DataHubVariable"" },
RelationType : ""GROUP_MEMBER"",
Properties : [ { Name : ""FromDate"", Value : ""2021-01-01""}, { Name : ""ToDate"", Value : ""2022-12-31""}]
}]
) { NumberOfNodes NumberOfRelations}}
Apply the mutation through /mutation
- Query the nodes
query {VariableGroups { Key }}
query {VariableGroups { Key GroupVariables {Id Name}} }
query {VariableGroups @where(Node: ""Type = 'Custom1'"") { Key GroupVariables {Id Name}} }
query {VariableGroups @where(Node: ""Key = 'Custom variables1'"") { Key GroupVariables {Id Name }} }
query {VariableGroups @where(Node: ""Type = 'Custom1' AND Key = 'Custom variables1'"") { Key GroupVariables {Id Name }} }
query {VariableGroups @where(Node: ""Type = 'Custom1'"") { Key GroupVariables @where(Node: ""Id = 100"") {Id Name}} }
query {VariableGroups @where(Node: ""Type = 'Custom1'"") { Key GroupVariables @where(Node: ""Id = 101"") {Id Name}} }
Run query through /query