-
Notifications
You must be signed in to change notification settings - Fork 375
/
notify.go
217 lines (188 loc) · 5.9 KB
/
notify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// Copyright (c) 2021 Terminus, Inc.
//
// This program is free software: you can use, redistribute, and/or modify
// it under the terms of the GNU Affero General Public License, version 3
// or later ("AGPL"), as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package apistructs
import (
"time"
"github.com/erda-project/erda/pkg/i18n"
)
type NotifyChannel string
// CreateNotifyRequest 创建通知请求
type CreateNotifyRequest struct {
Name string `json:"name"`
ScopeType string `json:"scopeType"`
ScopeID string `json:"scopeId"`
Enabled bool `json:"enabled"`
Channels string `json:"channels"`
NotifyGroupID int64 `json:"notifyGroupId"`
NotifyItemIDs []int64 `json:"notifyItemIds"`
WithGroup bool `json:"withGroup"`
GroupTargets []NotifyTarget `json:"groupTargets"`
Label string `json:"label"`
ClusterName string `json:"clusterName"`
NotifySources []NotifySource `json:"notifySources"`
WorkSpace string `json:"workspace"`
Creator string `json:"-"`
OrgID int64 `json:"-"`
}
// CreateNotifyResponse 创建通知响应
type CreateNotifyResponse struct {
Header
Data *NotifyDetail `json:"data"`
}
// UpdateNotifyRequest 更新通知请求
type UpdateNotifyRequest struct {
ID int64 `json:"id"`
Channels string `json:"channels"`
NotifyGroupID int64 `json:"notifyGroupId"`
NotifyItemIDs []int64 `json:"notifyItemIds"`
NotifySources []NotifySource `json:"notifySources"`
WithGroup bool `json:"withGroup"`
GroupTargets []NotifyTarget `json:"groupTargets"`
GroupName string `json:"-"`
OrgID int64 `json:"-"`
}
// UpdateNotifyResponse 更新通知响应
type UpdateNotifyResponse struct {
Header
Data *NotifyDetail `json:"data"`
}
// DeleteNotifyResponse 删除通知响应
type DeleteNotifyResponse struct {
Header
Data *NotifyDetail `json:"data"`
}
// QueryNotifyRequest 查询通知列表请求
type QueryNotifyRequest struct {
PageNo int64 `query:"pageNo"`
PageSize int64 `query:"pageSize"`
GroupDetail bool `query:"groupDetail"`
ScopeType string `query:"scopeType"`
ScopeID string `query:"scopeId"`
Label string `query:"label"`
ClusterName string `query:"clusterName"`
OrgID int64 `json:"-"`
}
// QueryNotifyResponse 查询通知列表响应
type QueryNotifyResponse struct {
Header
Data QueryNotifyData `json:"data"`
}
// QueryNotifyData 通知列表数据结构
type QueryNotifyData struct {
List []*NotifyDetail `json:"list"`
Total int `json:"total"`
}
// Notify 通知
type Notify struct {
Name string `json:"name"`
ScopeType string `json:"scopeType"`
ScopeID string `json:"scopeID"`
Channels string `json:"channels"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// NotifyDetail 通知详情
type NotifyDetail struct {
ID int64 `json:"id"`
Name string `json:"name"`
ScopeType string `json:"scopeType"`
ScopeID string `json:"scopeId"`
Channels string `json:"channels"`
NotifyItems []*NotifyItem `json:"notifyItems"`
NotifyGroup *NotifyGroup `json:"notifyGroup"`
NotifySources []*NotifySource `json:"notifySources"`
Enabled bool `json:"enabled"`
Creator string `json:"creator"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// QuerySourceNotifyResponse 查询通知列表响应
type QuerySourceNotifyResponse struct {
Header
Data []*NotifyDetail `json:"data"`
}
// EnableNotifyResponse 启用通知响应
type EnableNotifyResponse struct {
Header
Data *NotifyDetail `json:"data"`
}
// DisableNotifyResponse 禁用通知响应
type DisableNotifyResponse struct {
Header
Data *NotifyDetail `json:"data"`
}
// FuzzyQueryNotifiesBySourceRequest 模糊查询通知请求
type FuzzyQueryNotifiesBySourceRequest struct {
SourceType string
OrgID int64
Locale *i18n.LocaleResource
Label string
// 查询条件
PageNo int64
PageSize int64
ClusterName string
SourceName string
NotifyName string
ItemName string
Channel string
}
//消息通知对接组件化
type NotifyPageRequest struct {
Scope string `json:"scope"`
ScopeId string `json:"scopeId"`
UserId string `json:"userId"`
OrgId string `json:"orgId"`
}
type NotifyListResponse struct {
Header
Data NotifyListBody `json:"data"`
}
type NotifyListBody struct {
List []DataItem `json:"list"`
}
type DataItem struct {
UserId []string `json:"userId"`
CreatedAt time.Time `json:"createdAt"`
Id int64 `json:"id"`
NotifyID string `json:"notifyId"`
NotifyName string `json:"notifyName"`
Target string `json:"target"`
NotifyTarget []Value `json:"groupInfo"`
Enable bool `json:"enable"`
Items []string `json:"items"`
}
type Value struct {
Type string `json:"type"`
Values []ValueValue `json:"values"`
}
type ValueValue struct {
Receiver string `json:"receiver"`
Secret string `json:"secret"`
}
type SwitchOperation struct {
Meta SwitchOperationData `json:"meta"`
}
type SwitchOperationData struct {
Id uint64 `json:"id"`
Enable bool `json:"enable"`
}
type AllGroupResponse struct {
Header
Data []AllGroups `json:"data"`
}
type AllGroups struct {
Name string `json:"name"`
Value int64 `json:"value"`
Type string `json:"type"`
}