zrok/rest_model_zrok/environment_shares.go

147 lines
3.4 KiB
Go
Raw Permalink Normal View History

2022-08-03 20:36:40 +02:00
// Code generated by go-swagger; DO NOT EDIT.
package rest_model_zrok
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// EnvironmentShares environment shares
2022-08-03 20:36:40 +02:00
//
// swagger:model environmentShares
type EnvironmentShares struct {
2022-08-03 20:36:40 +02:00
// environment
Environment *Environment `json:"environment,omitempty"`
// shares
Shares Shares `json:"shares,omitempty"`
2022-08-03 20:36:40 +02:00
}
// Validate validates this environment shares
func (m *EnvironmentShares) Validate(formats strfmt.Registry) error {
2022-08-03 20:36:40 +02:00
var res []error
if err := m.validateEnvironment(formats); err != nil {
res = append(res, err)
}
if err := m.validateShares(formats); err != nil {
2022-08-03 20:36:40 +02:00
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *EnvironmentShares) validateEnvironment(formats strfmt.Registry) error {
2022-08-03 20:36:40 +02:00
if swag.IsZero(m.Environment) { // not required
return nil
}
if m.Environment != nil {
if err := m.Environment.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("environment")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("environment")
}
return err
}
}
return nil
}
func (m *EnvironmentShares) validateShares(formats strfmt.Registry) error {
if swag.IsZero(m.Shares) { // not required
2022-08-03 20:36:40 +02:00
return nil
}
if err := m.Shares.Validate(formats); err != nil {
2022-08-03 20:36:40 +02:00
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("shares")
2022-08-03 20:36:40 +02:00
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("shares")
2022-08-03 20:36:40 +02:00
}
return err
}
return nil
}
// ContextValidate validate this environment shares based on the context it is used
func (m *EnvironmentShares) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
2022-08-03 20:36:40 +02:00
var res []error
if err := m.contextValidateEnvironment(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateShares(ctx, formats); err != nil {
2022-08-03 20:36:40 +02:00
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *EnvironmentShares) contextValidateEnvironment(ctx context.Context, formats strfmt.Registry) error {
2022-08-03 20:36:40 +02:00
if m.Environment != nil {
if err := m.Environment.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("environment")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("environment")
}
return err
}
}
return nil
}
func (m *EnvironmentShares) contextValidateShares(ctx context.Context, formats strfmt.Registry) error {
2022-08-03 20:36:40 +02:00
if err := m.Shares.ContextValidate(ctx, formats); err != nil {
2022-08-03 20:36:40 +02:00
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("shares")
2022-08-03 20:36:40 +02:00
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("shares")
2022-08-03 20:36:40 +02:00
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *EnvironmentShares) MarshalBinary() ([]byte, error) {
2022-08-03 20:36:40 +02:00
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *EnvironmentShares) UnmarshalBinary(b []byte) error {
var res EnvironmentShares
2022-08-03 20:36:40 +02:00
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}