Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPayloadObject(apiVer string, payloadObject map[string]interface{}, objectType string, ...) (int, error)
- func IsAssociation(fl validator.FieldLevel) bool
- func IsISO8601Date(fl validator.FieldLevel) bool
- func IsOptional(fl validator.FieldLevel) bool
- func IsSliceOrArray(v interface{}) bool
- func MiddlewareFunc(next echo.HandlerFunc) echo.HandlerFunc
- func ParseStruct(tagName string, v reflect.Value, tag reflect.StructTag, ...)
- func PayloadCheck(c echo.Context, checkAssociation bool, objectType string, ...) (int, error)
- func ResponseStatus200(c echo.Context, response v0.Response) error
- func ResponseStatus201(c echo.Context, response v0.Response) error
- func ResponseStatus202(c echo.Context, response v0.Response) error
- func ResponseStatus400(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
- func ResponseStatus401(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
- func ResponseStatus403(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
- func ResponseStatus404(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
- func ResponseStatus409(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
- func ResponseStatus500(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
- func ResponseStatusErr(id int, c echo.Context, params *v0.PageRequestParams, error error, ...) error
- func ResponseStatusExpected(id int, c echo.Context, response v0.Response) error
- func Translate(tagName string, v reflect.Value, tag reflect.StructTag)
- func ValidateBoundData(c echo.Context, obj interface{}, objectType string) (int, error)
- func ValidateObj(c echo.Context, obj interface{}, missingRequiredFields *[]string) (int, error)
- type CustomContext
- type CustomValidator
- type FieldsByTag
- type VersionObject
Constants ¶
const ( QueryParamPage = "page" QueryParamSize = "size" DefaultParamSizeValue = 50 ErrMsgQueryParamInvalidPageValue = "Query parameter is not a valid integer value: " + QueryParamPage ErrMsgQueryParamInvalidSizeValue = "Query parameter is not a valid integer value: " + QueryParamSize ErrTokenIsNotProvided = "OAuth token is not provided" AuthorizationKey = "Authorization" BearerKey = "Bearer " )
const ( REQUIRED = "required" OPTIONAL = "optional" OPTIONAL_ASSOCIATION = "optional,association" )
const (
TagNameValidate = "validate"
)
const (
V0 = "v0"
)
Variables ¶
var AttachedObjectReferenceTaggedFields = make(map[string]*FieldsByTag)
var AwsAccountTaggedFields = make(map[string]*FieldsByTag)
var AwsEksKubernetesRuntimeDefinitionTaggedFields = make(map[string]*FieldsByTag)
var AwsEksKubernetesRuntimeInstanceTaggedFields = make(map[string]*FieldsByTag)
var AwsObjectStorageBucketDefinitionTaggedFields = make(map[string]*FieldsByTag)
var AwsObjectStorageBucketInstanceTaggedFields = make(map[string]*FieldsByTag)
var AwsRelationalDatabaseDefinitionTaggedFields = make(map[string]*FieldsByTag)
var AwsRelationalDatabaseInstanceTaggedFields = make(map[string]*FieldsByTag)
var ControlPlaneComponentTaggedFields = make(map[string]*FieldsByTag)
var ControlPlaneDefinitionTaggedFields = make(map[string]*FieldsByTag)
var ControlPlaneInstanceTaggedFields = make(map[string]*FieldsByTag)
var DefinitionTaggedFields = make(map[string]*FieldsByTag)
var DomainNameDefinitionTaggedFields = make(map[string]*FieldsByTag)
var DomainNameInstanceTaggedFields = make(map[string]*FieldsByTag)
var GatewayDefinitionTaggedFields = make(map[string]*FieldsByTag)
var GatewayHttpPortTaggedFields = make(map[string]*FieldsByTag)
var GatewayInstanceTaggedFields = make(map[string]*FieldsByTag)
var GatewayTcpPortTaggedFields = make(map[string]*FieldsByTag)
var HelmWorkloadDefinitionTaggedFields = make(map[string]*FieldsByTag)
var HelmWorkloadInstanceTaggedFields = make(map[string]*FieldsByTag)
var InstanceTaggedFields = make(map[string]*FieldsByTag)
var KubernetesRuntimeDefinitionTaggedFields = make(map[string]*FieldsByTag)
var KubernetesRuntimeInstanceTaggedFields = make(map[string]*FieldsByTag)
var LogBackendTaggedFields = make(map[string]*FieldsByTag)
var LogStorageDefinitionTaggedFields = make(map[string]*FieldsByTag)
var LogStorageInstanceTaggedFields = make(map[string]*FieldsByTag)
var LoggingDefinitionTaggedFields = make(map[string]*FieldsByTag)
var LoggingInstanceTaggedFields = make(map[string]*FieldsByTag)
var MetricsDefinitionTaggedFields = make(map[string]*FieldsByTag)
var MetricsInstanceTaggedFields = make(map[string]*FieldsByTag)
var ObjectTaggedFields = make(map[VersionObject]*FieldsByTag)
var ObservabilityDashboardDefinitionTaggedFields = make(map[string]*FieldsByTag)
var ObservabilityDashboardInstanceTaggedFields = make(map[string]*FieldsByTag)
var ObservabilityStackDefinitionTaggedFields = make(map[string]*FieldsByTag)
var ObservabilityStackInstanceTaggedFields = make(map[string]*FieldsByTag)
var ProfileTaggedFields = make(map[string]*FieldsByTag)
var SecretDefinitionTaggedFields = make(map[string]*FieldsByTag)
var SecretInstanceTaggedFields = make(map[string]*FieldsByTag)
var TerraformDefinitionTaggedFields = make(map[string]*FieldsByTag)
var TerraformInstanceTaggedFields = make(map[string]*FieldsByTag)
var TierTaggedFields = make(map[string]*FieldsByTag)
var Versions = make(map[int]string)
var WorkloadDefinitionTaggedFields = make(map[string]*FieldsByTag)
var WorkloadEventTaggedFields = make(map[string]*FieldsByTag)
var WorkloadInstanceTaggedFields = make(map[string]*FieldsByTag)
var WorkloadResourceDefinitionTaggedFields = make(map[string]*FieldsByTag)
var WorkloadResourceInstanceTaggedFields = make(map[string]*FieldsByTag)
Functions ¶
func CheckPayloadObject ¶
func CheckPayloadObject(apiVer string, payloadObject map[string]interface{}, objectType string, objectStruct interface{}, providedGORMModelFields *[]string, providedAssociationsFields *[]string, unsupportedFields *[]string) (int, error)
CheckPayloadObject analyzes payload using Object model tags and returns providedGORMModelFields, providedAssociationsFields, unsupportedFields for further decision making
func IsAssociation ¶
func IsAssociation(fl validator.FieldLevel) bool
func IsISO8601Date ¶
func IsISO8601Date(fl validator.FieldLevel) bool
IsISO8601Date function to check parameter pattern for valid ISO8601 Date
func IsOptional ¶
func IsOptional(fl validator.FieldLevel) bool
func IsSliceOrArray ¶
func IsSliceOrArray(v interface{}) bool
func MiddlewareFunc ¶
func MiddlewareFunc(next echo.HandlerFunc) echo.HandlerFunc
MiddlewareFunc is a potential replacement for PayloadCheck in the future
func ParseStruct ¶
func ParseStruct( tagName string, v reflect.Value, tag reflect.StructTag, fn func(string, reflect.Value, reflect.StructTag), tf map[string]*FieldsByTag, )
ParseStruct parses structure's fields into respective Required, Optional and OptionalAssociations arrays
func PayloadCheck ¶
func PayloadCheck(c echo.Context, checkAssociation bool, objectType string, objectStruct interface{}) (int, error)
PayloadCheck parses JSON request body into key value pairs to perform validations such as: - check for empty JSON object - check for GORM Model fields in the payload - check for optional associations fields in they payload if checkAssociation parameter is true - check for unsupported fields in the payload and returns an error code and error message if any of the conditions above are met
func ResponseStatus200 ¶
func ResponseStatus201 ¶
func ResponseStatus202 ¶
func ResponseStatus400 ¶
func ResponseStatus400(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
func ResponseStatus401 ¶
func ResponseStatus401(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
func ResponseStatus403 ¶ added in v0.4.0
func ResponseStatus403(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
func ResponseStatus404 ¶
func ResponseStatus404(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
func ResponseStatus409 ¶
func ResponseStatus409(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
func ResponseStatus500 ¶
func ResponseStatus500(c echo.Context, params *v0.PageRequestParams, error error, objectType string) error
func ResponseStatusErr ¶
func ResponseStatusExpected ¶
func ValidateBoundData ¶
func ValidateObj ¶
Types ¶
type CustomContext ¶
type CustomContext struct {
echo.Context
}
func (*CustomContext) GetBearerToken ¶
func (c *CustomContext) GetBearerToken() (token string, err error)
GetBearerToken extracts the OAuth token from Authorization header.
func (*CustomContext) GetPaginationParams ¶
func (c *CustomContext) GetPaginationParams() (params v0.PageRequestParams, err error)
GetPaginationParams parses pagination query parameters into PageRequestParams.
type CustomValidator ¶
type CustomValidator struct {
Validator *validator.Validate
}
func (*CustomValidator) Validate ¶
func (cv *CustomValidator) Validate(i interface{}) error