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

package ops

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

// EntitySecondaryConfirmInRepo entity secondary confirm in repo
//
// swagger:model entity.SecondaryConfirmInRepo
type EntitySecondaryConfirmInRepo struct {

	// applied policy
	AppliedPolicy EntityApplyStrategy `json:"applied_policy,omitempty"`

	// cluster id
	ClusterID string `json:"cluster_id,omitempty"`

	// cluster name
	ClusterName string `json:"cluster_name,omitempty"`

	// created
	Created string `json:"created,omitempty"`

	// diff info
	DiffInfo *EntityConfigPairs `json:"diff_info,omitempty"`

	// hot reloadable
	HotReloadable bool `json:"hot_reloadable,omitempty"`

	// id
	ID int64 `json:"id,omitempty"`

	// project id
	ProjectID string `json:"project_id,omitempty"`

	// revision id
	RevisionID string `json:"revision_id,omitempty"`

	// status
	Status EntitySecondaryConfirmStatus `json:"status,omitempty"`

	// tenant name
	TenantName string `json:"tenant_name,omitempty"`
}

// Validate validates this entity secondary confirm in repo
func (m *EntitySecondaryConfirmInRepo) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *EntitySecondaryConfirmInRepo) validateAppliedPolicy(formats strfmt.Registry) error {
	if swag.IsZero(m.AppliedPolicy) { // not required
		return nil
	}

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

	return nil
}

func (m *EntitySecondaryConfirmInRepo) validateDiffInfo(formats strfmt.Registry) error {
	if swag.IsZero(m.DiffInfo) { // not required
		return nil
	}

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

	return nil
}

func (m *EntitySecondaryConfirmInRepo) validateStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.Status) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this entity secondary confirm in repo based on the context it is used
func (m *EntitySecondaryConfirmInRepo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *EntitySecondaryConfirmInRepo) contextValidateAppliedPolicy(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

func (m *EntitySecondaryConfirmInRepo) contextValidateDiffInfo(ctx context.Context, formats strfmt.Registry) error {

	if m.DiffInfo != nil {

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

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

	return nil
}

func (m *EntitySecondaryConfirmInRepo) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

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

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