Skip to content

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 contractor
under management:ops-west or site = reno
SelectorPicks what
region = west (or ==)has west under region
region != westhas 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 badgehas a value under badge, whatever it is
region ^= west/nevadahas west/nevada, or a path under it (west/nevada/reno)
under management:ops-westis in organization ops-west of hierarchy management, or one under it
a and b, a, bboth
a or beither
not anot a
  • not binds tightest. It is worked out first, then and (or a comma), then or. Parentheses group: (a or b) and c.
  • A key is 1 to 128 letters, digits, _, -, . or /. It starts with a letter or digit. site/zone is 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, in and notin are the language’s own words. A value spelled like one is quoted (role = "and").
  • A path prefix matches whole segments between /. region ^= west/nev does not pick west/nevada.
  • A / at the end of the prefix changes nothing (west/ is west). A prefix of nothing but / is refused.
  • A value has no control characters (line breaks, tabs), quoted or not.
  • A list after in or notin has one value or more.
  • != and notin pick things with no value under the key. =, in and ^= 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 value

Each 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).

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 labels field (hourctl sync person set, PUT .../sync/{group}/people/{user_id}).

Where selectors pick:

WherePicksBy
A sync group’s placement rule, peoplethe people the rule placestheir labels
A sync group’s placement rule, devicesthe members it places them onthe members’ labels
A job’s targets.selectthe devices it runs ontheir labels
GET .../devices?select=the devices listedtheir labels
GET .../sync/{group}/people?select=the people listedtheir 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.

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-42
attributes.pay_group in (seasonal, part_time)
employer = acme-ca

Lists 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).