/* PostgreSQL Flex API This is the documentation for the STACKIT Postgres Flex service API version: 3alpha1 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package postgresflexalpha import ( "encoding/json" "fmt" ) // ReplicasOpt How many replicas the instance should have. type ReplicasOpt int32 // List of replicas.opt const ( REPLICASOPT__1 ReplicasOpt = 1 REPLICASOPT__3 ReplicasOpt = 3 ) // All allowed values of ReplicasOpt enum var AllowedReplicasOptEnumValues = []ReplicasOpt{ 1, 3, } func (v *ReplicasOpt) UnmarshalJSON(src []byte) error { var value int32 err := json.Unmarshal(src, &value) if err != nil { return err } // Allow unmarshalling zero value for testing purposes var zeroValue int32 if value == zeroValue { return nil } enumTypeValue := ReplicasOpt(value) for _, existing := range AllowedReplicasOptEnumValues { if existing == enumTypeValue { *v = enumTypeValue return nil } } return fmt.Errorf("%+v is not a valid ReplicasOpt", value) } // NewReplicasOptFromValue returns a pointer to a valid ReplicasOpt // for the value passed as argument, or an error if the value passed is not allowed by the enum func NewReplicasOptFromValue(v int32) (*ReplicasOpt, error) { ev := ReplicasOpt(v) if ev.IsValid() { return &ev, nil } else { return nil, fmt.Errorf("invalid value '%v' for ReplicasOpt: valid values are %v", v, AllowedReplicasOptEnumValues) } } // IsValid return true if the value is valid for the enum, false otherwise func (v ReplicasOpt) IsValid() bool { for _, existing := range AllowedReplicasOptEnumValues { if existing == v { return true } } return false } // Ptr returns reference to replicas.opt value func (v ReplicasOpt) Ptr() *ReplicasOpt { return &v } type NullableReplicasOpt struct { value *ReplicasOpt isSet bool } func (v NullableReplicasOpt) Get() *ReplicasOpt { return v.value } func (v *NullableReplicasOpt) Set(val *ReplicasOpt) { v.value = val v.isSet = true } func (v NullableReplicasOpt) IsSet() bool { return v.isSet } func (v *NullableReplicasOpt) Unset() { v.value = nil v.isSet = false } func NewNullableReplicasOpt(val *ReplicasOpt) *NullableReplicasOpt { return &NullableReplicasOpt{value: val, isSet: true} } func (v NullableReplicasOpt) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableReplicasOpt) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }