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

// VolumeRemoteCopyRelationship volume remote copy relationship
//
// swagger:model VolumeRemoteCopyRelationship
type VolumeRemoteCopyRelationship struct {
	RemoteCopyRelationship

	// Indicates the minimum period in seconds between multiple cycles
	CyclePeriodSeconds int64 `json:"cyclePeriodSeconds,omitempty"`

	// Volume ID
	ID string `json:"id,omitempty"`
}

// UnmarshalJSON unmarshals this object from a JSON structure
func (m *VolumeRemoteCopyRelationship) UnmarshalJSON(raw []byte) error {
	// AO0
	var aO0 RemoteCopyRelationship
	if err := swag.ReadJSON(raw, &aO0); err != nil {
		return err
	}
	m.RemoteCopyRelationship = aO0

	// now for regular properties
	var propsVolumeRemoteCopyRelationship struct {
		CyclePeriodSeconds int64 `json:"cyclePeriodSeconds,omitempty"`

		ID string `json:"id,omitempty"`
	}
	if err := swag.ReadJSON(raw, &propsVolumeRemoteCopyRelationship); err != nil {
		return err
	}
	m.CyclePeriodSeconds = propsVolumeRemoteCopyRelationship.CyclePeriodSeconds

	m.ID = propsVolumeRemoteCopyRelationship.ID

	return nil
}

// MarshalJSON marshals this object to a JSON structure
func (m VolumeRemoteCopyRelationship) MarshalJSON() ([]byte, error) {
	_parts := make([][]byte, 0, 1)

	aO0, err := swag.WriteJSON(m.RemoteCopyRelationship)
	if err != nil {
		return nil, err
	}
	_parts = append(_parts, aO0)

	// now for regular properties
	var propsVolumeRemoteCopyRelationship struct {
		CyclePeriodSeconds int64 `json:"cyclePeriodSeconds,omitempty"`

		ID string `json:"id,omitempty"`
	}
	propsVolumeRemoteCopyRelationship.CyclePeriodSeconds = m.CyclePeriodSeconds

	propsVolumeRemoteCopyRelationship.ID = m.ID

	jsonDataPropsVolumeRemoteCopyRelationship, errVolumeRemoteCopyRelationship := swag.WriteJSON(propsVolumeRemoteCopyRelationship)
	if errVolumeRemoteCopyRelationship != nil {
		return nil, errVolumeRemoteCopyRelationship
	}
	_parts = append(_parts, jsonDataPropsVolumeRemoteCopyRelationship)
	return swag.ConcatJSON(_parts...), nil
}

// Validate validates this volume remote copy relationship
func (m *VolumeRemoteCopyRelationship) Validate(formats strfmt.Registry) error {
	var res []error

	// validation for a type composition with RemoteCopyRelationship
	if err := m.RemoteCopyRelationship.Validate(formats); err != nil {
		res = append(res, err)
	}

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

// ContextValidate validate this volume remote copy relationship based on the context it is used
func (m *VolumeRemoteCopyRelationship) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	// validation for a type composition with RemoteCopyRelationship
	if err := m.RemoteCopyRelationship.ContextValidate(ctx, formats); err != nil {
		res = append(res, err)
	}

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

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

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