-
Notifications
You must be signed in to change notification settings - Fork 375
/
api_info_dto.go
95 lines (88 loc) · 2.8 KB
/
api_info_dto.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
// Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// 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 dto
import (
"google.golang.org/protobuf/types/known/structpb"
"github.com/erda-project/erda-proto-go/core/hepa/api/pb"
)
const (
RT_AUTO_REGISTER = "register"
RT_AUTO = "auto"
RT_MANUAL = "manual"
NT_IN = "inner"
NT_OUT = "outer"
ST_UP = "asc"
ST_DOWN = "desc"
)
type GetApisDto struct {
From string
Method string
ConsumerId string
RuntimeId string
RuntimeServiceId string
DiceApp string
DiceService string
ApiPath string
RegisterType string
NetType string
NeedAuth int
SortField string
SortType string
OrgId string
ProjectId string
Env string
Size int64
Page int64
}
type ApiInfoDto struct {
ApiId string `json:"apiId"`
// 列表中展示时使用此字段
Path string `json:"path"`
// API编辑时用于展现
DisplayPath string `json:"displayPath"`
// 若有此字段,API编辑时展现前缀
DisplayPathPrefix string `json:"displayPathPrefix,omitempty"`
OuterNetEnable bool `json:"outerNetEnable"`
RegisterType string `json:"registerType"`
NeedAuth bool `json:"needAuth"`
Method string `json:"method,omitempty"`
Description string `json:"description"`
RedirectAddr string `json:"redirectAddr"`
RedirectPath string `json:"redirectPath"`
RedirectType string `json:"redirectType"`
MonitorPath string `json:"monitorPath"`
Group GroupDto `json:"group"`
CreateAt string `json:"createAt"`
Policies []PolicyDto `json:"policies"`
Swagger interface{} `json:"swagger,omitempty"`
}
func MakePolicies(dtos []PolicyDto) (res []*pb.Policy) {
for _, dto := range dtos {
policy := &pb.Policy{
Category: dto.Category,
PolicyId: dto.PolicyId,
PolicyName: dto.PolicyName,
DisplayName: dto.DisplayName,
CreateAt: dto.CreateAt,
}
config := map[string]*structpb.Value{}
for key, value := range dto.Config {
v, _ := structpb.NewValue(value)
config[key] = v
}
policy.Config = config
res = append(res, policy)
}
return
}