Documentation ¶
Index ¶
- Variables
- func ApplyModelFilters(ctx context.Context, q *sqlchemy.SQuery, data *jsonutils.JSONDict, ...) (*sqlchemy.SQuery, error)
- func IsModelNotFoundError(err error) bool
- type ActorIPv4Prefix
- type ActorJoinedBy
- type ErrType
- type IValidateActor
- type IValidator
- type IValidatorBase
- type ModelFilterOptions
- type ValidateError
- type Validator
- type ValidatorBool
- type ValidatorByActor
- type ValidatorCertKey
- type ValidatorCertificate
- type ValidatorDomainName
- type ValidatorFunc
- type ValidatorHostPort
- type ValidatorIPv4Addr
- type ValidatorIPv4Prefix
- type ValidatorIntChoices
- type ValidatorModelIdOrName
- func (v *ValidatorModelIdOrName) AllowEmpty(b bool) *ValidatorModelIdOrName
- func (v *ValidatorModelIdOrName) AllowPendingDeleted(b bool) *ValidatorModelIdOrName
- func (v *ValidatorModelIdOrName) GetDomainId() string
- func (v *ValidatorModelIdOrName) GetDomainName() string
- func (v *ValidatorModelIdOrName) GetProjectDomain() string
- func (v *ValidatorModelIdOrName) GetProjectDomainId() string
- func (v *ValidatorModelIdOrName) GetProjectId() string
- func (v *ValidatorModelIdOrName) GetProjectName() string
- func (v *ValidatorModelIdOrName) GetTenantId() string
- func (v *ValidatorModelIdOrName) GetTenantName() string
- func (v *ValidatorModelIdOrName) GetUserId() string
- func (v *ValidatorModelIdOrName) GetUserName() string
- func (v *ValidatorModelIdOrName) ModelIdKey(modelIdKey string) *ValidatorModelIdOrName
- func (v *ValidatorModelIdOrName) QueryFilter(ctx context.Context, q *sqlchemy.SQuery, data *jsonutils.JSONDict) (*sqlchemy.SQuery, error)
- func (v *ValidatorModelIdOrName) Validate(ctx context.Context, data *jsonutils.JSONDict) error
- type ValidatorPEM
- type ValidatorPrivateKey
- type ValidatorRange
- type ValidatorRegexp
- type ValidatorSSHKey
- type ValidatorStringChoices
- type ValidatorStringLen
- type ValidatorStringMultiChoices
- func (v *ValidatorStringMultiChoices) Default(s string) IValidator
- func (v *ValidatorStringMultiChoices) KeepDup(b bool) *ValidatorStringMultiChoices
- func (v *ValidatorStringMultiChoices) Sep(s string) *ValidatorStringMultiChoices
- func (v *ValidatorStringMultiChoices) Validate(ctx context.Context, data *jsonutils.JSONDict) error
- type ValidatorStruct
- type ValidatorURLPath
Constants ¶
This section is empty.
Variables ¶
View Source
var ValidateModel = func(ctx context.Context, userCred mcclient.TokenCredential, manager db.IStandaloneModelManager, id *string) (db.IModel, error) { if len(*id) == 0 { return nil, httperrors.NewMissingParameterError(manager.Keyword() + "_id") } model, err := manager.FetchByIdOrName(ctx, userCred, *id) if err != nil { if errors.Cause(err) == sql.ErrNoRows { return nil, httperrors.NewResourceNotFoundError2(manager.Keyword(), *id) } if errors.Cause(err) == sqlchemy.ErrDuplicateEntry { return nil, httperrors.NewDuplicateResourceError(manager.Keyword(), *id) } return nil, httperrors.NewGeneralError(err) } *id = model.GetId() return model, nil }
Functions ¶
func ApplyModelFilters ¶
func IsModelNotFoundError ¶
Types ¶
type ActorIPv4Prefix ¶
type ActorIPv4Prefix struct {
// contains filtered or unexported fields
}
func NewActorIPv4Prefix ¶
func NewActorIPv4Prefix() *ActorIPv4Prefix
func (*ActorIPv4Prefix) Validate ¶
func (actor *ActorIPv4Prefix) Validate(val interface{}) (bool, error)
type ActorJoinedBy ¶
type ActorJoinedBy struct {
// contains filtered or unexported fields
}
func NewActorJoinedBy ¶
func NewActorJoinedBy(sep string, subActor IValidateActor) *ActorJoinedBy
func (*ActorJoinedBy) IgnoreEmpty ¶
func (actor *ActorJoinedBy) IgnoreEmpty(b bool) *ActorJoinedBy
func (*ActorJoinedBy) Set ¶
func (actor *ActorJoinedBy) Set(data *jsonutils.JSONDict, key string, val interface{})
func (*ActorJoinedBy) TrimSpace ¶
func (actor *ActorJoinedBy) TrimSpace(b bool) *ActorJoinedBy
func (*ActorJoinedBy) Validate ¶
func (actor *ActorJoinedBy) Validate(val interface{}) (bool, error)
type IValidateActor ¶
type IValidator ¶
type IValidator interface { IValidatorBase Optional(bool) IValidator // contains filtered or unexported methods }
type IValidatorBase ¶
type ModelFilterOptions ¶
type ModelFilterOptions struct { Key string ModelKeyword string OwnerId mcclient.IIdentityProvider }
type ValidateError ¶
func (*ValidateError) Cause ¶
func (ve *ValidateError) Cause() error
func (*ValidateError) Error ¶
func (ve *ValidateError) Error() string
type Validator ¶
type Validator struct { Key string // contains filtered or unexported fields }
func (*Validator) Default ¶
func (v *Validator) Default(defaultVal interface{}) IValidator
func (*Validator) Optional ¶
func (v *Validator) Optional(optional bool) IValidator
func (*Validator) SetParent ¶
func (v *Validator) SetParent(parent IValidator) IValidator
type ValidatorBool ¶
func NewBoolValidator ¶
func NewBoolValidator(key string) *ValidatorBool
func (*ValidatorBool) Default ¶
func (v *ValidatorBool) Default(i bool) IValidator
type ValidatorByActor ¶
type ValidatorByActor struct { Validator Value interface{} // contains filtered or unexported fields }
func NewValidatorByActor ¶
func NewValidatorByActor(key string, actor IValidateActor) *ValidatorByActor
func (*ValidatorByActor) Default ¶
func (v *ValidatorByActor) Default(val interface{}) IValidator
type ValidatorCertKey ¶
type ValidatorCertKey struct { *ValidatorCertificate *ValidatorPrivateKey // contains filtered or unexported fields }
func NewCertKeyValidator ¶
func NewCertKeyValidator(cert, key string) *ValidatorCertKey
func (*ValidatorCertKey) UpdateCertKeyInfo ¶
type ValidatorCertificate ¶
type ValidatorCertificate struct { ValidatorPEM Certificates []*x509.Certificate }
func NewCertificateValidator ¶
func NewCertificateValidator(key string) *ValidatorCertificate
func (*ValidatorCertificate) FingerprintSha256 ¶
func (v *ValidatorCertificate) FingerprintSha256() []byte
func (*ValidatorCertificate) FingerprintSha256String ¶
func (v *ValidatorCertificate) FingerprintSha256String() string
func (*ValidatorCertificate) PublicKeyBitLen ¶
func (v *ValidatorCertificate) PublicKeyBitLen() int
type ValidatorDomainName ¶
type ValidatorDomainName struct {
ValidatorRegexp
}
func NewDomainNameValidator ¶
func NewDomainNameValidator(key string) *ValidatorDomainName
type ValidatorHostPort ¶
type ValidatorHostPort struct { ValidatorRegexp Domain string Port int Value string // contains filtered or unexported fields }
func NewHostPortValidator ¶
func NewHostPortValidator(key string) *ValidatorHostPort
func (*ValidatorHostPort) OptionalPort ¶
func (v *ValidatorHostPort) OptionalPort(optionalPort bool) *ValidatorHostPort
type ValidatorIPv4Addr ¶
func NewIPv4AddrValidator ¶
func NewIPv4AddrValidator(key string) *ValidatorIPv4Addr
type ValidatorIPv4Prefix ¶
type ValidatorIPv4Prefix struct { Validator Value netutils.IPV4Prefix }
func NewIPv4PrefixValidator ¶
func NewIPv4PrefixValidator(key string) *ValidatorIPv4Prefix
type ValidatorIntChoices ¶
func NewIntChoicesValidator ¶
func NewIntChoicesValidator(key string, choices []int64) *ValidatorIntChoices
func (*ValidatorIntChoices) Default ¶
func (v *ValidatorIntChoices) Default(i int64) IValidator
type ValidatorModelIdOrName ¶
type ValidatorModelIdOrName struct { Validator ModelKeyword string OwnerId mcclient.IIdentityProvider ModelManager db.IModelManager Model db.IModel // contains filtered or unexported fields }
func NewModelIdOrNameValidator ¶
func NewModelIdOrNameValidator(key string, modelKeyword string, ownerId mcclient.IIdentityProvider) *ValidatorModelIdOrName
func (*ValidatorModelIdOrName) AllowEmpty ¶
func (v *ValidatorModelIdOrName) AllowEmpty(b bool) *ValidatorModelIdOrName
func (*ValidatorModelIdOrName) AllowPendingDeleted ¶
func (v *ValidatorModelIdOrName) AllowPendingDeleted(b bool) *ValidatorModelIdOrName
AllowPendingDeleted allows the to-be-validated id or name to be of a pending deleted model
func (*ValidatorModelIdOrName) GetDomainId ¶
func (v *ValidatorModelIdOrName) GetDomainId() string
func (*ValidatorModelIdOrName) GetDomainName ¶
func (v *ValidatorModelIdOrName) GetDomainName() string
func (*ValidatorModelIdOrName) GetProjectDomain ¶
func (v *ValidatorModelIdOrName) GetProjectDomain() string
func (*ValidatorModelIdOrName) GetProjectDomainId ¶
func (v *ValidatorModelIdOrName) GetProjectDomainId() string
func (*ValidatorModelIdOrName) GetProjectId ¶
func (v *ValidatorModelIdOrName) GetProjectId() string
func (*ValidatorModelIdOrName) GetProjectName ¶
func (v *ValidatorModelIdOrName) GetProjectName() string
func (*ValidatorModelIdOrName) GetTenantId ¶
func (v *ValidatorModelIdOrName) GetTenantId() string
func (*ValidatorModelIdOrName) GetTenantName ¶
func (v *ValidatorModelIdOrName) GetTenantName() string
func (*ValidatorModelIdOrName) GetUserId ¶
func (v *ValidatorModelIdOrName) GetUserId() string
func (*ValidatorModelIdOrName) GetUserName ¶
func (v *ValidatorModelIdOrName) GetUserName() string
func (*ValidatorModelIdOrName) ModelIdKey ¶
func (v *ValidatorModelIdOrName) ModelIdKey(modelIdKey string) *ValidatorModelIdOrName
func (*ValidatorModelIdOrName) QueryFilter ¶
type ValidatorPEM ¶
func NewPEMValidator ¶
func NewPEMValidator(key string) *ValidatorPEM
type ValidatorPrivateKey ¶
type ValidatorPrivateKey struct { ValidatorPEM PrivateKey crypto.PrivateKey }
func NewPrivateKeyValidator ¶
func NewPrivateKeyValidator(key string) *ValidatorPrivateKey
func (*ValidatorPrivateKey) MatchCertificate ¶
func (v *ValidatorPrivateKey) MatchCertificate(cert *x509.Certificate) error
type ValidatorRange ¶
func NewNonNegativeValidator ¶
func NewNonNegativeValidator(key string) *ValidatorRange
func NewPortValidator ¶
func NewPortValidator(key string) *ValidatorRange
func NewRangeValidator ¶
func NewRangeValidator(key string, lower int64, upper int64) *ValidatorRange
func NewVlanIdValidator ¶
func NewVlanIdValidator(key string) *ValidatorRange
func (*ValidatorRange) Default ¶
func (v *ValidatorRange) Default(i int64) IValidator
type ValidatorRegexp ¶
type ValidatorRegexp struct { Validator Regexp *regexp.Regexp Value string // contains filtered or unexported fields }
func NewRegexpValidator ¶
func NewRegexpValidator(key string, regexp *regexp.Regexp) *ValidatorRegexp
func (*ValidatorRegexp) AllowEmpty ¶
func (v *ValidatorRegexp) AllowEmpty(allowEmpty bool) *ValidatorRegexp
type ValidatorSSHKey ¶
func NewSSHKeyValidator ¶
func NewSSHKeyValidator(key string) *ValidatorSSHKey
func (*ValidatorSSHKey) Default ¶
func (v *ValidatorSSHKey) Default(s string) IValidator
type ValidatorStringChoices ¶
func NewStringChoicesValidator ¶
func NewStringChoicesValidator(key string, choices choices.Choices) *ValidatorStringChoices
func (*ValidatorStringChoices) Default ¶
func (v *ValidatorStringChoices) Default(s string) IValidator
type ValidatorStringLen ¶
func NewMaxStringLenValidator ¶
func NewMaxStringLenValidator(key string, maxLen int) *ValidatorStringLen
func NewMinStringLenValidator ¶
func NewMinStringLenValidator(key string, minLen int) *ValidatorStringLen
func NewStringLenRangeValidator ¶
func NewStringLenRangeValidator(key string, minLen, maxLen int) *ValidatorStringLen
func NewStringNonEmptyValidator ¶
func NewStringNonEmptyValidator(key string) *ValidatorStringLen
func (*ValidatorStringLen) Default ¶
func (v *ValidatorStringLen) Default(s string) IValidator
type ValidatorStringMultiChoices ¶
type ValidatorStringMultiChoices struct { Validator Choices choices.Choices Value string // contains filtered or unexported fields }
func NewStringMultiChoicesValidator ¶
func NewStringMultiChoicesValidator(key string, choices choices.Choices) *ValidatorStringMultiChoices
func (*ValidatorStringMultiChoices) Default ¶
func (v *ValidatorStringMultiChoices) Default(s string) IValidator
func (*ValidatorStringMultiChoices) KeepDup ¶
func (v *ValidatorStringMultiChoices) KeepDup(b bool) *ValidatorStringMultiChoices
func (*ValidatorStringMultiChoices) Sep ¶
func (v *ValidatorStringMultiChoices) Sep(s string) *ValidatorStringMultiChoices
type ValidatorStruct ¶
type ValidatorStruct struct { Validator Value interface{} }
func NewStructValidator ¶
func NewStructValidator(key string, value interface{}) *ValidatorStruct
type ValidatorURLPath ¶
type ValidatorURLPath struct {
ValidatorRegexp
}
func NewURLPathValidator ¶
func NewURLPathValidator(key string) *ValidatorURLPath
Click to show internal directories.
Click to hide internal directories.