types

package module
v1.3.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 3 Imported by: 22

README

insights-results-types

GoDoc GitHub Pages Build Status GitHub go.mod Go version License

Description

Common data types used across the whole CCX data pipeline.

Class diagram with all types defined in this project

Class diagram

Note

Please note that this repository should contain just "static" data types, which means that no runtime code is supposed to be there. Also this repository should not depend on any other RedHatInsigths packages to avoid circular dependencies.

Documentation

Overview

Package types contains declaration of various data types (usually structures) used elsewhere in the aggregator code.

Index

Constants

View Source
const (
	// ContextKeyUser is a constant for user authentication token in request
	ContextKeyUser = ContextKey("user")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Acknowledgement

type Acknowledgement struct {
	Acknowledged  bool   `json:"-"` // let's skip this one in responses
	Rule          string `json:"rule"`
	Justification string `json:"justification"`
	CreatedBy     string `json:"created_by"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
}

Acknowledgement represents user acknowledgement of given rule

type AcknowledgementJustification

type AcknowledgementJustification struct {
	Value string `json:"justification"`
}

AcknowledgementJustification data structure represents body of request with specified justification of given acknowledgement

type AcknowledgementRuleSelectorJustification

type AcknowledgementRuleSelectorJustification struct {
	RuleSelector RuleSelector `json:"rule_id"`
	Value        string       `json:"justification"`
}

AcknowledgementRuleSelectorJustification data structure represents body of request with specified rule selector and justification of given acknowledgement

type AcknowledgementsMetadata

type AcknowledgementsMetadata struct {
	Count int `json:"count"`
}

AcknowledgementsMetadata contains metadata about list of acknowledgements

type AcknowledgementsResponse

type AcknowledgementsResponse struct {
	Metadata AcknowledgementsMetadata `json:"meta"`
	Data     []Acknowledgement        `json:"data"`
}

AcknowledgementsResponse is structure returned to client in JSON serialization format

type ClusterInfo added in v1.3.21

type ClusterInfo struct {
	ID          ClusterName `json:"cluster_id"`
	DisplayName string      `json:"display_name"`
	Managed     bool        `json:"managed"`
	Status      string      `json:"status"`
}

ClusterInfo is a data structure containing some relevant cluster information

type ClusterListInRequest

type ClusterListInRequest struct {
	Clusters []string `json:"clusters"`
}

ClusterListInRequest represents request body containing list of clusters

type ClusterMetadata added in v1.3.9

type ClusterMetadata struct {
	Version Version `json:"cluster_version"`
}

ClusterMetadata contains metadata information for a given cluster, like its version

type ClusterName

type ClusterName string

ClusterName represents name of cluster in format c8590f31-e97e-4b85-b506-c45ce1911a12

type ClusterRecommendationList added in v1.3.1

type ClusterRecommendationList struct {
	CreatedAt       time.Time       `json:"created_at"`
	Meta            ClusterMetadata `json:"meta"`
	Recommendations []RuleID        `json:"recommendations"`
}

ClusterRecommendationList is used for the clusters list

type ClusterRecommendationMap added in v1.3.1

type ClusterRecommendationMap map[ClusterName]ClusterRecommendationList

ClusterRecommendationMap is used for the clusters list

type ClusterReport

type ClusterReport string

ClusterReport represents cluster report

type ClusterReports

type ClusterReports struct {
	ClusterList []ClusterName                   `json:"clusters"`
	Errors      []ClusterName                   `json:"errors"`
	Reports     map[ClusterName]json.RawMessage `json:"reports"`
	GeneratedAt string                          `json:"generated_at"`
	Status      string                          `json:"status"`
}

ClusterReports is a data structure containing list of clusters, list of errors and dictionary with results per cluster. This structure is used by aggregator to return more reports.

type ClustersDetailData added in v1.3.21

type ClustersDetailData struct {
	EnabledClusters  []HittingClustersData `json:"enabled"`
	DisabledClusters []DisabledClusterInfo `json:"disabled"`
}

ClustersDetailData is the inner data structure for /clusters_detail

type ClustersDetailResponse added in v1.3.21

type ClustersDetailResponse struct {
	Data   ClustersDetailData `json:"data"`
	Status string             `json:"status"`
}

ClustersDetailResponse is a data structure used as the response for /clusters_detail

type Component

type Component string

Component represent name of component (of rule)

type ContextKey

type ContextKey string

ContextKey is a type for user authentication token in request

type DBDriver

type DBDriver int

DBDriver type for db driver enum

const (
	// DBDriverSQLite3 shows that db driver is sqlite
	DBDriverSQLite3 DBDriver = iota
	// DBDriverPostgres shows that db driver is postgres
	DBDriverPostgres
	// DBDriverGeneral general sql(used for mock now)
	DBDriverGeneral
)

type DatabaseVersion

type DatabaseVersion uint

DatabaseVersion specifies the latest version the database has been migrated to. It might be zero in case of any migration issue.

type DatabaseVersionStruct

type DatabaseVersionStruct struct {
	DatabaseVersion DatabaseVersion `json:"database_version"`
}

DatabaseVersionStruct is a data structure to be returned in JSON format by Insights Results Aggregator.

type DisabledClusterInfo added in v1.3.4

type DisabledClusterInfo struct {
	ClusterID     ClusterName `json:"cluster_id"`
	ClusterName   string      `json:"cluster_name"`
	DisabledAt    time.Time   `json:"disabled_at"`
	Justification string      `json:"justification"`
}

DisabledClusterInfo represents information about disabled clusters for /clusters_detail

type DisabledRule

type DisabledRule struct {
	ClusterID  ClusterName
	RuleID     RuleID
	ErrorKey   ErrorKey
	Disabled   RuleToggle
	DisabledAt sql.NullTime
	EnabledAt  sql.NullTime
	UpdatedAt  sql.NullTime
}

DisabledRule represents a record from rule_cluster_toggle

type DisabledRuleReason

type DisabledRuleReason struct {
	ClusterID ClusterName
	RuleID    RuleID
	ErrorKey  ErrorKey
	Message   string
	AddedAt   sql.NullTime
	UpdatedAt sql.NullTime
}

DisabledRuleReason represents a record from cluster_user_rule_disable_feedback table

type DisabledRuleResponse

type DisabledRuleResponse struct {
	RuleModule  string `json:"rule_id"`
	Description string `json:"description"`
	Generic     string `json:"details"`
	DisabledAt  string `json:"disabled_at"`
}

DisabledRuleResponse represents a single disabled rule displaying only identifying information

type ErrorKey

type ErrorKey string

ErrorKey represents type for error key

type ErrorKeyMetadata

type ErrorKeyMetadata struct {
	Description    string   `yaml:"description" json:"description"`
	Impact         Impact   `yaml:"impact" json:"impact"`
	Likelihood     int      `yaml:"likelihood" json:"likelihood"`
	PublishDate    string   `yaml:"publish_date" json:"publish_date"`
	ResolutionRisk int      `yaml:"resolution_risk" json:"resolution_risk"`
	Status         string   `yaml:"status" json:"status"`
	Tags           []string `yaml:"tags" json:"tags"`
}

ErrorKeyMetadata is a Go representation of the `metadata.yaml` file inside of an error key content directory.

type ErrorKeyMetadataV1 added in v1.3.0

type ErrorKeyMetadataV1 struct {
	Description string   `yaml:"description" json:"description"`
	Impact      string   `yaml:"impact" json:"impact"`
	Likelihood  int      `yaml:"likelihood" json:"likelihood"`
	PublishDate string   `yaml:"publish_date" json:"publish_date"`
	Status      string   `yaml:"status" json:"status"`
	Tags        []string `yaml:"tags" json:"tags"`
}

ErrorKeyMetadataV1 is in RuleErrorKeyContentV1

type ErrorKeyMetadataV2 added in v1.3.0

type ErrorKeyMetadataV2 struct {
	Description string   `yaml:"description" json:"description"`
	Impact      int      `yaml:"impact" json:"impact"`
	Likelihood  int      `yaml:"likelihood" json:"likelihood"`
	PublishDate string   `yaml:"publish_date" json:"publish_date"`
	Status      string   `yaml:"status" json:"status"`
	Tags        []string `yaml:"tags" json:"tags"`
}

ErrorKeyMetadataV2 is in RuleErrorKeyContentV2

type GlobalRuleConfig

type GlobalRuleConfig struct {
	Impact         map[string]int `yaml:"impact" json:"impact"`
	ResolutionRisk map[string]int `yaml:"resolution_risk" json:"resolution_risk"`
}

GlobalRuleConfig represents the file that contains metadata globally applicable to any/all rule content.

type HittingClusters

type HittingClusters struct {
	Metadata    HittingClustersMetadata `json:"meta"`
	ClusterList []HittingClustersData   `json:"data"`
	Status      string                  `json:"status"`
}

HittingClusters is a data structure containing list of clusters hit by a concrete rule hitting the given rule.

type HittingClustersData

type HittingClustersData struct {
	Cluster       ClusterName     `json:"cluster"`
	Name          string          `json:"cluster_name"`
	LastSeen      string          `json:"last_checked_at"`
	ImpactedSince string          `json:"impacted"`
	Meta          ClusterMetadata `json:"meta"`
}

HittingClustersData used to store data of clusters hit by a concrete rule

type HittingClustersMetadata

type HittingClustersMetadata struct {
	Count    int          `json:"count"`
	Selector RuleSelector `json:"rule_id"`
}

HittingClustersMetadata used to store metadata of clusters hit by a concrete rule

type Identity

type Identity struct {
	AccountNumber UserID `json:"account_number"`
	OrgID         OrgID  `json:"org_id,string"`
	User          User   `json:"user"`
}

Identity contains information about users and their organization

type Impact

type Impact struct {
	Name   string `yaml:"name" json:"name"`
	Impact int    `yaml:"impact" json:"impact"`
}

Impact is contained in ErrorKeyMetadata

type ImpactedClustersCnt

type ImpactedClustersCnt uint32

ImpactedClustersCnt represents the number of clusters impacted by a rule

type JWTPayload

type JWTPayload struct {
	AccountNumber UserID `json:"account_number"`
	OrgID         OrgID  `json:"org_id,string"`
	UserID        UserID `json:"user_id"`
}

JWTPayload is structure that contain data from parsed JWT token jwt auth type is not used and will be removed

type KafkaOffset

type KafkaOffset int64

KafkaOffset type for kafka offset

type OrgID

type OrgID uint32

OrgID represents organization ID

type RecommendationImpactedClusters

type RecommendationImpactedClusters map[RuleID][]ClusterName

RecommendationImpactedClusters is returned by aggregator for the purposes of /rule/ recommendation list endpoint

type RecommendationListRow

type RecommendationListRow struct {
	RuleID              RuleID              `json:"rule_id"`
	ImpactedClustersCnt ImpactedClustersCnt `json:"impacted_clusters_cnt"`
}

RecommendationListRow represents a single row retrieved from recommendation table for the purposes of Recommendations List (list of rules + number of impacted clusters)

type RecommendationRow

type RecommendationRow struct {
	// RuleID is in "|" format
	RuleID    RuleID       `json:"rule_id"`
	RuleFQDN  RuleFQDN     `json:"rule_fqdn"`
	ErrorKey  ErrorKey     `json:"error_key"`
	OrgID     OrgID        `json:"org_id"`
	ClusterID ClusterName  `json:"cluster_id"`
	CreatedAt sql.NullTime `json:"created_at"`
}

RecommendationRow represents a single row in the recommendation table

type ReportItem

type ReportItem struct {
	Module       RuleID          `json:"component"`
	ErrorKey     ErrorKey        `json:"key"`
	TemplateData json.RawMessage `json:"details"`
}

ReportItem represents a single (hit) rule of the string encoded report

type ReportResponse

type ReportResponse struct {
	Meta   ReportResponseMeta `json:"meta"`
	Report []RuleOnReport     `json:"reports"`
}

ReportResponse represents the response of /report endpoint

type ReportResponseMeta

type ReportResponseMeta struct {
	DisplayName   string    `json:"cluster_name"`
	Count         int       `json:"count"`
	LastCheckedAt Timestamp `json:"last_checked_at,omitempty"`
	GatheredAt    Timestamp `json:"gathered_at,omitempty"`
}

ReportResponseMeta contains metadata about the report that is part of ReportResponse structure

type ReportResponseMetainfo added in v1.3.3

type ReportResponseMetainfo struct {
	Count         int       `json:"count"`
	LastCheckedAt Timestamp `json:"last_checked_at"`
	StoredAt      Timestamp `json:"stored_at"`
}

ReportResponseMetainfo contains just metadata about the report, to be used separately from ReportResponse structure

type ReportRules

type ReportRules struct {
	HitRules     []RuleOnReport `json:"reports"`
	SkippedRules []RuleOnReport `json:"skips"`
	PassedRules  []RuleOnReport `json:"pass"`
	TotalCount   int
}

ReportRules is a helper struct for easy JSON unmarshalling of string encoded report

type RequestID

type RequestID string

RequestID is used to store the request ID supplied in input Kafka records as a unique identifier of payloads. Empty string represents a missing request ID.

type Rule

type Rule struct {
	Module     RuleID `json:"module"`
	Name       string `json:"name"`
	Generic    string `json:"generic"`
	Summary    string `json:"summary"`
	Reason     string `json:"reason"`
	Resolution string `json:"resolution"`
	MoreInfo   string `json:"more_info"`
}

Rule represents the content of rule table

type RuleContent

type RuleContent struct {
	Plugin     RulePluginInfo                 `json:"plugin"`
	ErrorKeys  map[string]RuleErrorKeyContent `json:"error_keys"`
	Generic    string                         `json:"generic"`
	Summary    string                         `json:"summary"`
	Resolution string                         `json:"resolution"`
	MoreInfo   string                         `json:"more_info"`
	Reason     string                         `json:"reason"`
	HasReason  bool
}

RuleContent wraps all the content available for a rule into a single structure.

type RuleContentDirectory

type RuleContentDirectory struct {
	Config GlobalRuleConfig
	Rules  map[string]RuleContent
}

RuleContentDirectory contains content for all available rules in a directory.

type RuleContentResponse

type RuleContentResponse struct {
	CreatedAt    string      `json:"created_at"`
	Description  string      `json:"description"`
	ErrorKey     string      `json:"-"`
	Generic      string      `json:"details"`
	Reason       string      `json:"reason"`
	Resolution   string      `json:"resolution"`
	TotalRisk    int         `json:"total_risk"`
	RuleModule   RuleID      `json:"rule_id"`
	TemplateData interface{} `json:"extra_data"`
	Tags         []string    `json:"tags"`
	UserVote     UserVote    `json:"user_vote"`
	Disabled     bool        `json:"disabled"`
	Internal     bool        `json:"internal"`
}

RuleContentResponse represents a single rule in the response of /report endpoint

type RuleContentStatus

type RuleContentStatus struct {
	RuleType RuleType         `json:"type"`
	Loaded   bool             `json:"loaded"`
	Error    RuleParsingError `json:"error"`
}

RuleContentStatus type store information about rule content parsed and checked by Content Service

type RuleContentV1 added in v1.3.0

type RuleContentV1 struct {
	Plugin     RulePluginInfo                   `json:"plugin"`
	ErrorKeys  map[string]RuleErrorKeyContentV1 `json:"error_keys"`
	Generic    string                           `json:"generic"`
	Summary    string                           `json:"summary"`
	Resolution string                           `json:"resolution"`
	MoreInfo   string                           `json:"more_info"`
	Reason     string                           `json:"reason"`
	HasReason  bool
}

RuleContentV1 version 1 of RuleConted provided by smart proxy

type RuleContentV2 added in v1.3.0

type RuleContentV2 struct {
	Plugin     RulePluginInfo                   `json:"plugin"`
	ErrorKeys  map[string]RuleErrorKeyContentV2 `json:"error_keys"`
	Generic    string                           `json:"generic"`
	Summary    string                           `json:"summary"`
	Resolution string                           `json:"resolution"`
	MoreInfo   string                           `json:"more_info"`
	Reason     string                           `json:"reason"`
	HasReason  bool
}

RuleContentV2 version 2 of RuleContent provided by smart proxy

type RuleErrorKey

type RuleErrorKey struct {
	ErrorKey       ErrorKey  `json:"error_key"`
	RuleModule     RuleID    `json:"rule_module"`
	Condition      string    `json:"condition"`
	Description    string    `json:"description"`
	Impact         int       `json:"impact"`
	Likelihood     int       `json:"likelihood"`
	ResolutionRisk int       `json:"resolution_risk"`
	PublishDate    time.Time `json:"publish_date"`
	Active         bool      `json:"active"`
	Generic        string    `json:"generic"`
	Summary        string    `json:"summary"`
	Reason         string    `json:"reason"`
	Resolution     string    `json:"resolution"`
	MoreInfo       string    `json:"more_info"`
	Tags           []string  `json:"tags"`
}

RuleErrorKey represents the content of rule_error_key table

type RuleErrorKeyContent

type RuleErrorKeyContent struct {
	Metadata   ErrorKeyMetadata `json:"metadata"`
	TotalRisk  int              `json:"total_risk"`
	Generic    string           `json:"generic"`
	Summary    string           `json:"summary"`
	Resolution string           `json:"resolution"`
	MoreInfo   string           `json:"more_info"`
	Reason     string           `json:"reason"`
	// DONTFIX has_reason until CCXDEV-5021
	HasReason bool
}

RuleErrorKeyContent wraps content of a single error key.

type RuleErrorKeyContentV1 added in v1.3.0

type RuleErrorKeyContentV1 struct {
	Metadata   ErrorKeyMetadataV1 `json:"metadata"`
	TotalRisk  int                `json:"total_risk"`
	Generic    string             `json:"generic"`
	Summary    string             `json:"summary"`
	Resolution string             `json:"resolution"`
	MoreInfo   string             `json:"more_info"`
	Reason     string             `json:"reason"`
	// DONTFIX has_reason until CCXDEV-5021
	HasReason bool
}

RuleErrorKeyContentV1 is in RuleContentV1

type RuleErrorKeyContentV2 added in v1.3.0

type RuleErrorKeyContentV2 struct {
	Metadata   ErrorKeyMetadataV2 `json:"metadata"`
	TotalRisk  int                `json:"total_risk"`
	Generic    string             `json:"generic"`
	Summary    string             `json:"summary"`
	Resolution string             `json:"resolution"`
	MoreInfo   string             `json:"more_info"`
	Reason     string             `json:"reason"`
	// DONTFIX has_reason until CCXDEV-5021
	HasReason bool
}

RuleErrorKeyContentV2 is in RuleContentV2

type RuleFQDN

type RuleFQDN string

RuleFQDN represents type for rule FQDN (rule module)

type RuleID

type RuleID string

RuleID represents type for rule id

type RuleOnReport

type RuleOnReport struct {
	Module          RuleID      `json:"component"`
	ErrorKey        ErrorKey    `json:"key"`
	UserVote        UserVote    `json:"user_vote"`
	Disabled        bool        `json:"disabled"`
	DisableFeedback string      `json:"disable_feedback"`
	DisabledAt      Timestamp   `json:"disabled_at"`
	TemplateData    interface{} `json:"details"`
	CreatedAt       Timestamp   `json:"impacted,omitempty"`
}

RuleOnReport represents a single (hit) rule of the string encoded report

type RuleParsingError

type RuleParsingError string

RuleParsingError represents textual and human-readable form of (any) error occured during reading, parsing, and checking rule content in Content Service

type RulePluginInfo

type RulePluginInfo struct {
	Name         string `yaml:"name" json:"name"`
	NodeID       string `yaml:"node_id" json:"node_id"`
	ProductCode  string `yaml:"product_code" json:"product_code"`
	PythonModule string `yaml:"python_module" json:"python_module"`
}

RulePluginInfo is a Go representation of the `plugin.yaml` file inside of the rule content directory.

type RuleRating

type RuleRating struct {
	Rule   string   `json:"rule"`
	Rating UserVote `json:"rating"`
}

RuleRating represents the body request of request to the rating endpoint

type RuleSelector

type RuleSelector string

RuleSelector represents component + error key

type RuleToggle

type RuleToggle int

RuleToggle is a type for user's vote

type RuleType

type RuleType string

RuleType identifies whether the rule is external or internal one INFO: might be stored as a bool, but number of rule types might be enhanced later

type RuleWithContent

type RuleWithContent struct {
	Module      RuleID    `json:"module"`
	Name        string    `json:"name"`
	Summary     string    `json:"summary"`
	Reason      string    `json:"reason"`
	Resolution  string    `json:"resolution"`
	MoreInfo    string    `json:"more_info"`
	ErrorKey    ErrorKey  `json:"error_key"`
	Condition   string    `json:"condition"`
	Description string    `json:"description"`
	TotalRisk   int       `json:"total_risk"`
	PublishDate time.Time `json:"publish_date"`
	Active      bool      `json:"active"`
	Internal    bool      `json:"internal"`
	Generic     string    `json:"generic"`
	Tags        []string  `json:"tags"`
}

RuleWithContent represents a rule with content, basically the mix of rule and rule_error_key tables' content

type SchemaVersion

type SchemaVersion uint8

SchemaVersion is just a constant integer for now, max value 255. If we one day need more versions, better consider upgrading to semantic versioning.

type SimplifiedReport added in v1.3.23

type SimplifiedReport struct {
	RequestID          string    `redis:"request_id"`
	ClusterID          string    `redis:"cluster_id"`
	OrgID              int       `redis:"org_id"`
	ReceivedTimestamp  time.Time `redis:"received_timestamp"`
	ProcessedTimestamp time.Time `redis:"processed_timestamp"`
	RuleHitsCSV        string    `redis:"rule_hits"`
}

SimplifiedReport represents data structure to be stored in Redis

type SystemWideRuleDisable

type SystemWideRuleDisable struct {
	OrgID         OrgID        `json:"org_id"`
	UserID        UserID       `json:"user_id"`
	RuleID        RuleID       `json:"rule_id"`
	ErrorKey      ErrorKey     `json:"error_key"`
	Justification string       `json:"justification"`
	CreatedAt     sql.NullTime `json:"created_at"`
	UpdatedAT     sql.NullTime `json:"updated_at"`
}

SystemWideRuleDisable represents a record from rule_disable table

type Timestamp

type Timestamp string

Timestamp represents any timestamp in a form gathered from database TODO: need to be improved

type Token

type Token struct {
	Identity Identity `json:"identity"`
}

Token is x-rh-identity struct

type User added in v1.3.14

type User struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	UserID   UserID `json:"user_id"`
}

User struct contains single user data passed in the auth token

type UserID

type UserID string

UserID represents type for user id

type UserVote

type UserVote int

UserVote is a type for user's vote

const (
	// UserVoteDislike shows user's dislike
	UserVoteDislike UserVote = -1
	// UserVoteNone shows no vote from user
	UserVoteNone UserVote = 0
	// UserVoteLike shows user's like
	UserVoteLike UserVote = 1
)

type Version added in v1.3.8

type Version string

Version represents the version of the cluster

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL