mirror of https://github.com/vernonkeenan/lib
323 lines
6.8 KiB
Go
323 lines
6.8 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"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Service service
|
||
|
|
//
|
||
|
|
// swagger:model Service
|
||
|
|
type Service struct {
|
||
|
|
AuditFields
|
||
|
|
|
||
|
|
// contract ref
|
||
|
|
// Max Length: 255
|
||
|
|
ContractRef *string `json:"contractRef,omitempty"`
|
||
|
|
|
||
|
|
// description
|
||
|
|
Description *string `json:"description,omitempty"`
|
||
|
|
|
||
|
|
// name
|
||
|
|
// Required: true
|
||
|
|
// Max Length: 255
|
||
|
|
// Min Length: 1
|
||
|
|
Name *string `json:"name"`
|
||
|
|
|
||
|
|
// owner system
|
||
|
|
// Required: true
|
||
|
|
// Enum: ["members","crm","research","plex","external"]
|
||
|
|
OwnerSystem *string `json:"ownerSystem"`
|
||
|
|
|
||
|
|
// service key
|
||
|
|
// Required: true
|
||
|
|
// Max Length: 80
|
||
|
|
// Min Length: 1
|
||
|
|
ServiceKey *string `json:"serviceKey"`
|
||
|
|
|
||
|
|
// status
|
||
|
|
// Required: true
|
||
|
|
// Enum: ["draft","active","retired"]
|
||
|
|
Status *string `json:"status"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// UnmarshalJSON unmarshals this object from a JSON structure
|
||
|
|
func (m *Service) 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 {
|
||
|
|
ContractRef *string `json:"contractRef,omitempty"`
|
||
|
|
|
||
|
|
Description *string `json:"description,omitempty"`
|
||
|
|
|
||
|
|
Name *string `json:"name"`
|
||
|
|
|
||
|
|
OwnerSystem *string `json:"ownerSystem"`
|
||
|
|
|
||
|
|
ServiceKey *string `json:"serviceKey"`
|
||
|
|
|
||
|
|
Status *string `json:"status"`
|
||
|
|
}
|
||
|
|
if err := jsonutils.ReadJSON(raw, &dataAO1); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
m.ContractRef = dataAO1.ContractRef
|
||
|
|
|
||
|
|
m.Description = dataAO1.Description
|
||
|
|
|
||
|
|
m.Name = dataAO1.Name
|
||
|
|
|
||
|
|
m.OwnerSystem = dataAO1.OwnerSystem
|
||
|
|
|
||
|
|
m.ServiceKey = dataAO1.ServiceKey
|
||
|
|
|
||
|
|
m.Status = dataAO1.Status
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// MarshalJSON marshals this object to a JSON structure
|
||
|
|
func (m Service) 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 {
|
||
|
|
ContractRef *string `json:"contractRef,omitempty"`
|
||
|
|
|
||
|
|
Description *string `json:"description,omitempty"`
|
||
|
|
|
||
|
|
Name *string `json:"name"`
|
||
|
|
|
||
|
|
OwnerSystem *string `json:"ownerSystem"`
|
||
|
|
|
||
|
|
ServiceKey *string `json:"serviceKey"`
|
||
|
|
|
||
|
|
Status *string `json:"status"`
|
||
|
|
}
|
||
|
|
|
||
|
|
dataAO1.ContractRef = m.ContractRef
|
||
|
|
|
||
|
|
dataAO1.Description = m.Description
|
||
|
|
|
||
|
|
dataAO1.Name = m.Name
|
||
|
|
|
||
|
|
dataAO1.OwnerSystem = m.OwnerSystem
|
||
|
|
|
||
|
|
dataAO1.ServiceKey = m.ServiceKey
|
||
|
|
|
||
|
|
dataAO1.Status = m.Status
|
||
|
|
|
||
|
|
jsonDataAO1, errAO1 := jsonutils.WriteJSON(dataAO1)
|
||
|
|
if errAO1 != nil {
|
||
|
|
return nil, errAO1
|
||
|
|
}
|
||
|
|
_parts = append(_parts, jsonDataAO1)
|
||
|
|
return jsonutils.ConcatJSON(_parts...), nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// Validate validates this service
|
||
|
|
func (m *Service) 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.validateContractRef(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateName(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateOwnerSystem(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateServiceKey(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := m.validateStatus(formats); err != nil {
|
||
|
|
res = append(res, err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if len(res) > 0 {
|
||
|
|
return errors.CompositeValidationError(res...)
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *Service) validateContractRef(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if typeutils.IsZero(m.ContractRef) { // not required
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.MaxLength("contractRef", "body", *m.ContractRef, 255); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *Service) validateName(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("name", "body", m.Name); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.MaxLength("name", "body", *m.Name, 255); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
var serviceTypeOwnerSystemPropEnum []any
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
var res []string
|
||
|
|
if err := json.Unmarshal([]byte(`["members","crm","research","plex","external"]`), &res); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
for _, v := range res {
|
||
|
|
serviceTypeOwnerSystemPropEnum = append(serviceTypeOwnerSystemPropEnum, v)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// property enum
|
||
|
|
func (m *Service) validateOwnerSystemEnum(path, location string, value string) error {
|
||
|
|
if err := validate.EnumCase(path, location, value, serviceTypeOwnerSystemPropEnum, true); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *Service) validateOwnerSystem(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("ownerSystem", "body", m.OwnerSystem); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// value enum
|
||
|
|
if err := m.validateOwnerSystemEnum("ownerSystem", "body", *m.OwnerSystem); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *Service) validateServiceKey(formats strfmt.Registry) error {
|
||
|
|
|
||
|
|
if err := validate.Required("serviceKey", "body", m.ServiceKey); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.MinLength("serviceKey", "body", *m.ServiceKey, 1); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := validate.MaxLength("serviceKey", "body", *m.ServiceKey, 80); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
var serviceTypeStatusPropEnum []any
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
var res []string
|
||
|
|
if err := json.Unmarshal([]byte(`["draft","active","retired"]`), &res); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
for _, v := range res {
|
||
|
|
serviceTypeStatusPropEnum = append(serviceTypeStatusPropEnum, v)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// property enum
|
||
|
|
func (m *Service) validateStatusEnum(path, location string, value string) error {
|
||
|
|
if err := validate.EnumCase(path, location, value, serviceTypeStatusPropEnum, true); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (m *Service) 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
|
||
|
|
}
|
||
|
|
|
||
|
|
// ContextValidate validate this service based on the context it is used
|
||
|
|
func (m *Service) 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 len(res) > 0 {
|
||
|
|
return errors.CompositeValidationError(res...)
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// MarshalBinary interface implementation
|
||
|
|
func (m *Service) MarshalBinary() ([]byte, error) {
|
||
|
|
if m == nil {
|
||
|
|
return nil, nil
|
||
|
|
}
|
||
|
|
return jsonutils.WriteJSON(m)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UnmarshalBinary interface implementation
|
||
|
|
func (m *Service) UnmarshalBinary(b []byte) error {
|
||
|
|
var res Service
|
||
|
|
if err := jsonutils.ReadJSON(b, &res); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
*m = res
|
||
|
|
return nil
|
||
|
|
}
|