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

// OperatorHardwareRequirements operator hardware requirements
//
// swagger:model operator-hardware-requirements
type OperatorHardwareRequirements struct {

	// List of other operator unique names that are required to be installed. Corresponds to name property of the monitored-operator, i.e. "lso", "cnv", etc.
	Dependencies []string `json:"dependencies"`

	// Unique name of the operator. Corresponds to name property of the monitored-operator, i.e. "lso", "cnv", etc.
	OperatorName string `json:"operator_name,omitempty"`

	// requirements
	Requirements *HostTypeHardwareRequirementsWrapper `json:"requirements,omitempty"`
}

// Validate validates this operator hardware requirements
func (m *OperatorHardwareRequirements) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *OperatorHardwareRequirements) validateRequirements(formats strfmt.Registry) error {
	if swag.IsZero(m.Requirements) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *OperatorHardwareRequirements) contextValidateRequirements(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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