v0

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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 "
)
View Source
const (
	REQUIRED             = "required"
	OPTIONAL             = "optional"
	OPTIONAL_ASSOCIATION = "optional,association"
)
View Source
const (
	TagNameValidate = "validate"
)
View Source
const (
	V0 = "v0"
)

Variables

View Source
var AttachedObjectReferenceTaggedFields = make(map[string]*FieldsByTag)
View Source
var AwsAccountTaggedFields = make(map[string]*FieldsByTag)
View Source
var AwsEksKubernetesRuntimeDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var AwsEksKubernetesRuntimeInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var AwsObjectStorageBucketDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var AwsObjectStorageBucketInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var AwsRelationalDatabaseDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var AwsRelationalDatabaseInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var ControlPlaneComponentTaggedFields = make(map[string]*FieldsByTag)
View Source
var ControlPlaneDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var ControlPlaneInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var DefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var DomainNameDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var DomainNameInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var GatewayDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var GatewayHttpPortTaggedFields = make(map[string]*FieldsByTag)
View Source
var GatewayInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var GatewayTcpPortTaggedFields = make(map[string]*FieldsByTag)
View Source
var HelmWorkloadDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var HelmWorkloadInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var InstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var KubernetesRuntimeDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var KubernetesRuntimeInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var LogBackendTaggedFields = make(map[string]*FieldsByTag)
View Source
var LogStorageDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var LogStorageInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var LoggingDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var LoggingInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var MetricsDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var MetricsInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var ObjectTaggedFields = make(map[VersionObject]*FieldsByTag)
View Source
var ObservabilityDashboardDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var ObservabilityDashboardInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var ObservabilityStackDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var ObservabilityStackInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var ProfileTaggedFields = make(map[string]*FieldsByTag)
View Source
var SecretDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var SecretInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var TerraformDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var TerraformInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var TierTaggedFields = make(map[string]*FieldsByTag)
View Source
var Versions = make(map[int]string)
View Source
var WorkloadDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
var WorkloadEventTaggedFields = make(map[string]*FieldsByTag)
View Source
var WorkloadInstanceTaggedFields = make(map[string]*FieldsByTag)
View Source
var WorkloadResourceDefinitionTaggedFields = make(map[string]*FieldsByTag)
View Source
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 ResponseStatus200(c echo.Context, response v0.Response) error

func ResponseStatus201

func ResponseStatus201(c echo.Context, response v0.Response) error

func ResponseStatus202

func ResponseStatus202(c echo.Context, response v0.Response) error

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 ResponseStatusErr(id int, c echo.Context, params *v0.PageRequestParams, error error, objectType string) error

func ResponseStatusExpected

func ResponseStatusExpected(id int, c echo.Context, response v0.Response) error

func Translate

func Translate(tagName string, v reflect.Value, tag reflect.StructTag)

Translate performs translation of object v if needed

func ValidateBoundData

func ValidateBoundData(c echo.Context, obj interface{}, objectType string) (int, error)

func ValidateObj

func ValidateObj(c echo.Context, obj interface{}, missingRequiredFields *[]string) (int, error)

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

type FieldsByTag

type FieldsByTag struct {
	TagName              string
	Required             []string
	Optional             []string
	OptionalAssociations []string
}

type VersionObject

type VersionObject struct {
	Version string `json:"Version" validate:"required"`
	Object  string `json:"Object" validate:"required"`
}

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

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