/*
Merlin

API Guide for accessing Merlin's model management, deployment, and serving functionalities

API version: 0.14.0
*/

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

package client

import (
	"encoding/json"
	"fmt"
)

// ImageBuildingJobState the model 'ImageBuildingJobState'
type ImageBuildingJobState string

// List of ImageBuildingJobState
const (
	IMAGEBUILDINGJOBSTATE_ACTIVE    ImageBuildingJobState = "active"
	IMAGEBUILDINGJOBSTATE_SUCCEEDED ImageBuildingJobState = "succeeded"
	IMAGEBUILDINGJOBSTATE_FAILED    ImageBuildingJobState = "failed"
	IMAGEBUILDINGJOBSTATE_UNKNOWN   ImageBuildingJobState = "unknown"
)

// All allowed values of ImageBuildingJobState enum
var AllowedImageBuildingJobStateEnumValues = []ImageBuildingJobState{
	"active",
	"succeeded",
	"failed",
	"unknown",
}

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

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

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

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

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

type NullableImageBuildingJobState struct {
	value *ImageBuildingJobState
	isSet bool
}

func (v NullableImageBuildingJobState) Get() *ImageBuildingJobState {
	return v.value
}

func (v *NullableImageBuildingJobState) Set(val *ImageBuildingJobState) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableImageBuildingJobState(val *ImageBuildingJobState) *NullableImageBuildingJobState {
	return &NullableImageBuildingJobState{value: val, isSet: true}
}

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

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