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

// OsImage os image
//
// swagger:model os-image
type OsImage struct {

	// The CPU architecture of the image (x86_64/arm64/etc).
	// Required: true
	// Enum: [x86_64 aarch64 arm64 ppc64le s390x]
	CPUArchitecture *string `json:"cpu_architecture" gorm:"default:'x86_64'"`

	// Version of the operating system image
	// Example: 4.12
	// Required: true
	OpenshiftVersion *string `json:"openshift_version"`

	// The base OS image used for the discovery iso.
	// Required: true
	URL *string `json:"url"`

	// Build ID of the OS image.
	// Required: true
	Version *string `json:"version"`
}

// Validate validates this os image
func (m *OsImage) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

var osImageTypeCPUArchitecturePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["x86_64","aarch64","arm64","ppc64le","s390x"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		osImageTypeCPUArchitecturePropEnum = append(osImageTypeCPUArchitecturePropEnum, v)
	}
}

const (

	// OsImageCPUArchitectureX8664 captures enum value "x86_64"
	OsImageCPUArchitectureX8664 string = "x86_64"

	// OsImageCPUArchitectureAarch64 captures enum value "aarch64"
	OsImageCPUArchitectureAarch64 string = "aarch64"

	// OsImageCPUArchitectureArm64 captures enum value "arm64"
	OsImageCPUArchitectureArm64 string = "arm64"

	// OsImageCPUArchitecturePpc64le captures enum value "ppc64le"
	OsImageCPUArchitecturePpc64le string = "ppc64le"

	// OsImageCPUArchitectureS390x captures enum value "s390x"
	OsImageCPUArchitectureS390x string = "s390x"
)

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

func (m *OsImage) validateCPUArchitecture(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateCPUArchitectureEnum("cpu_architecture", "body", *m.CPUArchitecture); err != nil {
		return err
	}

	return nil
}

func (m *OsImage) validateOpenshiftVersion(formats strfmt.Registry) error {

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

	return nil
}

func (m *OsImage) validateURL(formats strfmt.Registry) error {

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

	return nil
}

func (m *OsImage) validateVersion(formats strfmt.Registry) error {

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

	return nil
}

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

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

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