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

// VolumeGroup volume group
//
// swagger:model VolumeGroup
type VolumeGroup struct {

	// The name of consistencyGroup at storage host level
	ConsistencyGroupName string `json:"consistencyGroupName,omitempty"`

	// The ID of the volume group
	// Required: true
	ID *string `json:"id"`

	// The name of the volume group
	// Required: true
	Name *string `json:"name"`

	// Replication status of volume group
	ReplicationStatus string `json:"replicationStatus,omitempty"`

	// Status of the volume group
	Status string `json:"status,omitempty"`

	// Status details of the volume group
	StatusDescription *StatusDescription `json:"statusDescription,omitempty"`
}

// Validate validates this volume group
func (m *VolumeGroup) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *VolumeGroup) validateID(formats strfmt.Registry) error {

	if err := validate.Required("id", "body", m.ID); err != nil {
		return err
	}

	return nil
}

func (m *VolumeGroup) validateName(formats strfmt.Registry) error {

	if err := validate.Required("name", "body", m.Name); err != nil {
		return err
	}

	return nil
}

func (m *VolumeGroup) validateStatusDescription(formats strfmt.Registry) error {
	if swag.IsZero(m.StatusDescription) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *VolumeGroup) contextValidateStatusDescription(ctx context.Context, formats strfmt.Registry) error {

	if m.StatusDescription != nil {

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

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

	return nil
}

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

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