MCPcopy
hub / github.com/portainer/portainer / endpointInspect

Method endpointInspect

api/http/handler/endpoints/endpoint_inspect.go:28–86  ·  view source on GitHub ↗

@id EndpointInspect @summary Inspect an environment(endpoint) @description Retrieve details about an environment(endpoint). @description **Access policy**: restricted @tags endpoints @security ApiKeyAuth @security jwt @produce json @param id path int true "Environment(Endpoint) identifier" @param ex

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

26// @failure 500 "Server error"
27// @router /endpoints/{id} [get]
28func (handler *Handler) endpointInspect(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
29 endpointID, err := request.RetrieveNumericRouteVariableValue(r, "id")
30 if err != nil {
31 return httperror.BadRequest("Invalid environment identifier route variable", err)
32 }
33
34 endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID))
35 if handler.DataStore.IsErrObjectNotFound(err) {
36 return httperror.NotFound("Unable to find an environment with the specified identifier inside the database", err)
37 } else if err != nil {
38 return httperror.InternalServerError("Unable to find an environment with the specified identifier inside the database", err)
39 }
40
41 if err := handler.requestBouncer.AuthorizedEndpointOperation(r, endpoint); err != nil {
42 return httperror.Forbidden("Permission denied to access environment", err)
43 }
44
45 settings, err := handler.DataStore.Settings().Settings()
46 if err != nil {
47 return httperror.InternalServerError("Unable to retrieve settings from the database", err)
48 }
49
50 hideFields(endpoint)
51 endpointutils.UpdateEdgeEndpointHeartbeat(endpoint, settings)
52 endpoint.ComposeSyntaxMaxVersion = handler.ComposeStackManager.ComposeSyntaxMaxVersion()
53
54 excludeSnapshot, _ := request.RetrieveBooleanQueryParameter(r, "excludeSnapshot", true)
55
56 if !excludeSnapshot {
57 if err := handler.SnapshotService.FillSnapshotData(endpoint, false); err != nil {
58 return httperror.InternalServerError("Unable to add snapshot data", err)
59 }
60 }
61
62 if endpointutils.IsKubernetesEndpoint(endpoint) {
63 isServerMetricsDetected := endpoint.Kubernetes.Flags.IsServerMetricsDetected
64 if !isServerMetricsDetected && handler.K8sClientFactory != nil {
65 endpointutils.InitialMetricsDetection(
66 endpoint,
67 handler.DataStore.Endpoint(),
68 handler.K8sClientFactory,
69 )
70 }
71
72 isServerStorageDetected := endpoint.Kubernetes.Flags.IsServerStorageDetected
73 if !isServerStorageDetected && handler.K8sClientFactory != nil {
74 endpointutils.InitialStorageDetection(
75 endpoint,
76 handler.DataStore.Endpoint(),
77 handler.K8sClientFactory,
78 )
79 }
80 }
81
82 // Execute endpoint pending actions
83 handler.PendingActionsService.Execute(endpoint.ID)
84
85 return response.JSON(w, endpoint)

Callers

nothing calls this directly

Calls 15

IsKubernetesEndpointFunction · 0.92
InitialMetricsDetectionFunction · 0.92
InitialStorageDetectionFunction · 0.92
JSONFunction · 0.92
hideFieldsFunction · 0.70
EndpointMethod · 0.65
IsErrObjectNotFoundMethod · 0.65
SettingsMethod · 0.65

Tested by

no test coverage detected