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

// HashicorpCloudVault20201125ClusterPerformanceReplicationInfo PerformanceReplicationInfo holds Performance Replication information
//
// swagger:model hashicorp.cloud.vault_20201125.Cluster.PerformanceReplicationInfo
type HashicorpCloudVault20201125ClusterPerformanceReplicationInfo struct {

	// Mode holds the replication mode type.
	Mode *HashicorpCloudVault20201125ClusterPerformanceReplicationInfoMode `json:"mode,omitempty"`

	// paths_filter holds the information on which paths the cluster can replicate from the Primary.
	// This field only applies when the cluster is a Secondary under Performance Replication.
	PathsFilter *HashicorpCloudVault20201125ClusterPerformanceReplicationPathsFilter `json:"paths_filter,omitempty"`

	// primary_cluster_link holds the link information of the
	// primary cluster to which the current cluster is replicated to. This field
	// only applies when the cluster is a Secondary under Cluster Performance Replication.
	PrimaryClusterLink *HashicorpCloudInternalLocationLink `json:"primary_cluster_link,omitempty"`
}

// Validate validates this hashicorp cloud vault 20201125 cluster performance replication info
func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) validateMode(formats strfmt.Registry) error {
	if swag.IsZero(m.Mode) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) validatePathsFilter(formats strfmt.Registry) error {
	if swag.IsZero(m.PathsFilter) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) validatePrimaryClusterLink(formats strfmt.Registry) error {
	if swag.IsZero(m.PrimaryClusterLink) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud vault 20201125 cluster performance replication info based on the context it is used
func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) contextValidateMode(ctx context.Context, formats strfmt.Registry) error {

	if m.Mode != nil {

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

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

	return nil
}

func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) contextValidatePathsFilter(ctx context.Context, formats strfmt.Registry) error {

	if m.PathsFilter != nil {

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

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

	return nil
}

func (m *HashicorpCloudVault20201125ClusterPerformanceReplicationInfo) contextValidatePrimaryClusterLink(ctx context.Context, formats strfmt.Registry) error {

	if m.PrimaryClusterLink != nil {

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

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

	return nil
}

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

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