Selectors
A selector is a short expression. It picks things by their labels or attributes, and by their place in hierarchies of organizations. Both engines use the same language. Connect picks devices and people with it. Time and Attendance picks which people a policy layer applies to. This page is the language reference, then where each engine uses it.
region ^= west/nevada and role in (lead, manager) and not has contractorunder management:ops-west or site = reno| Selector | Picks what |
|---|---|
region = west (or ==) | has west under region |
region != west | has another value under region, or none |
region in (west, east) | has one of the values |
region notin (west, east) | has none of them, or no value |
has badge | has a value under badge, whatever it is |
region ^= west/nevada | has west/nevada, or a path under it (west/nevada/reno) |
under management:ops-west | is in organization ops-west of hierarchy management, or one under it |
a and b, a, b | both |
a or b | either |
not a | not a |
notbinds tightest. It is worked out first, thenand(or a comma), thenor. Parentheses group:(a or b) and c.- A key is 1 to 128 letters, digits,
_,-,.or/. It starts with a letter or digit.site/zoneis one key. - A value is a word of letters, digits and
_ - . / : @ +. Or it is a string in double quotes ("Night shift"). In a string,\"is a quote and\\a backslash. and,or,not,has,under,inandnotinare the language’s own words. A value spelled like one is quoted (role = "and").- A path prefix matches whole segments between
/.region ^= west/nevdoes not pickwest/nevada. - A
/at the end of the prefix changes nothing (west/iswest). A prefix of nothing but/is refused. - A value has no control characters (line breaks, tabs), quoted or not.
- A list after
inornotinhas one value or more. !=andnotinpick things with no value under the key.=,inand^=do not.- A selector is at most 4096 bytes. It nests at most 32 deep (parentheses and
nots).
Text that is not a selector is refused. The refusal gives the column the mistake is at, counting characters from 1:
column 10: 'and' is a word of the language: quote it to mean the valueEach selector has one canonical form, which the engines show it in. It has one space around each operator, and and for a comma. Values are quoted only where they must be. Parentheses are used only where the meaning needs them (a=1,(b=2,c=3) is a = 1 and b = 2 and c = 3).
In Connect
Section titled “In Connect”Connect picks devices and people by their labels. A label is key = value. A key is 1 to 63 letters, digits, -, _, . or /. A value is 1 to 255 characters of plain words (letters, digits, -, _, .). The words are joined by / into a path: west/nevada/plant-7. An endpoint, a device and a person each have at most 64 labels.
- A device’s labels are its endpoint’s. The device’s own are put over them (
hourctl device label,PATCH .../devices/{endpoint}/{device}). - A person’s labels are their
labelsfield (hourctl sync person set,PUT .../sync/{group}/people/{user_id}).
Where selectors pick:
| Where | Picks | By |
|---|---|---|
A sync group’s placement rule, people | the people the rule places | their labels |
A sync group’s placement rule, devices | the members it places them on | the members’ labels |
A job’s targets.select | the devices it runs on | their labels |
GET .../devices?select= | the devices listed | their labels |
GET .../sync/{group}/people?select= | the people listed | their labels |
[[sync_group.placement]]people = "role in (lead, manager)"devices = "region ^= west/nevada and kind != kiosk"A person is placed on a member when any rule’s people selector picks the person and its devices selector picks the member. A rule without people picks every person. A rule without devices picks every member. A group without rules places everyone on every member. A person’s own devices list ("<endpoint>/<device>") places them instead of the rules. A person enrolled at a clock and not linked yet stays on that clock alone.
Connect has no hierarchies of organizations. So a selector that uses under is refused at the column of the word. Selectors are checked when the settings are loaded or changed, and when a list is asked for.
The Connect policy recipes show labels at work with selectors. onboard-first, multi-agency-clock and enroll-for-the-agency read the device labels that selectors pick devices by. enroll-for-the-agency also writes the person labels that a placement rule’s people selector picks by.
In Time and Attendance
Section titled “In Time and Attendance”A policy layer’s eligibility rule (applies_to) is a selector. It is asked of the person as they are on each day. That means their id, employer, worker, work location and its jurisdiction, their employment attributes, and where they are in each hierarchy (under <hierarchy>:<org>). A rule only decides which layers apply to a person. It is never a way to list people (eligibility rules).
jurisdiction = us-ca and not under unions:local-42attributes.pay_group in (seasonal, part_time)employer = acme-caLists of people filter by place with under=<hierarchy>:<org> instead (organizations). An approval stage picks the organization a decision waits on. It does so with a selector over organizations’ labels (level = division).