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

// EndpointStatus the model 'EndpointStatus'
type EndpointStatus string

// List of EndpointStatus
const (
	ENDPOINTSTATUS_PENDING    EndpointStatus = "pending"
	ENDPOINTSTATUS_RUNNING    EndpointStatus = "running"
	ENDPOINTSTATUS_SERVING    EndpointStatus = "serving"
	ENDPOINTSTATUS_FAILED     EndpointStatus = "failed"
	ENDPOINTSTATUS_TERMINATED EndpointStatus = "terminated"
)

// All allowed values of EndpointStatus enum
var AllowedEndpointStatusEnumValues = []EndpointStatus{
	"pending",
	"running",
	"serving",
	"failed",
	"terminated",
}

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

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

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

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

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

type NullableEndpointStatus struct {
	value *EndpointStatus
	isSet bool
}

func (v NullableEndpointStatus) Get() *EndpointStatus {
	return v.value
}

func (v *NullableEndpointStatus) Set(val *EndpointStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableEndpointStatus(val *EndpointStatus) *NullableEndpointStatus {
	return &NullableEndpointStatus{value: val, isSet: true}
}

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

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