Action Context Schema
An Action’s rule and response fields support liquid templating. When templates are evaluated, they receive a context object. This allows the action to behave dynamically based on the information in the context.
Context fields are accessed using Liquid's double handle bar notation: {{ identifier }}
. When evaluated this would be replaced by the matching value in the context.
The action context contains the following properties:
Service
When an action is defined to apply to a service, the actions will have access to the context of the specific service it is triggered against. These properties all refer to that service. For more information on how to configure an action to have access to service context, see the guide to creating your first action.
Description | |
---|---|
service.framework | The primary software development framework that the service uses. |
service.href | A link to the HTML page for the service. |
service.id | The unique identifier for the service. |
service.language | The primary programming language that the service is written in. |
service.lifecycle_index | The lifecycle stage of the service. |
service.name | The display name of the service. |
service.product | A product is an application that your end user interacts with. Multiple services can work together to power a single product. |
service.service_repositories | A list of repositories that are linked to the service. For details on what values are available on the repository, see Service Repositories. |
service.slug | The URL friendly name of the service. |
service.tier_index | The software tier that the service belongs to. |
service.owner | An object representing the team that owns the service. For details on what values are available on the owner, see Owner. |
Service Repositories
If a Service has a connected repositories, their details will also be available to the action.
Description | |
---|---|
service_repositories[0].is_primary | If true, the repository is considered the main source code for the service.** |
service_repositories[0].display_name | The name of the repository as it is displayed in OpsLevel. |
service_repositories[0].deep_url | An HTTP URL to the repository in the external Git Forge. |
service_repositories[0].default_branch | The name of the default branch for the repository. |
** primary is only true if the connected repo has an opslevel.yml file. If you do not use opslevel.yml to define your services and you use service_repositories[0].is_primary in a custom action, you will see a Liquid error when you try to run it:
Liquid Undefined Variable Error
Liquid error: undefined variable repository
User
Actions are invoked by an individual user. These properties all refer to that user.
Description | |
---|---|
user.api_token_count | The number of api tokens owned by this user. |
user.deactivated | True if this user is deactivated and cannot be used. |
user.deactivated_at | The time that the user was deactivated. |
user.email | The user's email. |
user.gravatar_url | The url to the user's gravatar image. |
user.has_provider | Whether this user is managed externally. |
user.href | A link to the HTML page for the user. |
user.id | The unique identifier for the user. |
user.name | The user's full name. |
user.pending | Whether the user accepted their invitation to OpsLevel or not. |
user.provisioned_by | How the user was provisioned. Possible values:, SCIM , OpsLevel CLI , Terraform , API , SSO (Okta) , SSO , OpsLevel Admin , and Unknown . |
user.role | The user's assigned role. |
Manual Inputs
Manual inputs are the fields presented to a user when they invoke an Action. They are also injected into the context and can be referenced using the value defined in the identifier property.
Manual inputs are available as sub-properties of the manualInputs property.
Given this defined input:
---
version: 1
inputs:
- identifier: bucketName
# ...
The value of this input would be available to the Action’s context with {{ manualInputs.bucketName }}
.
For more information, see our guide on configuring manual inputs.
Secrets
Secrets are a way to store information like API or Access tokens used in Action and Service Template webhooks. Secrets are only available in the Webhook URL, Payload and Headers fields and.
You can access Secrets values by using their alias as the sub-property of the secret or secrets property in the context.
For example, given a secret with the alias: opslevel_api_token
.
The value of the secret would be available to the action's context with this syntax: {{ 'opslevel_api_token' | secret }}
.
For more information, see our guide on secrets.
Secrets will not appear in the Action Execution History's context object and will appear as
********
when referenced in parts of the webhook
Owner
An owner reference is the Team responsible for a component in OpsLevel. An action's context may contain many owner references including action_owner --
the team responsible for the action being invoked and service.owner --. This field may be blank if the Team specified as the owner has been deleted from OpsLevel.
Description | |
---|---|
action_owner.contacts | A list of details for contacting the action owner. See Contact for more details. |
action_owner.href | A link to the HTML page for the action owner. |
action_owner.id | The unique identifier for the action owner. |
action_owner.manager | The user who manages the action owner. See User for more details. |
action_owner.name | The display name of the action owner. |
action_owner.slug | A human-friendly, unique identifier. |
Contact
Contacts are the communication channels used to get in touch with the action owner.
Description | |
---|---|
contact.address | The contact address. Examples: Email ([email protected]) and Web (https://opslevel.com). |
contact.contact_method | The method of contact. Possible values:email , slack , slack_handle , and web . |
contact.display_name | The name shown in the UI for the contact. |
contact.display_type | The type shown in the UI for the contact. Possible values: Primary , Secondary , and None . |
contact.id | The unique identifier for the contact. |
contact.target_href | The fully qualified URI for the contact. |
Response
The Response Details property injects an additional object into the Action’s context. These properties all refer to the response received from the webhook URL when invoking the action.
The response headers and body will be coerced into JSON if possible and can be referenced in the Liquid template as {{ response.headers.<property> }}
.
Description | |
---|---|
response.status | The HTTP status code. |
response.headers | The HTTP headers. |
response.body | The response body. |
Example Context
Action Template Context
{
"user":
{
"id": "SOME-ID",
"name": "First Last",
"email": "[email protected]",
"href": "/users/SOME-ID",
"role": "admin",
"deactivated_at": null,
"deactivated": false,
"gravatar_src": "",
"pending": false,
"has_provider": false,
"api_token_count": 3,
"provisioned_by": "OpsLevel Admin"
},
"service":
{
"id": "SOME-ID",
"name": "Django Test",
"href": "/services/django_test",
"product": null,
"language": "Java",
"framework": "Spring",
"slug": "django_test",
"tier_index": null,
"lifecycle_index": null,
"service_stat":
{
"num_checks": 9,
"num_passing_checks": 4
},
"tags":
[
{
"key": "is_approved",
"value": "false",
"id": "SOME-ID",
"gid": "SOME-ID",
"locked": false
}
],
"service_repositories":
[
{
"id": 9999,
"gid": "SOME-ID",
"repo_path": "",
"is_primary": false,
"managed": false,
"locked": false,
"at_root": true,
"display_name": "GROUP/django-test",
"deep_url": "https://github.com/GROUP/django-test",
"repository":
{
"id": 9999,
"gid": "SOME-ID",
"name": "django-test",
"url": "https://github.com/GROUP/django-test",
"default_branch": "main",
"invalidated_at": null,
"active": true,
"forked": false,
"repo_key": "SOME-ID",
"display_name": "GROUP/django-test",
"description": null,
"type_string": "github",
"visible": true,
"archived_at": null,
"branch_protection": false,
"created_on": "2022-08-04T12:12:33.000000Z",
"account_name": "GROUP",
"type_display_name": "GitHub",
"icon": "github",
"integration_href": "https://app.opslevel.com/integrations/github/SOME-ID",
"locked": false,
"private": true,
"href": "/repositories/SOME-ID"
}
}
],
"owner":
{
"id": "SOME-ID",
"name": "Aes Sedai",
"href": "/teams/aes_sedai",
"slug": "aes_sedai",
"service_stat":
{
"num_checks": 38,
"num_passing_checks": 13
},
"manager":
{
"id": 9999999,
"email": "[email protected]",
"session_token": "SOME-ID",
"last_sign_in_method": null,
"name": "Moirane Damodred",
"account_id": 999999,
"accepted_tos_at": null,
"role": "user",
"provisioned_by_id": null,
"provisioned_by_type": null,
"provisioned_by_details": null,
"deactivated_at": null,
"created_at": "2022-06-29T22:43:06.619978Z",
"updated_at": "2022-06-29T22:43:06.713373Z",
"seen_team_cta": null
},
"tags":
[],
"contacts":
[
{
"id": 99999,
"address": "#the-white-tower",
"contact_method": "SLACK",
"display_name": "Slack Channel",
"display_type": null,
"target_href": "https://my-workspace.slack.com/channels/the-white-tower/",
"type": "Slack",
"short_name": "#the-white-tower",
"icon": "slack"
}
]
}
},
"action_owner":
{
"id": "SOME-ID",
"name": "Team A",
"href": "/teams/team_a",
"slug": "team_a",
"service_stat":
{
"num_checks": 0,
"num_passing_checks": 0
},
"manager": null,
"contacts":
[]
},
"manualInputs":
{
"message": "This is a message!"
}
}
Filters
In addition to Liquid’s standard filters, we also support:
contacts_by_display_name
Find contacts by their display name
- Input:
{{ team | contacts_by_display_name: 'pagerduty' }}
- Output:
\[contact_1, contact_2\]
tag_value
Returns the value of the first matching tag.
- Input:
{{ service | tag_value: "version" }}
- Output:
"3.2.1"
tag_values
Returns the array of matching tag values.
- Input:
{{ service | tag_values: "ip" }}
- Output:
\["1.1.1.1", "2.2.2.2"\]
This can be combined with the standard filters to extract specific values:
- Input:
{{ service | tag_values: "ip" | last }}
- Output:
"1.1.1.1"
Updated 26 days ago