// 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"
	"encoding/json"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// VolumeReference volume reference
//
// swagger:model VolumeReference
type VolumeReference struct {

	// Auxiliary volume name at storage host level
	AuxVolumeName string `json:"auxVolumeName,omitempty"`

	// true if volume is auxiliary otherwise false
	Auxiliary *bool `json:"auxiliary,omitempty"`

	// Indicates if the volume is the server's boot volume
	BootVolume *bool `json:"bootVolume,omitempty"`

	// Indicates if the volume is boot capable
	// Required: true
	Bootable *bool `json:"bootable"`

	// Consistency Group Name if volume is a part of volume group
	ConsistencyGroupName string `json:"consistencyGroupName,omitempty"`

	// Creation Date
	// Required: true
	// Format: date-time
	CreationDate *strfmt.DateTime `json:"creationDate"`

	// Indicates if the volume should be deleted when the server terminates
	DeleteOnTermination *bool `json:"deleteOnTermination,omitempty"`

	// Type of Disk
	// Required: true
	DiskType *string `json:"diskType"`

	// Volume Group ID
	GroupID string `json:"groupID,omitempty"`

	// Link to Volume resource
	// Required: true
	Href *string `json:"href"`

	// Amount of iops assigned to the volume
	IoThrottleRate string `json:"ioThrottleRate,omitempty"`

	// Last Update Date
	// Required: true
	// Format: date-time
	LastUpdateDate *strfmt.DateTime `json:"lastUpdateDate"`

	// Master volume name at storage host level
	MasterVolumeName string `json:"masterVolumeName,omitempty"`

	// mirroring state for replication enabled volume
	MirroringState string `json:"mirroringState,omitempty"`

	// Volume Name
	// Required: true
	Name *string `json:"name"`

	// true if volume does not exist on storage controller, as volume has been deleted by deleting its paired volume from the mapped replication site.
	OutOfBandDeleted bool `json:"outOfBandDeleted,omitempty"`

	// indicates whether master/aux volume is playing the primary role
	// Enum: [master aux]
	PrimaryRole string `json:"primaryRole,omitempty"`

	// List of PCloud PVM Instance attached to the volume
	PvmInstanceIDs []string `json:"pvmInstanceIDs"`

	// True if volume is replication enabled otherwise false
	ReplicationEnabled *bool `json:"replicationEnabled,omitempty"`

	// shows the replication status of a volume
	ReplicationStatus string `json:"replicationStatus,omitempty"`

	// type of replication(metro, global)s
	ReplicationType string `json:"replicationType,omitempty"`

	// Indicates if the volume is shareable between VMs
	// Required: true
	Shareable *bool `json:"shareable"`

	// Volume Size
	// Required: true
	Size *float64 `json:"size"`

	// Volume State
	// Required: true
	State *string `json:"state"`

	// Volume ID
	// Required: true
	VolumeID *string `json:"volumeID"`

	// Volume pool, name of storage pool where the volume is located
	VolumePool string `json:"volumePool,omitempty"`

	// Volume type, name of storage template used to create the volume
	VolumeType string `json:"volumeType,omitempty"`

	// Volume world wide name
	// Required: true
	Wwn *string `json:"wwn"`
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *VolumeReference) validateBootable(formats strfmt.Registry) error {

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

	return nil
}

func (m *VolumeReference) validateCreationDate(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("creationDate", "body", "date-time", m.CreationDate.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *VolumeReference) validateDiskType(formats strfmt.Registry) error {

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

	return nil
}

func (m *VolumeReference) validateHref(formats strfmt.Registry) error {

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

	return nil
}

func (m *VolumeReference) validateLastUpdateDate(formats strfmt.Registry) error {

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

	if err := validate.FormatOf("lastUpdateDate", "body", "date-time", m.LastUpdateDate.String(), formats); err != nil {
		return err
	}

	return nil
}

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

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

	return nil
}

var volumeReferenceTypePrimaryRolePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["master","aux"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		volumeReferenceTypePrimaryRolePropEnum = append(volumeReferenceTypePrimaryRolePropEnum, v)
	}
}

const (

	// VolumeReferencePrimaryRoleMaster captures enum value "master"
	VolumeReferencePrimaryRoleMaster string = "master"

	// VolumeReferencePrimaryRoleAux captures enum value "aux"
	VolumeReferencePrimaryRoleAux string = "aux"
)

// prop value enum
func (m *VolumeReference) validatePrimaryRoleEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, volumeReferenceTypePrimaryRolePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *VolumeReference) validatePrimaryRole(formats strfmt.Registry) error {
	if swag.IsZero(m.PrimaryRole) { // not required
		return nil
	}

	// value enum
	if err := m.validatePrimaryRoleEnum("primaryRole", "body", m.PrimaryRole); err != nil {
		return err
	}

	return nil
}

func (m *VolumeReference) validateShareable(formats strfmt.Registry) error {

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

	return nil
}

func (m *VolumeReference) validateSize(formats strfmt.Registry) error {

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

	return nil
}

func (m *VolumeReference) validateState(formats strfmt.Registry) error {

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

	return nil
}

func (m *VolumeReference) validateVolumeID(formats strfmt.Registry) error {

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

	return nil
}

func (m *VolumeReference) validateWwn(formats strfmt.Registry) error {

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

	return nil
}

// ContextValidate validates this volume reference based on context it is used
func (m *VolumeReference) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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