// 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"
	"github.com/go-openapi/validate"
)

// ReplicationAttributes replication attributes
//
// swagger:model ReplicationAttributes
type ReplicationAttributes struct {

	// asset path regex
	// Read Only: true
	AssetPathRegex string `json:"assetPathRegex,omitempty"`

	// preemptive pull enabled
	// Required: true
	// Read Only: true
	PreemptivePullEnabled bool `json:"preemptivePullEnabled"`
}

// Validate validates this replication attributes
func (m *ReplicationAttributes) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *ReplicationAttributes) validatePreemptivePullEnabled(formats strfmt.Registry) error {

	if err := validate.Required("preemptivePullEnabled", "body", bool(m.PreemptivePullEnabled)); err != nil {
		return err
	}

	return nil
}

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

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

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

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

func (m *ReplicationAttributes) contextValidateAssetPathRegex(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "assetPathRegex", "body", string(m.AssetPathRegex)); err != nil {
		return err
	}

	return nil
}

func (m *ReplicationAttributes) contextValidatePreemptivePullEnabled(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "preemptivePullEnabled", "body", bool(m.PreemptivePullEnabled)); err != nil {
		return err
	}

	return nil
}

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

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