= Keywords

The following tables list the keywords used in `Unlang`.  These keywords
implement the "flow control" of the policies.

== Flow Control Keywords

The _flow control_ keywords allow _if / then / else_ checks, simple
looping, etc.

.Flow Control
[options="header"]
[cols="30%,70%"]
|=====
| Keyword | Description
| xref:unlang/break.adoc[break]     | Exit early from a `foreach` loop.
| xref:unlang/case.adoc[case]       | Match inside of a `switch`.
| xref:unlang/else.adoc[else]       | Do something when an `if` does not match.
| xref:unlang/elsif.adoc[elsif]     | Check for condition when a previous `if` does not match.
| xref:unlang/foreach.adoc[foreach] | Loop over a list of attributes.
| xref:unlang/if.adoc[if]           | Check for a condition, and execute a sub-policy if it matches.
| xref:unlang/return.adoc[return]   | Immediately stop processing a section.
| xref:unlang/switch.adoc[switch]   | Check for multiple values.
|=====

== Attribute Editing Keywords

The _attribute editing_ keywords allow policies to add, delete, and
modify attributes in any list or packet.

.Attribute Editing
[options="header"]
[cols="30%,70%"]
|=====
| Keyword | Description
| xref:unlang/map.adoc[map]         | Map database fields to server attributes.
| xref:unlang/edit.adoc[editing]    | Creating, modifying, and deleting attributes.
| xref:unlang/update.adoc[update]   | DEPRECATED - v3 compatible attribute editing.
|=====

== Grouping Keywords

The _grouping_ keywords allow policies to be organized into groups,
including fail-over, load-balancing, limits, etc.

.Grouping and Limits
[options="header"]
[cols="30%,70%"]
|=====
| Keyword | Description
| xref:unlang/group.adoc[group]               | Group a series of statements.
| xref:unlang/load-balance.adoc[load-balance] | Define a load balancing group without fail-over.
| xref:unlang/limit.adoc[limit]               | Limit the number of requests in a section
| xref:unlang/redundant.adoc[redundant]       | Define a redundant group with fail-over.
| xref:unlang/redundant-load-balance.adoc[redundant-load-balance] | Define a redundant group with fail-over and load balancing.
| xref:unlang/timeout.adoc[timeout]           | Enforce a timeout for processing a section
|=====

== Parent-Child Keywords

The _parent-child_ keywords allow for creation of parent-child
relationships between requests.

For example, it is possible to create a child request, edit its
attributes, and then proxy that packet to an external destination.
This process must be specified manually, unlike in version 3, the
child was created automatically when the `proxy` list was used.

The benefit of these new keywords is that it is now possible to
control when child requests are created.  It is also possible to
control whether or not the parent waits for the child to finish, or
operates independently of the child.  It is also finally possible to
have multiple child requests via the `parallel` keyword.

These new keywords can unfortunately make some simple configurations
more complex than they would have been in version 3.  The trade-off is
that many complex configurations now become trivial, where they were
impossible to create before.

.Parent-Child
[options="header"]
[cols="30%,70%"]
|=====
| Keyword | Description
| xref:unlang/call.adoc[call]             | Call one virtual server from another
| xref:unlang/caller.adoc[caller]         | Check if the request is from a parent `call`
| xref:unlang/detach.adoc[detach]         | Detach a child from a parent
| xref:unlang/parallel.adoc[parallel]     | Create multiple parallel child requests
| xref:unlang/subrequest.adoc[subrequest] | Create a child request
|=====

== Module Keywords

The _module_ keywords refer pre-packaged libraries that implement
specific functionality, such as connecting to SQL, LDAP, etc.  The
name used here is not the literal string `module`.  Instead, it is the
name of an instance of a pre-packaged module such as `sql`, or `ldap`, or
`eap`.

The documentation below describes how to reference modules.  That is,
how to use `sql`, etc. in the policies.  Please see the
xref:raddb:mods-available/index.adoc[module configuration] and the
xref:howto:modules/configuring_modules.adoc[configuring modules] howto
pages for information on configuring and using the modules.

.Modules
[options="header"]
[cols="30%,70%"]
|=====
| Keyword | Description
| xref:unlang/module.adoc[<module>]                 | Execute a named module, e.g., `sql`.
| xref:unlang/module_method.adoc[<module>.<method>] | Execute a particular method of a named module, e.g., `pap.authorize`
| xref:unlang/module_builtin.adoc[reject]           | Built-in modules, e.g., `reject`, or `ok`, etc.
|=====

// Copyright (C) 2021 Network RADIUS SAS.  Licenced under CC-by-NC 4.0.
// This documentation was developed by Network RADIUS SAS.
