/* 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" ) // InstanceSort the model 'InstanceSort' type InstanceSort string // List of instance.sort const ( INSTANCESORT_INDEX_DESC InstanceSort = "index.desc" INSTANCESORT_INDEX_ASC InstanceSort = "index.asc" INSTANCESORT_ID_DESC InstanceSort = "id.desc" INSTANCESORT_ID_ASC InstanceSort = "id.asc" INSTANCESORT_IS_DELETABLE_DESC InstanceSort = "is_deletable.desc" INSTANCESORT_IS_DELETABLE_ASC InstanceSort = "is_deletable.asc" INSTANCESORT_NAME_ASC InstanceSort = "name.asc" INSTANCESORT_NAME_DESC InstanceSort = "name.desc" INSTANCESORT_STATUS_ASC InstanceSort = "status.asc" INSTANCESORT_STATUS_DESC InstanceSort = "status.desc" ) // All allowed values of InstanceSort enum var AllowedInstanceSortEnumValues = []InstanceSort{ "index.desc", "index.asc", "id.desc", "id.asc", "is_deletable.desc", "is_deletable.asc", "name.asc", "name.desc", "status.asc", "status.desc", } func (v *InstanceSort) UnmarshalJSON(src []byte) error { var value string err := json.Unmarshal(src, &value) if err != nil { return err } // Allow unmarshalling zero value for testing purposes var zeroValue string if value == zeroValue { return nil } enumTypeValue := InstanceSort(value) for _, existing := range AllowedInstanceSortEnumValues { if existing == enumTypeValue { *v = enumTypeValue return nil } } return fmt.Errorf("%+v is not a valid InstanceSort", value) } // NewInstanceSortFromValue returns a pointer to a valid InstanceSort // for the value passed as argument, or an error if the value passed is not allowed by the enum func NewInstanceSortFromValue(v string) (*InstanceSort, error) { ev := InstanceSort(v) if ev.IsValid() { return &ev, nil } else { return nil, fmt.Errorf("invalid value '%v' for InstanceSort: valid values are %v", v, AllowedInstanceSortEnumValues) } } // IsValid return true if the value is valid for the enum, false otherwise func (v InstanceSort) IsValid() bool { for _, existing := range AllowedInstanceSortEnumValues { if existing == v { return true } } return false } // Ptr returns reference to instance.sort value func (v InstanceSort) Ptr() *InstanceSort { return &v } type NullableInstanceSort struct { value *InstanceSort isSet bool } func (v NullableInstanceSort) Get() *InstanceSort { return v.value } func (v *NullableInstanceSort) Set(val *InstanceSort) { v.value = val v.isSet = true } func (v NullableInstanceSort) IsSet() bool { return v.isSet } func (v *NullableInstanceSort) Unset() { v.value = nil v.isSet = false } func NewNullableInstanceSort(val *InstanceSort) *NullableInstanceSort { return &NullableInstanceSort{value: val, isSet: true} } func (v NullableInstanceSort) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableInstanceSort) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }