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

// PodCapacity List of available resources within a Pod
//
// swagger:model PodCapacity
type PodCapacity struct {

	// pod data
	PodData *PodData `json:"PodData,omitempty"`

	// storage controllers
	StorageControllers StorageControllers `json:"StorageControllers,omitempty"`

	// system pools
	SystemPools SystemPoolsCapacity `json:"SystemPools,omitempty"`
}

// Validate validates this pod capacity
func (m *PodCapacity) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *PodCapacity) validatePodData(formats strfmt.Registry) error {
	if swag.IsZero(m.PodData) { // not required
		return nil
	}

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

	return nil
}

func (m *PodCapacity) validateStorageControllers(formats strfmt.Registry) error {
	if swag.IsZero(m.StorageControllers) { // not required
		return nil
	}

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

	return nil
}

func (m *PodCapacity) validateSystemPools(formats strfmt.Registry) error {
	if swag.IsZero(m.SystemPools) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

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

func (m *PodCapacity) contextValidatePodData(ctx context.Context, formats strfmt.Registry) error {

	if m.PodData != nil {

		if swag.IsZero(m.PodData) { // not required
			return nil
		}

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

	return nil
}

func (m *PodCapacity) contextValidateStorageControllers(ctx context.Context, formats strfmt.Registry) error {

	if swag.IsZero(m.StorageControllers) { // not required
		return nil
	}

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

	return nil
}

func (m *PodCapacity) contextValidateSystemPools(ctx context.Context, formats strfmt.Registry) error {

	if swag.IsZero(m.SystemPools) { // not required
		return nil
	}

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

	return nil
}

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

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