Summary
Adds the ability to configure custom (granular) deletion policies for posts and/or files for specific teams and/or channels so that when the daily retention job runs it can selectively delete those resources based on their configurationwhat’s configured.
The retention job (or at least the queries) will have to be modified such that the global setting does not delete posts for any team or channel that is configured via granular policies. The granular policies completely override the global setting. Put another way a granular setting can cause a post to live longer or shorter than the global setting.
API
...
Global Policy (existing API)
GET /api/v4/data_retention/policy
(existing). Retrieves to retrieve the global retention settings:
Code Block |
---|
{ "message_deletion_enabled": false, "file_deletion_enabled": false, "message_retention_cutoff": 0, "file_retention_cutoff": 0 } |
...
Updating the global policy continues to be managed via the config API.
Retention Policies
POST /api/v4/retention_policies
to create a new retention policy with the following payload
Request:
Code Block | ||
---|---|---|
| ||
{ "filedisplay_retention_durationname": 2"foo", "message_retentionpost_duration": 4 } |
Response:
Code Block |
---|
{ "id": "m8zoumpj9pn9zexospoxi5dzoc", "display_name": "foo", "post_duration": 4 } |
PUT /api/v4/retention_policies/:policy_id/patch
to patch a retention policy
Request:
Code Block |
---|
{ "display_name": "foo2", "file_retentionpost_duration": 90365 } |
Response:
Code Block |
---|
{ "id": "m8zoumpj9pn9zexospoxi5dzoc", "message_retentiondisplay_name": "foo2", "post_duration": 365 } |
GET /api/v4/retention_policies/:policy_id
to get a retention policy by id
Code Block |
---|
{
"id": "m8zoumpj9pn9zexospoxi5dzoc",
"display_name": "foo2",
"post_duration": 365,
"teams": ["z7rxbxbfb7yxdydxzi8pestath"],
"channels": ["z7rxbxbfb7yxdydxzi8pestath"]
} |
DELETE /api/v4/retention_policies/:policy_id
to delete a retention policy
As a prerequisite one must delete all of the RetentionPoliciesChannels
and RetentionPoliciesTeams
first, otherwise the request is rejected.
GET /api/v4/retention_policies?page=0&per_page=100
to list all retention policies, including associated teams and channels
Code Block |
---|
{ "policies": [ { "file_retentiondisplay_name": "foo", "post_duration": 2, "message_retention_durationteams": 2["z7rxbxbfb7yxdydxzi8pestath"], "display_namechannels": ["fooz7rxbxbfb7yxdydxzi8pestath"] } ], "total_count": 1 } |
Retention Policies Teams
GET /api/v4/retention_policies_teams
...
language | json |
---|
TBD: How much easier is it to just include the team and channel display names rather than just ids? For example:
Code Block |
---|
{ "policies": [ { "policydisplay_idname": "m8zoumpj9pn9zexospoxi5dzocfoo", "teampost_idduration": "z7rxbxbfb7yxdydxzi8pestath" 2, } ], "total_countteams": 1 } |
POST /api/v4/retention_policies_teams
Code Block |
---|
{ "policy_[{"id": "m8zoumpj9pn9zexospoxi5dzocz7rxbxbfb7yxdydxzi8pestath", "teamdisplay_idname": "z7rxbxbfb7yxdydxzi8pestathMy Team 1" } |
DELETE /api/v4/retention_policies_teams/team_id
Retention Policies Channels
GET /api/v4/retention_policies_channels
Code Block |
---|
{}], "policies": [ "channels": { "policy_[{"id": "m8zoumpj9pn9zexospoxi5dzocz7rxbxbfb7yxdydxzi8pestath", "display_name": "Off "channel_idTopic", "team_display_name": "z7rxbxbfb7yxdydxzi8pestath"My Team 1"}] } ], "total_count": 1 } |
Retention Policies Teams
POST /api/v4/retention_policies_channels/:policy_id/teams
to associate a team to a retention policy
Code Block |
---|
{ "policyteam_id": "m8zoumpj9pn9zexospoxi5dzoc",z7rxbxbfb7yxdydxzi8pestath" } |
DELETE /api/v4/retention_policies/:policy_id/teams/:team_id
to remove a team from a retention policy
Retention Policies Channels
POST /api/v4/retention_policies/:policy_id/channels
to associate a channel to a retention policy
Code Block |
---|
{
"channel_id": "z7rxbxbfb7yxdydxzi8pestath"
} |
DELETE /api/v4/retention_policies/:policy_id/channels/:channel_id
to delete a channel from a retention policy
Database
RetentionPolicies
table
Column name | Description | |
---|---|---|
| varchar, primary key | |
| varchar | |
| int, the duration in days to keep postsFileDuration | int, the duration in days to keep files |
RetentionPoliciesChannelsRetentionPoliciesChannels
table
Column name | Description |
---|---|
| varchar, the RetentionPolicies.Id foreign key |
| varchar, the Channels.Id foreign key |
RetentionPoliciesTeams
table
Column name | Description |
---|---|
| varchar, the RetentionPolicies.Id foreign key |
| varchar, the Teams.Id foreign key |
...