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

// DiskInfo disk info
//
// swagger:model disk_info
type DiskInfo struct {

	// disk speed
	DiskSpeed *DiskSpeed `json:"disk_speed,omitempty"`

	// id
	// Format: uuid
	ID strfmt.UUID `json:"id,omitempty"`

	// path
	Path string `json:"path,omitempty"`
}

// Validate validates this disk info
func (m *DiskInfo) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *DiskInfo) validateDiskSpeed(formats strfmt.Registry) error {
	if swag.IsZero(m.DiskSpeed) { // not required
		return nil
	}

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

	return nil
}

func (m *DiskInfo) validateID(formats strfmt.Registry) error {
	if swag.IsZero(m.ID) { // not required
		return nil
	}

	if err := validate.FormatOf("id", "body", "uuid", m.ID.String(), formats); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this disk info based on the context it is used
func (m *DiskInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *DiskInfo) contextValidateDiskSpeed(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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