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

// CloudInitialization cloud initialization
//
// swagger:model CloudInitialization
type CloudInitialization struct {

	// Virtual Machine's Cloud Initialization Virtual Optical Device
	// Enum: [attach detach]
	VirtualOpticalDevice string `json:"virtualOpticalDevice,omitempty"`
}

// Validate validates this cloud initialization
func (m *CloudInitialization) Validate(formats strfmt.Registry) error {
	var res []error

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

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

var cloudInitializationTypeVirtualOpticalDevicePropEnum []interface{}

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

const (

	// CloudInitializationVirtualOpticalDeviceAttach captures enum value "attach"
	CloudInitializationVirtualOpticalDeviceAttach string = "attach"

	// CloudInitializationVirtualOpticalDeviceDetach captures enum value "detach"
	CloudInitializationVirtualOpticalDeviceDetach string = "detach"
)

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

func (m *CloudInitialization) validateVirtualOpticalDevice(formats strfmt.Registry) error {
	if swag.IsZero(m.VirtualOpticalDevice) { // not required
		return nil
	}

	// value enum
	if err := m.validateVirtualOpticalDeviceEnum("virtualOpticalDevice", "body", m.VirtualOpticalDevice); err != nil {
		return err
	}

	return nil
}

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

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

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