mirror of https://github.com/vernonkeenan/lib
645 lines
14 KiB
Go
645 lines
14 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"
|
|
|
|
"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"
|
|
)
|
|
|
|
// Entitlement entitlement
|
|
//
|
|
// swagger:model Entitlement
|
|
type Entitlement struct {
|
|
AuditFields
|
|
|
|
// effect
|
|
// Required: true
|
|
// Enum: ["allow","deny"]
|
|
Effect *string `json:"effect"`
|
|
|
|
// effective from
|
|
// Required: true
|
|
// Format: date-time
|
|
EffectiveFrom *strfmt.DateTime `json:"effectiveFrom"`
|
|
|
|
// effective until
|
|
// Format: date-time
|
|
EffectiveUntil *strfmt.DateTime `json:"effectiveUntil,omitempty"`
|
|
|
|
// limit period
|
|
// Enum: ["none","day","month","billing_period","lifetime"]
|
|
LimitPeriod *string `json:"limitPeriod,omitempty"`
|
|
|
|
// Exact decimal string matching SQL DECIMAL(20,6).
|
|
// Max Length: 21
|
|
// Min Length: 1
|
|
// Pattern: ^(0|[1-9][0-9]{0,13})(\.[0-9]{1,6})?$
|
|
LimitQuantity *string `json:"limitQuantity,omitempty"`
|
|
|
|
// revoked at
|
|
// Read Only: true
|
|
// Format: date-time
|
|
RevokedAt *strfmt.DateTime `json:"revokedAt,omitempty"`
|
|
|
|
// revoked by Id
|
|
// Read Only: true
|
|
// Format: uuid
|
|
RevokedByID *strfmt.UUID `json:"revokedById,omitempty"`
|
|
|
|
// service Id
|
|
// Required: true
|
|
// Format: uuid
|
|
ServiceID *strfmt.UUID `json:"serviceId"`
|
|
|
|
// source
|
|
// Required: true
|
|
// Enum: ["subscription","manual","trial","promotion"]
|
|
Source *string `json:"source"`
|
|
|
|
// status
|
|
// Required: true
|
|
// Enum: ["scheduled","active","revoked","expired"]
|
|
Status *string `json:"status"`
|
|
|
|
// subscription Id
|
|
// Format: uuid
|
|
SubscriptionID *strfmt.UUID `json:"subscriptionId,omitempty"`
|
|
|
|
// tenant Id
|
|
// Required: true
|
|
// Format: uuid
|
|
TenantID *strfmt.UUID `json:"tenantId"`
|
|
|
|
// unit
|
|
// Max Length: 40
|
|
Unit *string `json:"unit,omitempty"`
|
|
|
|
// Null means tenant-level; non-null must belong to the tenant.
|
|
// Format: uuid
|
|
UserID *strfmt.UUID `json:"userId,omitempty"`
|
|
}
|
|
|
|
// UnmarshalJSON unmarshals this object from a JSON structure
|
|
func (m *Entitlement) UnmarshalJSON(raw []byte) error {
|
|
// AO0
|
|
var aO0 AuditFields
|
|
if err := jsonutils.ReadJSON(raw, &aO0); err != nil {
|
|
return err
|
|
}
|
|
m.AuditFields = aO0
|
|
|
|
// AO1
|
|
var dataAO1 struct {
|
|
Effect *string `json:"effect"`
|
|
|
|
EffectiveFrom *strfmt.DateTime `json:"effectiveFrom"`
|
|
|
|
EffectiveUntil *strfmt.DateTime `json:"effectiveUntil,omitempty"`
|
|
|
|
LimitPeriod *string `json:"limitPeriod,omitempty"`
|
|
|
|
LimitQuantity *string `json:"limitQuantity,omitempty"`
|
|
|
|
RevokedAt *strfmt.DateTime `json:"revokedAt,omitempty"`
|
|
|
|
RevokedByID *strfmt.UUID `json:"revokedById,omitempty"`
|
|
|
|
ServiceID *strfmt.UUID `json:"serviceId"`
|
|
|
|
Source *string `json:"source"`
|
|
|
|
Status *string `json:"status"`
|
|
|
|
SubscriptionID *strfmt.UUID `json:"subscriptionId,omitempty"`
|
|
|
|
TenantID *strfmt.UUID `json:"tenantId"`
|
|
|
|
Unit *string `json:"unit,omitempty"`
|
|
|
|
UserID *strfmt.UUID `json:"userId,omitempty"`
|
|
}
|
|
if err := jsonutils.ReadJSON(raw, &dataAO1); err != nil {
|
|
return err
|
|
}
|
|
|
|
m.Effect = dataAO1.Effect
|
|
|
|
m.EffectiveFrom = dataAO1.EffectiveFrom
|
|
|
|
m.EffectiveUntil = dataAO1.EffectiveUntil
|
|
|
|
m.LimitPeriod = dataAO1.LimitPeriod
|
|
|
|
m.LimitQuantity = dataAO1.LimitQuantity
|
|
|
|
m.RevokedAt = dataAO1.RevokedAt
|
|
|
|
m.RevokedByID = dataAO1.RevokedByID
|
|
|
|
m.ServiceID = dataAO1.ServiceID
|
|
|
|
m.Source = dataAO1.Source
|
|
|
|
m.Status = dataAO1.Status
|
|
|
|
m.SubscriptionID = dataAO1.SubscriptionID
|
|
|
|
m.TenantID = dataAO1.TenantID
|
|
|
|
m.Unit = dataAO1.Unit
|
|
|
|
m.UserID = dataAO1.UserID
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON marshals this object to a JSON structure
|
|
func (m Entitlement) MarshalJSON() ([]byte, error) {
|
|
_parts := make([][]byte, 0, 2)
|
|
|
|
aO0, err := jsonutils.WriteJSON(m.AuditFields)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
_parts = append(_parts, aO0)
|
|
var dataAO1 struct {
|
|
Effect *string `json:"effect"`
|
|
|
|
EffectiveFrom *strfmt.DateTime `json:"effectiveFrom"`
|
|
|
|
EffectiveUntil *strfmt.DateTime `json:"effectiveUntil,omitempty"`
|
|
|
|
LimitPeriod *string `json:"limitPeriod,omitempty"`
|
|
|
|
LimitQuantity *string `json:"limitQuantity,omitempty"`
|
|
|
|
RevokedAt *strfmt.DateTime `json:"revokedAt,omitempty"`
|
|
|
|
RevokedByID *strfmt.UUID `json:"revokedById,omitempty"`
|
|
|
|
ServiceID *strfmt.UUID `json:"serviceId"`
|
|
|
|
Source *string `json:"source"`
|
|
|
|
Status *string `json:"status"`
|
|
|
|
SubscriptionID *strfmt.UUID `json:"subscriptionId,omitempty"`
|
|
|
|
TenantID *strfmt.UUID `json:"tenantId"`
|
|
|
|
Unit *string `json:"unit,omitempty"`
|
|
|
|
UserID *strfmt.UUID `json:"userId,omitempty"`
|
|
}
|
|
|
|
dataAO1.Effect = m.Effect
|
|
|
|
dataAO1.EffectiveFrom = m.EffectiveFrom
|
|
|
|
dataAO1.EffectiveUntil = m.EffectiveUntil
|
|
|
|
dataAO1.LimitPeriod = m.LimitPeriod
|
|
|
|
dataAO1.LimitQuantity = m.LimitQuantity
|
|
|
|
dataAO1.RevokedAt = m.RevokedAt
|
|
|
|
dataAO1.RevokedByID = m.RevokedByID
|
|
|
|
dataAO1.ServiceID = m.ServiceID
|
|
|
|
dataAO1.Source = m.Source
|
|
|
|
dataAO1.Status = m.Status
|
|
|
|
dataAO1.SubscriptionID = m.SubscriptionID
|
|
|
|
dataAO1.TenantID = m.TenantID
|
|
|
|
dataAO1.Unit = m.Unit
|
|
|
|
dataAO1.UserID = m.UserID
|
|
|
|
jsonDataAO1, errAO1 := jsonutils.WriteJSON(dataAO1)
|
|
if errAO1 != nil {
|
|
return nil, errAO1
|
|
}
|
|
_parts = append(_parts, jsonDataAO1)
|
|
return jsonutils.ConcatJSON(_parts...), nil
|
|
}
|
|
|
|
// Validate validates this entitlement
|
|
func (m *Entitlement) Validate(formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
// validation for a type composition with AuditFields
|
|
if err := m.AuditFields.Validate(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
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.validateLimitPeriod(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateLimitQuantity(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateRevokedAt(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateRevokedByID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateServiceID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateSource(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateStatus(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateSubscriptionID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateTenantID(formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.validateUnit(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 entitlementTypeEffectPropEnum []any
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["allow","deny"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
entitlementTypeEffectPropEnum = append(entitlementTypeEffectPropEnum, v)
|
|
}
|
|
}
|
|
|
|
// property enum
|
|
func (m *Entitlement) validateEffectEnum(path, location string, value string) error {
|
|
if err := validate.EnumCase(path, location, value, entitlementTypeEffectPropEnum, true); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) 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 *Entitlement) validateEffectiveFrom(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("effectiveFrom", "body", m.EffectiveFrom); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.FormatOf("effectiveFrom", "body", "date-time", m.EffectiveFrom.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) 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
|
|
}
|
|
|
|
var entitlementTypeLimitPeriodPropEnum []any
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["none","day","month","billing_period","lifetime"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
entitlementTypeLimitPeriodPropEnum = append(entitlementTypeLimitPeriodPropEnum, v)
|
|
}
|
|
}
|
|
|
|
// property enum
|
|
func (m *Entitlement) validateLimitPeriodEnum(path, location string, value string) error {
|
|
if err := validate.EnumCase(path, location, value, entitlementTypeLimitPeriodPropEnum, true); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) validateLimitPeriod(formats strfmt.Registry) error {
|
|
|
|
if typeutils.IsZero(m.LimitPeriod) { // not required
|
|
return nil
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validateLimitPeriodEnum("limitPeriod", "body", *m.LimitPeriod); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) validateLimitQuantity(formats strfmt.Registry) error {
|
|
|
|
if typeutils.IsZero(m.LimitQuantity) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.MinLength("limitQuantity", "body", *m.LimitQuantity, 1); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.MaxLength("limitQuantity", "body", *m.LimitQuantity, 21); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.Pattern("limitQuantity", "body", *m.LimitQuantity, `^(0|[1-9][0-9]{0,13})(\.[0-9]{1,6})?$`); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) validateRevokedAt(formats strfmt.Registry) error {
|
|
|
|
if typeutils.IsZero(m.RevokedAt) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("revokedAt", "body", "date-time", m.RevokedAt.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) validateRevokedByID(formats strfmt.Registry) error {
|
|
|
|
if typeutils.IsZero(m.RevokedByID) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("revokedById", "body", "uuid", m.RevokedByID.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) 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
|
|
}
|
|
|
|
var entitlementTypeSourcePropEnum []any
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["subscription","manual","trial","promotion"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
entitlementTypeSourcePropEnum = append(entitlementTypeSourcePropEnum, v)
|
|
}
|
|
}
|
|
|
|
// property enum
|
|
func (m *Entitlement) validateSourceEnum(path, location string, value string) error {
|
|
if err := validate.EnumCase(path, location, value, entitlementTypeSourcePropEnum, true); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) validateSource(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("source", "body", m.Source); err != nil {
|
|
return err
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validateSourceEnum("source", "body", *m.Source); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
var entitlementTypeStatusPropEnum []any
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["scheduled","active","revoked","expired"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
entitlementTypeStatusPropEnum = append(entitlementTypeStatusPropEnum, v)
|
|
}
|
|
}
|
|
|
|
// property enum
|
|
func (m *Entitlement) validateStatusEnum(path, location string, value string) error {
|
|
if err := validate.EnumCase(path, location, value, entitlementTypeStatusPropEnum, true); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) validateStatus(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Required("status", "body", m.Status); err != nil {
|
|
return err
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validateStatusEnum("status", "body", *m.Status); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) validateSubscriptionID(formats strfmt.Registry) error {
|
|
|
|
if typeutils.IsZero(m.SubscriptionID) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.FormatOf("subscriptionId", "body", "uuid", m.SubscriptionID.String(), formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) 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 *Entitlement) validateUnit(formats strfmt.Registry) error {
|
|
|
|
if typeutils.IsZero(m.Unit) { // not required
|
|
return nil
|
|
}
|
|
|
|
if err := validate.MaxLength("unit", "body", *m.Unit, 40); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) 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 entitlement based on the context it is used
|
|
func (m *Entitlement) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
var res []error
|
|
|
|
// validation for a type composition with AuditFields
|
|
if err := m.AuditFields.ContextValidate(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateRevokedAt(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if err := m.contextValidateRevokedByID(ctx, formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) contextValidateRevokedAt(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if err := validate.ReadOnly(ctx, "revokedAt", "body", m.RevokedAt); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *Entitlement) contextValidateRevokedByID(ctx context.Context, formats strfmt.Registry) error {
|
|
|
|
if err := validate.ReadOnly(ctx, "revokedById", "body", m.RevokedByID); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalBinary interface implementation
|
|
func (m *Entitlement) MarshalBinary() ([]byte, error) {
|
|
if m == nil {
|
|
return nil, nil
|
|
}
|
|
return jsonutils.WriteJSON(m)
|
|
}
|
|
|
|
// UnmarshalBinary interface implementation
|
|
func (m *Entitlement) UnmarshalBinary(b []byte) error {
|
|
var res Entitlement
|
|
if err := jsonutils.ReadJSON(b, &res); err != nil {
|
|
return err
|
|
}
|
|
*m = res
|
|
return nil
|
|
}
|