// @failure 400 "Invalid request payload, such as missing required fields or fields not meeting validation criteria."
// @failure 401 "Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions."
// @failure 403 "Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions."
// @failure 404 "Unable to find an environment with the specified identifier."
// @failure 500 "Server error occurred while attempting to retrieve the total resource requests and limits for all applications from the cluster."
log.Error().Err(err).Str("context","getApplicationsResources").Msg("Unable to get the total resource requests and limits for all applications in the namespace")
returnhttperror.Unauthorized("Unable to get the total resource requests and limits for all applications in the namespace",err)
}
ifk8serrors.IsForbidden(err){
log.Error().Err(err).Str("context","getApplicationsResources").Msg("Unable to get the total resource requests and limits for all applications in the namespace")
returnhttperror.Forbidden("Unable to get the total resource requests and limits for all applications in the namespace",err)
}
log.Error().Err(err).Str("context","getApplicationsResources").Msg("Unable to calculate the total resource requests and limits for all applications in the namespace")
returnhttperror.InternalServerError("Unable to calculate the total resource requests and limits for all applications in the namespace",err)
}
returnresponse.JSON(w,applicationsResources)
}
// @id GetAllKubernetesApplications
// @summary Get a list of applications across all namespaces in the cluster. If the nodeName is provided, it will return the applications running on that node.
// @description Get a list of applications across all namespaces in the cluster. If the nodeName is provided, it will return the applications running on that node.
// @description **Access policy**: authenticated
// @tags kubernetes
// @security ApiKeyAuth || jwt
// @produce json
// @param id path int true "Environment(Endpoint) identifier"
// @failure 400 "Invalid request payload, such as missing required fields or fields not meeting validation criteria."
// @failure 401 "Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions."
// @failure 403 "Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions."
// @failure 404 "Unable to find an environment with the specified identifier."
// @failure 500 "Server error occurred while attempting to retrieve the list of applications from the cluster."
// @description Get the count of Applications across all namespaces in the cluster. If the nodeName is provided, it will return the count of applications running on that node.
// @param id path int true "Environment identifier"
// @success 200 {integer} integer "Success"
// @failure 400 "Invalid request payload, such as missing required fields or fields not meeting validation criteria."
// @failure 401 "Unauthorized access - the user is not authenticated or does not have the necessary permissions. Ensure that you have provided a valid API key or JWT token, and that you have the required permissions."
// @failure 403 "Permission denied - the user is authenticated but does not have the necessary permissions to access the requested resource or perform the specified operation. Check your user roles and permissions."
// @failure 404 "Unable to find an environment with the specified identifier."
// @failure 500 "Server error occurred while attempting to retrieve the count of all applications from the cluster."
log.Error().Err(err).Str("context","getAllKubernetesApplications").Msg("Unable to parse the nodeName query parameter")
returnnil,httperror.BadRequest("Unable to parse the nodeName query parameter",err)
}
cli,httpErr:=handler.prepareKubeClient(r)
ifhttpErr!=nil{
log.Error().Err(httpErr).Str("context","getAllKubernetesApplications").Str("namespace",namespace).Str("nodeName",nodeName).Msg("Unable to get a Kubernetes client for the user")
returnnil,httperror.InternalServerError("Unable to get a Kubernetes client for the user",httpErr)
log.Error().Err(err).Str("context","getAllKubernetesApplications").Str("namespace",namespace).Str("nodeName",nodeName).Msg("Unable to get the list of applications")
returnnil,httperror.Unauthorized("Unable to get the list of applications",err)
}
log.Error().Err(err).Str("context","getAllKubernetesApplications").Str("namespace",namespace).Str("nodeName",nodeName).Msg("Unable to get the list of applications")
returnnil,httperror.InternalServerError("Unable to get the list of applications",err)