/
serviceinstance.go
157 lines (152 loc) · 6.1 KB
/
serviceinstance.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
/*
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package parser
import (
"net/http"
"regexp"
"configcenter/src/ac/meta"
)
var ServiceInstanceAuthConfigs = []AuthConfig{
{
Name: "createServiceInstancePattern",
Description: "创建服务实例",
Pattern: "/api/v3/create/proc/service_instance",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Create,
}, {
Name: "createServiceInstancePreviewPattern",
Description: "创建服务实例预览",
Pattern: "/api/v3/create/proc/service_instance/preview",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Create,
}, {
Name: "findServiceInstancePattern",
Description: "list 服务实例",
Pattern: "/api/v3/findmany/proc/service_instance",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.FindMany,
}, {
Name: "findServiceInstanceWebPattern",
Description: "list 服务实例",
Pattern: "/api/v3/findmany/proc/web/service_instance",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.FindMany,
}, {
Name: "findServiceInstanceDetailsPattern",
Description: "list 服务实例详情",
Pattern: "/api/v3/findmany/proc/service_instance/details",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.FindMany,
}, {
Name: "findServiceInstanceByHostPattern",
Description: "根据主机服务实例",
Pattern: "/api/v3/findmany/proc/service_instance/with_host",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.FindMany,
}, {
Name: "findServiceInstanceByHostWebPattern",
Description: "根据主机服务实例-frontend",
Pattern: "/api/v3/findmany/proc/web/service_instance/with_host",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.FindMany,
}, {
Name: "deleteServiceInstancePattern",
Description: "删除服务实例",
Pattern: "/api/v3/deletemany/proc/service_instance",
HTTPMethod: http.MethodDelete,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Delete,
}, {
Name: "diffServiceInstanceWithTemplatePattern",
Description: "对比服务实例与模板",
Pattern: "/api/v3/find/proc/service_instance/difference",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Find,
}, {
Name: "syncServiceInstanceAccordingToServiceTemplate",
Description: "用服务模板更新服务实例",
Pattern: "/api/v3/update/proc/service_instance/sync",
HTTPMethod: http.MethodPut,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Update,
}, {
Name: "listServiceInstanceWithHostPattern",
Description: "根据主机查询服务实例",
Pattern: "/api/v3/findmany/proc/service_instance/with_host",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.FindMany,
}, {
Name: "aggregationServiceInstanceLabels",
Description: "聚合服务实例labels",
Pattern: "/api/v3/findmany/proc/service_instance/labels/aggregation",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.FindMany,
}, {
Name: "addServiceInstanceLabelsPattern",
Description: "服务实例添加label",
Pattern: "/api/v3/createmany/proc/service_instance/labels",
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Find,
}, {
Name: "removeServiceInstanceLabelsPattern",
Description: "服务实例删除label",
Pattern: "/api/v3/deletemany/proc/service_instance/labels",
HTTPMethod: http.MethodDelete,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Find,
}, {
Name: "deleteProcessInstanceInServiceInstanceRegexp",
Description: "删除进程实例",
Regex: regexp.MustCompile(`/api/v3/delete/proc/service_instance/[0-9]+/process/?$`),
HTTPMethod: http.MethodDelete,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
ResourceAction: meta.Delete,
}, {
Name: "deleteServiceInstancePreviewRegexp",
Description: "删除服务实例预览",
Regex: regexp.MustCompile(`/api/v3/deletemany/proc/service_instance/preview/?$`),
HTTPMethod: http.MethodPost,
BizIDGetter: DefaultBizIDGetter,
ResourceType: meta.ProcessServiceInstance,
// ResourceAction: meta.Find,
ResourceAction: meta.SkipAction,
},
}
func (ps *parseStream) ServiceInstance() *parseStream {
return ParseStreamWithFramework(ps, ServiceInstanceAuthConfigs)
}