// 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"
)

// ModelsEIPService models e IP service
//
// swagger:model models.EIPService
type ModelsEIPService struct {

	// auth
	Auth string `json:"auth,omitempty"`

	// locations
	Locations map[string]ModelsLocation `json:"locations,omitempty"`

	// openvpn configuration
	OpenvpnConfiguration map[string]interface{} `json:"openvpn_configuration,omitempty"`

	// serial
	Serial int64 `json:"serial,omitempty"`

	// version
	Version int64 `json:"version,omitempty"`
}

// Validate validates this models e IP service
func (m *ModelsEIPService) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *ModelsEIPService) validateLocations(formats strfmt.Registry) error {
	if swag.IsZero(m.Locations) { // not required
		return nil
	}

	for k := range m.Locations {

		if err := validate.Required("locations"+"."+k, "body", m.Locations[k]); err != nil {
			return err
		}
		if val, ok := m.Locations[k]; ok {
			if err := val.Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("locations" + "." + k)
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("locations" + "." + k)
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this models e IP service based on the context it is used
func (m *ModelsEIPService) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *ModelsEIPService) contextValidateLocations(ctx context.Context, formats strfmt.Registry) error {

	for k := range m.Locations {

		if val, ok := m.Locations[k]; ok {
			if err := val.ContextValidate(ctx, formats); err != nil {
				return err
			}
		}

	}

	return nil
}

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

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