/*
 * In-Memory DB API
 *
 * API description for the IONOS In-Memory DB
 *
 * API version: 1.0.0
 * Contact: support@cloud.ionos.com
 */

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

package ionoscloud

import (
	"encoding/json"
	"fmt"
)

// PersistenceMode Specifies How and If data is persisted. | Mode                          | Description | |-------------------------------|-------------| | **None**                      | Data is inMemory only and will not be persisted. Useful for cache only applications. | | **AOF** (Append Only File)    | AOF persistence logs every write operation received by the server. These operations can then be replayed again at server startup, reconstructing the original dataset. Commands are logged using the same format as the In-Memory DB protocol itself. | | **RDB**                       | RDB persistence performs snapshots of the current in memory state. | | **RDB_AOF**                   | Booth, RDB and AOF persistence are enabled. |
type PersistenceMode string

// List of PersistenceMode
const (
	PERSISTENCEMODE_NONE    PersistenceMode = "None"
	PERSISTENCEMODE_AOF     PersistenceMode = "AOF"
	PERSISTENCEMODE_RDB     PersistenceMode = "RDB"
	PERSISTENCEMODE_RDB_AOF PersistenceMode = "RDB_AOF"
)

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

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

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

type NullablePersistenceMode struct {
	value *PersistenceMode
	isSet bool
}

func (v NullablePersistenceMode) Get() *PersistenceMode {
	return v.value
}

func (v *NullablePersistenceMode) Set(val *PersistenceMode) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullablePersistenceMode(val *PersistenceMode) *NullablePersistenceMode {
	return &NullablePersistenceMode{value: val, isSet: true}
}

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

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