/*
 * VM Auto Scaling API
 *
 * The VM Auto Scaling Service enables IONOS clients to horizontally scale the number of VM replicas based on configured rules. You can use VM Auto Scaling to ensure that you have a sufficient number of replicas to handle your application loads at all times.  For this purpose, create a VM Auto Scaling Group that contains the server replicas. The VM Auto Scaling Service ensures that the number of replicas in the group is always within the defined limits.   When scaling policies are set, VM Auto Scaling creates or deletes replicas according to the requirements of your applications. For each policy, specified 'scale-in' and 'scale-out' actions are performed when the corresponding thresholds are reached.
 *
 * API version: 1-SDK.1
 * Contact: support@cloud.ionos.com
 */

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

package ionoscloud

import (
	"encoding/json"
	"fmt"
)

// Metric The metric that triggers the scaling actions. Metric values are checked at fixed intervals.
type Metric string

// List of Metric
const (
	METRIC_CPU_UTILIZATION_AVERAGE Metric = "INSTANCE_CPU_UTILIZATION_AVERAGE"
	METRIC_NETWORK_IN_BYTES        Metric = "INSTANCE_NETWORK_IN_BYTES"
	METRIC_NETWORK_IN_PACKETS      Metric = "INSTANCE_NETWORK_IN_PACKETS"
	METRIC_NETWORK_OUT_BYTES       Metric = "INSTANCE_NETWORK_OUT_BYTES"
	METRIC_NETWORK_OUT_PACKETS     Metric = "INSTANCE_NETWORK_OUT_PACKETS"
)

func (v *Metric) UnmarshalJSON(src []byte) error {
	var value string
	err := json.Unmarshal(src, &value)
	if err != nil {
		return err
	}
	enumTypeValue := Metric(value)
	for _, existing := range []Metric{"INSTANCE_CPU_UTILIZATION_AVERAGE", "INSTANCE_NETWORK_IN_BYTES", "INSTANCE_NETWORK_IN_PACKETS", "INSTANCE_NETWORK_OUT_BYTES", "INSTANCE_NETWORK_OUT_PACKETS"} {
		if existing == enumTypeValue {
			*v = enumTypeValue
			return nil
		}
	}

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

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

type NullableMetric struct {
	value *Metric
	isSet bool
}

func (v NullableMetric) Get() *Metric {
	return v.value
}

func (v *NullableMetric) Set(val *Metric) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableMetric(val *Metric) *NullableMetric {
	return &NullableMetric{value: val, isSet: true}
}

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

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