Documentation
¶
Index ¶
- Variables
- func Authentication(authenticator authnapi.Authenticator) func(middleware.Handler) middleware.Handler
- func ExtractMapField(data map[string]interface{}, key string, opts ...ExtractOption) (map[string]interface{}, error)
- func ExtractStringField(data map[string]interface{}, key string, opts ...ExtractOption) (string, error)
- func GetFromContext[V any, I any](i I) func(context.Context) (*V, error)
- func GetSchemaFromCache(cacheKey string) (string, error)
- func LoadCommonResourceDataSchema(resourceType string, baseSchemaDir string) (string, error)
- func LoadConfigFile(resourceDir string, resourceType string) (struct{ ... }, error)
- func LoadFromCache(resourceType string) ([]string, error)
- func LoadFromFilesystem(resourceType string) ([]string, error)
- func LoadResourceSchema(resourceType string, reporterType string, dir string) (string, bool, error)
- func LoadSchemaCacheFromJSON(filePath string) error
- func LoadValidReporters(resourceType string) ([]string, error)
- func MarshalProtoToJSON(msg proto.Message) ([]byte, error)
- func NormalizeResourceType(resourceType string) string
- func Pagination(next http.Handler) http.Handler
- func PreloadAllSchemas(resourceDir string) error
- func PreloadAllSchemasFromFilesystem(resourceDir string) error
- func RemoveNulls(m map[string]interface{}) map[string]interface{}
- func UnmarshalJSONToMap(data []byte) (map[string]interface{}, error)
- func ValidateCommonRepresentation(resourceType string, commonRepresentation map[string]interface{}) error
- func ValidateJSONSchema(schemaStr string, jsonData interface{}) error
- func ValidateReportResourceJSON(msg proto.Message) error
- func ValidateReporterRepresentation(resourceType string, reporterType string, ...) error
- func ValidateResourceReporterCombination(resourceType, reporterType string) error
- func Validation(validator protovalidate.Validator) middleware.Middleware
- type ExtractOption
- type PagedResponse
- type PagedResponseMetadata
- type PaginationRequest
Constants ¶
This section is empty.
Variables ¶
var ( IdentityRequestKey = &contextKey{"authnapi.Identity"} GetIdentity = GetFromContext[authnapi.Identity](IdentityRequestKey) )
var ( PaginationRequestKey = &contextKey{"paginationRequest"} GetPaginationRequest = GetFromContext[PaginationRequest](PaginationRequestKey) )
var (
ErrWrongContext = errors.Unauthorized(reason, "Wrong context for middleware")
)
var SchemaCache sync.Map
Functions ¶
func Authentication ¶
func Authentication(authenticator authnapi.Authenticator) func(middleware.Handler) middleware.Handler
func ExtractMapField ¶
func ExtractMapField(data map[string]interface{}, key string, opts ...ExtractOption) (map[string]interface{}, error)
Extracts a Map Field from another map
func ExtractStringField ¶
func ExtractStringField(data map[string]interface{}, key string, opts ...ExtractOption) (string, error)
Extracts a String Field from a map
func GetSchemaFromCache ¶
Retrieves schema from cache
func LoadCommonResourceDataSchema ¶
Load Common Resource Data Schema
func LoadConfigFile ¶
func LoadFromCache ¶
func LoadFromFilesystem ¶
LoadValidReporters Takes the resource_type from the provided config.yaml and compares it to the defined reporter_types
func LoadResourceSchema ¶
LoadResourceSchema finds the resources schema based on the directory structure of data/resources
func LoadSchemaCacheFromJSON ¶
LoadSchemaCacheFromJSON loads schema cache from a JSON file
func LoadValidReporters ¶
LoadValidReporters retrieves valid reporters for a given resource type. It either loads from the cache (JSON-based) or the filesystem (YAML-based).
func NormalizeResourceType ¶
func Pagination ¶
Pagination is HTTP middleware that extracts pagination parameters from query string and makes them available in the request context.
func PreloadAllSchemas ¶
func RemoveNulls ¶
RemoveNulls recursively creates a new map with keys removed where the value is null. This function is safe for concurrent use as it does not modify the input map.
func UnmarshalJSONToMap ¶
func ValidateCommonRepresentation ¶
func ValidateCommonRepresentation(resourceType string, commonRepresentation map[string]interface{}) error
ValidateCommonRepresentation Validates the "common" field in ResourceRepresentations using a predefined schema.
func ValidateJSONSchema ¶
func ValidateReporterRepresentation ¶
func ValidateReporterRepresentation(resourceType string, reporterType string, reporterRepresentation map[string]interface{}) error
Validates the reporter-specific representation against its schema based on resourceType and reporterType.
func Validation ¶
func Validation(validator protovalidate.Validator) middleware.Middleware
Types ¶
type ExtractOption ¶
type ExtractOption func(*extractConfig)
ExtractOption configures extraction behavior
func ValidateFieldExists ¶
func ValidateFieldExists() ExtractOption
ValidateFieldExists makes the extraction fail if the field doesn't exist
type PagedResponse ¶
type PagedResponse[R any] struct { PagedResponseMetadata Items []R `json:"items"` }
PagedResponse represents a paginated response containing items and metadata.
type PagedResponseMetadata ¶
type PagedResponseMetadata struct {
Page int `json:"page"`
Size int `json:"size"`
Total int64 `json:"total"`
}
PagedResponseMetadata contains metadata for paginated responses including page number, size, and total count.