-
Notifications
You must be signed in to change notification settings - Fork 375
/
api_asset_req_resp.go
957 lines (800 loc) · 27.4 KB
/
api_asset_req_resp.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
// 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 (
"encoding/json"
"net/http"
"net/url"
"time"
"github.com/getkin/kin-openapi/openapi3"
)
const (
CreateAPIAssetSourceAction = "action"
CreateAPIAssetSourceDesignCenter = "design_center"
)
type APIAssetCreateRequest struct {
AssetID string `json:"assetID"`
AssetName string `json:"assetName"`
Desc string `json:"desc"`
Logo string `json:"logo"`
Source string `json:"source"`
Versions []APIAssetVersionCreateRequest `json:"versions"`
OrgID uint64 `json:"orgID"`
ProjectID uint64 `json:"projectID,omitempty"`
AppID uint64 `json:"appID,omitempty"`
IdentityInfo
}
type APIAssetVersionCreateRequest struct {
OrgID uint64 `json:"orgID"`
APIAssetID string `json:"apiAssetID"`
Major uint64 `json:"major"` // 可以不指定,默认版本为 1.0.0,之后依次增加小版本
Minor uint64 `json:"minor"`
Patch uint64 `json:"patch"`
Desc string `json:"desc"`
SpecProtocol APISpecProtocol `json:"specProtocol"`
SpecDiceFileUUID string `json:"specDiceFileUUID,omitempty"` // specDiceFileUUID -> spec
Spec string `json:"spec"`
Inode string `json:"inode,omitempty"`
Instances []APIAssetVersionInstanceCreateRequest `json:"instances,omitempty"`
IdentityInfo
Source string `json:"source"` // local, action, design_center
AppID uint64 `json:"appID"` // 如果 source == design_center, appID 为设计中心文档所在应用
Branch string `json:"branch"` // 如果 source == design_center, branch 为设计中心文档所在分支
ServiceName string `json:"serviceName"` // 如果 source = design_center, serviceName 为文档表述的服务的名称
}
type GetAPIAssetReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *GetAPIAssetURIPrams
}
type GetAPIAssetURIPrams struct {
AssetID string `json:"assetID"`
}
type GetAPIAssetResponse struct {
Asset *APIAssetsModel `json:"asset"`
Permission map[string]bool `json:"permission"`
}
type APIAssetGetResponse struct {
Header
Data *APIAssetsModel `json:"data"`
}
type PagingAPIAssetsReq struct {
OrgID uint64
Identity *IdentityInfo
QueryParams *PagingAPIAssetsQueryParams
}
type PagingAPIAssetsQueryParams struct {
Paging bool `json:"paging" schema:"paging"` // 是否分页查询
PageNo int `json:"pageNo" schema:"pageNo"` // 页码
PageSize int `json:"pageSize" schema:"pageSize"` // 每页数量
Keyword string `json:"keyword" schema:"keyword"` // 搜索关键字
Scope string `json:"scope" schema:"scope"` // 查询范围: mine, all (如果不是 mine, 就当做 all 处理)
HasProject bool `json:"hasProject" schema:"hasProject"` // 是否关联了项目
LatestVersion bool `json:"latestVersion" schema:"latestVersion"` // 返回结果中是否需要带上最新版本信息
LatestSpec bool `json:"latestSpec" schema:"latestSpec"` // 返回结果中是否需要带上最新的 Spec 文本
Instantiation bool `json:"instantiation"` // 返回结果是否要求已经实例化了
}
type APIAssetPagingResponse struct {
Total uint64 `json:"total"`
List []*PagingAssetRspObj `json:"list"`
UserIDs []string `json:"userIDs"`
}
type PagingAssetRspObj struct {
Asset *APIAssetsModel `json:"asset"`
LatestVersion *APIAssetVersionsModel `json:"latestVersion,omitempty"`
LatestSpec *APIAssetVersionSpecsModel `json:"latestSpec,omitempty"`
Permission map[string]bool `json:"permission"`
}
type CreateAPIAssetVersionBody struct {
AssetID string `json:"assetID"`
Major uint64 `json:"major"`
Minor uint64 `json:"minor"`
Patch uint64 `json:"patch"`
SpecProtocol string `json:"specProtocol"`
SpecDiceFileUUID string `json:"specDiceFileUUID"`
}
type PagingAPIAssetVersionsReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *PagingAPIAssetVersionURIParams
QueryParams *PagingAPIAssetVersionQueryParams
}
type PagingAPIAssetVersionURIParams struct {
AssetID string
}
type PagingAPIAssetVersionQueryParams struct {
Paging bool `json:"paging" schema:"paging"`
PageNo uint64 `json:"pageNo" schema:"pageNo"`
PageSize uint64 `json:"pageSize" schema:"pageSize"`
Major *int `json:"major" schema:"major"`
Minor *int `json:"minor" schema:"minor"`
Spec bool `json:"spec" schema:"spec"`
}
type PagingAPIAssetVersionResponse struct {
OrgID uint64 `json:"orgID"`
AssetID string `json:"assetID"`
Total uint64 `json:"total"`
List []*PagingAPIAssetVersionRspObj `json:"list"`
}
type PagingAPIAssetVersionRspObj struct {
Version *APIAssetVersionsModel `json:"version"`
Spec *APIAssetVersionSpecsModel `json:"spec"`
Permission map[string]bool `json:"permission"`
}
type GetAPIAssetVersionReq struct {
OrgID uint64 `json:"orgID"`
Identity *IdentityInfo
URIParams *AssetVersionDetailURI
QueryParams *GetAPIAssetVersionQueryParams
}
type AssetVersionDetailURI struct {
AssetID string `json:"assetID"`
VersionID interface{} `json:"versionID"`
}
type GetAPIAssetVersionQueryParams struct {
Asset bool `json:"asset" schema:"asset"`
Spec bool `json:"spec" schema:"spec"`
}
type GetAssetVersionRsp struct {
Asset *APIAssetsModel `json:"asset"`
Version *APIAssetVersionsModel `json:"version"`
Spec *APIAssetVersionSpecsModel `json:"spec"`
HasInstantiation bool `json:"hasInstantiation"`
HasAccess bool `json:"hasAccess"`
Access *APIAccessesModel `json:"access,omitempty"`
}
type APIAssetVersionInstanceCreateRequest struct {
Name string `json:"name"`
// 实例类型,必填
InstanceType APIInstanceType `json:"instanceType"`
// 关联一个 Runtime Service
RuntimeID uint64 `json:"runtimeID,omitempty"`
ServiceName string `json:"serviceName,omitempty"`
// 关联 API Gateway EndpointID
EndpointID string `json:"endpointID,omitempty"`
// URL 为用户直接输入
URL string `json:"url,omitempty"`
AssetID string `json:"-"`
VersionID uint64 `json:"-"`
IdentityInfo
}
type UpdateAPIAssetReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *UpdateAPIAssetURIParams
Keys map[string]interface{} // assetName, desc, logo, public, projectID, appID
}
type UpdateAPIAssetURIParams struct {
AssetID string `json:"assetID"`
}
type UpdateAPIAssetBody struct {
Name *string `json:"assetName"`
Desc *string `json:"desc"`
Logo *string `json:"logo"`
ProjectID *uint64 `json:"projectID,omitempty"`
AppID *uint64 `json:"appID,omitempty"`
Public *bool `json:"public"`
}
type APIAssetDeleteRequest struct {
OrgID uint64
AssetID string
IdentityInfo
}
// 查询版本树的请求结构
type ListSwaggerVersionsReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListSwaggerVersionsURIParams
QueryParams *ListSwaggerVersionsQueryParams
}
type ListSwaggerVersionsURIParams struct {
AssetID string
}
type ListSwaggerVersionsQueryParams struct {
Patch bool `json:"patch" schema:"patch"` // 返回结果是否到 patch 粒度
Instantiation bool `json:"instantiation" schema:"instantiation"` // 返回的结果是否筛选有 instantiation 的记录
Access bool `json:"access" schema:"access"` // 返回的结果是否筛选有 access 的记录
}
// 查询版本树的响应体 Data 结构
type ListSwaggerVersionRsp struct {
Total uint64 `json:"total"`
List []*ListSwaggerVersionRspObj `json:"list"`
}
type ListSwaggerVersionRspObj struct {
SwaggerVersion string `json:"swaggerVersion"`
Major uint64 `json:"-"`
Versions []map[string]interface{} `json:"versions"`
}
// 创建一条实例关联记录
type CreateInstantiationReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *CreateInstantiationURIParams
Body *CreateInstantiationBody
}
type CreateInstantiationURIParams struct {
AssetID string
SwaggerVersion string
Minor uint64
}
type CreateInstantiationBody struct {
Type string `json:"type"` // "dice", "external"
URL string `json:"url"`
ProjectID uint64 `json:"projectID,omitempty"`
AppID uint64 `json:"appID,omitempty"`
RuntimeID uint64 `json:"runtimeID"` // 20201013 新增
ServiceName string `json:"serviceName"` // 20201013 新增
Workspace string `json:"workspace"` // 20201013 新增
}
// 查询实例化记录列表的参数
type GetInstantiationsReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *GetInstantiationsURIParams
}
type GetInstantiationRsp struct {
InstantiationModel
ProjectName string `json:"projectName"`
RuntimeName string `json:"runtimeName"`
}
type GetInstantiationsURIParams struct {
AssetID string
SwaggerVersion string
Minor uint64
}
// 更新实例化记录列表的参数
type UpdateInstantiationReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *UpdateInstantiationURIParams
Body *UpdateInstantiationBody
}
type UpdateInstantiationURIParams struct {
AssetID string
SwaggerVersion string
Minor uint64
InstantiationID uint64
}
type UpdateInstantiationBody struct {
Type string `json:"type"`
URL string `json:"url"`
ProjectID uint64 `json:"projectID,omitempty"`
AppID uint64 `json:"appID,omitempty"`
RuntimeID uint64 `json:"runtimeID"`
ServiceName string `json:"serviceName"`
Workspace string `json:"workspace"`
}
type DownloadSpecTextReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *DownloadSpecTextURIParams
QueryParams *DownloadSpecTextQueryParams
}
type DownloadSpecTextURIParams struct {
AssetID string
VersionID uint64
}
type DownloadSpecTextQueryParams struct {
SpecProtocol string
}
type CreateClientReq struct {
OrgID uint64
Identity *IdentityInfo
Body *CreateClientBody
}
type CreateClientBody struct {
Name string `json:"name"`
DisplayName string `json:"displayName"`
Desc string `json:"desc"`
}
type ListMyClientsReq struct {
OrgID uint64
Identity *IdentityInfo
QueryParams *ListMyClientsQueryParams
}
type ListMyClientsQueryParams struct {
Paging bool `json:"paging" schema:"paging"`
PageNo uint64 `json:"pageNo" schema:"pageNo"`
PageSize uint64 `json:"pageSize" schema:"pageSize"`
Keyword string `json:"keyword" schema:"keyword"`
}
type ListMyClientsRsp struct {
Total uint64 `json:"total"`
List []*ClientObj `json:"list"`
}
type ClientObj struct {
Client *ClientModel `json:"client"`
SK *SK `json:"sk"`
}
type SK struct {
ClientID string `json:"clientID"`
ClientSecret string `json:"clientSecret"`
}
// 查询客户端详情的参数结构
type GetClientReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *GetClientURIParams
}
type GetClientURIParams struct {
ClientID string `json:"clientID" schema:"clientID"`
}
// 创建合约(申请使用)的参数结构
type CreateContractReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *CreateContractURIParams
Body *CreateContractBody
}
type CreateContractURIParams struct {
ClientID string
}
type CreateContractBody struct {
AssetID string `json:"assetID"`
SwaggerVersion string `json:"swaggerVersion"`
SLAID *uint64 `json:"slaID"`
}
// 查询合约列表的参数结构
type ListContractsReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListContractsURIParams
QueryParams *ListContractQueryParams
}
type ListContractsURIParams struct {
ClientID string
}
type ListContractQueryParams struct {
Paging bool `json:"paging" schema:"paging"`
PageNo uint64 `json:"pageNo" schema:"pageNo"`
PageSize uint64 `json:"pageSize" schema:"pageSize"`
Status []ContractStatus `json:"status"`
}
// 查询合约列表响应结构
type ListContractsRsp struct {
Total uint64 `json:"total"`
List []*ContractModelAdvance `json:"list"`
}
// 查询合约详情的参数结构
type GetContractReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *GetContractURIParams
}
type GetContractURIParams struct {
ClientID string
ContractID string
}
// 查询合约操作记录参数结构
type ListContractRecordsReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListContractRecordsURIParams
}
type ListContractRecordsURIParams struct {
ClientID string
ContractID string
}
// 查询合约操作记录响应结构
type ListContractRecordsRsp struct {
Total uint64 `json:"total"`
List []*ContractRecordModel `json:"list"`
}
// 创建一个访问管理条目的参数结构
type CreateAccessReq struct {
OrgID uint64
Identity *IdentityInfo
Body *CreateAccessBody
}
type CreateAccessBody struct {
AssetID string `json:"assetID"`
OrgID uint64 `json:"orgID"`
Major uint64 `json:"major"`
Minor uint64 `json:"minor"`
ProjectID uint64 `json:"projectID,omitempty"`
AppID uint64 `json:"appID,omitempty"`
Workspace string `json:"workspace"`
Authentication Authentication `json:"authentication"`
Authorization Authorization `json:"authorization"`
BindDomain []string `json:"bindDomain"`
AddonInstanceID string `json:"addonInstanceID"`
}
type UpdateAccessReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *GetAccessURIParams
Body *UpdateAccessBody
}
type UpdateAccessBody struct {
Minor uint64 `json:"minor"`
Workspace string `json:"workspace"`
Authentication Authentication `json:"authentication"`
Authorization Authorization `json:"authorization"`
BindDomain []string `json:"bindDomain"`
AddonInstanceID string `json:"addonInstanceID"`
}
// 查询管理条目列表参数结构
type ListAccessReq struct {
OrgID uint64
Identity *IdentityInfo
QueryParams *ListAccessQueryParams
}
type ListAccessQueryParams struct {
Paging bool `json:"paging" schema:"paging"`
PageNo uint64 `json:"pageNo" schema:"pageNo"`
PageSize uint64 `json:"pageSize" schema:"pageSize"`
Keyword string `json:"keyword" schema:"keyword"`
}
// 查询管理条目的响应
type ListAccessRsp struct {
OrgID uint64 `json:"orgID"`
List []*ListAccessObj `json:"list"`
Total uint64 `json:"total"`
}
type ListAccessObj struct {
AssetID string `json:"assetID"`
AssetName string `json:"assetName"`
TotalChildren uint64 `json:"totalChildren"`
UpdatedAt time.Time `json:"-"`
Children []*ListAccessObjChild `json:"children"`
}
type ListAccessObjChild struct {
ID uint64 `json:"id"`
SwaggerVersion string `json:"swaggerVersion"`
AppCount uint64 `json:"appCount"`
ProjectID uint64 `json:"-"`
CreatorID string `json:"-"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Permission map[string]bool `json:"permission"`
}
// 查询 SwaggerVersion 下的客户端列表参数结构
type ListSwaggerVersionClientsReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListSwaggerVersionClientURIParams
QueryParams *ListSwaggerVersionClientQueryParams
}
type ListSwaggerVersionClientURIParams struct {
AssetID string
SwaggerVersion string
}
type ListSwaggerVersionClientQueryParams struct {
Paging bool `json:"paging" schema:"paging"`
PageNo uint64 `json:"pageNo" schema:"pageNo"`
PageSize uint64 `json:"pageSize" schema:"pageSize"`
Status string `json:"status" schema:"status"`
}
type ListSwaggerVersionClientRsp struct {
Total uint64 `json:"total"`
List []*ListSwaggerVersionClientOjb `json:"list"`
}
type ListSwaggerVersionClientOjb struct {
Client *ClientModel `json:"client"`
Contract *ContractModelAdvance `json:"contract"`
Permission map[string]bool `json:"permission"`
}
type ContractModelAdvance struct {
ContractModel
ClientName string `json:"clientName,omitempty"`
ClientDisplayName string `json:"clientDisplayName,omitempty"`
CurSLAName string `json:"curSLAName,omitempty"`
RequestSLAName string `json:"requestSLAName,omitempty"`
EndpointName string `json:"endpointName,omitempty"`
ProjectID uint64 `json:"projectID,omitempty"`
Workspace string `json:"workspace,omitempty"`
}
type ListAPIGatewaysReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListAPIGatewaysURIParams
}
type ListProjectAPIGatewaysReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListProjectAPIGatewaysURIParams
}
type ListProjectAPIGatewaysURIParams struct {
ProjectID string
}
type ListAPIGatewaysURIParams struct {
AssetID string
}
type DeleteClientReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *DeleteClientURIParams
}
type DeleteClientURIParams struct {
ClientID uint64 `json:"clientID" schema:"clientID"`
}
type GetAccessReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *GetAccessURIParams
}
type GetAccessURIParams struct {
AccessID string
}
type GetAccessRspTenantGroup struct {
TenantGroupID string
}
type UpdateClientReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *UpdateClientURIParams
QueryParams *UpdateClientQueryParams
Body *UpdateClientBody
}
type UpdateClientURIParams struct {
ClientID uint64
}
type UpdateClientQueryParams struct {
ResetClientSecret bool `json:"resetClientSecret" schema:"resetClientSecret"`
}
type UpdateClientBody struct {
DisplayName string `json:"displayName"`
Desc string `json:"desc"`
}
type GetAccessRspAccess struct {
ID uint64 `json:"id"`
AssetID string `json:"assetID"`
AssetName string `json:"assetName"`
OrgID uint64 `json:"orgID"`
SwaggerVersion string `json:"swaggerVersion"`
Major uint64 `json:"major"`
Minor uint64 `json:"minor"`
ProjectID uint64 `json:"projectID"`
ProjectName string `json:"projectName"`
Workspace string `json:"workspace"`
EndpointID string `json:"endpointID"`
Authentication Authentication `json:"authentication"`
Authorization Authorization `json:"authorization"`
AddonInstanceID string `json:"addonInstanceID"`
BindDomain []string `json:"bindDomain"`
CreatorID string `json:"creatorID"`
UpdaterID string `json:"updaterID"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
TenantGroupID string `json:"tenantGroupID"`
EndpointName string `json:"endpointName"`
}
type UpdateContractReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *UpdateContractURIParams
Body *UpdateContractBody
}
type UpdateContractURIParams struct {
ClientID string
ContractID string
}
type UpdateContractBody struct {
Status *ContractStatus `json:"status"`
CurSLAID *uint64 `json:"curSLAID"`
RequestSLAID *uint64 `json:"requestSLAID"`
}
type AttempTestURIParams struct {
AssetID string
SwaggerVersion string
}
type ListRuntimeServicesResp struct {
RuntimeID uint64 `json:"runtimeID"`
RuntimeName string `json:"runtimeName"`
Workspace string `json:"workspace"`
ProjectID uint64 `json:"projectID,omitempty"`
AppID uint64 `json:"appID,omitempty"`
ServiceName string `json:"serviceName"`
ServiceAddr []string `json:"serviceAddr"`
ServiceExpose []string `json:"serviceExpose"`
}
type ListSLAsReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListSLAsURIs
QueryParams *ListSLAsQueries
}
type ListSLAsURIs struct {
AssetID string
SwaggerVersion string
}
type ListSLAsQueries struct {
ClientID uint64 `json:"clientID" schema:"clientID"` // 库表主键, 不是 客户端 ID 字符串
}
type ListSLAsRsp struct {
Total uint64 `json:"total"`
List []*ListSLAsRspObj `json:"list"`
}
type ListSLAsRspObj struct {
SLAModel
Limits []*SLALimitModel `json:"limits"`
AssetID string `json:"assetID"`
AssetName string `json:"assetName"`
SwaggerVersion string `json:"swaggerVersion"`
UserTo SLAUsedInContract `json:"userTo,omitempty"` // current, requesting
Default bool `json:"default"`
ClientCount uint64 `json:"clientCount"`
}
type CreateSLAReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *ListSLAsURIs
Body *CreateSLABody
}
type CreateSLABody struct {
Name string `json:"name"`
Desc string `json:"desc"`
Approval Authorization `json:"approval"`
Default bool `json:"default"`
Limits []*CreateUpdateSLALimitObj `json:"limits"`
}
type CreateUpdateSLALimitObj struct {
Limit uint64 `json:"limit"`
Unit DurationUnit `json:"unit"`
}
type GetSLAReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *SLADetailURI
}
type SLADetailURI struct {
AssetID string
SwaggerVersion string
SLAID uint64
}
type GetSLARsp ListSLAsRspObj
type DeleteSLAReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *SLADetailURI
}
type UpdateSLAReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *SLADetailURI
Body *UpdateSLABody
}
type UpdateSLABody struct {
Name *string `json:"name"`
Desc *string `json:"desc"`
Approval *Authorization `json:"approval"`
Default *bool `json:"default"`
Limits []*CreateUpdateSLALimitObj `json:"limits"`
}
type UpdateAssetVersionReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams *AssetVersionDetailURI
Body *UpdateAssetVersionBody
}
type UpdateAssetVersionBody struct {
Deprecated bool `json:"deprecated"`
}
type APITestReq struct {
ClientID string `json:"clientID"`
ClientSecret string `json:"clientSecret"`
APIs []*ProxyAPIs `json:"apis"`
}
type ProxyAPIs struct {
ID string `json:"id"`
Name string `json:"name"`
Schema string `json:"schema"`
URL string `json:"url"`
Method string `json:"method"`
Header []APIHeader `json:"header"`
Params []APIParam `json:"params"`
Body ProxyAPIBody `json:"body"`
OutParams []APIOutParam `json:"outParams"`
Asserts [][]APIAssert `json:"asserts"`
}
type ProxyAPIBody struct {
Type string `json:"type"`
Content json.RawMessage `json:"content"`
}
type ProxyContent struct {
Key string
Value string
}
type ProxyAPIRequestInfo struct {
Host string `json:"host"`
URL string `json:"url"`
Method string `json:"method"`
Headers http.Header `json:"headers"`
Params url.Values `json:"params"`
Body ProxyAPIBody `json:"body"`
}
type SearchOperationsReq struct {
OrgID uint64
Identity *IdentityInfo
QueryParams SearchOperationQueryParameters
}
type SearchOperationQueryParameters struct {
Keyword string
}
type GetOperationReq struct {
OrgID uint64
Identity *IdentityInfo
URIParams GetOperationURIParameters
}
type GetOperationURIParameters struct {
ID uint64
}
type GetOperationResp struct {
ID uint64 `json:"id"`
AssetID string `json:"assetID"`
AssetName string `json:"assetName"`
Version string `json:"version"`
Path string `json:"path"`
Method string `json:"method"`
OperationID string `json:"operationID"`
Operation json.RawMessage `json:"operation"`
}
// APIOperationSummary 接口摘要信息, 作为搜索结果列表的 item
// 其中 AssetID + Version + Path + Method 能确定唯一的一篇文档
type APIOperationSummary struct {
ID uint64 `json:"id"` // 接口 primary key, 全局唯一
AssetID string `json:"assetID"` // required 集市 id
AssetName string `json:"assetName"` // required 集市名(文档名)
Version string `json:"version"` // required 版本
Path string `json:"path"` // required 路径
Method string `json:"method"` // required http 方法
OperationID string `json:"operationID"` // 接口名称
}
type APIOperation struct {
ID uint64 `json:"id"` // 接口 primary key, 全局唯一
AssetID string `json:"assetID" yaml:"assetID"` // required
AssetName string `json:"assetName" yaml:"assetName"` // 集市名(文档名)
Version string `json:"version" yaml:"version"` // required
Path string `json:"path" yaml:"path"` // required
Method string `json:"method" yaml:"method"` // required
// Optional description. Should use CommonMark syntax.
Description string `json:"description" yaml:"description"`
// Optional operation ID.
OperationID string `json:"operationId" yaml:"operationId"`
// Optional Headers
Headers []*Parameter `json:"headers"`
// Optional parameters.
Parameters []*Parameter `json:"parameters" yaml:"parameters"`
// Optional body parameter.
RequestBodyDescription string `json:"requestBodyDescription"`
RequestBodyRequired bool `json:"requestBodyRequired"`
RequestBody []*RequestBody `json:"requestBody" yaml:"requestBody"`
// Responses.
// 其中 key 为 http status code
Responses []*Response `json:"responses" yaml:"responses"` // Required
}
type Parameter struct {
// 参数名
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
AllowEmptyValue bool `json:"allowEmptyValue" yaml:"allowEmptyValue"`
AllowReserved bool `json:"allowReserved" yaml:"allowReserved"`
Deprecated bool `json:"deprecated" yaml:"deprecated"`
Required bool `json:"required" yaml:"required"`
Type string `json:"type" yaml:"type"`
Enum []interface{} `json:"enum" yaml:"enum"`
Default interface{} `json:"default" yaml:"default"`
Example interface{} `json:"example" yaml:"example"`
}
// RequestBody is specified by OpenAPI/Swagger 3.0 standard.
type RequestBody struct {
MediaType string `json:"mediaType"`
Body *openapi3.Schema `json:"body"`
}
// Response is specified by OpenAPI/Swagger 3.0 standard.
type Response struct {
StatusCode string `json:"statusCode"`
MediaType string `json:"mediaType"`
Description string `json:"description" yaml:"description"`
Body *openapi3.Schema `json:"body"`
}