/*
TiDB Cloud Console API

TiDB Cloud Console API.

API version: v1beta1
*/

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

package client

import (
	"encoding/json"
	"fmt"
)

// Commonv1beta1ServicePlan the model 'Commonv1beta1ServicePlan'
type Commonv1beta1ServicePlan string

// List of commonv1beta1ServicePlan
const (
	COMMONV1BETA1SERVICEPLAN_STARTER Commonv1beta1ServicePlan = "Starter"
	COMMONV1BETA1SERVICEPLAN_ESSENTIAL Commonv1beta1ServicePlan = "Essential"
	COMMONV1BETA1SERVICEPLAN_PREMIUM Commonv1beta1ServicePlan = "Premium"
	COMMONV1BETA1SERVICEPLAN_BYOC Commonv1beta1ServicePlan = "BYOC"
)

// All allowed values of Commonv1beta1ServicePlan enum
var AllowedCommonv1beta1ServicePlanEnumValues = []Commonv1beta1ServicePlan{
	"Starter",
	"Essential",
	"Premium",
	"BYOC",
}

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

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

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

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

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

type NullableCommonv1beta1ServicePlan struct {
	value *Commonv1beta1ServicePlan
	isSet bool
}

func (v NullableCommonv1beta1ServicePlan) Get() *Commonv1beta1ServicePlan {
	return v.value
}

func (v *NullableCommonv1beta1ServicePlan) Set(val *Commonv1beta1ServicePlan) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableCommonv1beta1ServicePlan(val *Commonv1beta1ServicePlan) *NullableCommonv1beta1ServicePlan {
	return &NullableCommonv1beta1ServicePlan{value: val, isSet: true}
}

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

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

