mirror of https://github.com/portainer/portainer
42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
package endpointgroups
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/request"
|
|
"github.com/portainer/libhttp/response"
|
|
portainer "github.com/portainer/portainer/api"
|
|
"github.com/portainer/portainer/api/bolt/errors"
|
|
)
|
|
|
|
// @summary Inspect an Environment(Endpoint) group
|
|
// @description Retrieve details abont an environment(endpoint) group.
|
|
// @description **Access policy**: administrator
|
|
// @tags endpoint_groups
|
|
// @security ApiKeyAuth
|
|
// @security jwt
|
|
// @accept json
|
|
// @produce json
|
|
// @param id path int true "Environment(Endpoint) group identifier"
|
|
// @success 200 {object} portainer.EndpointGroup "Success"
|
|
// @failure 400 "Invalid request"
|
|
// @failure 404 "EndpointGroup not found"
|
|
// @failure 500 "Server error"
|
|
// @router /endpoint_groups/{id} [get]
|
|
func (handler *Handler) endpointGroupInspect(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
endpointGroupID, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid environment group identifier route variable", err}
|
|
}
|
|
|
|
endpointGroup, err := handler.DataStore.EndpointGroup().EndpointGroup(portainer.EndpointGroupID(endpointGroupID))
|
|
if err == errors.ErrObjectNotFound {
|
|
return &httperror.HandlerError{http.StatusNotFound, "Unable to find an environment group with the specified identifier inside the database", err}
|
|
} else if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find an environment group with the specified identifier inside the database", err}
|
|
}
|
|
|
|
return response.JSON(w, endpointGroup)
|
|
}
|