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

// AlertConditionMetricType the model 'AlertConditionMetricType'
type AlertConditionMetricType string

// List of AlertConditionMetricType
const (
	ALERTCONDITIONMETRICTYPE_THROUGHPUT AlertConditionMetricType = "throughput"
	ALERTCONDITIONMETRICTYPE_LATENCY    AlertConditionMetricType = "latency"
	ALERTCONDITIONMETRICTYPE_ERROR_RATE AlertConditionMetricType = "error_rate"
	ALERTCONDITIONMETRICTYPE_CPU        AlertConditionMetricType = "cpu"
	ALERTCONDITIONMETRICTYPE_MEMORY     AlertConditionMetricType = "memory"
)

// All allowed values of AlertConditionMetricType enum
var AllowedAlertConditionMetricTypeEnumValues = []AlertConditionMetricType{
	"throughput",
	"latency",
	"error_rate",
	"cpu",
	"memory",
}

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

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

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

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

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

type NullableAlertConditionMetricType struct {
	value *AlertConditionMetricType
	isSet bool
}

func (v NullableAlertConditionMetricType) Get() *AlertConditionMetricType {
	return v.value
}

func (v *NullableAlertConditionMetricType) Set(val *AlertConditionMetricType) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableAlertConditionMetricType(val *AlertConditionMetricType) *NullableAlertConditionMetricType {
	return &NullableAlertConditionMetricType{value: val, isSet: true}
}

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

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