Skip to main content

rules

Creates, updates, deletes, gets or lists a rules resource.

Overview​

Namerules
TypeResource
Idokta.groups.rules

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringID of the group rule
namestringName of the group rule
_embeddedobjectThis object appears with embedded resources related to the group rule if you use the expand query parameter
actionsobjectDefines which users and groups to assign
conditionsobjectDefines group rule conditions
createdstring (date-time)Creation date for group rule
lastUpdatedstring (date-time)Date group rule was last updated
statusstringStatus of group rule. You can't update the status of a rule from INACTIVE to ACTIVE. You must use the activate and deactivate lifecycle operations. (ACTIVE, INACTIVE, INVALID)
typestringType to indicate a group rule operation. Only group_rule is allowed.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_group_ruleselectgroupRuleId, subdomainexpandRetrieves a specific group rule by ID from your org
list_group_rulesselectsubdomainlimit, after, search, expandLists all group rules for your org
create_group_ruleinsertsubdomainCreates a group rule to dynamically add users to the specified group if they match the condition.
> Note: Group rules are created with the status set to 'INACTIVE'.
replace_group_rulereplacegroupRuleId, subdomainReplaces a group rule
> Notes: You can only update rules with a group whose status is set to INACTIVE.
>
> You currently can't update the actions section.
delete_group_ruledeletegroupRuleId, subdomainremoveUsersDeletes a specific group rule by groupRuleId
activate_group_ruleexecgroupRuleId, subdomainActivates a specific group rule by ID from your org
deactivate_group_ruleexecgroupRuleId, subdomainDeactivates a specific group rule by ID from your org

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
groupRuleIdstringThe id of the group rule
subdomainstring(default: my-org)
afterstringSpecifies the pagination cursor for the next page of rules
expandstringIf specified, returns the mapping of group IDs to group names in the _embedded object.
limitinteger (int32)Specifies the number of rule results in a page
removeUsersstringIf set to true, removes users from groups assigned by this rule

SELECT examples​

Retrieves a specific group rule by ID from your org

SELECT
id,
name,
_embedded,
actions,
conditions,
created,
lastUpdated,
status,
type
FROM okta.groups.rules
WHERE groupRuleId = '{{ groupRuleId }}' -- required
AND subdomain = '{{ subdomain }}' -- required
AND expand = '{{ expand }}'
;

INSERT examples​

Creates a group rule to dynamically add users to the specified group if they match the condition.
> Note: Group rules are created with the status set to 'INACTIVE'.

INSERT INTO okta.groups.rules (
actions,
conditions,
name,
type,
subdomain
)
SELECT
'{{ actions }}',
'{{ conditions }}',
'{{ name }}',
'{{ type }}',
'{{ subdomain }}'
RETURNING
id,
name,
_embedded,
actions,
conditions,
created,
lastUpdated,
status,
type
;

REPLACE examples​

Replaces a group rule
> Notes: You can only update rules with a group whose status is set to INACTIVE.
>
> You currently can't update the actions section.

REPLACE okta.groups.rules
SET
actions = '{{ actions }}',
conditions = '{{ conditions }}',
name = '{{ name }}',
status = '{{ status }}',
type = '{{ type }}'
WHERE
groupRuleId = '{{ groupRuleId }}' --required
AND subdomain = '{{ subdomain }}' --required
RETURNING
id,
name,
_embedded,
actions,
conditions,
created,
lastUpdated,
status,
type;

DELETE examples​

Deletes a specific group rule by groupRuleId

DELETE FROM okta.groups.rules
WHERE groupRuleId = '{{ groupRuleId }}' --required
AND subdomain = '{{ subdomain }}' --required
AND removeUsers = '{{ removeUsers }}'
;

Lifecycle Methods​

Activates a specific group rule by ID from your org

EXEC okta.groups.rules.activate_group_rule
@groupRuleId='{{ groupRuleId }}' --required,
@subdomain='{{ subdomain }}' --required
;