pub struct DynamicGroupsResource<'a> { /* private fields */ }Expand description
client.dynamic_groups()
Implementations§
Source§impl<'a> DynamicGroupsResource<'a>
impl<'a> DynamicGroupsResource<'a>
Sourcepub fn delete_ruleset(&self, group_id: impl Display) -> Result<()>
pub fn delete_ruleset(&self, group_id: impl Display) -> Result<()>
Remove automatic membership rules
DELETE /dynamicgroups/{groupId}/ruleset
Clears the stored rule set and resets the stored dynamicGroupStatus to null (reported as none by GET /status). Requires churchcore administer persons. Existing group memberships and the group itself remain in place. No refresh is run. The current implementation returns HTTP 200 with an empty body, including when no rule set was stored.
§Example
client.dynamic_groups().delete_ruleset(42)?;Sourcepub fn get_status(
&self,
group_id: impl Display,
) -> Result<DynamicGroupStatusUpdate>
pub fn get_status( &self, group_id: impl Display, ) -> Result<DynamicGroupStatusUpdate>
Get the dynamic membership refresh mode
GET /dynamicgroups/{groupId}/status
Returns the stored refresh mode of an ordinary group. A missing/null stored status is returned as none. This is configuration, not the progress of an in-flight job or proof that the rules are valid. Requires churchcore administer persons. The response is a flat object without a data wrapper.
§Example
let statu = client.dynamic_groups().get_status(42)?;
println!("{}", statu.dynamic_group_status);Sourcepub fn list(&self) -> Result<Vec<i64>>
pub fn list(&self) -> Result<Vec<i64>>
List groups with automatic membership refresh
GET /dynamicgroups
Returns IDs of groups whose dynamicGroupStatus is active. A dynamic group is an ordinary ChurchTools group whose memberships can be maintained by a set of query rules. Groups in manual, inactive or none status are excluded, even when a rule set is stored. Conversely, active groups without a valid rule set are included and may fail during refresh. Requires churchcore administer persons. Results are not paginated and no ordering is guaranteed. This preliminary API may change.
§Example
for dynamic_group in client.dynamic_groups().list()? {
println!("{:?}", dynamic_group);
}Sourcepub fn list_ruleset(
&self,
group_id: impl Display,
) -> Result<Vec<DynamicGroupRule>>
pub fn list_ruleset( &self, group_id: impl Display, ) -> Result<Vec<DynamicGroupRule>>
Get stored automatic membership rules
GET /dynamicgroups/{groupId}/ruleset
Returns the stored rule array directly, without a data wrapper. Requires churchcore administer persons. Rules can exist independently of the refresh status. If the group has no rules, including after an empty array was saved, this returns 404. Reading rules does not execute or validate their query results.
§Example
for ruleset in client.dynamic_groups().list_ruleset(42)? {
println!("{}", ruleset.description);
}Sourcepub fn refresh(
&self,
group_id: impl Display,
) -> Result<Vec<DynamicGroupRefreshResult>>
pub fn refresh( &self, group_id: impl Display, ) -> Result<Vec<DynamicGroupRefreshResult>>
Refresh memberships of one dynamic group
POST /dynamicgroups/{groupId}/refresh
Synchronously evaluates and applies the stored rules of one group. Requires churchcore administer persons and dynamicGroupStatus active or manual. inactive and none reject manual refreshes. The request has no body and no dry-run option. Rules run against the initial membership snapshot and changes are applied as the system user, with at most 500 actual changes per run. Inspect unprocessed and runsNeeded before assuming convergence. A caught processing failure returns 400 with a message; it does not return a successful statistics object. Membership updates have their own transaction, but later timestamp/event/logging failures can occur after those changes have committed.
§Example
for dynamic_group in client.dynamic_groups().refresh(42)? {
println!("{}", dynamic_group.created);
}Sourcepub fn refresh_all(&self) -> Result<Vec<Value>>
pub fn refresh_all(&self) -> Result<Vec<Value>>
Refresh all active dynamic groups
POST /dynamicgroups/refresh
Synchronously evaluates and applies membership rules for all groups with active dynamicGroupStatus. Requires churchcore administer persons. Manual, inactive and none groups are excluded. Rules run in ascending importance order against the starting membership snapshot; later field updates can override earlier ones, while any deletion action takes precedence. Membership writes run as the system user and can bypass the group size limit. Each group is processed separately; this is not a transaction across groups. At most 500 actual changes are applied per group per run, so inspect unprocessed and runsNeeded and repeat if necessary. A 200 response can contain per-group failures alongside successful statistics. Error entries lack a structured groupId; unexpected Errors can still abort the whole request. This endpoint performs changes immediately and does not support a dry run.
§Example
for dynamic_group in client.dynamic_groups().refresh_all()? {
println!("{:?}", dynamic_group);
}Sourcepub fn update_ruleset(
&self,
group_id: impl Display,
body: &DynamicGroupRuleSetUpdate,
) -> Result<PutDynamicgroupsIdRulesetResponse>
pub fn update_ruleset( &self, group_id: impl Display, body: &DynamicGroupRuleSetUpdate, ) -> Result<PutDynamicgroupsIdRulesetResponse>
Replace automatic membership rules
PUT /dynamicgroups/{groupId}/ruleset
Stores the complete rule array after validation against the dynamic-group JSON schema. Requires churchcore administer persons. Rule syntax validation does not execute queries or validate all referenced roles, fields and runtime process values. Saving rules does not change dynamicGroupStatus or immediately update memberships. Use PUT /status to select the refresh mode and POST /refresh to run it explicitly. An empty array stores no rule set and returns dynamicGroupRuleSet: null, even if the group remains active. The response has a dynamicGroupRuleSet property directly, without a data wrapper.
§Example
let body = models::DynamicGroupRuleSetUpdate {
dynamic_group_rule_set: vec![models::DynamicGroupRule {
description: "Add selected people to the group.".into(),
importance: 10,
person_id_field_name: "person.id".into(),
process: models::DynamicGroupProcessSets {
group_and_query_result: models::DynamicGroupProcessSetsGroupAndQueryResult::default(),
group_only: models::DynamicGroupProcessSetsGroupOnly::default(),
query_result_only: models::DynamicGroupProcessSetsQueryResultOnly::default(),
..Default::default()
},
query: models::DynamicGroupQuery {
method: "ChurchQuery".into(),
params: models::DynamicGroupQueryParams::default(),
..Default::default()
},
shorty: "selected-people".into(),
..Default::default()
}],
..Default::default()
};
let result = client.dynamic_groups().update_ruleset(42, &body)?;
println!("{:?}", result);Sourcepub fn update_status(
&self,
group_id: impl Display,
body: &DynamicGroupStatusUpdate,
) -> Result<DynamicGroupStatusUpdate>
pub fn update_status( &self, group_id: impl Display, body: &DynamicGroupStatusUpdate, ) -> Result<DynamicGroupStatusUpdate>
Set the dynamic membership refresh mode
PUT /dynamicgroups/{groupId}/status
Sets active, manual, inactive or none for an existing group. Requires churchcore administer persons. This does not run a refresh, delete stored rules or alter existing memberships. The mode is not checked against the presence or validity of a rule set, so an active group can subsequently fail to refresh. To remove rules as well, use DELETE /ruleset. The response is a flat object without a data wrapper.
§Example
let body = models::DynamicGroupStatusUpdate {
dynamic_group_status: "manual".into(),
..Default::default()
};
let result = client.dynamic_groups().update_status(42, &body)?;
println!("{}", result.dynamic_group_status);