github.com/cilium/cilium@v1.16.2/pkg/clustermesh/operator/api.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package operator
     5  
     6  import (
     7  	"github.com/go-openapi/runtime/middleware"
     8  
     9  	"github.com/cilium/cilium/api/v1/models"
    10  	restapi "github.com/cilium/cilium/api/v1/operator/server/restapi/cluster"
    11  )
    12  
    13  func newAPIClustersHandler(cm *clusterMesh) restapi.GetClusterHandler {
    14  	return &clustersHandler{cm}
    15  }
    16  
    17  // REST API handler for the '/cluster' path to expose the list of
    18  // remote clusters and their status.
    19  type clustersHandler struct{ cm *clusterMesh }
    20  
    21  func (h *clustersHandler) Handle(params restapi.GetClusterParams) middleware.Responder {
    22  	var status []*models.RemoteCluster
    23  	if h.cm != nil {
    24  		status = h.cm.status()
    25  	}
    26  
    27  	return restapi.NewGetClusterOK().WithPayload(status)
    28  }