![]() ![]() A result variable was set to simplify the readability of the following examples. This string can be passed into the from_json filter to provide a valid JSON data structure. On Palo Alto devices the default stdout response is returned as a JSON encoded string. The jmespath third-party library must be installed on the host for the json_query filter to operate. It uses the third-party jmespath library, a powerful JSON query language supporting the parsing of complex structured data. ![]() The built-in json_query filter provides the functionality for filtering, shaping, and transforming JSON data. This can lead to complex task definition, making playbook maintenance more difficult. The extensive filters available, and what to use and when, can be overwhelming at first and the desired result can often require multiple filters chained together. array - an ordered sequence of objects (like Python list)Īnsible provides many built-in capabilities to consume JSON using Ansible specific filters or the Jinja2 built-in filters.object - an unordered collection of key/value pairs (like Python dict).Nowadays, the JSON format is heavily used by equipment vendors to represent complex objects in a structured way to allow programmatic interaction with devices. The following query returns all cases created at the beginning of the year until today's date.įor example, if today's date was March 24, 2020, then the query would return all cases created on Januuntil March 24, 2020.Parsing structured JSON data in Ansible playbooks is a common task. If you copy and paste these examples into your interface, they will not evaluate. Record type object references are specific to each environment. See Query Recipes for more examples filtering data from a record type or from a data store entity. The following examples illustrate how to filter data in a!queryRecordType() for a sample Case record type. =,, in, not in, starts with, not starts with, ends with, not ends with, includes, not includes, is null, not null The following table shows which operators can be applied to each data type. You can set up one rule input or local variable that contains a list of two values, or create a list of two values in expression mode. ![]() Since a!recordData() references the Employee record type in the recordType parameter, the filter must reference a field starting from recordType!Employee.Ī!queryRecordType ( ! recordType: recordType!Employee,įields. When applying a filter to a records-powered chart or grid, you must reference record fields or related record fields from the record type specified in a!recordData().įor example, lets say you want to create a pie chart to show the number of employees per department, and you want to filter by employee status. QueryFilter Usage considerations Filter record data When set to false, the filter is not evaluated. Filter is ignored if value is empty or null and operator is neither "is null" or "not null".ĭetermines whether the filter is applied on the query. Optional if the operator value is "is null" or "not null". The value to compare to the given field using the given operator. For example, "department".įilter operator to apply to the data. ![]() When filtering data from a data store entity, use the field name in quotations. When filtering record data, use the recordType! domain to reference a record field, related record field, or record type relationship. The name of the field or relationship to be filtered. A!queryFilter( field, operator, value, applyWhen )Ĭreates a value of type QueryFilter for use with a!pickerFieldRecords(), a!queryRecordType(), a!recordData(), a!relatedRecordData(), a!recordFilterListOption(), or a!query(). ![]()
0 Comments
Leave a Reply. |