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

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// HostNetwork host network
//
// swagger:model host_network
type HostNetwork struct {

	// cidr
	Cidr string `json:"cidr,omitempty"`

	// host ids
	HostIds []strfmt.UUID `json:"host_ids"`
}

// Validate validates this host network
func (m *HostNetwork) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HostNetwork) validateHostIds(formats strfmt.Registry) error {
	if swag.IsZero(m.HostIds) { // not required
		return nil
	}

	for i := 0; i < len(m.HostIds); i++ {

		if err := validate.FormatOf("host_ids"+"."+strconv.Itoa(i), "body", "uuid", m.HostIds[i].String(), formats); err != nil {
			return err
		}

	}

	return nil
}

// ContextValidate validates this host network based on context it is used
func (m *HostNetwork) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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