/*
Mender API

Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

API version: 1
Contact: support@mender.io
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package client

import (
	"encoding/json"
	"fmt"
)

// DeviceStatus the model 'DeviceStatus'
type DeviceStatus string

// List of DeviceStatus
const (
	FAILURE DeviceStatus = "failure"
	ABORTED DeviceStatus = "aborted"
	PAUSE_BEFORE_INSTALLING DeviceStatus = "pause_before_installing"
	PAUSE_BEFORE_COMMITTING DeviceStatus = "pause_before_committing"
	PAUSE_BEFORE_REBOOTING DeviceStatus = "pause_before_rebooting"
	DOWNLOADING DeviceStatus = "downloading"
	INSTALLING DeviceStatus = "installing"
	REBOOTING DeviceStatus = "rebooting"
	PENDING DeviceStatus = "pending"
	SUCCESS DeviceStatus = "success"
	NOARTIFACT DeviceStatus = "noartifact"
	ALREADY_INSTALLED DeviceStatus = "already-installed"
	DECOMMISSIONED DeviceStatus = "decommissioned"
)

// All allowed values of DeviceStatus enum
var AllowedDeviceStatusEnumValues = []DeviceStatus{
	"failure",
	"aborted",
	"pause_before_installing",
	"pause_before_committing",
	"pause_before_rebooting",
	"downloading",
	"installing",
	"rebooting",
	"pending",
	"success",
	"noartifact",
	"already-installed",
	"decommissioned",
}

func (v *DeviceStatus) UnmarshalJSON(src []byte) error {
	var value string
	err := json.Unmarshal(src, &value)
	if err != nil {
		return err
	}
	enumTypeValue := DeviceStatus(value)
	for _, existing := range AllowedDeviceStatusEnumValues {
		if existing == enumTypeValue {
			*v = enumTypeValue
			return nil
		}
	}

	return fmt.Errorf("%+v is not a valid DeviceStatus", value)
}

// NewDeviceStatusFromValue returns a pointer to a valid DeviceStatus
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewDeviceStatusFromValue(v string) (*DeviceStatus, error) {
	ev := DeviceStatus(v)
	if ev.IsValid() {
		return &ev, nil
	} else {
		return nil, fmt.Errorf("invalid value '%v' for DeviceStatus: valid values are %v", v, AllowedDeviceStatusEnumValues)
	}
}

// IsValid return true if the value is valid for the enum, false otherwise
func (v DeviceStatus) IsValid() bool {
	for _, existing := range AllowedDeviceStatusEnumValues {
		if existing == v {
			return true
		}
	}
	return false
}

// Ptr returns reference to DeviceStatus value
func (v DeviceStatus) Ptr() *DeviceStatus {
	return &v
}

type NullableDeviceStatus struct {
	value *DeviceStatus
	isSet bool
}

func (v NullableDeviceStatus) Get() *DeviceStatus {
	return v.value
}

func (v *NullableDeviceStatus) Set(val *DeviceStatus) {
	v.value = val
	v.isSet = true
}

func (v NullableDeviceStatus) IsSet() bool {
	return v.isSet
}

func (v *NullableDeviceStatus) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableDeviceStatus(val *DeviceStatus) *NullableDeviceStatus {
	return &NullableDeviceStatus{value: val, isSet: true}
}

func (v NullableDeviceStatus) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableDeviceStatus) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}

