// Code generated by go-swagger; DO NOT EDIT.

package models

// 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"
	"github.com/go-openapi/validate"
)

// VPNaaSOptions v p naa s options
//
// swagger:model VPNaaSOptions
type VPNaaSOptions struct {

	// dead peer detection
	// Required: true
	DeadPeerDetection *DeadPeerDetection `json:"deadPeerDetection"`

	// ike policy options
	// Required: true
	IkePolicyOptions *IKEPolicyOptions `json:"ikePolicyOptions"`

	// ike policy template
	// Required: true
	IkePolicyTemplate *IKEPolicyTemplate `json:"ikePolicyTemplate"`

	// ip sec policy options
	// Required: true
	IPSecPolicyOptions *IPSecPolicyOptions `json:"ipSecPolicyOptions"`

	// ip sec policy template
	// Required: true
	IPSecPolicyTemplate *IPSecPolicyTemplate `json:"ipSecPolicyTemplate"`
}

// Validate validates this v p naa s options
func (m *VPNaaSOptions) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateDeadPeerDetection(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateIkePolicyOptions(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateIkePolicyTemplate(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateIPSecPolicyOptions(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateIPSecPolicyTemplate(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *VPNaaSOptions) validateDeadPeerDetection(formats strfmt.Registry) error {

	if err := validate.Required("deadPeerDetection", "body", m.DeadPeerDetection); err != nil {
		return err
	}

	if m.DeadPeerDetection != nil {
		if err := m.DeadPeerDetection.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("deadPeerDetection")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("deadPeerDetection")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) validateIkePolicyOptions(formats strfmt.Registry) error {

	if err := validate.Required("ikePolicyOptions", "body", m.IkePolicyOptions); err != nil {
		return err
	}

	if m.IkePolicyOptions != nil {
		if err := m.IkePolicyOptions.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ikePolicyOptions")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ikePolicyOptions")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) validateIkePolicyTemplate(formats strfmt.Registry) error {

	if err := validate.Required("ikePolicyTemplate", "body", m.IkePolicyTemplate); err != nil {
		return err
	}

	if m.IkePolicyTemplate != nil {
		if err := m.IkePolicyTemplate.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ikePolicyTemplate")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ikePolicyTemplate")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) validateIPSecPolicyOptions(formats strfmt.Registry) error {

	if err := validate.Required("ipSecPolicyOptions", "body", m.IPSecPolicyOptions); err != nil {
		return err
	}

	if m.IPSecPolicyOptions != nil {
		if err := m.IPSecPolicyOptions.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ipSecPolicyOptions")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ipSecPolicyOptions")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) validateIPSecPolicyTemplate(formats strfmt.Registry) error {

	if err := validate.Required("ipSecPolicyTemplate", "body", m.IPSecPolicyTemplate); err != nil {
		return err
	}

	if m.IPSecPolicyTemplate != nil {
		if err := m.IPSecPolicyTemplate.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ipSecPolicyTemplate")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ipSecPolicyTemplate")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this v p naa s options based on the context it is used
func (m *VPNaaSOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateDeadPeerDetection(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateIkePolicyOptions(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateIkePolicyTemplate(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateIPSecPolicyOptions(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateIPSecPolicyTemplate(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *VPNaaSOptions) contextValidateDeadPeerDetection(ctx context.Context, formats strfmt.Registry) error {

	if m.DeadPeerDetection != nil {

		if err := m.DeadPeerDetection.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("deadPeerDetection")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("deadPeerDetection")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) contextValidateIkePolicyOptions(ctx context.Context, formats strfmt.Registry) error {

	if m.IkePolicyOptions != nil {

		if err := m.IkePolicyOptions.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ikePolicyOptions")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ikePolicyOptions")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) contextValidateIkePolicyTemplate(ctx context.Context, formats strfmt.Registry) error {

	if m.IkePolicyTemplate != nil {

		if err := m.IkePolicyTemplate.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ikePolicyTemplate")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ikePolicyTemplate")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) contextValidateIPSecPolicyOptions(ctx context.Context, formats strfmt.Registry) error {

	if m.IPSecPolicyOptions != nil {

		if err := m.IPSecPolicyOptions.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ipSecPolicyOptions")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ipSecPolicyOptions")
			}
			return err
		}
	}

	return nil
}

func (m *VPNaaSOptions) contextValidateIPSecPolicyTemplate(ctx context.Context, formats strfmt.Registry) error {

	if m.IPSecPolicyTemplate != nil {

		if err := m.IPSecPolicyTemplate.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("ipSecPolicyTemplate")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("ipSecPolicyTemplate")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *VPNaaSOptions) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *VPNaaSOptions) UnmarshalBinary(b []byte) error {
	var res VPNaaSOptions
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
