// Code generated by go-swagger; DO NOT EDIT.

package model

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

// V1beta1ClusterEndpoints Message for endpoint information for connecting to a cluster.
//
// swagger:model v1beta1ClusterEndpoints
type V1beta1ClusterEndpoints struct {

	// Output_only. Private endpoint to securely connect to the cluster.
	// Read Only: true
	Private *EndpointsPrivate `json:"private,omitempty"`

	// Optional. Public endpoint to connect to the cluster.
	Public *EndpointsPublic `json:"public,omitempty"`
}

// Validate validates this v1beta1 cluster endpoints
func (m *V1beta1ClusterEndpoints) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *V1beta1ClusterEndpoints) validatePrivate(formats strfmt.Registry) error {
	if swag.IsZero(m.Private) { // not required
		return nil
	}

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

	return nil
}

func (m *V1beta1ClusterEndpoints) validatePublic(formats strfmt.Registry) error {
	if swag.IsZero(m.Public) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

func (m *V1beta1ClusterEndpoints) contextValidatePrivate(ctx context.Context, formats strfmt.Registry) error {

	if m.Private != nil {

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

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

	return nil
}

func (m *V1beta1ClusterEndpoints) contextValidatePublic(ctx context.Context, formats strfmt.Registry) error {

	if m.Public != nil {

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

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

	return nil
}

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

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