Mm 30807 granular data retention scaffold (#17464)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
368b642105
Коммит
f36f5c74b1
@@ -53,6 +53,7 @@ type Channel struct {
|
||||
GroupConstrained *bool `json:"group_constrained"`
|
||||
Shared *bool `json:"shared"`
|
||||
TotalMsgCountRoot int64 `json:"total_msg_count_root"`
|
||||
PolicyID *string `json:"policy_id" db:"-"`
|
||||
}
|
||||
|
||||
type ChannelWithTeamData struct {
|
||||
@@ -122,18 +123,21 @@ type ChannelModeratedRolesPatch struct {
|
||||
// PerPage number of results per page, if paginated.
|
||||
//
|
||||
type ChannelSearchOpts struct {
|
||||
NotAssociatedToGroup string
|
||||
ExcludeDefaultChannels bool
|
||||
IncludeDeleted bool
|
||||
Deleted bool
|
||||
ExcludeChannelNames []string
|
||||
TeamIds []string
|
||||
GroupConstrained bool
|
||||
ExcludeGroupConstrained bool
|
||||
Public bool
|
||||
Private bool
|
||||
Page *int
|
||||
PerPage *int
|
||||
NotAssociatedToGroup string
|
||||
ExcludeDefaultChannels bool
|
||||
IncludeDeleted bool
|
||||
Deleted bool
|
||||
ExcludeChannelNames []string
|
||||
TeamIds []string
|
||||
GroupConstrained bool
|
||||
ExcludeGroupConstrained bool
|
||||
PolicyID string
|
||||
ExcludePolicyConstrained bool
|
||||
IncludePolicyID bool
|
||||
Public bool
|
||||
Private bool
|
||||
Page *int
|
||||
PerPage *int
|
||||
}
|
||||
|
||||
type ChannelMemberCountByGroup struct {
|
||||
|
||||
@@ -11,18 +11,19 @@ import (
|
||||
const CHANNEL_SEARCH_DEFAULT_LIMIT = 50
|
||||
|
||||
type ChannelSearch struct {
|
||||
Term string `json:"term"`
|
||||
ExcludeDefaultChannels bool `json:"exclude_default_channels"`
|
||||
NotAssociatedToGroup string `json:"not_associated_to_group"`
|
||||
TeamIds []string `json:"team_ids"`
|
||||
GroupConstrained bool `json:"group_constrained"`
|
||||
ExcludeGroupConstrained bool `json:"exclude_group_constrained"`
|
||||
Public bool `json:"public"`
|
||||
Private bool `json:"private"`
|
||||
IncludeDeleted bool `json:"include_deleted"`
|
||||
Deleted bool `json:"deleted"`
|
||||
Page *int `json:"page,omitempty"`
|
||||
PerPage *int `json:"per_page,omitempty"`
|
||||
Term string `json:"term"`
|
||||
ExcludeDefaultChannels bool `json:"exclude_default_channels"`
|
||||
NotAssociatedToGroup string `json:"not_associated_to_group"`
|
||||
TeamIds []string `json:"team_ids"`
|
||||
GroupConstrained bool `json:"group_constrained"`
|
||||
ExcludeGroupConstrained bool `json:"exclude_group_constrained"`
|
||||
ExcludePolicyConstrained bool `json:"exclude_policy_constrained"`
|
||||
Public bool `json:"public"`
|
||||
Private bool `json:"private"`
|
||||
IncludeDeleted bool `json:"include_deleted"`
|
||||
Deleted bool `json:"deleted"`
|
||||
Page *int `json:"page,omitempty"`
|
||||
PerPage *int `json:"per_page,omitempty"`
|
||||
}
|
||||
|
||||
// ToJson convert a Channel to a json string
|
||||
|
||||
267
model/client4.go
267
model/client4.go
@@ -429,6 +429,10 @@ func (c *Client4) GetDataRetentionRoute() string {
|
||||
return "/data_retention"
|
||||
}
|
||||
|
||||
func (c *Client4) GetDataRetentionPolicyRoute(policyID string) string {
|
||||
return fmt.Sprintf(c.GetDataRetentionRoute()+"/policies/%v", policyID)
|
||||
}
|
||||
|
||||
func (c *Client4) GetElasticsearchRoute() string {
|
||||
return "/elasticsearch"
|
||||
}
|
||||
@@ -577,6 +581,14 @@ func (c *Client4) DoApiPost(url string, data string) (*http.Response, *AppError)
|
||||
return c.DoApiRequest(http.MethodPost, c.ApiUrl+url, data, "")
|
||||
}
|
||||
|
||||
func (c *Client4) doApiDeleteBytes(url string, data []byte) (*http.Response, *AppError) {
|
||||
return c.doApiRequestBytes(http.MethodDelete, c.ApiUrl+url, data, "")
|
||||
}
|
||||
|
||||
func (c *Client4) doApiPatchBytes(url string, data []byte) (*http.Response, *AppError) {
|
||||
return c.doApiRequestBytes(http.MethodPatch, c.ApiUrl+url, data, "")
|
||||
}
|
||||
|
||||
func (c *Client4) doApiPostBytes(url string, data []byte) (*http.Response, *AppError) {
|
||||
return c.doApiRequestBytes(http.MethodPost, c.ApiUrl+url, data, "")
|
||||
}
|
||||
@@ -1853,6 +1865,18 @@ func (c *Client4) GetAllTeamsWithTotalCount(etag string, page int, perPage int)
|
||||
return teamsListWithCount.Teams, teamsListWithCount.TotalCount, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetAllTeamsExcludePolicyConstrained returns all teams which are not part of a data retention policy.
|
||||
// Must be a system administrator.
|
||||
func (c *Client4) GetAllTeamsExcludePolicyConstrained(etag string, page int, perPage int) ([]*Team, *Response) {
|
||||
query := fmt.Sprintf("?page=%v&per_page=%v&exclude_policy_constrained=%v", page, perPage, true)
|
||||
r, err := c.DoApiGet(c.GetTeamsRoute()+query, etag)
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return TeamListFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetTeamByName returns a team based on the provided team name string.
|
||||
func (c *Client4) GetTeamByName(name, etag string) (*Team, *Response) {
|
||||
r, err := c.DoApiGet(c.GetTeamByNameRoute(name), etag)
|
||||
@@ -2347,16 +2371,23 @@ func (c *Client4) RemoveTeamIcon(teamId string) (bool, *Response) {
|
||||
|
||||
// GetAllChannels get all the channels. Must be a system administrator.
|
||||
func (c *Client4) GetAllChannels(page int, perPage int, etag string) (*ChannelListWithTeamData, *Response) {
|
||||
return c.getAllChannels(page, perPage, etag, false)
|
||||
return c.getAllChannels(page, perPage, etag, ChannelSearchOpts{})
|
||||
}
|
||||
|
||||
// GetAllChannelsIncludeDeleted get all the channels. Must be a system administrator.
|
||||
func (c *Client4) GetAllChannelsIncludeDeleted(page int, perPage int, etag string) (*ChannelListWithTeamData, *Response) {
|
||||
return c.getAllChannels(page, perPage, etag, true)
|
||||
return c.getAllChannels(page, perPage, etag, ChannelSearchOpts{IncludeDeleted: true})
|
||||
}
|
||||
|
||||
func (c *Client4) getAllChannels(page int, perPage int, etag string, includeDeleted bool) (*ChannelListWithTeamData, *Response) {
|
||||
query := fmt.Sprintf("?page=%v&per_page=%v&include_deleted=%v", page, perPage, includeDeleted)
|
||||
// GetAllChannelsExcludePolicyConstrained gets all channels which are not part of a data retention policy.
|
||||
// Must be a system administrator.
|
||||
func (c *Client4) GetAllChannelsExcludePolicyConstrained(page, perPage int, etag string) (*ChannelListWithTeamData, *Response) {
|
||||
return c.getAllChannels(page, perPage, etag, ChannelSearchOpts{ExcludePolicyConstrained: true})
|
||||
}
|
||||
|
||||
func (c *Client4) getAllChannels(page int, perPage int, etag string, opts ChannelSearchOpts) (*ChannelListWithTeamData, *Response) {
|
||||
query := fmt.Sprintf("?page=%v&per_page=%v&include_deleted=%v&exclude_policy_constrained=%v",
|
||||
page, perPage, opts.IncludeDeleted, opts.ExcludePolicyConstrained)
|
||||
r, err := c.DoApiGet(c.GetChannelsRoute()+query, etag)
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
@@ -4540,14 +4571,236 @@ func (c *Client4) PurgeBleveIndexes() (bool, *Response) {
|
||||
|
||||
// Data Retention Section
|
||||
|
||||
// GetDataRetentionPolicy will get the current server data retention policy details.
|
||||
func (c *Client4) GetDataRetentionPolicy() (*DataRetentionPolicy, *Response) {
|
||||
// GetDataRetentionPolicy will get the current global data retention policy details.
|
||||
func (c *Client4) GetDataRetentionPolicy() (*GlobalRetentionPolicy, *Response) {
|
||||
r, err := c.DoApiGet(c.GetDataRetentionRoute()+"/policy", "")
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return DataRetentionPolicyFromJson(r.Body), BuildResponse(r)
|
||||
return GlobalRetentionPolicyFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetDataRetentionPolicyByID will get the details for the granular data retention policy with the specified ID.
|
||||
func (c *Client4) GetDataRetentionPolicyByID(policyID string) (*RetentionPolicyWithTeamAndChannelCounts, *Response) {
|
||||
r, appErr := c.DoApiGet(c.GetDataRetentionPolicyRoute(policyID), "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
policy, err := RetentionPolicyWithTeamAndChannelCountsFromJson(r.Body)
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.GetDataRetentionPolicyByID", "model.utils.decode_json.app_error", nil, err.Error(), r.StatusCode))
|
||||
}
|
||||
return policy, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetDataRetentionPoliciesCount will get the total number of granular data retention policies.
|
||||
func (c *Client4) GetDataRetentionPoliciesCount() (int64, *Response) {
|
||||
type CountBody struct {
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
r, appErr := c.DoApiGet(c.GetDataRetentionRoute()+"/policies_count", "")
|
||||
if appErr != nil {
|
||||
return 0, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
var countObj CountBody
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&countObj)
|
||||
if jsonErr != nil {
|
||||
return 0, BuildErrorResponse(r, NewAppError("Client4.GetDataRetentionPoliciesCount", "model.utils.decode_json.app_error", nil, jsonErr.Error(), r.StatusCode))
|
||||
}
|
||||
return countObj.TotalCount, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetDataRetentionPolicies will get the current granular data retention policies' details.
|
||||
func (c *Client4) GetDataRetentionPolicies(page, perPage int) (*RetentionPolicyWithTeamAndChannelCountsList, *Response) {
|
||||
query := fmt.Sprintf("?page=%d&per_page=%d", page, perPage)
|
||||
r, appErr := c.DoApiGet(c.GetDataRetentionRoute()+"/policies"+query, "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
policies, err := RetentionPolicyWithTeamAndChannelCountsListFromJson(r.Body)
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.GetDataRetentionPolicies", "model.utils.decode_json.app_error", nil, err.Error(), r.StatusCode))
|
||||
}
|
||||
return policies, BuildResponse(r)
|
||||
}
|
||||
|
||||
// CreateDataRetentionPolicy will create a new granular data retention policy which will be applied to
|
||||
// the specified teams and channels. The Id field of `policy` must be empty.
|
||||
func (c *Client4) CreateDataRetentionPolicy(policy *RetentionPolicyWithTeamAndChannelIDs) (*RetentionPolicyWithTeamAndChannelCounts, *Response) {
|
||||
r, appErr := c.doApiPostBytes(c.GetDataRetentionRoute()+"/policies", policy.ToJson())
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
newPolicy, err := RetentionPolicyWithTeamAndChannelCountsFromJson(r.Body)
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.CreateDataRetentionPolicy", "model.utils.decode_json.app_error", nil, err.Error(), r.StatusCode))
|
||||
}
|
||||
return newPolicy, BuildResponse(r)
|
||||
}
|
||||
|
||||
// DeleteDataRetentionPolicy will delete the granular data retention policy with the specified ID.
|
||||
func (c *Client4) DeleteDataRetentionPolicy(policyID string) *Response {
|
||||
r, appErr := c.DoApiDelete(c.GetDataRetentionPolicyRoute(policyID))
|
||||
if appErr != nil {
|
||||
return BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r)
|
||||
}
|
||||
|
||||
// PatchDataRetentionPolicy will patch the granular data retention policy with the specified ID.
|
||||
// The Id field of `patch` must be non-empty.
|
||||
func (c *Client4) PatchDataRetentionPolicy(patch *RetentionPolicyWithTeamAndChannelIDs) (*RetentionPolicyWithTeamAndChannelCounts, *Response) {
|
||||
r, appErr := c.doApiPatchBytes(c.GetDataRetentionPolicyRoute(patch.ID), patch.ToJson())
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
policy, err := RetentionPolicyWithTeamAndChannelCountsFromJson(r.Body)
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.PatchDataRetentionPolicy", "model.utils.decode_json.app_error", nil, err.Error(), r.StatusCode))
|
||||
}
|
||||
return policy, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetTeamsForRetentionPolicy will get the teams to which the specified policy is currently applied.
|
||||
func (c *Client4) GetTeamsForRetentionPolicy(policyID string, page, perPage int) (*TeamsWithCount, *Response) {
|
||||
query := fmt.Sprintf("?page=%d&per_page=%d", page, perPage)
|
||||
r, appErr := c.DoApiGet(c.GetDataRetentionPolicyRoute(policyID)+"/teams"+query, "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
var teams *TeamsWithCount
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&teams)
|
||||
if jsonErr != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.GetTeamsForRetentionPolicy", "model.utils.decode_json.app_error", nil, jsonErr.Error(), r.StatusCode))
|
||||
}
|
||||
return teams, BuildResponse(r)
|
||||
}
|
||||
|
||||
// SearchTeamsForRetentionPolicy will search the teams to which the specified policy is currently applied.
|
||||
func (c *Client4) SearchTeamsForRetentionPolicy(policyID string, term string) ([]*Team, *Response) {
|
||||
body, _ := json.Marshal(map[string]interface{}{"term": term})
|
||||
r, appErr := c.doApiPostBytes(c.GetDataRetentionPolicyRoute(policyID)+"/teams/search", body)
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
var teams []*Team
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&teams)
|
||||
if jsonErr != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.SearchTeamsForRetentionPolicy", "model.utils.decode_json.app_error", nil, jsonErr.Error(), r.StatusCode))
|
||||
}
|
||||
return teams, BuildResponse(r)
|
||||
}
|
||||
|
||||
// AddTeamsToRetentionPolicy will add the specified teams to the granular data retention policy
|
||||
// with the specified ID.
|
||||
func (c *Client4) AddTeamsToRetentionPolicy(policyID string, teamIDs []string) *Response {
|
||||
body, _ := json.Marshal(teamIDs)
|
||||
r, appErr := c.doApiPostBytes(c.GetDataRetentionPolicyRoute(policyID)+"/teams", body)
|
||||
if appErr != nil {
|
||||
return BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r)
|
||||
}
|
||||
|
||||
// RemoveTeamsFromRetentionPolicy will remove the specified teams from the granular data retention policy
|
||||
// with the specified ID.
|
||||
func (c *Client4) RemoveTeamsFromRetentionPolicy(policyID string, teamIDs []string) *Response {
|
||||
body, _ := json.Marshal(teamIDs)
|
||||
r, appErr := c.doApiDeleteBytes(c.GetDataRetentionPolicyRoute(policyID)+"/teams", body)
|
||||
if appErr != nil {
|
||||
return BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetChannelsForRetentionPolicy will get the channels to which the specified policy is currently applied.
|
||||
func (c *Client4) GetChannelsForRetentionPolicy(policyID string, page, perPage int) (*ChannelsWithCount, *Response) {
|
||||
query := fmt.Sprintf("?page=%d&per_page=%d", page, perPage)
|
||||
r, appErr := c.DoApiGet(c.GetDataRetentionPolicyRoute(policyID)+"/channels"+query, "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
var channels *ChannelsWithCount
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&channels)
|
||||
if jsonErr != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.GetChannelsForRetentionPolicy", "model.utils.decode_json.app_error", nil, jsonErr.Error(), r.StatusCode))
|
||||
}
|
||||
return channels, BuildResponse(r)
|
||||
}
|
||||
|
||||
// SearchChannelsForRetentionPolicy will search the channels to which the specified policy is currently applied.
|
||||
func (c *Client4) SearchChannelsForRetentionPolicy(policyID string, term string) (ChannelListWithTeamData, *Response) {
|
||||
body, _ := json.Marshal(map[string]interface{}{"term": term})
|
||||
r, appErr := c.doApiPostBytes(c.GetDataRetentionPolicyRoute(policyID)+"/channels/search", body)
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
var channels ChannelListWithTeamData
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&channels)
|
||||
if jsonErr != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.SearchChannelsForRetentionPolicy", "model.utils.decode_json.app_error", nil, jsonErr.Error(), r.StatusCode))
|
||||
}
|
||||
return channels, BuildResponse(r)
|
||||
}
|
||||
|
||||
// AddChannelsToRetentionPolicy will add the specified channels to the granular data retention policy
|
||||
// with the specified ID.
|
||||
func (c *Client4) AddChannelsToRetentionPolicy(policyID string, channelIDs []string) *Response {
|
||||
body, _ := json.Marshal(channelIDs)
|
||||
r, appErr := c.doApiPostBytes(c.GetDataRetentionPolicyRoute(policyID)+"/channels", body)
|
||||
if appErr != nil {
|
||||
return BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r)
|
||||
}
|
||||
|
||||
// RemoveChannelsFromRetentionPolicy will remove the specified channels from the granular data retention policy
|
||||
// with the specified ID.
|
||||
func (c *Client4) RemoveChannelsFromRetentionPolicy(policyID string, channelIDs []string) *Response {
|
||||
body, _ := json.Marshal(channelIDs)
|
||||
r, appErr := c.doApiDeleteBytes(c.GetDataRetentionPolicyRoute(policyID)+"/channels", body)
|
||||
if appErr != nil {
|
||||
return BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetTeamPoliciesForUser will get the data retention policies for the teams to which a user belongs.
|
||||
func (c *Client4) GetTeamPoliciesForUser(userID string, offset, limit int) (*RetentionPolicyForTeamList, *Response) {
|
||||
r, appErr := c.DoApiGet(c.GetUserRoute(userID)+"/data_retention/team_policies", "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
var teams RetentionPolicyForTeamList
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&teams)
|
||||
if jsonErr != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.GetTeamPoliciesForUser", "model.utils.decode_json.app_error", nil, jsonErr.Error(), r.StatusCode))
|
||||
}
|
||||
return &teams, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetChannelPoliciesForUser will get the data retention policies for the channels to which a user belongs.
|
||||
func (c *Client4) GetChannelPoliciesForUser(userID string, offset, limit int) (*RetentionPolicyForChannelList, *Response) {
|
||||
r, appErr := c.DoApiGet(c.GetUserRoute(userID)+"/data_retention/channel_policies", "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
var channels RetentionPolicyForChannelList
|
||||
jsonErr := json.NewDecoder(r.Body).Decode(&channels)
|
||||
if jsonErr != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("Client4.GetChannelPoliciesForUser", "model.utils.decode_json.app_error", nil, jsonErr.Error(), r.StatusCode))
|
||||
}
|
||||
return &channels, BuildResponse(r)
|
||||
}
|
||||
|
||||
// Commands Section
|
||||
|
||||
@@ -8,20 +8,119 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type DataRetentionPolicy struct {
|
||||
type GlobalRetentionPolicy struct {
|
||||
MessageDeletionEnabled bool `json:"message_deletion_enabled"`
|
||||
FileDeletionEnabled bool `json:"file_deletion_enabled"`
|
||||
MessageRetentionCutoff int64 `json:"message_retention_cutoff"`
|
||||
FileRetentionCutoff int64 `json:"file_retention_cutoff"`
|
||||
}
|
||||
|
||||
func (drp *DataRetentionPolicy) ToJson() string {
|
||||
b, _ := json.Marshal(drp)
|
||||
return string(b)
|
||||
type RetentionPolicy struct {
|
||||
ID string `db:"Id" json:"id"`
|
||||
DisplayName string `json:"display_name"`
|
||||
PostDuration *int64 `json:"post_duration"`
|
||||
}
|
||||
|
||||
func DataRetentionPolicyFromJson(data io.Reader) *DataRetentionPolicy {
|
||||
var drp *DataRetentionPolicy
|
||||
json.NewDecoder(data).Decode(&drp)
|
||||
return drp
|
||||
type RetentionPolicyWithTeamAndChannelIDs struct {
|
||||
RetentionPolicy
|
||||
TeamIDs []string `json:"team_ids"`
|
||||
ChannelIDs []string `json:"channel_ids"`
|
||||
}
|
||||
|
||||
type RetentionPolicyWithTeamAndChannelCounts struct {
|
||||
RetentionPolicy
|
||||
ChannelCount int64 `json:"channel_count"`
|
||||
TeamCount int64 `json:"team_count"`
|
||||
}
|
||||
|
||||
type RetentionPolicyChannel struct {
|
||||
PolicyID string `db:"PolicyId"`
|
||||
ChannelID string `db:"ChannelId"`
|
||||
}
|
||||
|
||||
type RetentionPolicyTeam struct {
|
||||
PolicyID string `db:"PolicyId"`
|
||||
TeamID string `db:"TeamId"`
|
||||
}
|
||||
|
||||
type RetentionPolicyWithTeamAndChannelCountsList struct {
|
||||
Policies []*RetentionPolicyWithTeamAndChannelCounts `json:"policies"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type RetentionPolicyForTeam struct {
|
||||
TeamID string `db:"Id" json:"team_id"`
|
||||
PostDuration int64 `json:"post_duration"`
|
||||
}
|
||||
|
||||
type RetentionPolicyForTeamList struct {
|
||||
Policies []*RetentionPolicyForTeam `json:"policies"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
type RetentionPolicyForChannel struct {
|
||||
ChannelID string `db:"Id" json:"channel_id"`
|
||||
PostDuration int64 `json:"post_duration"`
|
||||
}
|
||||
|
||||
type RetentionPolicyForChannelList struct {
|
||||
Policies []*RetentionPolicyForChannel `json:"policies"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
func (rp *GlobalRetentionPolicy) ToJson() []byte {
|
||||
b, _ := json.Marshal(rp)
|
||||
return b
|
||||
}
|
||||
|
||||
func GlobalRetentionPolicyFromJson(data io.Reader) *GlobalRetentionPolicy {
|
||||
var grp *GlobalRetentionPolicy
|
||||
json.NewDecoder(data).Decode(&grp)
|
||||
return grp
|
||||
}
|
||||
|
||||
func RetentionPolicyWithTeamAndChannelCountsFromJson(data io.Reader) (*RetentionPolicyWithTeamAndChannelCounts, error) {
|
||||
var rp RetentionPolicyWithTeamAndChannelCounts
|
||||
err := json.NewDecoder(data).Decode(&rp)
|
||||
return &rp, err
|
||||
}
|
||||
|
||||
func (rp *RetentionPolicyWithTeamAndChannelCounts) ToJson() []byte {
|
||||
b, _ := json.Marshal(rp)
|
||||
return b
|
||||
}
|
||||
|
||||
func RetentionPolicyWithTeamAndChannelCountsListFromJson(data io.Reader) (*RetentionPolicyWithTeamAndChannelCountsList, error) {
|
||||
var rpList *RetentionPolicyWithTeamAndChannelCountsList
|
||||
err := json.NewDecoder(data).Decode(&rpList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rpList, nil
|
||||
}
|
||||
|
||||
func (rpList *RetentionPolicyWithTeamAndChannelCountsList) ToJson() []byte {
|
||||
b, _ := json.Marshal(rpList)
|
||||
return b
|
||||
}
|
||||
|
||||
func RetentionPolicyWithTeamAndChannelIdsFromJson(data io.Reader) (*RetentionPolicyWithTeamAndChannelIDs, error) {
|
||||
var rp *RetentionPolicyWithTeamAndChannelIDs
|
||||
err := json.NewDecoder(data).Decode(&rp)
|
||||
return rp, err
|
||||
}
|
||||
|
||||
func (rp *RetentionPolicyWithTeamAndChannelIDs) ToJson() []byte {
|
||||
b, _ := json.Marshal(rp)
|
||||
return b
|
||||
}
|
||||
|
||||
func (lst *RetentionPolicyForTeamList) ToJson() []byte {
|
||||
b, _ := json.Marshal(lst)
|
||||
return b
|
||||
}
|
||||
|
||||
func (lst *RetentionPolicyForChannelList) ToJson() []byte {
|
||||
b, _ := json.Marshal(lst)
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ type Team struct {
|
||||
LastTeamIconUpdate int64 `json:"last_team_icon_update,omitempty"`
|
||||
SchemeId *string `json:"scheme_id"`
|
||||
GroupConstrained *bool `json:"group_constrained"`
|
||||
PolicyID *string `json:"policy_id" db:"-"`
|
||||
}
|
||||
|
||||
type TeamPatch struct {
|
||||
|
||||
@@ -9,12 +9,17 @@ import (
|
||||
)
|
||||
|
||||
type TeamSearch struct {
|
||||
Term string `json:"term"`
|
||||
Page *int `json:"page,omitempty"`
|
||||
PerPage *int `json:"per_page,omitempty"`
|
||||
AllowOpenInvite *bool `json:"allow_open_invite,omitempty"`
|
||||
GroupConstrained *bool `json:"group_constrained,omitempty"`
|
||||
IncludeGroupConstrained *bool `json:"include_group_constrained,omitempty"`
|
||||
Term string `json:"term"`
|
||||
Page *int `json:"page,omitempty"`
|
||||
PerPage *int `json:"per_page,omitempty"`
|
||||
AllowOpenInvite *bool `json:"allow_open_invite,omitempty"`
|
||||
GroupConstrained *bool `json:"group_constrained,omitempty"`
|
||||
IncludeGroupConstrained *bool `json:"include_group_constrained,omitempty"`
|
||||
PolicyID *string `json:"policy_id,omitempty"`
|
||||
ExcludePolicyConstrained *bool `json:"exclude_policy_constrained,omitempty"`
|
||||
IncludePolicyID *bool `json:"-"`
|
||||
IncludeDeleted *bool `json:"-"`
|
||||
TeamType *string `json:"-"`
|
||||
}
|
||||
|
||||
func (t *TeamSearch) IsPaginated() bool {
|
||||
|
||||
@@ -330,6 +330,12 @@ func StringFromJson(data io.Reader) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// ToJson serializes an arbitrary data type to JSON, discarding the error.
|
||||
func ToJson(v interface{}) []byte {
|
||||
b, _ := json.Marshal(v)
|
||||
return b
|
||||
}
|
||||
|
||||
func GetServerIpAddress(iface string) string {
|
||||
var addrs []net.Addr
|
||||
if iface == "" {
|
||||
|
||||
Ссылка в новой задаче
Block a user