Documentation ¶
Overview ¶
Package server contains implementation of REST API server (HTTPServer) for the Insights content service. In current version, the following REST API endpoints are available:
Index ¶
- Constants
- func ValidateClusterName(clusterName string) (types.ClusterName, error)
- func ValidateRequestID(requestID string) (types.RequestID, error)
- type AllDVONamespacesResponse
- type ClusterEntry
- type ClusterList
- type ClusterReports
- type Configuration
- type DVOObject
- type DVORecommendation
- type HTTPServer
- type HittingClusters
- type HittingClustersMetadata
- type MetadataEntry
- type NamespaceEntry
- type RequestList
- type RequestStatus
- type Workload
- type WorkloadsForCluster
Constants ¶
const ( // MainEndpoint defines suffix of the root endpoint MainEndpoint = "" // GroupsEndpoint defines suffix of the groups request endpoint GroupsEndpoint = "groups" // ContentEndpoint defines suffix of the content request endpoint ContentEndpoint = "content" // DeleteOrganizationsEndpoint deletes all {organizations}(comma separated array). DEBUG only DeleteOrganizationsEndpoint = "organizations/{organizations}" // DeleteClustersEndpoint deletes all {clusters}(comma separated array). DEBUG only DeleteClustersEndpoint = "clusters/{clusters}" // OrganizationsEndpoint returns all organizations OrganizationsEndpoint = "organizations" // ClustersEndpoint returns reports for selected clusters ClustersEndpoint = "clusters" // ClustersInOrgEndpoint returns reports for all clusters in selected organization ClustersInOrgEndpoint = "clusters/{organization}" // ReportEndpoint returns report for provided {organization} and {cluster} ReportEndpoint = "report/{organization}/{cluster}" // ReportForClusterEndpoint returns report for provided {cluster} (w/o organization) ReportForClusterEndpoint = "report/{cluster}" // ReportForClusterEndpoint2 returns report for provided {cluster} (w/o organization) ReportForClusterEndpoint2 = "clusters/{cluster}/report" // LikeRuleEndpoint likes rule with {rule_id} for {cluster} using current user(from auth header) LikeRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/like" // DislikeRuleEndpoint dislikes rule with {rule_id} for {cluster} using current user(from auth header) DislikeRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/dislike" // ResetVoteOnRuleEndpoint resets vote on rule with {rule_id} for {cluster} using current user(from auth header) ResetVoteOnRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/reset_vote" // GetVoteOnRuleEndpoint is an endpoint to get vote on rule. DEBUG only GetVoteOnRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/get_vote" // RuleEndpoint is an endpoint to create&delete a rule. DEBUG only RuleEndpoint = "rules/{rule_id}" // RuleErrorKeyEndpoint is for endpoints to create&delete a rule_error_key (DEBUG only) // and for endpoint to get a rule RuleErrorKeyEndpoint = "rules/{rule_id}/error_keys/{error_key}" // RuleGroupsEndpoint is a simple redirect endpoint to the insights-content-service API specified in configuration RuleGroupsEndpoint = "groups" // ClustersForOrganizationEndpoint returns all clusters for {organization} ClustersForOrganizationEndpoint = "organizations/{organization}/clusters" // DisableRuleForClusterEndpoint disables a rule for specified cluster DisableRuleForClusterEndpoint = "clusters/{cluster}/rules/{rule_id}/disable" // EnableRuleForClusterEndpoint re-enables a rule for specified cluster EnableRuleForClusterEndpoint = "clusters/{cluster}/rules/{rule_id}/enable" // RuleClusterDetailEndpoint should return a list of all the clusters IDs affected by this rule RuleClusterDetailEndpoint = "rule/{rule_selector}/clusters_detail/" // ListAllRequestIDs should return list of all request IDs detected for // given cluster. In reality the list is refreshing as old request IDs // are forgotten after 24 hours ListAllRequestIDs = "cluster/{cluster}/requests/" // StatusOfRequestID should return status of processing one given // request ID StatusOfRequestID = "cluster/{cluster}/request/{request_id}/status" // RuleHitsForRequestID should return simplified results for given // cluster and requestID RuleHitsForRequestID = "cluster/{cluster}/request/{request_id}/report" // AckListEndpoint list acks from this account where the rule is // active. Will return an empty list if this account has no acks. AckListEndpoint = "ack" // AckAcknowledgePostEndpoint acknowledges (and therefore hides) a rule // from view in an account. If there's already an acknowledgement of // this rule by this account, then return that. Otherwise, a new ack is // created. AckAcknowledgePostEndpoint = "ack" // AckGetEndpoint acknowledges (and therefore hides) a rule from view // in an account. This view handles listing, retrieving, creating and // deleting acks. Acks are created and deleted by Insights rule ID, not // by their own ack ID. AckGetEndpoint = "ack/{rule_selector}" // AckUpdateEndpoint updates an acknowledgement for a rule, by rule ID. // A new justification can be supplied. The username is taken from the // authenticated request. The updated ack is returned. AckUpdateEndpoint = "ack/{rule_selector}" // AckDeleteEndpoint deletes an acknowledgement for a rule, by its rule // ID. If the ack existed, it is deleted and a 204 is returned. // Otherwise, a 404 is returned. AckDeleteEndpoint = "ack/{rule_selector}" // UpgradeRisksPredictionEndpoint returns the prediction about upgrading // the given cluster. UpgradeRisksPredictionEndpoint = "cluster/{cluster}/upgrade-risks-prediction" // MetricsEndpoint returns prometheus metrics MetricsEndpoint = "metrics" // ExitEndpoint perform server shutdown (in Debug mode only) ExitEndpoint = "exit" // AllDVONamespaces endpoint address. // // Returns the list of all DVO namespaces (i.e. array of objects) to // which this particular account has access. Each object contains the // namespace ID, the namespace display name if available, the cluster // ID under which this namespace is created, and the number of // affecting recommendations for this namespace as well. // // BDD scenarios for this endpoint: // https://github.com/RedHatInsights/insights-behavioral-spec/blob/main/features/DVO_Recommendations/Smart_Proxy_REST_API.feature // - Accessing Smart Proxy REST API endpoint to retrieve list of all DVO namespaces for current organization // - Returning just active clusters in Smart Proxy REST API endpoint to retrieve list of all DVO namespaces for current organization // - Checking organization in Smart Proxy REST API endpoint to retrieve list of all DVO namespaces for current organization // AllDVONamespaces = "namespaces/dvo" // DVONamespaceForCluster1 endpoint address. // // Returns the list of all namespaces (i.e. array of objects) to which // this particular account has access filtered by {cluster_name}. Each // object contains the namespace ID, the namespace display name if // available, the cluster ID under which this namespace is created // (repeated input), and the number of affecting recommendations for // this namespace as well. // // BDD scenarios for this endpoint: // https://github.com/RedHatInsights/insights-behavioral-spec/blob/main/features/DVO_Recommendations/Smart_Proxy_REST_API.feature // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for not known cluster // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for known cluster without DVO namespaces // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for improper cluster UUID // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for improper organization // DVONamespaceForCluster1 = "cluster/{cluster_name}/namespaces/dvo/{namespace}" // DVONamespaceForCluster2 endpoint address. // // This endpoint has the same meaning as DVONamespaceForCluster1, but // order of selectors is different. // // BDD scenarios for this endpoint: // https://github.com/RedHatInsights/insights-behavioral-spec/blob/main/features/DVO_Recommendations/Smart_Proxy_REST_API.feature // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for selected existing cluster // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for not known cluster // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for known cluster without DVO namespaces // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for improper cluster UUID // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces for improper organization // - Accessing Smart Proxy REST API endpoint to retrieve DVO namespaces when cluster is not specified // DVONamespaceForCluster2 = "namespaces/dvo/{namespace}/cluster/{cluster_name}" // DVONamespaceInfo endpoint address. // // Returns information about the requested namespace. Contains the display name, // associated cluster ID. Probably, some other metadata like last seen (but not // needed according to current UX pre-design). // // BDD scenarios for this endpoint: // https://github.com/RedHatInsights/insights-behavioral-spec/blob/main/features/DVO_Recommendations/Smart_Proxy_REST_API.feature // - Accessing Smart Proxy REST API endpoint to retrieve information about selected DVO namespace // - Accessing Smart Proxy REST API endpoint to retrieve information about selected DVO namespace when no such namespace exists // - Accessing Smart Proxy REST API endpoint to retrieve information about selected DVO namespace for improper organization // - Accessing Smart Proxy REST API endpoint to retrieve information about selected DVO namespace for improper user // DVONamespaceInfo = "namespaces/dvo/{namespace_id}/info" // DVONamespaceReports endpoint address. // // Returns the list of all recommendations affecting this namespace. It // is basically an array with objects meeting the // https://github.com/RedHatInsights/insights-results-smart-proxy/blob/master/server/api/v2/openapi.json#L1537 // // BDD scenarios for this endpoint: // https://github.com/RedHatInsights/insights-behavioral-spec/blob/main/features/DVO_Recommendations/Smart_Proxy_REST_API.feature // - Accessing Smart Proxy REST API endpoint to retrieve list of all recommendations affecting the selected namespace when no rules are hitting // - Accessing Smart Proxy REST API endpoint to retrieve list of all recommendations affecting the selected namespace when just one rule is hitting // - Accessing Smart Proxy REST API endpoint to retrieve list of all recommendations affecting the selected namespace when two rules are hitting // - Accessing Smart Proxy REST API endpoint to retrieve list of all recommendations affecting the selected namespace when no such namespace exists // - Accessing Smart Proxy REST API endpoint to retrieve list of all recommendations affecting the selected namespace for improper organization // - Accessing Smart Proxy REST API endpoint to retrieve list of all recommendations affecting the selected namespace for improper user // DVONamespaceReports = "namespaces/dvo/{namespace_id}/reports" )
const ( // ClusterOk is the cluster name for a OK response with no upgrade risks detected ClusterOk = "00000001-624a-49a5-bab8-4fdc5e51a266" // ClusterOkFailUpgrade is the cluster name for a OK response with upgrade risks detected ClusterOkFailUpgrade = "00000003-eeee-eeee-eeee-000000000001" // ClusterManaged is the cluster name for the response when a cluster in "managed" ClusterManaged = "6cab9726-c2be-438e-af11-db846a678abb" // ClusterNoAMS is the cluster name for the response when the AMS API is not available ClusterNoAMS = "c60ba611-6af4-4d62-9b9e-36344da5e7bc" ClusterUnavailable = "897ec1a1-4679-4122-aacb-f0ae9f9e1a5f" // ClusterNoData is the cluster name for the response when the Upgrade risks prediction service returns a 404 ClusterNoData = "234ec1a1-4679-4122-aacb-f0ae9f9e1a56" )
const StatusProcessed = "processed"
StatusProcessed is message returned for already processed reports (rule hits)
Variables ¶
This section is empty.
Functions ¶
func ValidateClusterName ¶
func ValidateClusterName(clusterName string) (types.ClusterName, error)
ValidateClusterName checks that the cluster name is a valid UUID. Converted cluster name is returned if everything is okay, otherwise an error is returned.
Types ¶
type AllDVONamespacesResponse ¶
type AllDVONamespacesResponse struct { Status string `json:"status"` Workloads []Workload `json:"workloads"` }
AllDVONamespacesResponse is a data structure that represents list of namespaces that is returned from REST API endpoint used for Workloads page
type ClusterEntry ¶
ClusterEntry structure contains cluster UUID and cluster name
type ClusterList ¶
type ClusterList struct {
Clusters []string `json:"clusters"`
}
ClusterList is a data structure that store list of cluster IDs (names).
type ClusterReports ¶
type ClusterReports struct { ClusterList []types.ClusterName `json:"clusters"` Errors []types.ClusterName `json:"errors"` Reports map[types.ClusterName]interface{} `json:"reports"` GeneratedAt string `json:"generated_at"` }
ClusterReports is a data structure containing list of clusters, list of errors and dictionary with results per cluster.
type Configuration ¶
type Configuration struct { Address string `mapstructure:"address" toml:"address"` APIPrefix string `mapstructure:"api_prefix" toml:"api_prefix"` APISpecFile string `mapstructure:"api_spec_file" toml:"api_spec_file"` Debug bool `mapstructure:"debug" toml:"debug"` }
Configuration represents configuration of REST API HTTP server
type DVORecommendation ¶
type DVORecommendation struct { Check string `json:"check"` Description string `json:"description"` Remediation string `json:"remediation"` Objects []DVOObject `json:"objects"` }
DVORecommendation structure represents one DVO-related recommendation
type HTTPServer ¶
type HTTPServer struct { Config Configuration Storage storage.Storage Groups map[string]groups.Group Serv *http.Server Content []content.RuleContent // contains filtered or unexported fields }
HTTPServer in an implementation of Server interface
func New ¶
func New(config Configuration, storageInstance storage.Storage, ruleGroups map[string]groups.Group, ruleContents []content.RuleContent) *HTTPServer
New constructs new implementation of Server interface
func (*HTTPServer) Initialize ¶
func (server *HTTPServer) Initialize(address string) http.Handler
Initialize perform the server initialization
type HittingClusters ¶
type HittingClusters struct { Metadata HittingClustersMetadata `json:"meta"` ClusterList []types.ClusterName `json:"data"` }
HittingClusters is a data structure containing list of clusters hitting the given rule.
type HittingClustersMetadata ¶
type HittingClustersMetadata struct { Count int `json:"count"` Component types.Component `json:"component"` ErrorKey types.ErrorKey `json:"error_key"` GeneratedAt string `json:"generated_at"` }
HittingClustersMetadata used to store metadata of hitting clusters
type MetadataEntry ¶
type MetadataEntry struct { Recommendations int `json:"recommendations"` Objects int `json:"objects"` ReportedAt string `json:"reported_at"` LastCheckedAt string `json:"last_checked_at"` HighestSeverity int `json:"highest_severity"` }
MetadataEntry structure contains basic information about workload metadata
type NamespaceEntry ¶
NamespaceEntry structure contains basic information about namespace
type RequestList ¶
RequestList represents sequence of request IDs
type RequestStatus ¶
type RequestStatus struct { RequestID string `json:"requestID"` Valid bool `json:"valid"` Received string `json:"received"` Processed string `json:"processed"` }
RequestStatus contains description about one request ID
type Workload ¶
type Workload struct { ClusterEntry ClusterEntry `json:"cluster"` Namespace NamespaceEntry `json:"namespace"` MetadataEntry MetadataEntry `json:"metadata"` }
Workload structure represents one workload entry in list of workloads
type WorkloadsForCluster ¶
type WorkloadsForCluster struct { Status string `json:"status"` ClusterEntry ClusterEntry `json:"cluster"` Namespace NamespaceEntry `json:"namespace"` MetadataEntry MetadataEntry `json:"metadata"` Recommendations []DVORecommendation `json:"recommendations"` }
WorkloadsForCluster structure represents workload for one selected cluster