/*
Mender API

Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

API version: 1
Contact: support@mender.io
*/

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

package client

import (
	"encoding/json"
	"fmt"
)

// Scope The scope of the attribute.  Scope is a string and acts as namespace for the attribute name.  * __inventory__: Attributes reported by the device. * __system__: Attributes populated by the mender-server. * __identity__: Device's identity attributes provided in the device's auth request. * __monitor__: Attributes populated by the monitoring add-on. * __tags__: User-defined attributes associated with the device. 
type Scope string

// List of Scope
const (
	SYSTEM Scope = "system"
	IDENTITY Scope = "identity"
	INVENTORY Scope = "inventory"
	MONITOR Scope = "monitor"
	TAGS Scope = "tags"
)

// All allowed values of Scope enum
var AllowedScopeEnumValues = []Scope{
	"system",
	"identity",
	"inventory",
	"monitor",
	"tags",
}

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

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

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

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

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

type NullableScope struct {
	value *Scope
	isSet bool
}

func (v NullableScope) Get() *Scope {
	return v.value
}

func (v *NullableScope) Set(val *Scope) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableScope(val *Scope) *NullableScope {
	return &NullableScope{value: val, isSet: true}
}

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

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

