github.com/polarismesh/polaris@v1.17.8/apiserver/httpserver/docs/naming_client_access_apidoc.go (about) 1 /** 2 * Tencent is pleased to support the open source community by making Polaris available. 3 * 4 * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 * 6 * Licensed under the BSD 3-Clause License (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * https://opensource.org/licenses/BSD-3-Clause 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed 13 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 * specific language governing permissions and limitations under the License. 16 */ 17 18 package docs 19 20 import ( 21 "github.com/emicklei/go-restful/v3" 22 restfulspec "github.com/polarismesh/go-restful-openapi/v2" 23 "github.com/polarismesh/specification/source/go/api/v1/service_manage" 24 apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage" 25 ) 26 27 var ( 28 registerInstanceApiTags = []string{"Client"} 29 ) 30 31 func EnrichReportClientApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { 32 return r.Doc("上报客户端信息"). 33 Metadata(restfulspec.KeyOpenAPITags, registerInstanceApiTags). 34 Doc("上报客户端"). 35 Reads(apiservice.Client{}). 36 Returns(0, "", struct { 37 BaseResponse 38 Client service_manage.Client `json:"client,omitempty"` 39 }{}) 40 } 41 42 func EnrichRegisterInstanceApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { 43 return r.Doc("注册实例"). 44 Metadata(restfulspec.KeyOpenAPITags, registerInstanceApiTags). 45 Reads(apiservice.Instance{}). 46 Returns(0, "", service_manage.Instance{}) 47 } 48 49 func EnrichDeregisterInstanceApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { 50 return r.Doc("注销实例"). 51 Metadata(restfulspec.KeyOpenAPITags, registerInstanceApiTags). 52 Reads(apiservice.Instance{}). 53 Returns(0, "", service_manage.Instance{}) 54 } 55 56 func EnrichHeartbeatApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { 57 return r.Doc("上报心跳"). 58 Metadata(restfulspec.KeyOpenAPITags, registerInstanceApiTags). 59 Reads(apiservice.Instance{}). 60 Returns(0, "", service_manage.Instance{}) 61 } 62 63 func EnrichDiscoverApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder { 64 return r.Doc("服务发现"). 65 Metadata(restfulspec.KeyOpenAPITags, registerInstanceApiTags). 66 Reads(DiscoverRequest{}, 67 "Type 支持 [UNKNOWN/INSTANCE/ROUTING/RATE_LIMIT/CIRCUIT_BREAKER/SERVICES/NAMESPACES/FAULT_DETECTOR]"). 68 Returns(0, "", service_manage.DiscoverResponse{}) 69 }