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

// CentralNodeProfile central node profile
//
// swagger:model centralNodeProfile
type CentralNodeProfile struct {

	// compute
	// Required: true
	Compute *CentralCompute `json:"compute"`

	// display name
	// Required: true
	DisplayName *string `json:"display_name"`

	// name
	// Required: true
	Name *string `json:"name"`

	// node profile id
	// Required: true
	NodeProfileID *string `json:"node_profile_id"`

	// storage gi
	// Required: true
	StorageGi *int64 `json:"storage_gi"`
}

// Validate validates this central node profile
func (m *CentralNodeProfile) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *CentralNodeProfile) validateCompute(formats strfmt.Registry) error {

	if err := validate.Required("compute", "body", m.Compute); err != nil {
		return err
	}

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

	return nil
}

func (m *CentralNodeProfile) validateDisplayName(formats strfmt.Registry) error {

	if err := validate.Required("display_name", "body", m.DisplayName); err != nil {
		return err
	}

	return nil
}

func (m *CentralNodeProfile) validateName(formats strfmt.Registry) error {

	if err := validate.Required("name", "body", m.Name); err != nil {
		return err
	}

	return nil
}

func (m *CentralNodeProfile) validateNodeProfileID(formats strfmt.Registry) error {

	if err := validate.Required("node_profile_id", "body", m.NodeProfileID); err != nil {
		return err
	}

	return nil
}

func (m *CentralNodeProfile) validateStorageGi(formats strfmt.Registry) error {

	if err := validate.Required("storage_gi", "body", m.StorageGi); err != nil {
		return err
	}

	return nil
}

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

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

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

func (m *CentralNodeProfile) contextValidateCompute(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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