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

// HashicorpCloudVault20201125ListAllClustersResponseVaultCluster hashicorp cloud vault 20201125 list all clusters response vault cluster
//
// swagger:model hashicorp.cloud.vault_20201125.ListAllClustersResponse.VaultCluster
type HashicorpCloudVault20201125ListAllClustersResponseVaultCluster struct {

	// linked cluster
	LinkedCluster *HashicorpCloudVaultLink20221107LinkedCluster `json:"linked_cluster,omitempty"`

	// managed cluster
	ManagedCluster *HashicorpCloudVault20201125Cluster `json:"managed_cluster,omitempty"`
}

// Validate validates this hashicorp cloud vault 20201125 list all clusters response vault cluster
func (m *HashicorpCloudVault20201125ListAllClustersResponseVaultCluster) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVault20201125ListAllClustersResponseVaultCluster) validateLinkedCluster(formats strfmt.Registry) error {
	if swag.IsZero(m.LinkedCluster) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudVault20201125ListAllClustersResponseVaultCluster) validateManagedCluster(formats strfmt.Registry) error {
	if swag.IsZero(m.ManagedCluster) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud vault 20201125 list all clusters response vault cluster based on the context it is used
func (m *HashicorpCloudVault20201125ListAllClustersResponseVaultCluster) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVault20201125ListAllClustersResponseVaultCluster) contextValidateLinkedCluster(ctx context.Context, formats strfmt.Registry) error {

	if m.LinkedCluster != nil {

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

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

	return nil
}

func (m *HashicorpCloudVault20201125ListAllClustersResponseVaultCluster) contextValidateManagedCluster(ctx context.Context, formats strfmt.Registry) error {

	if m.ManagedCluster != nil {

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

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

	return nil
}

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

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