/*
Object Storage

REST API OpenAPI documentation for the Object Storage

API version: 1.0.0 (v1)
*/

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

package storage

import (
	"encoding/json"
	"fmt"
)

// EdgeAccessEnum the model 'EdgeAccessEnum'
type EdgeAccessEnum string

// List of EdgeAccessEnum
const (
	READ_ONLY EdgeAccessEnum = "read_only"
	READ_WRITE EdgeAccessEnum = "read_write"
	RESTRICTED EdgeAccessEnum = "restricted"
)

// All allowed values of EdgeAccessEnum enum
var AllowedEdgeAccessEnumEnumValues = []EdgeAccessEnum{
	"read_only",
	"read_write",
	"restricted",
}

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

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

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

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

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

type NullableEdgeAccessEnum struct {
	value *EdgeAccessEnum
	isSet bool
}

func (v NullableEdgeAccessEnum) Get() *EdgeAccessEnum {
	return v.value
}

func (v *NullableEdgeAccessEnum) Set(val *EdgeAccessEnum) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableEdgeAccessEnum(val *EdgeAccessEnum) *NullableEdgeAccessEnum {
	return &NullableEdgeAccessEnum{value: val, isSet: true}
}

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

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

