Advanced Usage and Reference
Create Filters and Checks based on custom properties.
Service Property Checks has been renamed to the Property Check
Service Property Checks have been renamed to the Property Check as part of the Components Release.
Component Maturity
Custom Properties is available for use through our Maturity offering:
Filters
Custom Properties can be used within filters by first selecting Property
and then the desired Property Definition, followed by a jq expression to apply the correct filter.

Custom component property filter creation page.
Property Checks
Our existing Property Check has been extended to support Property Definition values. You can leverage the existing check, selecting a Property Definition name for the “Property” field under the Component group you wish to check a property on. By default the checks will ensure a value has been assigned to each component the check applies to. Optionally you can also apply a predicate in the “Advanced” section to write more custom validation.

Configuring a Property Check on a custom property.
Note: Property Checks will only evaluate against the Component Type that you select the property for. This means that if you have a filter that applies to more than one component type, the Property Check will be a union of the filter AND the Component Type of the property select.
API Reference
Below are a series of common API requests which can be used to manage Property Definitions or Component Property values
Property Definitions
Create Component and its Properties
mutation {
componentTypeCreate(input: {
name: "Mobile App",
alias: "mobile_app",
properties: [{
name: "Latest Release",
alias: "latest_release",
schema: "{ \"type\": \"string\", \"format\": \"date-time\" }",
description: "The date of the last release.",
propertyDisplayStatus: "visible",
allowedInConfigFiles: false
}]
}){
componentType {
id
name
alias
description
properties {
nodes {
id
name
alias
schema
description
propertyDisplayStatus
allowedInConfigFiles
}
}
}
errors{
path
message
}
}
}
Update Component Type
mutation {
componentTypeCreate(
componentType: { alias: "mobile_app" },
properties: [{
name: "Latest Release",
alias: "latest_release",
schema: "{ \"type\": \"string\", \"format\": \"date-time\" }",
description: "The date of the last release.",
propertyDisplayStatus: "visible",
allowedInConfigFiles: true
}]
){
componentType {
id
name
alias
description
properties {
nodes {
id
name
alias
schema
description
propertyDisplayStatus
allowedInConfigFiles
}
}
}
errors{
path
message
}
}
}
Delete Component Type
mutation {
componentTypeDelete(resource: {alias: "mobile_app"}){
deletedId
errors {
path
message
}
}
}
List Properties for a Component Type
query {
account {
componentType(input: { alias: "mobile_app" }) {
componentType {
properties {
nodes {
id
name
aliases
schema
}
}
}
}
}
}
Component Properties
Our public API for
services
is the API used for interacting with Components.Components are currently released in Beta and the Service APIs along with the new
type
field are used to interact with Components. If you do not have Components enabled on your account, please reach out to your customer service representative or email us at support@opslevel.com to get it enabled.
Property Assign
mutation {
propertyAssign(input: {
owner: { alias: "music_catalogue"},
definition: { alias: "latest_release"},
value: "\"2023-10-12T20:20:39+00:00\""
}){
property {
value
owner {
__typename
...on Service {
name
}
}
}
errors {
path
message
}
}
}
Property Unassign
mutation {
propertyUnassign(
owner: { alias: "music_catalogue"},
definition: { alias: "latest_release"}
){
definition {
name
}
owner {
__typename
...on Service {
name
}
}
errors {
path
message
}
}
}
List Property Values on a component
query list {
account {
service(alias: "music_catalogue") {
properties {
nodes {
value
definition {
name
schema
aliases
}
}
}
}
}
}
Get Property Value
query get {
account {
property(
owner: { alias: "music_catalogue"},
definition: { alias: "latest_release"}
) {
value
}
}
}
Filtering Reference
For details, take a look at the JQ language documentation.
Property Exists / Does Not Exist
// exists
.
// does not exist
. | not
Boolean
. == true
String
// matches "some value"
. == "some value"
// matches all other values that are not "some value" and the property is set
. != "some value"
Number
. > 4
Object
.key == "value"
Array
// map through the array to check for values
.[] | . == true
// pick a particular index
.[0] | . == true
// Array contains value
any(. == true)
// Array contains object with property value
any(.severity == "high")
Advanced Examples
JQ is very expressive and allows very complex queries. Keep in mind that we’re always interpreting the result of the expression as either false or true.
// Array contains more than 4 items with high severity
reduce .[] as $item (0; if $item.severity == "high" then . + 1 else . end) > 4
Sample Data
Not sure how to get started with using componentd properties? We have you covered! Below is a list of different objects we thought you’d like to track
Vulnerabilities
Track a list of vulnerabilities that are linked to your component
{
"title": "Vulnerabilities",
"description": "A list of vulnerable packages",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"severity": {
"type": "string",
"enum": ["low", "medium", "high", "critical"]
},
"introduced_through": { "type": "string" },
"fixed_in": { "type": "string" }
},
"required": ["name", "severity"]
},
"minItems": 0,
"uniqueItems": true
}
Packages
{
"title": "Packages",
"description": "A list of packages.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"version": { "type": "string" },
"lock_file": { "type": "string" },
"manager": { "type": "string" }
},
"required": ["name", "version"]
},
"minItems": 0,
"uniqueItems": true
}
Environments
{
"title": "Environments",
"description": "The different environments a component can be deployed to.",
"type": "string",
"enum": ["prod", "dev"]
}
Publicly Routable
{
"title": "Publicly Routable",
"description": "Can the component be accessed through the public internet?",
"type": "boolean"
}
Updated about 24 hours ago