Aquarium Query Language Schema

Validated JSON Schemas (https://json-schema.org/)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Aquarium Query Language (AQL) Schema",
  "description": "This schema validates query schema for AQL",
  "type": "object",
  "definitions": {
    "time": {
      "type": "object",
      "description": "Delta time definition (from now)",
      "properties": {
        "__time__": {
          "type": "object",
          "properties": {
            "__seconds__": {
              "type": "integer"
            },
            "__hours__": {
              "type": "integer"
            },
            "__days__": {
              "type": "integer"
            },
            "__weeks__": {
              "type": "integer"
            }
          },
          "minProperties": 1
        }
      },
      "minProperties": 1,
      "maxProperties": 1,
      "required": [
        "__time__"
      ],
      "additionalProperties": false
    },
    "value": {
      "description": "Valid query value",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "$ref": "#/definitions/time"
        }
      ]
    },
    "valueArray": {
      "description": "Valid query value array. Cannot be empty.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/value"
      },
      "minItems": 1
    },
    "sql": {
      "type": "object",
      "description": "Query for NOT, LESS THAN, GREATER THAN, e.g.",
      "properties": {
        "__not__": {
          "$ref": "#/definitions/value",
          "description": "Negation of the value"
        },
        "__lt__": {
          "$ref": "#/definitions/value",
          "description": "Less than the value"
        },
        "__le__": {
          "$ref": "#/definitions/value",
          "description": "Less than or equal to the value"
        },
        "__gt__": {
          "$ref": "#/definitions/value",
          "description": "Greater than the value"
        },
        "__ge__": {
          "$ref": "#/definitions/value",
          "description": "Greater than or equal to the value"
        }
      },
      "minProperties": 1,
      "maxProperties": 1
    },
    "queryObj": {
      "type": "object",
      "patternProperties": {
        "^(?!__)\\w+(?<!__)$": {
          "anyOf": [
            {
              "$ref": "#/definitions/queryObj"
            },
            {
              "$ref": "#/definitions/value"
            },
            {
              "$ref": "#/definitions/valueArray"
            },
            {
              "#ref": "#/definitions/sql"
            }
          ]
        }
      },
      "properties": {
        "__options__": {
          "type": "object",
          "properties": {
            "limit": {
              "type": "integer",
              "description": "limit the number of the models to return"
            },
            "pageSize": {
              "type": "integer",
              "description": "limit the number of models to return per query",
              "default": null
            }
          }
        },
        "__return__": {
          "type": "object"
        }
      },
      "additionalProperties": false
    }
  },
  "properties": {
    "__query__": {
      "description": "Query to find models.",
      "$ref": "#/definitions/queryObj"
    },
    "__description__": {
      "description": "Query description. Effectively ignored",
      "type": "string"
    },
    "__model__": {
      "description": "Name of the Aquarium model",
      "type": "string"
    },
    "__json__": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "include_uri": {
              "type": "boolean",
              "default": true
            },
            "include_model_type": {
              "type": "boolean",
              "default": true
            }
          },
          "additionalProperties": false
        },
        {
          "type": "boolean",
          "default": false
        }
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "__model__": "Sample",
      "__query__": {
        "items": {
          "__query__": {
            "object_type": {
              "__query__": {
                "name": "Yeast Glycerol Stock"
              }
            },
            "__options__": {
              "limit": 1
            }
          }
        },
        "user_id": 1,
        "__return__": {
          "sample_type": "field_types"
        }
      }
    }
  ],
  "required": [
    "__query__",
    "__model__"
  ]
}

Aquarium Query Language (AQL) Schema

This schema validates query schema for AQL

type

object

examples

__model__

Sample

__query__

items

__query__

object_type

__query__

name

Yeast Glycerol Stock

__options__

limit

1

user_id

1

__return__

sample_type

field_types

properties

  • __query__

Query to find models.

#/definitions/queryObj

  • __description__

Query description. Effectively ignored

type

string

  • __model__

Name of the Aquarium model

type

string

  • __json__

anyOf

type

object

properties

  • include_uri

type

boolean

default

True

  • include_model_type

type

boolean

default

True

additionalProperties

False

type

boolean

default

False

additionalProperties

False

definitions

  • time

Delta time definition (from now)

type

object

properties

  • __time__

type

object

properties

  • __seconds__

type

integer

  • __hours__

type

integer

  • __days__

type

integer

  • __weeks__

type

integer

minProperties

1

additionalProperties

False

maxProperties

1

minProperties

1

  • value

Valid query value

anyOf

type

string

type

integer

#/definitions/time

  • valueArray

Valid query value array. Cannot be empty.

type

array

items

#/definitions/value

minItems

1

  • sql

Query for NOT, LESS THAN, GREATER THAN, e.g.

type

object

properties

  • __not__

Negation of the value

#/definitions/value

  • __lt__

Less than the value

#/definitions/value

  • __le__

Less than or equal to the value

#/definitions/value

  • __gt__

Greater than the value

#/definitions/value

  • __ge__

Greater than or equal to the value

#/definitions/value

maxProperties

1

minProperties

1

  • queryObj

type

object

properties

  • __options__

type

object

properties

  • limit

limit the number of the models to return

type

integer

  • pageSize

limit the number of models to return per query

type

integer

default

null

  • __return__

type

object

patternProperties

  • ^(?!__)\w+(?<!__)$

anyOf

#/definitions/queryObj

#/definitions/value

#/definitions/valueArray

additionalProperties

False

Examples

Get most recent primers

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "__model__": "Item",
  "__description__": "Get available primers created in last 7 days",
  "__query__": {
    "object_type": {
      "__query__": {
        "sample_type": {
          "__query__": {
            "name": "Primer"
          }
        }
      }
    },
    "created_at": {
      "__time__": {
        "__days__": -7
      }
    },
    "__options__": {
      "limit": 1
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "__model__": "Sample",
  "__description__": "Get one primer sample",
  "__query__": {
    "sample_type": {
      "__query__": {
        "name": "Primer"
      }
    },
    "__options__": {
      "limit": 1
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "__model__": "Item",
  "__description__": "Get available primers created in last 7 days",
  "__query__": {
    "object_type": {
      "__query__": {
        "sample_type": {
          "__query__": {
            "name": "Primer"
          }
        }
      }
    },
    "created_at": {
      "__time__": {
        "__days__": -7
      }
    },
    "__options__": {
      "limit": 1
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "__model__": "Item",
  "__description__": "Get three items by ids",
  "__query__": {
    "id": [1, 2, 3],
    "__options__": {
      "limit": 10
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "__model__": "Item",
  "__description__": "Get one item",
  "__query__": {
    "id": 1,
    "__options__": {
      "limit": 1
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "__model__": "Sample",
  "__description__": "Return samples that have available Primer Aliquots",
  "__query__": {
    "items": {
      "__query__": {
        "object_type": {
          "__query__": { "name": "Primer Aliquot" }
        },
        "location": {
          "__not__": "deleted"
        },
        "__options__": {
          "limit": 1
        }
      }
    },
    "__options__": {
      "limit": 1
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "__model__": "Sample",
  "__description__": "Return samples that have available Primer Aliquots",
  "__json__": true,
  "__query__": {
    "items": {
      "__query__": {
        "object_type": {
          "__query__": { "name": "Primer Aliquot" }
        },
        "location": {
          "__not__": "deleted"
        },
        "__options__": {
          "limit": 1
        }
      }
    },
    "__options__": {
      "limit": 1
    }
  }
}