mirror of https://github.com/vernonkeenan/lib
354 lines
8.3 KiB
Go
354 lines
8.3 KiB
Go
|
|
// Code generated by go-swagger; DO NOT EDIT.
|
||
|
|
|
||
|
|
// (c) 2012-2020 by Taxnexus, Inc.
|
||
|
|
// All rights reserved worldwide.
|
||
|
|
// Proprietary product; unlicensed use is not allowed
|
||
|
|
|
||
|
|
package members_models
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
stderrors "errors"
|
||
|
|
|
||
|
|
"github.com/go-openapi/errors"
|
||
|
|
"github.com/go-openapi/strfmt"
|
||
|
|
"github.com/go-openapi/swag/jsonutils"
|
||
|
|
"github.com/go-openapi/swag/typeutils"
|
||
|
|
"github.com/go-openapi/validate"
|
||
|
|
)
|
||
|
|
|
||
|
|
// EffectiveEntitlement effective entitlement
|
||
|
|
//
|
||
|
|
// swagger:model EffectiveEntitlement
|
||
|
|
type EffectiveEntitlement struct {
|
||
|
|
|
||
|
|
// effect
|
||
|
|
// Required: true
|
||
|
|
// Enum: ["allow","deny"]
|
||
|
|
Effect *string `json:"effect"`
|
||
|
|
|
||
|
|
// effective from
|
||
|
|
// Format: date-time
|
||
|
|
EffectiveFrom *strfmt.DateTime `json:"effectiveFrom,omitempty"`
|
||
|
|
|
||
|
|
// effective until
|
||
|
|
// Format: date-time
|
||
|
|
EffectiveUntil *strfmt.DateTime `json:"effectiveUntil,omitempty"`
|
||
|
|
|
||
|
|
// evaluated at
|
||
|
|
// Required: true
|
||
|
|
// Format: date-time
|
||
|
|
EvaluatedAt *strfmt.DateTime `json:"evaluatedAt"`
|
||
|
|
|
||
|
|
// limit
|
||
|
|
// Required: true
|
||
|
|
Limit *DescriptiveLimit `json:"limit"`
|
||
|
|
|
||
|
|
// provenance
|
||
|
|
// Required: true
|
||
|
|
// Enum: ["user_entitlement","tenant_entitlement","subscription_plan"]
|
||
|
|
Provenance *string `json:"provenance"`
|
||
|
|
|
||
|
|
// service Id
|
||
|
|
// Required: true
|
||
|
|
// Format: uuid
|
||
|
|
ServiceID *strfmt.UUID `json:"serviceId"`
|
||
|
|
|
||
|
|
// tenant Id
|
||
|
|
// Required: true
|
||
|
|
// Format: uuid
|
||
|
|
TenantID *strfmt.UUID `json:"tenantId"`
|
||
|
|
|
||
|
|
// user Id
|
||
|
|
// Format: uuid
|
||
|
|
UserID *strfmt.UUID `json:"userId,omitempty"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// Validate validates this effective entitlement
|
||
|
|
func (m *EffectiveEntitlement) Validate(formats strfmt.Registry) error {
|
||
|
|
var res []error
|
||
|
|
|
||
|
|
if err := m.validateEffect(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateEffectiveFrom(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateEffectiveUntil(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateEvaluatedAt(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateLimit(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateProvenance(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateServiceID(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateTenantID(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateUserID(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if len(res) > 0 {
|
||
|
|
return errors.CompositeValidationError(res...)
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
var effectiveEntitlementTypeEffectPropEnum []any
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
var res []string
|
||
|
|
if err := json.Unmarshal([]byte(`["allow","deny"]`), &res); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
for _, v := range res {
|
||
|
|
effectiveEntitlementTypeEffectPropEnum = append(effectiveEntitlementTypeEffectPropEnum, v)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const (
|
||
|
|
|
||
|
|
// EffectiveEntitlementEffectAllow captures enum value "allow"
|
||
|
|
EffectiveEntitlementEffectAllow string = "allow"
|
||
|
|
|
||
|
|
// EffectiveEntitlementEffectDeny captures enum value "deny"
|
||
|
|
EffectiveEntitlementEffectDeny string = "deny"
|
||
|
|
)
|
||
|
|
|
||
|
|
// prop value enum
|
||
|
|
func (m *EffectiveEntitlement) validateEffectEnum(path, location string, value string) error {
|
||
|
|
if err := validate.EnumCase(path, location, value, effectiveEntitlementTypeEffectPropEnum, true); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateEffect(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("effect", "body", m.Effect); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// value enum
|
||
|
|
if err := m.validateEffectEnum("effect", "body", *m.Effect); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateEffectiveFrom(formats strfmt.Registry) error {
|
||
|
|
if typeutils.IsZero(m.EffectiveFrom) { // not required
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.FormatOf("effectiveFrom", "body", "date-time", m.EffectiveFrom.String(), formats); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateEffectiveUntil(formats strfmt.Registry) error {
|
||
|
|
if typeutils.IsZero(m.EffectiveUntil) { // not required
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.FormatOf("effectiveUntil", "body", "date-time", m.EffectiveUntil.String(), formats); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateEvaluatedAt(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("evaluatedAt", "body", m.EvaluatedAt); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.FormatOf("evaluatedAt", "body", "date-time", m.EvaluatedAt.String(), formats); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateLimit(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("limit", "body", m.Limit); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if m.Limit != nil {
|
||
|
|
if err := m.Limit.Validate(formats); err != nil {
|
||
|
|
ve := new(errors.Validation)
|
||
|
|
if stderrors.As(err, &ve) {
|
||
|
|
return ve.ValidateName("limit")
|
||
|
|
}
|
||
|
|
ce := new(errors.CompositeError)
|
||
|
|
if stderrors.As(err, &ce) {
|
||
|
|
return ce.ValidateName("limit")
|
||
|
|
}
|
||
|
|
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
var effectiveEntitlementTypeProvenancePropEnum []any
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
var res []string
|
||
|
|
if err := json.Unmarshal([]byte(`["user_entitlement","tenant_entitlement","subscription_plan"]`), &res); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
for _, v := range res {
|
||
|
|
effectiveEntitlementTypeProvenancePropEnum = append(effectiveEntitlementTypeProvenancePropEnum, v)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const (
|
||
|
|
|
||
|
|
// EffectiveEntitlementProvenanceUserEntitlement captures enum value "user_entitlement"
|
||
|
|
EffectiveEntitlementProvenanceUserEntitlement string = "user_entitlement"
|
||
|
|
|
||
|
|
// EffectiveEntitlementProvenanceTenantEntitlement captures enum value "tenant_entitlement"
|
||
|
|
EffectiveEntitlementProvenanceTenantEntitlement string = "tenant_entitlement"
|
||
|
|
|
||
|
|
// EffectiveEntitlementProvenanceSubscriptionPlan captures enum value "subscription_plan"
|
||
|
|
EffectiveEntitlementProvenanceSubscriptionPlan string = "subscription_plan"
|
||
|
|
)
|
||
|
|
|
||
|
|
// prop value enum
|
||
|
|
func (m *EffectiveEntitlement) validateProvenanceEnum(path, location string, value string) error {
|
||
|
|
if err := validate.EnumCase(path, location, value, effectiveEntitlementTypeProvenancePropEnum, true); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateProvenance(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("provenance", "body", m.Provenance); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// value enum
|
||
|
|
if err := m.validateProvenanceEnum("provenance", "body", *m.Provenance); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateServiceID(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("serviceId", "body", m.ServiceID); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.FormatOf("serviceId", "body", "uuid", m.ServiceID.String(), formats); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateTenantID(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("tenantId", "body", m.TenantID); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.FormatOf("tenantId", "body", "uuid", m.TenantID.String(), formats); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) validateUserID(formats strfmt.Registry) error {
|
||
|
|
if typeutils.IsZero(m.UserID) { // not required
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.FormatOf("userId", "body", "uuid", m.UserID.String(), formats); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// ContextValidate validate this effective entitlement based on the context it is used
|
||
|
|
func (m *EffectiveEntitlement) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
var res []error
|
||
|
|
|
||
|
|
if err := m.contextValidateLimit(ctx, formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if len(res) > 0 {
|
||
|
|
return errors.CompositeValidationError(res...)
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *EffectiveEntitlement) contextValidateLimit(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if m.Limit != nil {
|
||
|
|
|
||
|
|
if err := m.Limit.ContextValidate(ctx, formats); err != nil {
|
||
|
|
ve := new(errors.Validation)
|
||
|
|
if stderrors.As(err, &ve) {
|
||
|
|
return ve.ValidateName("limit")
|
||
|
|
}
|
||
|
|
ce := new(errors.CompositeError)
|
||
|
|
if stderrors.As(err, &ce) {
|
||
|
|
return ce.ValidateName("limit")
|
||
|
|
}
|
||
|
|
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// MarshalBinary interface implementation
|
||
|
|
func (m *EffectiveEntitlement) MarshalBinary() ([]byte, error) {
|
||
|
|
if m == nil {
|
||
|
|
return nil, nil
|
||
|
|
}
|
||
|
|
return jsonutils.WriteJSON(m)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UnmarshalBinary interface implementation
|
||
|
|
func (m *EffectiveEntitlement) UnmarshalBinary(b []byte) error {
|
||
|
|
var res EffectiveEntitlement
|
||
|
|
if err := jsonutils.ReadJSON(b, &res); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
*m = res
|
||
|
|
return nil
|
||
|
|
}
|