github.com/polarismesh/polaris@v1.17.8/apiserver/httpserver/docs/core_console_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  	apimodel "github.com/polarismesh/specification/source/go/api/v1/model"
    24  )
    25  
    26  var (
    27  	namespaceApiTags = []string{"Namespaces"}
    28  )
    29  
    30  func EnrichGetNamespacesApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder {
    31  	return r.
    32  		Doc("查询命名空间列表(New)").
    33  		Metadata(restfulspec.KeyOpenAPITags, namespaceApiTags).
    34  		Param(restful.QueryParameter("name", "命名空间唯一名称").
    35  			DataType(typeNameString).Required(true)).
    36  		Param(restful.QueryParameter("offset", "查询偏移量").
    37  			DataType(typeNameInteger).Required(false).DefaultValue("0")).
    38  		Param(restful.QueryParameter("limit", "查询条数,**最多查询100条**").
    39  			DataType(typeNameInteger).Required(false)).
    40  		Returns(0, "", struct {
    41  			BatchQueryResponse
    42  			Namespaces []apimodel.Namespace `json:"namespaces"`
    43  		}{})
    44  }
    45  
    46  func EnrichCreateNamespacesApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder {
    47  	return r.
    48  		Doc("创建命名空间(New)").
    49  		Metadata(restfulspec.KeyOpenAPITags, namespaceApiTags).
    50  		Reads([]apimodel.Namespace{}, "create namespaces").
    51  		Returns(0, "", struct {
    52  			BatchWriteResponse
    53  			Responses []struct {
    54  				BaseResponse
    55  				Namespace apimodel.Namespace `json:"namespace"`
    56  			} `json:"responses"`
    57  		}{})
    58  }
    59  
    60  func EnrichDeleteNamespacesApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder {
    61  	return r.
    62  		Doc("删除命名空间(New)").
    63  		Metadata(restfulspec.KeyOpenAPITags, namespaceApiTags).
    64  		Reads([]apimodel.Namespace{}, "delete namespaces").
    65  		Returns(0, "", struct {
    66  			BatchWriteResponse
    67  			Responses []struct {
    68  				BaseResponse
    69  				Namespace apimodel.Namespace `json:"namespace"`
    70  			} `json:"responses"`
    71  		}{})
    72  }
    73  
    74  func EnrichUpdateNamespacesApiDocs(r *restful.RouteBuilder) *restful.RouteBuilder {
    75  	return r.
    76  		Doc("更新命名空间(New)").
    77  		Metadata(restfulspec.KeyOpenAPITags, namespaceApiTags).
    78  		Reads([]apimodel.Namespace{}, "update namespaces").
    79  		Returns(0, "", struct {
    80  			BatchWriteResponse
    81  			Responses []struct {
    82  				BaseResponse
    83  				Namespace apimodel.Namespace `json:"namespace"`
    84  			} `json:"responses"`
    85  		}{})
    86  }