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

// HashicorpCloudConsulCloudManager20231010ClusterConfig ClusterConfig holds the configuration for a Consul cluster.
//
// swagger:model hashicorp.cloud.consul_cloud_manager_20231010.ClusterConfig
type HashicorpCloudConsulCloudManager20231010ClusterConfig struct {

	// consul config
	ConsulConfig *HashicorpCloudConsulCloudManager20231010ConsulConfig `json:"consul_config,omitempty"`

	// Public and Private DNS names for the cluster
	DNSNames *HashicorpCloudConsulCloudManager20231010DNSNames `json:"dns_names,omitempty"`

	// NetworkConfig contains the network to deploy the Consul cluster into.
	NetworkConfig *HashicorpCloudConsulCloudManager20231010NetworkConfig `json:"network_config,omitempty"`

	// size
	Size *HashicorpCloudConsulCloudManager20231010ClusterConfigSize `json:"size,omitempty"`

	// The type of tier this Consul cluster is provisioned as.
	Tier *HashicorpCloudConsulCloudManager20231010ClusterConfigTier `json:"tier,omitempty"`
}

// Validate validates this hashicorp cloud consul cloud manager 20231010 cluster config
func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) validateConsulConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.ConsulConfig) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) validateDNSNames(formats strfmt.Registry) error {
	if swag.IsZero(m.DNSNames) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) validateNetworkConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.NetworkConfig) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) validateSize(formats strfmt.Registry) error {
	if swag.IsZero(m.Size) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) validateTier(formats strfmt.Registry) error {
	if swag.IsZero(m.Tier) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud consul cloud manager 20231010 cluster config based on the context it is used
func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) contextValidateConsulConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.ConsulConfig != nil {

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

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) contextValidateDNSNames(ctx context.Context, formats strfmt.Registry) error {

	if m.DNSNames != nil {

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

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) contextValidateNetworkConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.NetworkConfig != nil {

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

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) contextValidateSize(ctx context.Context, formats strfmt.Registry) error {

	if m.Size != nil {

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

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

	return nil
}

func (m *HashicorpCloudConsulCloudManager20231010ClusterConfig) contextValidateTier(ctx context.Context, formats strfmt.Registry) error {

	if m.Tier != nil {

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

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

	return nil
}

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

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